@yaks/extension 0.0.0-stage → 0.2.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +275 -2
  3. package/_dist/act.d.ts +12 -0
  4. package/_dist/act.d.ts.map +1 -0
  5. package/_dist/answer.d.ts +42 -0
  6. package/_dist/answer.d.ts.map +1 -0
  7. package/_dist/build.d.ts +3 -0
  8. package/_dist/build.d.ts.map +1 -0
  9. package/_dist/connect.d.ts +22 -0
  10. package/_dist/connect.d.ts.map +1 -0
  11. package/_dist/consent.d.ts +16 -0
  12. package/_dist/consent.d.ts.map +1 -0
  13. package/_dist/manifest.d.ts +22 -0
  14. package/_dist/manifest.d.ts.map +1 -0
  15. package/_dist/mod.d.ts +12 -0
  16. package/_dist/mod.d.ts.map +1 -0
  17. package/_dist/read.d.ts +11 -0
  18. package/_dist/read.d.ts.map +1 -0
  19. package/_dist/screen.d.ts +22 -0
  20. package/_dist/screen.d.ts.map +1 -0
  21. package/_dist/signin.d.ts +27 -0
  22. package/_dist/signin.d.ts.map +1 -0
  23. package/_dist/tools.d.ts +23 -0
  24. package/_dist/tools.d.ts.map +1 -0
  25. package/_dist/touch.d.ts +32 -0
  26. package/_dist/touch.d.ts.map +1 -0
  27. package/_dist/wire.d.ts +33 -0
  28. package/_dist/wire.d.ts.map +1 -0
  29. package/act.js +41 -0
  30. package/act.js.map +1 -0
  31. package/act.ts +67 -0
  32. package/answer.js +157 -0
  33. package/answer.js.map +1 -0
  34. package/answer.ts +269 -0
  35. package/background.ts +190 -0
  36. package/build.js +67 -0
  37. package/build.js.map +1 -0
  38. package/build.ts +71 -0
  39. package/chrome.ts +76 -0
  40. package/connect.js +59 -0
  41. package/connect.js.map +1 -0
  42. package/connect.ts +85 -0
  43. package/consent.js +50 -0
  44. package/consent.js.map +1 -0
  45. package/consent.ts +67 -0
  46. package/deno.json +1 -0
  47. package/give.ts +124 -0
  48. package/icon.js +60 -0
  49. package/icon.js.map +1 -0
  50. package/icon.ts +53 -0
  51. package/manifest.js +50 -0
  52. package/manifest.js.map +1 -0
  53. package/manifest.ts +53 -0
  54. package/mod.js +15 -0
  55. package/mod.js.map +1 -0
  56. package/mod.ts +15 -0
  57. package/package.json +36 -4
  58. package/popup.css +117 -0
  59. package/popup.html +5 -0
  60. package/popup.ts +89 -0
  61. package/read.js +61 -0
  62. package/read.js.map +1 -0
  63. package/read.ts +80 -0
  64. package/screen.js +41 -0
  65. package/screen.js.map +1 -0
  66. package/screen.ts +125 -0
  67. package/signin.js +77 -0
  68. package/signin.js.map +1 -0
  69. package/signin.ts +94 -0
  70. package/tools.js +183 -0
  71. package/tools.js.map +1 -0
  72. package/tools.ts +192 -0
  73. package/touch.js +216 -0
  74. package/touch.js.map +1 -0
  75. package/touch.ts +259 -0
  76. package/wire.js +66 -0
  77. package/wire.js.map +1 -0
  78. package/wire.ts +91 -0
@@ -0,0 +1,11 @@
1
+ /** What a tab gave when its page was read. */ export type Page = {
2
+ url: string;
3
+ title: string;
4
+ text: string;
5
+ selection: string;
6
+ };
7
+ /** The page a document shows, read as a person sees it: scripts, styles and
8
+ * hidden elements skipped, whitespace collapsed to single spaces within a
9
+ * line, one line per block, and the text and selection each cut at `limit`
10
+ * characters with a note saying so. */ export declare let read: (doc?: Document, selected?: string, limit?: number) => Page;
11
+ //# sourceMappingURL=read.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.d.ts","sources":["../read.ts"],"names":[],"mappings":"AAUA,4CAA4C,GAC5C,YAAY;EACV,KAAK,MAAM;EACX,OAAO,MAAM;EACb,MAAM,MAAM;EACZ,WAAW,MAAM;;AAGnB;;;qCAGqC,GACrC,OAAO,YAAI,OACT,MAAK,UACL,WAAU,MAAM,EAChB,QAAO,MAAM,KACZ,KAqDF"}
@@ -0,0 +1,22 @@
1
+ import type { Config } from "./connect.js";
2
+ import { type Consent } from "./consent.js";
3
+ /** How the socket to the space is. */ export type Link = 'connecting' | 'connected' | 'offline';
4
+ /** A step the agent asks the person to let it do. */ export type Asked = {
5
+ site: string;
6
+ doing: string;
7
+ };
8
+ /** What the popup shows. */ export type State = {
9
+ signed: boolean;
10
+ space?: string;
11
+ link?: Link;
12
+ consent: Consent;
13
+ /** The site of a tab the agent wants a screenshot of, waiting on the
14
+ * person's click on the extension's button there. */ lend?: string;
15
+ /** A step waiting on the person's Do it: the site it is on, and what it
16
+ * does, in words that may be the page's. */ confirm?: Asked;
17
+ /** The last thing that went wrong, said to the person. */ error?: string;
18
+ };
19
+ /** Text as HTML. */ export declare let esc: (s: string) => string;
20
+ /** The popup's HTML for a state. */ export declare let screen: (config: Config, s: State) => string;
21
+ /** Whether anything waits on the person, which the badge shows. */ export declare let asked: (s: Pick<State, 'consent' | 'lend' | 'confirm'>) => boolean;
22
+ //# sourceMappingURL=screen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screen.d.ts","sources":["../screen.ts"],"names":[],"mappings":"AAQA,cAAc,MAAM,uBAAsB;AAE1C,SAAS,KAAK,OAAO,uBAA4B;AAEjD,oCAAoC,GACpC,YAAY,OAAO,eAAe,cAAc;AAEhD,mDAAmD,GACnD,YAAY;EAAU,MAAM,MAAM;EAAE,OAAO,MAAM;;AAEjD,0BAA0B,GAC1B,YAAY;EACV,QAAQ,OAAO;EACf,QAAQ,MAAM;EACd,OAAO;EACP,SAAS;EACT;qDACmD,GACnD,OAAO,MAAM;EACb;4CAC0C,GAC1C,UAAU;EACV,wDAAwD,GACxD,QAAQ,MAAM;;AAYhB,kBAAkB,GAClB,OAAO,YAAI,MAAO,GAAG,MAAM,KAAG,MAAM,CAA2C;AA2D/E,kCAAkC,GAClC,OAAO,YAAI,SAAU,QAAQ,QAAQ,GAAG,UAAQ,MAAM,CAapC;AAIlB,iEAAiE,GACjE,OAAO,YAAI,QACT,GAAG,KAAK,OAAO,YAAY,SAAS,eACnC,OAAO,CAA+C"}
@@ -0,0 +1,27 @@
1
+ import type { AuthorizationStore, Provider, Tokens } from "@yaks/oauth";
2
+ import type { Config } from "./connect.js";
3
+ /** The host's OAuth door, as the paths every host of this kind serves. */ export declare let DOOR: {
4
+ readonly authorize: string;
5
+ readonly token: string;
6
+ readonly register: string;
7
+ readonly scope: string;
8
+ };
9
+ /** A dynamic-registration request (RFC 7591 §2). */ export type Registration = {
10
+ client_name: string;
11
+ redirect_uris: string[];
12
+ grant_types: string[];
13
+ response_types: string[];
14
+ token_endpoint_auth_method: string;
15
+ };
16
+ /** The dynamic-registration request for a public client at `redirect`. */ export declare let registration: (config: Config, redirect: string) => Registration;
17
+ /** Register a public client with the host, and answer its id. */ export declare let register: (config: Config, redirect: string, ask?: typeof fetch) => Promise<string>;
18
+ /** The host as an OAuth provider, for the client it registered. */ export declare let provider: (config: Config, client: string) => Provider;
19
+ /** Where a store keeps values: `chrome.storage.local` in the browser, a Map
20
+ * in a test. */ export type Area = {
21
+ get: (key: string) => Promise<unknown>;
22
+ set: (key: string, value: unknown) => Promise<void>;
23
+ };
24
+ /** A grant store over an area. Updates run one at a time, so two callers
25
+ * refreshing at once never both spend the refresh token, and a record is
26
+ * saved even when its update throws (@yaks/oauth's `AuthorizationStore`). */ export declare let kept: (area: Area) => AuthorizationStore<Tokens>;
27
+ //# sourceMappingURL=signin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signin.d.ts","sources":["../signin.ts"],"names":[],"mappings":"AAOA,cAAc,kBAAkB,EAAE,QAAQ,EAAE,MAAM,2BAAgC;AAClF,cAAc,MAAM,uBAAsB;AAE1C,wEAAwE,GACxE,OAAO,YAAI;WACT;WACA;WACA;WACA;EACD;AAED,kDAAkD,GAClD,YAAY;EACV,aAAa,MAAM;EACnB,eAAe,MAAM;EACrB,aAAa,MAAM;EACnB,gBAAgB,MAAM;EACtB,4BAA4B,MAAM;;AAGpC,wEAAwE,GACxE,OAAO,YAAI,eAAgB,QAAQ,QAAQ,UAAU,MAAM,KAAG,aAM5D;AAEF,+DAA+D,GAC/D,OAAO,YAAI,WACT,QAAQ,QACR,UAAU,MAAM,EAChB,aAAY,UACX,QAAQ,MAAM,EAWhB;AAED,iEAAiE,GACjE,OAAO,YAAI,WAAY,QAAQ,QAAQ,QAAQ,MAAM,KAAG,SAKtD;AAEF;cACc,GACd,YAAY;EACV,MAAM,KAAK,MAAM,KAAK,QAAQ,OAAO;EACrC,MAAM,KAAK,MAAM,EAAE,OAAO,OAAO,KAAK,QAAQ,IAAI;;AAGpD;;2EAE2E,GAC3E,OAAO,YAAI,OAAQ,MAAM,SAAO,mBAAmB,QAqBlD"}
@@ -0,0 +1,23 @@
1
+ /** How a call reads to a person, while it runs and once it answered, chosen
2
+ * by an argument's value when `by` names one (@yaks/tools `Steps`). */ export type Step = {
3
+ doing: string;
4
+ done: string;
5
+ };
6
+ /** One browser tool as a host declares it to its model. */ export type BrowserTool = {
7
+ name: string;
8
+ title: string;
9
+ step: Step & {
10
+ by?: Record<string, Record<string, Step>>;
11
+ };
12
+ description: string;
13
+ parameters: Record<string, unknown>;
14
+ /** The call only reads the tab, so a turn that heard outsiders' words
15
+ * keeps it. */ readOnly?: true;
16
+ /** A call may wait on the person: the browser waits for them at most
17
+ * `PERSON`, and a host waits that much longer for its answer. */ waits?: boolean;
18
+ };
19
+ /** How long a browser waits on the person for a call that `waits`, in
20
+ * milliseconds. */ export declare let PERSON: number;
21
+ /** The tools that read the tab the person is looking at, and act in it. */ export declare let TOOLS: BrowserTool[];
22
+ /** The browser tool a name declares. */ export declare let toolOf: (name: string) => BrowserTool | undefined;
23
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sources":["../tools.ts"],"names":[],"mappings":"AAKA;qEACqE,GACrE,YAAY;EAAS,OAAO,MAAM;EAAE,MAAM,MAAM;;AAEhD,yDAAyD,GACzD,YAAY;EACV,MAAM,MAAM;EACZ,OAAO,MAAM;EACb,MAAM;IAAS,KAAK,OAAO,MAAM,EAAE,OAAO,MAAM,EAAE;;EAClD,aAAa,MAAM;EACnB,YAAY,OAAO,MAAM,EAAE,OAAO;EAClC;eACa,GACb,WAAW,IAAI;EACf;iEAC+D,GAC/D,QAAQ,OAAO;;AAGjB;iBACiB,GACjB,OAAO,YAAI,eAAgB;AAqC3B,yEAAyE,GACzE,OAAO,YAAI,OAAO,cA2HhB;AAEF,sCAAsC,GACtC,OAAO,YAAI,SAAU,MAAM,MAAM,KAAG,cAAc,SAAS,CACxB"}
@@ -0,0 +1,32 @@
1
+ /** One thing on a page a person can press or type into, as the agent is told
2
+ * of it. Every string but `ref` and `role` is the page's own words. */ export type Control = {
3
+ ref: string;
4
+ /** What it is: `link`, `button`, `textbox`, `searchbox`, `checkbox`,
5
+ * `radio`, `select`, or the role the page gave it. */ role: string;
6
+ /** What it says or is labelled, as a person reads it. */ name: string;
7
+ /** Pressing it submits a form: a submit button. */ submits?: boolean;
8
+ /** It sits in a form, so Enter in it may submit that form. */ form?: boolean;
9
+ /** It is a search: its own role or type says so, or a search landmark
10
+ * holds it. */ search?: boolean;
11
+ href?: string;
12
+ /** A field's value; a password's is never read. */ value?: string;
13
+ checked?: boolean;
14
+ disabled?: boolean;
15
+ /** A select's options, as their words. */ options?: string[];
16
+ };
17
+ /** What a touch gives back: the controls it found or acted on, or why it
18
+ * could not. */ export type Touched = {
19
+ controls: Control[];
20
+ error?: string;
21
+ };
22
+ /** What a touch does: `list` names every control afresh; `find` describes the
23
+ * one a ref names; `click` and `type` act on it, once its name is still the
24
+ * name given, so a page that changed under a wait is not acted on. */ export type Touch = {
25
+ op: 'list' | 'find' | 'click' | 'type';
26
+ ref?: string;
27
+ name?: string;
28
+ text?: string;
29
+ enter?: boolean;
30
+ };
31
+ /** A touch on a document, holding refs in `held`. */ export declare let touch: (asked: Touch, doc?: Document, held?: Record<string, unknown>) => Touched;
32
+ //# sourceMappingURL=touch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"touch.d.ts","sources":["../touch.ts"],"names":[],"mappings":"AAYA;qEACqE,GACrE,YAAY;EACV,KAAK,MAAM;EACX;sDACoD,GACpD,MAAM,MAAM;EACZ,uDAAuD,GACvD,MAAM,MAAM;EACZ,iDAAiD,GACjD,UAAU,OAAO;EACjB,4DAA4D,GAC5D,OAAO,OAAO;EACd;eACa,GACb,SAAS,OAAO;EAChB,OAAO,MAAM;EACb,iDAAiD,GACjD,QAAQ,MAAM;EACd,UAAU,OAAO;EACjB,WAAW,OAAO;EAClB,wCAAwC,GACxC,UAAU,MAAM;;AAGlB;cACc,GACd,YAAY;EAAY,UAAU;EAAW,QAAQ,MAAM;;AAE3D;;oEAEoE,GACpE,YAAY;EACV,IAAI,SAAS,SAAS,UAAU;EAChC,MAAM,MAAM;EACZ,OAAO,MAAM;EACb,OAAO,MAAM;EACb,QAAQ,OAAO;;AAGjB,mDAAmD,GACnD,OAAO,YAAI,QACT,OAAO,OACP,MAAK,UACL,OAAM,OAAO,MAAM,EAAE,OAAO,MAC3B,QAyMF"}
@@ -0,0 +1,33 @@
1
+ /** A tool call the host sends the browser. */ export type Call = {
2
+ call: {
3
+ id: string;
4
+ tool: string;
5
+ args: Args;
6
+ };
7
+ };
8
+ /** The arguments a call carries, as the model gave them. */ export type Args = Record<string, unknown>;
9
+ /** An image an answer carries, base64 so it fits a text frame. */ export type Shot = {
10
+ mime: string;
11
+ base64: string;
12
+ };
13
+ /** What the browser answers a call: words for the model, an image beside
14
+ * them, or why it could not. */ export type Answer = {
15
+ answer: {
16
+ id: string;
17
+ text?: string;
18
+ image?: Shot;
19
+ error?: string;
20
+ };
21
+ };
22
+ /** A call frame. */ export declare let call: (id: string, tool: string, args?: Args) => string;
23
+ /** An answer frame. */ export declare let answer: (a: Answer['answer']) => string;
24
+ /** The call a frame holds, or null for anything else. */ export declare let callOf: (data: unknown) => Call['call'] | null;
25
+ /** The answer a frame holds, or null for anything else. */ export declare let answerOf: (data: unknown) => Answer['answer'] | null;
26
+ /** A frame the browser sends every so often to keep its socket open. A host
27
+ * answers nothing and ignores it, as it ignores every frame that is not an
28
+ * answer. */ export declare let PING: string;
29
+ /** The subprotocol the socket speaks, and the one the host's 101 names. */ export declare let PROTOCOL: string;
30
+ /** The subprotocols a browser opens its socket with, for a bearer token. */ export declare let protocols: (token: string) => string[];
31
+ /** The bearer token a socket's `sec-websocket-protocol` header carries, or
32
+ * null when it carries none. */ export declare let bearerOf: (header: string | null) => string | null;
33
+ //# sourceMappingURL=wire.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire.d.ts","sources":["../wire.ts"],"names":[],"mappings":"AAQA,4CAA4C,GAC5C,YAAY;EAAS;IAAQ,IAAI,MAAM;IAAE,MAAM,MAAM;IAAE,MAAM;;;AAE7D,0DAA0D,GAC1D,YAAY,OAAO,OAAO,MAAM,EAAE,OAAO;AAEzC,gEAAgE,GAChE,YAAY;EAAS,MAAM,MAAM;EAAE,QAAQ,MAAM;;AAEjD;8BAC8B,GAC9B,YAAY;EACV;IAAU,IAAI,MAAM;IAAE,OAAO,MAAM;IAAE,QAAQ;IAAM,QAAQ,MAAM;;;AAGnE,kBAAkB,GAClB,OAAO,YAAI,OAAQ,IAAI,MAAM,EAAE,MAAM,MAAM,EAAE,OAAM,SAAY,MAAM,CACR;AAE7D,qBAAqB,GACrB,OAAO,YAAI,SAAU,GAAG,OAAO,cAAY,MAAM,CACD;AAYhD,uDAAuD,GACvD,OAAO,YAAI,SAAU,MAAM,OAAO,KAAG,KAAK,UAAU,IAAI,CAKvD;AAED,yDAAyD,GACzD,OAAO,YAAI,WAAY,MAAM,OAAO,KAAG,OAAO,YAAY,IAAI,CAG7D;AAED;;WAEW,GACX,OAAO,YAAI,aAAsB;AAKjC,yEAAyE,GACzE,OAAO,YAAI,iBAAiB;AAK5B,0EAA0E,GAC1E,OAAO,YAAI,YAAa,OAAO,MAAM,KAAG,MAAM,GAG7C;AAKD;8BAC8B,GAC9B,OAAO,YAAI,WAAY,QAAQ,MAAM,GAAG,IAAI,KAAG,MAAM,GAAG,IAAI,CAU3D"}
package/act.js ADDED
@@ -0,0 +1,41 @@
1
+ // What acting on a page needs before the browser does it: the element the
2
+ // agent named, still the one it listed, and for a step that sends, buys,
3
+ // posts or deletes, the person's **Do it**. The rule is the extension's own,
4
+ // read from the element and the action. The agent's word (`confirm: true`)
5
+ // can only add a question, never take one away, and nothing a page says
6
+ // reaches the rule except the element's own name, so a page can't talk its
7
+ // way past it.
8
+ // Words that mark a step whose effect leaves the page: something sent,
9
+ // bought, posted or deleted. Each matches as a word, with its usual endings.
10
+ let WEIGHTY = /\b(send|buy|pay|order|post|publish|delete|confirm|purchase|checkout|check out|remove|transfer|submit|reply|donate|subscribe|book|reserve)(s|es|ed|ing|ment|ments)?\b/i;
11
+ /// weighty('Place order') -> true
12
+ /// weighty('Payment') -> true
13
+ /// weighty('Postcode') -> false
14
+ /// weighty('Next') -> false
15
+ /** Whether words name a step that sends, buys, posts or deletes. */ export let weighty = (words)=>WEIGHTY.test(words);
16
+ /// aims({ id: 'c', tool: 'browser_navigate', args: { url: 'https://b.com/' } }, 'https://a.com/') -> 'https://b.com/'
17
+ /// aims({ id: 'c', tool: 'browser_click', args: {} }, 'https://a.com/') -> 'https://a.com/'
18
+ /** The address a call acts on, whose site needs the person's consent: where
19
+ * a navigation goes, and the tab's own address for everything else. */ export let aims = (call, url)=>call.tool == 'browser_navigate' ? String(call.args.url ?? '') : url;
20
+ let plain = (s)=>s.replace(/\s+/g, ' ').trim().replace(/…$/, '').toLowerCase();
21
+ /// named('place Order', { ref: 'e1', role: 'button', name: 'Place order' }) -> true
22
+ /// named('Cancel', { ref: 'e1', role: 'button', name: 'Place order' }) -> false
23
+ /** Whether the name an agent gave is the element's, as it was listed: a ref
24
+ * from an older listing, or a page that changed, names something else. */ export let named = (given, c)=>typeof given == 'string' && plain(given) == plain(c.name);
25
+ /** Whether a step waits for the person's Do it: a click that submits a form
26
+ * or whose words are weighty, Enter in a field that is not a search, or a
27
+ * search whose words are, and anything the agent asked to confirm. */ export let confirms = (call, c)=>{
28
+ if (call.args.confirm === true) return true;
29
+ if (!c) return false;
30
+ if (call.tool == 'browser_click') return !!c.submits || weighty(c.name);
31
+ if (call.tool == 'browser_type' && call.args.enter === true) {
32
+ return !c.search || weighty(c.name);
33
+ }
34
+ return false;
35
+ };
36
+ let quote = (s, n = 80)=>`“${s.length > n ? s.slice(0, n) + '…' : s}”`;
37
+ /** What a step does, as the person is asked about it. */ export let doing = (call, c)=>{
38
+ let on = c ? `the ${c.role} ${quote(c.name)}` : 'the page';
39
+ return call.tool == 'browser_click' ? `Click ${on}` : call.tool == 'browser_type' ? `Type ${quote(String(call.args.text ?? ''))} into ${on}` + (call.args.enter === true ? ' and press Enter' : '') : call.tool == 'browser_navigate' ? `Go to ${String(call.args.url ?? '')}` : call.tool;
40
+ };
41
+ //# sourceMappingURL=act.js.map
package/act.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"act.js","sources":["./act.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,yEAAyE;AACzE,6EAA6E;AAC7E,2EAA2E;AAC3E,wEAAwE;AACxE,2EAA2E;AAC3E,eAAe;AAKf,uEAAuE;AACvE,6EAA6E;AAC7E,IAAI,UACF;AAEF,kCAAkC;AAClC,8BAA8B;AAC9B,gCAAgC;AAChC,4BAA4B;AAC5B,kEAAkE,GAClE,OAAO,IAAI,UAAU,CAAC,QAA2B,QAAQ,IAAI,CAAC,OAAM;AAEpE,sHAAsH;AACtH,4FAA4F;AAC5F;qEACqE,GACrE,OAAO,IAAI,OAAO,CAAC,MAAoB,MACrC,KAAK,IAAI,IAAI,qBAAqB,OAAO,KAAK,IAAI,CAAC,GAAG,IAAI,MAAM,IAAG;AAErE,IAAI,QAAQ,CAAC,IACX,EAAE,OAAO,CAAC,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,MAAM,IAAI,WAAW;AAE7D,qFAAqF;AACrF,gFAAgF;AAChF;wEACwE,GACxE,OAAO,IAAI,QAAQ,CAAC,OAAgB,IAClC,OAAO,SAAS,YAAY,MAAM,UAAU,MAAM,EAAE,IAAI,EAAC;AAE3D;;oEAEoE,GACpE,OAAO,IAAI,WAAW,CAAC,MAAoB;EACzC,IAAI,KAAK,IAAI,CAAC,OAAO,KAAK,MAAM,OAAO;EACvC,IAAI,CAAC,GAAG,OAAO;EACf,IAAI,KAAK,IAAI,IAAI,iBAAiB,OAAO,CAAC,CAAC,EAAE,OAAO,IAAI,QAAQ,EAAE,IAAI;EACtE,IAAI,KAAK,IAAI,IAAI,kBAAkB,KAAK,IAAI,CAAC,KAAK,KAAK,MAAM;IAC3D,OAAO,CAAC,EAAE,MAAM,IAAI,QAAQ,EAAE,IAAI;EACpC;EACA,OAAO;AACT,EAAC;AAED,IAAI,QAAQ,CAAC,GAAW,IAAI,EAAE,GAAK,CAAC,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,CAAC,GAAG,KAAK,MAAM,EAAE,CAAC,CAAC;AAEhF,uDAAuD,GACvD,OAAO,IAAI,QAAQ,CAAC,MAAoB;EACtC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,GAAG,GAAG;EAChD,OAAO,KAAK,IAAI,IAAI,kBAChB,CAAC,MAAM,EAAE,IAAI,GACb,KAAK,IAAI,IAAI,iBACb,CAAC,KAAK,EAAE,MAAM,OAAO,KAAK,IAAI,CAAC,IAAI,IAAI,KAAK,MAAM,EAAE,IAAI,GACxD,CAAC,KAAK,IAAI,CAAC,KAAK,KAAK,OAAO,qBAAqB,EAAE,IACnD,KAAK,IAAI,IAAI,qBACb,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,IAAI,KAAK,GACtC,KAAK,IAAI;AACf,EAAC"}
package/act.ts ADDED
@@ -0,0 +1,67 @@
1
+ // What acting on a page needs before the browser does it: the element the
2
+ // agent named, still the one it listed, and for a step that sends, buys,
3
+ // posts or deletes, the person's **Do it**. The rule is the extension's own,
4
+ // read from the element and the action. The agent's word (`confirm: true`)
5
+ // can only add a question, never take one away, and nothing a page says
6
+ // reaches the rule except the element's own name, so a page can't talk its
7
+ // way past it.
8
+
9
+ import type { Control } from './touch.ts'
10
+ import type { Call } from './wire.ts'
11
+
12
+ // Words that mark a step whose effect leaves the page: something sent,
13
+ // bought, posted or deleted. Each matches as a word, with its usual endings.
14
+ let WEIGHTY =
15
+ /\b(send|buy|pay|order|post|publish|delete|confirm|purchase|checkout|check out|remove|transfer|submit|reply|donate|subscribe|book|reserve)(s|es|ed|ing|ment|ments)?\b/i
16
+
17
+ /// weighty('Place order') -> true
18
+ /// weighty('Payment') -> true
19
+ /// weighty('Postcode') -> false
20
+ /// weighty('Next') -> false
21
+ /** Whether words name a step that sends, buys, posts or deletes. */
22
+ export let weighty = (words: string): boolean => WEIGHTY.test(words)
23
+
24
+ /// aims({ id: 'c', tool: 'browser_navigate', args: { url: 'https://b.com/' } }, 'https://a.com/') -> 'https://b.com/'
25
+ /// aims({ id: 'c', tool: 'browser_click', args: {} }, 'https://a.com/') -> 'https://a.com/'
26
+ /** The address a call acts on, whose site needs the person's consent: where
27
+ * a navigation goes, and the tab's own address for everything else. */
28
+ export let aims = (call: Call['call'], url: string): string =>
29
+ call.tool == 'browser_navigate' ? String(call.args.url ?? '') : url
30
+
31
+ let plain = (s: string) =>
32
+ s.replace(/\s+/g, ' ').trim().replace(/…$/, '').toLowerCase()
33
+
34
+ /// named('place Order', { ref: 'e1', role: 'button', name: 'Place order' }) -> true
35
+ /// named('Cancel', { ref: 'e1', role: 'button', name: 'Place order' }) -> false
36
+ /** Whether the name an agent gave is the element's, as it was listed: a ref
37
+ * from an older listing, or a page that changed, names something else. */
38
+ export let named = (given: unknown, c: Control): boolean =>
39
+ typeof given == 'string' && plain(given) == plain(c.name)
40
+
41
+ /** Whether a step waits for the person's Do it: a click that submits a form
42
+ * or whose words are weighty, Enter in a field that is not a search, or a
43
+ * search whose words are, and anything the agent asked to confirm. */
44
+ export let confirms = (call: Call['call'], c?: Control): boolean => {
45
+ if (call.args.confirm === true) return true
46
+ if (!c) return false
47
+ if (call.tool == 'browser_click') return !!c.submits || weighty(c.name)
48
+ if (call.tool == 'browser_type' && call.args.enter === true) {
49
+ return !c.search || weighty(c.name)
50
+ }
51
+ return false
52
+ }
53
+
54
+ let quote = (s: string, n = 80) => `“${s.length > n ? s.slice(0, n) + '…' : s}”`
55
+
56
+ /** What a step does, as the person is asked about it. */
57
+ export let doing = (call: Call['call'], c?: Control): string => {
58
+ let on = c ? `the ${c.role} ${quote(c.name)}` : 'the page'
59
+ return call.tool == 'browser_click'
60
+ ? `Click ${on}`
61
+ : call.tool == 'browser_type'
62
+ ? `Type ${quote(String(call.args.text ?? ''))} into ${on}` +
63
+ (call.args.enter === true ? ' and press Enter' : '')
64
+ : call.tool == 'browser_navigate'
65
+ ? `Go to ${String(call.args.url ?? '')}`
66
+ : call.tool
67
+ }
package/answer.js ADDED
@@ -0,0 +1,157 @@
1
+ // What the browser answers a call, decided from what the tab gave. The glue
2
+ // asks the tab for what a tool `needs` (the page read, a screenshot, its
3
+ // controls, a step done), and only on a site the person allowed; `answering`
4
+ // turns that into the answer frame's fields. Every word from the page reaches
5
+ // the model fenced, as the page's.
6
+ import { host, site } from "./consent.js";
7
+ import { aims, doing, named } from "./act.js";
8
+ /// unlent("Either the '<all_urls>' or 'activeTab' permission is required.") -> true
9
+ /// unlent('frame gone') -> false
10
+ /** Whether a screenshot failed because Chrome wants the person's click: it
11
+ * captures a tab only under `activeTab`, which a click on the extension's
12
+ * button grants for that tab, or under every site's permission, which a
13
+ * site allowed on its own is not (Chromium's `CanCaptureVisiblePage`). */ export let unlent = (failed = '')=>/'activeTab'/.test(failed);
14
+ /// fence('a ``` b') -> '````\na ``` b\n````'
15
+ /** Text between backtick fences longer than any run inside it, so nothing the
16
+ * text says can close the fence early. */ export let fence = (text)=>{
17
+ let longest = Math.max(0, ...(text.match(/`+/g) ?? []).map((r)=>r.length));
18
+ let bar = '`'.repeat(Math.max(3, longest + 1));
19
+ return `${bar}\n${text}\n${bar}`;
20
+ };
21
+ // What precedes the page's words, so the model reads them as content.
22
+ let quoted = (what, text)=>`${what}, written by the site, not by the person or by you:\n${fence(text)}`;
23
+ /// shot('data:image/png;base64,iVBO') -> { mime: 'image/png', base64: 'iVBO' }
24
+ /// shot('nonsense') -> undefined
25
+ /** The image a `data:` URL holds. */ export let shot = (url)=>{
26
+ let m = /^data:([^;,]+);base64,(.*)$/s.exec(url);
27
+ return m ? {
28
+ mime: m[1],
29
+ base64: m[2]
30
+ } : undefined;
31
+ };
32
+ let titled = (s)=>quoted("The page's title", s.page?.title ?? s.title ?? '');
33
+ /// line({ ref: 'e3', role: 'textbox', name: 'Email', form: true, value: 'a@b.c' }) -> 'e3 textbox "Email" in a form, value "a@b.c"'
34
+ /// line({ ref: 'e4', role: 'link', name: 'Home' }) -> 'e4 link "Home"'
35
+ /** One control as the agent reads it in a listing. */ export let line = (c)=>[
36
+ `${c.ref} ${c.role} ${JSON.stringify(c.name)}`,
37
+ [
38
+ c.submits ? 'submits a form' : c.form ? 'in a form' : '',
39
+ c.search ? 'a search' : '',
40
+ c.href ? `to ${c.href}` : '',
41
+ c.value != null ? `value ${JSON.stringify(c.value)}` : '',
42
+ c.checked != null ? c.checked ? 'checked' : 'not checked' : '',
43
+ c.options ? `options ${JSON.stringify(c.options)}` : '',
44
+ c.disabled ? 'disabled' : ''
45
+ ].filter(Boolean).join(', ')
46
+ ].filter(Boolean).join(' ');
47
+ // Where a step left the tab: its address and title on a site the person
48
+ // allowed, and only the site's name on one they have not.
49
+ let after = ({ now })=>!now ? '' : now.allowed ? `The tab is now at ${now.url}\n${quoted("The page's title", now.title ?? '')}` : site(now.url) ? `The tab is now on ${host(site(now.url))}, which the person has not allowed, so nothing of it is read.` : `The tab is now at ${now.url}.`;
50
+ let did = (call, s)=>`Did this on ${s.url}: ${doing(call, s.controls?.[0])}.\n${after(s)}`;
51
+ // Each tool: what it needs, and what it says once it has it.
52
+ let TOLD = {
53
+ browser_page: {
54
+ says: (s)=>({
55
+ text: `The person's tab is at ${s.url}\n${titled(s)}`
56
+ })
57
+ },
58
+ browser_text: {
59
+ needs: 'page',
60
+ says: (s)=>({
61
+ text: `The text of ${s.url}\n${quoted('The page', s.page?.text ?? '')}`
62
+ })
63
+ },
64
+ browser_selection: {
65
+ needs: 'page',
66
+ says: ({ url, page })=>({
67
+ text: page?.selection ? `What the person selected on ${url}\n` + quoted('The selection', page.selection) : `The person has nothing selected on ${url}.`
68
+ })
69
+ },
70
+ browser_screenshot: {
71
+ needs: 'shot',
72
+ says: (s)=>{
73
+ let image = shot(s.shot ?? '');
74
+ return image ? {
75
+ text: `A screenshot of the visible part of ${s.url}.`,
76
+ image
77
+ } : {
78
+ error: 'The browser gave no image for the screenshot.'
79
+ };
80
+ }
81
+ },
82
+ browser_elements: {
83
+ needs: 'list',
84
+ says: (s)=>({
85
+ text: s.controls?.length ? `The links, buttons and fields on ${s.url}, each after its ref` + (s.more ? ` (${s.more})` : '') + '\n' + quoted('Their names and values', s.controls.map(line).join('\n')) : `${s.url} has no links, buttons or fields to press or type into.`
86
+ })
87
+ },
88
+ browser_click: {
89
+ needs: 'act',
90
+ says: (s, call)=>({
91
+ text: did(call, s)
92
+ })
93
+ },
94
+ browser_type: {
95
+ needs: 'act',
96
+ says: (s, call)=>({
97
+ text: did(call, s)
98
+ })
99
+ },
100
+ browser_navigate: {
101
+ needs: 'go',
102
+ says: (s)=>({
103
+ text: after(s)
104
+ })
105
+ }
106
+ };
107
+ /// needs('browser_text') -> 'page'
108
+ /// needs('browser_page') -> undefined
109
+ /** What a tool needs the tab to give, if anything. */ export let needs = (tool)=>TOLD[tool]?.needs;
110
+ // What each need gives the answer, which an answer can't do without; a step
111
+ // on a control says for itself what it lacks.
112
+ let GIVES = {
113
+ page: 'page',
114
+ shot: 'shot',
115
+ list: 'controls',
116
+ act: undefined,
117
+ go: 'now'
118
+ };
119
+ // Why the site a call aims at is not open to it.
120
+ let unallowed = (s, on)=>s.answered == 'no' ? `The person chose not to let you use ${host(on)}. Ask them in the conversation before trying it again.` : s.answered == 'none' ? `The person has not answered whether you may use ${host(on)}. The extension still asks them in its popup; ask them to open it and choose.` : `The person has not allowed you to use ${host(on)} yet. The extension is asking them now; try again once they allow it.`;
121
+ // Why a step on a control was not done.
122
+ let undone = (call, s)=>{
123
+ let [c] = s.controls ?? [];
124
+ let ref = String(call.args.ref ?? '');
125
+ return !c ? `${s.url} has no ${ref} now. List the elements again with browser_elements and use a ref from that.` : !named(call.args.name, c) ? `${ref} on ${s.url} is not ${JSON.stringify(call.args.name ?? '')} but the ${c.role} named below. List the elements again with browser_elements and use the ref of what you mean.\n${quoted('Its name', c.name)}` : s.answered == 'no' ? `The person pressed Don't, so nothing was done: ${doing(call, c)}.` : s.answered == 'none' ? `The person did not press Do it in time, so nothing was done: ${doing(call, c)}. Ask them in the conversation, then try again.` : undefined;
126
+ };
127
+ // Why a call can't be answered.
128
+ let refusal = (call, s)=>{
129
+ let { tool } = call;
130
+ let aimed = aims(call, s.url);
131
+ let on = site(aimed);
132
+ let need = needs(tool);
133
+ return !TOLD[tool] ? `This browser has no tool called ${tool}.` : !on ? tool == 'browser_navigate' ? `${aimed || 'No address'} is not a web address the browser opens.` : `The person's tab (${s.url || 'no address'}) is not a web page, so the browser can't use it.` : !s.allowed ? unallowed(s, on) : need == 'shot' && unlent(s.failed) ? `Chrome lets the extension take a screenshot of a tab only after the person clicks the extension's button in their browser's toolbar while on that tab, and they have not yet. Ask them to click it on ${host(on)}, then try again; it then works on that site in that tab until the tab leaves it. browser_text reads the page without it.` : need == 'act' && undone(call, s) ? undone(call, s) : tool == 'browser_navigate' && s.answered ? `The person ${s.answered == 'no' ? "pressed Don't" : 'did not press Do it in time'}, so the tab did not go to ${aimed}.` : s.failed ? `The browser could not do ${tool} on ${s.url}: ${s.failed}` : need && GIVES[need] && !s[GIVES[need]] ? `The browser gave nothing for ${tool}.` : undefined;
134
+ };
135
+ /** The answer to a call, from what the tab gave. */ export let answering = (call, seen)=>{
136
+ let refused = refusal(call, seen);
137
+ return {
138
+ answer: {
139
+ id: call.id,
140
+ ...refused ? {
141
+ error: refused
142
+ } : TOLD[call.tool].says(seen, call)
143
+ }
144
+ };
145
+ };
146
+ /** Whether a call waits on the person's consent for the site it aims at: the
147
+ * glue keeps the question for the popup, and waits for their answer. */ export let asks = (call, seen)=>{
148
+ let on = site(aims(call, seen.url));
149
+ return TOLD[call.tool] && on && !seen.allowed && !seen.answered ? on : null;
150
+ };
151
+ /** Whether a screenshot waits on the person's click on the extension's
152
+ * button, on the site it names: the glue keeps it for the popup, and takes it
153
+ * again once the popup opens. */ export let lends = (call, seen)=>{
154
+ let on = site(seen.url);
155
+ return needs(call.tool) == 'shot' && on && unlent(seen.failed) ? on : null;
156
+ };
157
+ //# sourceMappingURL=answer.js.map
package/answer.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"answer.js","sources":["./answer.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,yEAAyE;AACzE,6EAA6E;AAC7E,8EAA8E;AAC9E,mCAAmC;AAKnC,SAAS,IAAI,EAAE,IAAI,uBAAsB;AACzC,SAAS,IAAI,EAAE,KAAK,EAAE,KAAK,mBAAkB;AA4B7C,oFAAoF;AACpF,iCAAiC;AACjC;;;wEAGwE,GACxE,OAAO,IAAI,SAAS,CAAC,SAAS,EAAE,GAAc,cAAc,IAAI,CAAC,QAAO;AAQxE,6CAA6C;AAC7C;wCACwC,GACxC,OAAO,IAAI,QAAQ,CAAC;EAClB,IAAI,UAAU,KAAK,GAAG,CAAC,MAAM,CAAC,KAAK,KAAK,CAAC,UAAU,EAAE,EAAE,GAAG,CAAC,CAAC,IAAM,EAAE,MAAM;EAC1E,IAAI,MAAM,IAAI,MAAM,CAAC,KAAK,GAAG,CAAC,GAAG,UAAU;EAC3C,OAAO,GAAG,IAAI,EAAE,EAAE,KAAK,EAAE,E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