@allyhub/sdk 0.10.0 → 0.11.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/node_modules/@allyhub/audio/package.json +1 -1
  3. package/dist/node_modules/@allyhub/chart/package.json +1 -1
  4. package/dist/node_modules/@allyhub/diagnostics/dist/problem.d.ts +7 -0
  5. package/dist/node_modules/@allyhub/diagnostics/package.json +1 -1
  6. package/dist/node_modules/@allyhub/formats/dist/note-shape.d.ts +20 -0
  7. package/dist/node_modules/@allyhub/formats/dist/note-shape.js +1 -1
  8. package/dist/node_modules/@allyhub/formats/package.json +1 -1
  9. package/dist/node_modules/@allyhub/image-draw/package.json +1 -1
  10. package/dist/node_modules/@allyhub/image-measure/package.json +1 -1
  11. package/dist/node_modules/@allyhub/image-sdk/dist/index.d.ts +1 -1
  12. package/dist/node_modules/@allyhub/image-sdk/package.json +1 -1
  13. package/dist/node_modules/@allyhub/measure/package.json +1 -1
  14. package/dist/node_modules/@allyhub/ooxml/package.json +1 -1
  15. package/dist/node_modules/@allyhub/piece/dist/layer.d.ts +2 -0
  16. package/dist/node_modules/@allyhub/piece/dist/page/index.d.ts +1 -1
  17. package/dist/node_modules/@allyhub/piece/dist/page/index.js +1 -1
  18. package/dist/node_modules/@allyhub/piece/dist/page/locate.d.ts +14 -1
  19. package/dist/node_modules/@allyhub/piece/dist/page/locate.js +1 -1
  20. package/dist/node_modules/@allyhub/piece/dist/stage.d.ts +12 -0
  21. package/dist/node_modules/@allyhub/piece/package.json +1 -1
  22. package/dist/node_modules/@allyhub/protocol/dist/account.d.ts +8 -0
  23. package/dist/node_modules/@allyhub/protocol/dist/cloud.d.ts +4 -0
  24. package/dist/node_modules/@allyhub/protocol/dist/cloud.js +1 -1
  25. package/dist/node_modules/@allyhub/protocol/dist/editor.d.ts +6 -0
  26. package/dist/node_modules/@allyhub/protocol/dist/editor.js +1 -1
  27. package/dist/node_modules/@allyhub/protocol/dist/frame.d.ts +61 -1
  28. package/dist/node_modules/@allyhub/protocol/dist/frame.js +1 -1
  29. package/dist/node_modules/@allyhub/protocol/dist/index.d.ts +0 -1
  30. package/dist/node_modules/@allyhub/protocol/dist/index.js +1 -1
  31. package/dist/node_modules/@allyhub/protocol/dist/notes.d.ts +41 -3
  32. package/dist/node_modules/@allyhub/protocol/dist/notes.js +1 -1
  33. package/dist/node_modules/@allyhub/protocol/dist/snapshots.d.ts +17 -0
  34. package/dist/node_modules/@allyhub/protocol/dist/snapshots.js +1 -1
  35. package/dist/node_modules/@allyhub/protocol/dist/teams.d.ts +7 -0
  36. package/dist/node_modules/@allyhub/protocol/dist/teams.js +1 -1
  37. package/dist/node_modules/@allyhub/protocol/dist/tools.d.ts +12 -0
  38. package/dist/node_modules/@allyhub/protocol/dist/tools.js +1 -1
  39. package/dist/node_modules/@allyhub/protocol/package.json +1 -5
  40. package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
  41. package/dist/node_modules/@allyhub/scenery/package.json +1 -1
  42. package/dist/node_modules/@allyhub/sheet/dist/export.d.ts +0 -8
  43. package/dist/node_modules/@allyhub/sheet/dist/export.js +2 -4
  44. package/dist/node_modules/@allyhub/sheet/dist/index.d.ts +1 -1
  45. package/dist/node_modules/@allyhub/sheet/dist/index.js +1 -1
  46. package/dist/node_modules/@allyhub/sheet/package.json +1 -1
  47. package/dist/node_modules/@allyhub/slides-core/package.json +1 -1
  48. package/dist/node_modules/@allyhub/video-core/package.json +1 -1
  49. package/dist/node_modules/@allyhub/video-sdk/package.json +1 -1
  50. package/docs/README.md +2 -0
  51. package/docs/defaults.md +10 -2
  52. package/docs/docs.md +4 -4
  53. package/docs/image.md +3 -3
  54. package/docs/linkedin.md +96 -0
  55. package/docs/reports.md +89 -0
  56. package/docs/sheets.md +1 -1
  57. package/docs/x.md +1 -1
  58. package/package.json +1 -1
  59. package/dist/node_modules/@allyhub/protocol/dist/browser-bridge.d.ts +0 -337
  60. package/dist/node_modules/@allyhub/protocol/dist/browser-bridge.js +0 -2
@@ -0,0 +1,89 @@
1
+ # Reports
2
+
3
+ A report is a page read on a screen and sent as a link: one HTML file you write freely, in HTML, CSS and JavaScript, listed in `allyhub.yaml` as `kind: report` ([project.md](project.md#items)), and whatever it loads beside it. AllyHub gives it no components, classes or layout: every part of the page is yours. It draws the page offline, the same on every computer, checks it for what is objectively wrong, draws pictures of it to look at, and makes it into files.
4
+
5
+ ## A report item
6
+
7
+ ```
8
+ research/channels/
9
+ channels.html the report
10
+ charts.js anything it loads, beside it or elsewhere in the project
11
+ ```
12
+
13
+ ```yaml
14
+ work:
15
+ - file: research/channels/channels.html
16
+ kind: report
17
+ title: AI productivity channels
18
+ ```
19
+
20
+ - Its id is its file without its extension (`research/channels/channels`); commands take either.
21
+ - Its file ends in `.html`; one that does not, or is not there, is AK-M017.
22
+
23
+ ## What it loads
24
+
25
+ The page is drawn from a server of the project's folder: it loads the project's files by their paths, relative to the report (`../../data/channels.csv`), and nothing else.
26
+
27
+ - **Data**: `fetch` a CSV or a JSON by its path and draw from it, so a figure, a table and a chart are one number. A sheet's table files hold the rows typed into it, not what its formulas compute: for those, render the sheet into the report's folder (`allyhub render <sheet> --type csv` or `json`, then copy the file beside the report) and load that.
28
+ - **Libraries** are files of the project: a package installed and loaded by its path (`../../node_modules/chart.js/dist/chart.umd.min.js`), or a file beside the report. A classic script or a module with no imports is carried by the self-contained HTML export; a module that imports others is not (bundle it into one file).
29
+ - **Faces** are files: `@font-face` rules naming font files in the project (a `@fontsource` package's CSS, or your own). The built-in faces of the stage (project.md, "Fonts") are not loaded for a report.
30
+ - **Nothing from the network**: an address outside the project (a CDN, Google Fonts) is refused when the page is drawn and is AK-N003. Put the file in the project instead.
31
+ - A report style (below) brings its faces and Chart.js as files.
32
+
33
+ ## How it is drawn
34
+
35
+ `check`, `frames` and `render` draw the page the same way, in the pinned Chrome:
36
+
37
+ - At a window of 1440 × 900 CSS pixels (`100vh` is 900), at 1 device pixel per CSS pixel, unless asked otherwise.
38
+ - `prefers-reduced-motion: reduce` and `prefers-color-scheme: light`, unless asked otherwise. `Math.random` gives the same numbers each time; the clock is the real one.
39
+ - It is drawn once it has settled: loaded, its network quiet (up to 3 s after the load event), its fonts ready, its pictures decoded, `window.allyhubReady` kept when the page sets it to a promise, its CSS animations finished (an endless one paused at its start), then 1.2 s more for what scripts animate. A page that draws later than that (a chart animating for longer) sets `window.allyhubReady`, or turns its motion off under reduced motion.
40
+ - A page that has not loaded and settled within 30 s is AK-P004.
41
+
42
+ Each of these is a `--param` of `allyhub render` (`width`, `height`, `scale`, `timeout`, `network`, `quiet`, `dark`, `paper`): `allyhub help render`.
43
+
44
+ ## Check
45
+
46
+ `allyhub check` draws each report and reports objective errors alone:
47
+
48
+ | Code | What |
49
+ | --- | --- |
50
+ | AK-M017 | Its file is not an HTML file, or is not there |
51
+ | AK-A001 | It asks for a file of the project that is not there |
52
+ | AK-N003 | It asks for an address outside the project, which is refused |
53
+ | AK-R001 | Its scripts threw and did not catch |
54
+ | AK-P004 | It did not load, or did not settle, within its timeout |
55
+ | AK-L006 | Text is drawn in a face of the computer rather than a file of the project (a warning: another computer draws it in its own) |
56
+
57
+ How it looks, what it says and how it is laid out are never problems.
58
+
59
+ ## In Studio and allyhub dev
60
+
61
+ A report opens in its view: the page in a frame, served from the project's files with the same rule as the render (nothing from outside the project loads), at the window's width or a desktop's, a tablet's or a phone's, scaled down when wider than the window. It is drawn again when a file it is made from changes: its own, or one its page loaded (the CSV it fetched, a face its stylesheet named), wherever it is in the project. A person changes one thing in it by hand, its theme, where its report style writes themes: the view's theme menu sets `data-theme` on the page's `<html>`, every other byte of the file kept, and you see it in the file. A read-only view (a snapshot) and a share's viewer offer no theme to set, as they offer nothing that changes the item. Anything else they point at with Mark up and send to you.
62
+
63
+ ## Look at it
64
+
65
+ `allyhub frames <report>` draws the page as the render does, from its top, and writes the picture under `.allyhub/work/frames/<place>/`:
66
+
67
+ - `--width 375` at a phone's width, `--dark` as a reader who asks for dark sees it (a page with no `prefers-color-scheme: dark` styles looks the same), `--print` laid out for paper (`@media print`) as one long picture;
68
+ - `--at <selector>` one element alone, at its size, its picture named by the selector;
69
+ - a page more than about 1.6 times as tall as it is wide is cut into bands laid side by side (at most six), so one picture shows all of it.
70
+
71
+ It says the page's height, and what it asked for that was missing or refused and what it threw.
72
+
73
+ ## Render
74
+
75
+ `allyhub render <report>` writes under `.allyhub/out/`, by its id:
76
+
77
+ - `html` (the default): one self-contained HTML file, and the render says its size and how much of it is faces. Every file the page loaded is put inside it, its bytes as they are in the project: scripts and style sheets in their tags, pictures and faces as `data:` URLs, and what its scripts loaded (`fetch`, `XMLHttpRequest`, a picture or a script made by code) answered from a table in a first script. It runs offline on any computer, its interactivity kept. A module script that imports another file stops it, with why.
78
+ - `pdf`: Chrome's print of the page, its backgrounds printed, on Letter (`--param paper=a4`) unless its `@page` names a size; write `@media print` for paper.
79
+ - `png`: the whole page as one long picture at its width.
80
+
81
+ `--type html,pdf,png` makes them all.
82
+
83
+ ## Report styles
84
+
85
+ A report style is a look written down for a report to start from when the person gives no style of their own: a reference, never a limit, and never a component.
86
+
87
+ - `allyhub report style list` names them, each with its themes.
88
+ - `allyhub report style show <name>` prints one: its themes, tokens, type, page, example parts and charts.
89
+ - `allyhub report style use <report> <name>` writes its `style.css` (the tokens as CSS variables, each theme as `[data-theme="…"]`, the faces' `@font-face` rules, reduced motion) and `tokens.js` (the same tokens for a canvas chart: `reportToken("hero-deco2")`) in the report's `style/` folder, and copies its faces and Chart.js once into the project's `assets/report-styles/<name>/`. It prints the lines to link them. The files are then the report's own: change them as it needs; `--force` writes style.css and tokens.js again.
package/docs/sheets.md CHANGED
@@ -402,7 +402,7 @@ A name of openpyxl's that is not held throws where it is used, naming what the c
402
402
  - `allyhub sheet diff <was> <now>` compares two versions, two folders or a folder and an `.xlsx`: what changed value under a formula that did not, what changed formula with its value the same, both, what came and went, names, a table's rows lined up by its `key`, else by their place. `--tolerance`, `--all`, `--json`.
403
403
  - `allyhub sheet capabilities` says what the SDK holds of openpyxl's.
404
404
  - `allyhub sheet import <file> --to finance/forecast.yaml` makes a sheet of an Excel, CSV or TSV file, its tables' rows in `finance/data/`, never over a place that is taken (see [Excel](#excel)).
405
- - `allyhub render` writes each sheet to `.allyhub/out/<id>/`: `--type xlsx` (the default), `pdf`, `png`, `csv` (a file a sheet), `md`, `json`. A sheet with a problem is not written.
405
+ - `allyhub render` writes each sheet to `.allyhub/out/<id>/`: `--type xlsx` (the default), `pdf`, `png`, `csv` (a file a sheet, named after it). An agent reads a sheet's values with `allyhub sheet calc`, not a file. A sheet with a problem is not written.
406
406
  - `allyhub frames <sheet>` draws a picture of a sheet as a person sees it, letters and numbers on its edges; `--range` names a sheet (`Summary`), a range (`Summary!B3:D9`), columns (`A:C`) or rows (`1:20`). Without a range it draws the first 200 rows and 60 columns of each sheet, and says what it left out.
407
407
 
408
408
  `allyhub help sheet` and `allyhub help render` give every option.
package/docs/x.md CHANGED
@@ -70,4 +70,4 @@ $$
70
70
 
71
71
  `allyhub check` reports what X refuses under `allyhub.x/…`, at its line. `allyhub inspect <post>` gives each post's weighted length beside 280 and 25,000, its links, mentions, hashtags and cashtags, and its media's bytes; `allyhub inspect <article>` its words, its weighted length, its headings, its media, its embedded posts and links' cards, and its code's weight against 10,000. `allyhub frames` draws a post or an article as X shows it once published (a thread as the timeline does, an article in X's column), in Inter in place of X's own face; an embedded post and a link's card are drawn by their address, as their content is X's to fetch.
72
72
 
73
- `allyhub render <post>` writes POST /2/tweets's request for each post (`posts.json`, the media beside it), or each post's text (`--type txt`). `allyhub render <article>` writes POST /2/articles/draft's request (`article.json`, its media beside it with `media.json`). Publishing to X is not built.
73
+ `allyhub render <post>` writes POST /2/tweets's request for each post (`posts.json`, the media beside it), or what a person posts by hand (`--type txt`: each post's text as written, `1.txt`, `2.txt`…, each medium beside it as `<post>-<place>` and its alt text in `<post>-<place>.alt.txt`). `allyhub render <article>` writes POST /2/articles/draft's request (`article.json`, its media beside it with `media.json`). The editor's Export offers `txt` and a picture (`png`) of a post, and a picture of an article; the requests wait for publishing. Publishing to X is not built.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/sdk",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "What an agent writes videos, decks and workbooks with: each built-in kind's authoring API, re-exported from its extension. The root, /dom, /media and /scenery are the video's: video(), parts with their speech, footage and sounds, defineComponent() and custom() layers, the layout, motion and input helpers, the scenery() layer's options; /slides is the deck's, python-pptx's API; /image is the image's, its boards each its own size; /sheets is the sheet's, openpyxl's API. Nothing a host needs.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "homepage": "https://allyhub.com",
@@ -1,337 +0,0 @@
1
- import { z } from "zod";
2
- /** The version of these messages; `bridge/hello` carries each end's. */
3
- export declare const BRIDGE_PROTOCOL = 1;
4
- /** The native messaging host Studio installs, by the name Chrome knows it. */
5
- export declare const BRIDGE_NATIVE_HOST = "com.allyhub.browser";
6
- /**
7
- * What an agent names the person's own browser by when it does not care
8
- * which (`ALLYHUB_BROWSER=person`): their default one if it is connected,
9
- * else the one connected.
10
- */
11
- export declare const PERSON_BROWSER = "person";
12
- /** Where a Host's door takes the extension's WebSocket (behind a cloud Studio's gateway, with a ticket). */
13
- export declare const BRIDGE_PATH = "/browser";
14
- /**
15
- * The extension's IDs: the store's (v1's listing, which carries the
16
- * bridge beside v1's features) and the development build's, fixed by the
17
- * `key` in its manifest. A native host's manifest names both; a Host's
18
- * door lets in only their origins.
19
- */
20
- export declare const BRIDGE_EXTENSION_IDS: {
21
- readonly store: "pmckbhaedjblcbkbkcbmmogpealiaeol";
22
- readonly development: "dbmenjkebdgjkhjdcicplkaakmjcjhdp";
23
- };
24
- /** Where a person installs the extension (Chrome's store; Edge, Brave, Arc and the others install from it too). */
25
- export declare const BRIDGE_STORE_URL: string;
26
- /** The origins a Host's door accepts the extension's WebSocket from. */
27
- export declare const BRIDGE_EXTENSION_ORIGINS: readonly string[];
28
- /**
29
- * The pages that may hand the extension a ticket to a cloud Studio (its
30
- * `externally_connectable`): AllyHub's window, production's and staging's.
31
- * Never `*.allyhub.studio`, which serves projects' code.
32
- */
33
- export declare const BRIDGE_WINDOW_ORIGINS: readonly ["https://app.allyhub.com", "https://app.allyhub-staging.com"];
34
- /** The domains a cloud Studio's Host is reached under (its gateway's), production's and staging's. */
35
- export declare const BRIDGE_STUDIO_DOMAINS: readonly ["allyhub.studio", "allyhub-studio-staging.com"];
36
- /** What AllyHub's window asks the extension (`chrome.runtime.sendMessage` to it). */
37
- export declare const BridgeWindowMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
38
- type: z.ZodLiteral<"allyhub/bridge/status">;
39
- }, z.core.$strip>, z.ZodObject<{
40
- type: z.ZodLiteral<"allyhub/bridge/connect">;
41
- url: z.ZodString;
42
- }, z.core.$strip>], "type">;
43
- export type BridgeWindowMessage = z.infer<typeof BridgeWindowMessageSchema>;
44
- /** The extension's answer to the window. */
45
- export declare const BridgeWindowAnswerSchema: z.ZodObject<{
46
- version: z.ZodString;
47
- connected: z.ZodArray<z.ZodString>;
48
- error: z.ZodOptional<z.ZodString>;
49
- }, z.core.$strip>;
50
- export type BridgeWindowAnswer = z.infer<typeof BridgeWindowAnswerSchema>;
51
- /**
52
- * The address the extension may connect to, a window gave it: a cloud
53
- * Studio's door (`wss://<sandbox>.allyhub.studio/browser`), never another
54
- * server; a development build, a Host on this computer too, named
55
- * `localhost`, `127.0.0.1` or any `*.localhost` (`cloud:local` reaches a
56
- * Host as `<sandbox>.studio.localhost`). `undefined` for any other.
57
- *
58
- * Read by the URL parser, not a pattern: what it returns is the address
59
- * the extension connects to, so a spelling a pattern reads apart from the
60
- * parser (a backslash, an encoded slash) cannot reach another server.
61
- */
62
- export declare function bridgeTarget(url: string, development: boolean): URL | undefined;
63
- /**
64
- * The largest message Chrome passes from a native host to its extension
65
- * is 1 MB; the other way, 64 MiB. A Host splits what it sends over native
66
- * messaging into parts well under that (`splitNative`), and the extension
67
- * puts them together again (`NativeParts`).
68
- */
69
- export declare const NATIVE_PART_CHARS: number;
70
- /** Browsers the extension runs in, by their product. */
71
- export declare const BROWSER_PRODUCTS: readonly ["chrome", "edge", "brave", "arc", "opera", "vivaldi", "chromium"];
72
- export declare const BrowserProductSchema: z.ZodUnion<readonly [z.ZodEnum<{
73
- chrome: "chrome";
74
- edge: "edge";
75
- brave: "brave";
76
- arc: "arc";
77
- opera: "opera";
78
- vivaldi: "vivaldi";
79
- chromium: "chromium";
80
- }>, z.core.$ZodBranded<z.ZodString, "Unknown", "out">]>;
81
- export type BrowserProduct = z.infer<typeof BrowserProductSchema>;
82
- /** How a browser is called to a person. */
83
- export declare const BROWSER_PRODUCT_NAMES: Record<(typeof BROWSER_PRODUCTS)[number], string>;
84
- /** A browser's name for a person: its product's, or the word itself for one this version does not know. */
85
- export declare const browserName: (product: string) => string;
86
- /** The extension says who it is, first, on every connection. */
87
- export declare const BridgeHelloSchema: z.ZodObject<{
88
- protocol: z.ZodInt;
89
- extension: z.ZodObject<{
90
- id: z.ZodString;
91
- version: z.ZodString;
92
- }, z.core.$strip>;
93
- browser: z.ZodObject<{
94
- id: z.ZodString;
95
- product: z.ZodUnion<readonly [z.ZodEnum<{
96
- chrome: "chrome";
97
- edge: "edge";
98
- brave: "brave";
99
- arc: "arc";
100
- opera: "opera";
101
- vivaldi: "vivaldi";
102
- chromium: "chromium";
103
- }>, z.core.$ZodBranded<z.ZodString, "Unknown", "out">]>;
104
- version: z.ZodString;
105
- userAgent: z.ZodString;
106
- }, z.core.$strip>;
107
- }, z.core.$strip>;
108
- export type BridgeHello = z.infer<typeof BridgeHelloSchema>;
109
- /** The Host's answer: who it is, so the extension can name it. */
110
- export declare const BridgeWelcomeSchema: z.ZodObject<{
111
- protocol: z.ZodInt;
112
- host: z.ZodObject<{
113
- name: z.ZodString;
114
- remote: z.ZodBoolean;
115
- }, z.core.$strip>;
116
- }, z.core.$strip>;
117
- export type BridgeWelcome = z.infer<typeof BridgeWelcomeSchema>;
118
- /** A tab, as `chrome.tabs` describes it, and only what the Host uses. */
119
- export declare const BridgeTabSchema: z.ZodObject<{
120
- tabId: z.ZodInt;
121
- windowId: z.ZodOptional<z.ZodInt>;
122
- url: z.ZodOptional<z.ZodString>;
123
- title: z.ZodOptional<z.ZodString>;
124
- openerTabId: z.ZodOptional<z.ZodInt>;
125
- active: z.ZodOptional<z.ZodBoolean>;
126
- status: z.ZodOptional<z.ZodString>;
127
- }, z.core.$strip>;
128
- export type BridgeTab = z.infer<typeof BridgeTabSchema>;
129
- /**
130
- * A group of the agent's tabs: a Chrome tab group per project, named for
131
- * it. `key` is the Host's, the same for the same project.
132
- */
133
- export declare const BridgeGroupSchema: z.ZodObject<{
134
- key: z.ZodString;
135
- title: z.ZodString;
136
- }, z.core.$strip>;
137
- export type BridgeGroup = z.infer<typeof BridgeGroupSchema>;
138
- /** Why Chrome let go of a tab (`chrome.debugger.onDetach`'s reasons, and the extension's own). */
139
- export declare const DETACH_REASONS: readonly ["target_closed", "canceled_by_user", "not_allowed", "released"];
140
- export declare const DetachReasonSchema: z.ZodUnion<readonly [z.ZodEnum<{
141
- target_closed: "target_closed";
142
- canceled_by_user: "canceled_by_user";
143
- not_allowed: "not_allowed";
144
- released: "released";
145
- }>, z.core.$ZodBranded<z.ZodString, "Unknown", "out">]>;
146
- /** A CDP command for a tab: the tab's own session, or a child's (a frame in another process, a worker). */
147
- export declare const BridgeCdpSchema: z.ZodObject<{
148
- tabId: z.ZodInt;
149
- sessionId: z.ZodOptional<z.ZodString>;
150
- method: z.ZodString;
151
- params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
152
- }, z.core.$strip>;
153
- /** What the Host asks of the extension. */
154
- export declare const BRIDGE_EXTENSION_METHODS: {
155
- readonly "tabs/create": import("./jsonrpc.js").MethodSpec<z.ZodObject<{
156
- group: z.ZodObject<{
157
- key: z.ZodString;
158
- title: z.ZodString;
159
- }, z.core.$strip>;
160
- url: z.ZodOptional<z.ZodString>;
161
- }, z.core.$strip>, z.ZodObject<{
162
- tabId: z.ZodInt;
163
- windowId: z.ZodOptional<z.ZodInt>;
164
- url: z.ZodOptional<z.ZodString>;
165
- title: z.ZodOptional<z.ZodString>;
166
- openerTabId: z.ZodOptional<z.ZodInt>;
167
- active: z.ZodOptional<z.ZodBoolean>;
168
- status: z.ZodOptional<z.ZodString>;
169
- }, z.core.$strip>>;
170
- readonly "tabs/close": import("./jsonrpc.js").MethodSpec<z.ZodObject<{
171
- tabId: z.ZodInt;
172
- }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>>;
173
- readonly "tabs/activate": import("./jsonrpc.js").MethodSpec<z.ZodObject<{
174
- tabId: z.ZodInt;
175
- }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>>;
176
- readonly "debugger/attach": import("./jsonrpc.js").MethodSpec<z.ZodObject<{
177
- tabId: z.ZodInt;
178
- group: z.ZodObject<{
179
- key: z.ZodString;
180
- title: z.ZodString;
181
- }, z.core.$strip>;
182
- }, z.core.$strip>, z.ZodObject<{
183
- targetInfo: z.ZodRecord<z.ZodString, z.ZodUnknown>;
184
- }, z.core.$strip>>;
185
- readonly "debugger/detach": import("./jsonrpc.js").MethodSpec<z.ZodObject<{
186
- tabId: z.ZodInt;
187
- }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>>;
188
- readonly "debugger/send": import("./jsonrpc.js").MethodSpec<z.ZodObject<{
189
- tabId: z.ZodInt;
190
- sessionId: z.ZodOptional<z.ZodString>;
191
- method: z.ZodString;
192
- params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
193
- }, z.core.$strip>, z.ZodRecord<z.ZodString, z.ZodUnknown>>;
194
- readonly "groups/release": import("./jsonrpc.js").MethodSpec<z.ZodObject<{
195
- key: z.ZodString;
196
- }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>>;
197
- };
198
- /** What the extension asks of the Host. */
199
- export declare const BRIDGE_HOST_METHODS: {
200
- readonly "bridge/hello": import("./jsonrpc.js").MethodSpec<z.ZodObject<{
201
- protocol: z.ZodInt;
202
- extension: z.ZodObject<{
203
- id: z.ZodString;
204
- version: z.ZodString;
205
- }, z.core.$strip>;
206
- browser: z.ZodObject<{
207
- id: z.ZodString;
208
- product: z.ZodUnion<readonly [z.ZodEnum<{
209
- chrome: "chrome";
210
- edge: "edge";
211
- brave: "brave";
212
- arc: "arc";
213
- opera: "opera";
214
- vivaldi: "vivaldi";
215
- chromium: "chromium";
216
- }>, z.core.$ZodBranded<z.ZodString, "Unknown", "out">]>;
217
- version: z.ZodString;
218
- userAgent: z.ZodString;
219
- }, z.core.$strip>;
220
- }, z.core.$strip>, z.ZodObject<{
221
- protocol: z.ZodInt;
222
- host: z.ZodObject<{
223
- name: z.ZodString;
224
- remote: z.ZodBoolean;
225
- }, z.core.$strip>;
226
- }, z.core.$strip>>;
227
- };
228
- /** What the extension tells the Host. */
229
- export declare const BRIDGE_HOST_NOTIFICATIONS: {
230
- readonly "tabs/added": import("./jsonrpc.js").NotificationSpec<z.ZodObject<{
231
- key: z.ZodString;
232
- tab: z.ZodObject<{
233
- tabId: z.ZodInt;
234
- windowId: z.ZodOptional<z.ZodInt>;
235
- url: z.ZodOptional<z.ZodString>;
236
- title: z.ZodOptional<z.ZodString>;
237
- openerTabId: z.ZodOptional<z.ZodInt>;
238
- active: z.ZodOptional<z.ZodBoolean>;
239
- status: z.ZodOptional<z.ZodString>;
240
- }, z.core.$strip>;
241
- }, z.core.$strip>>;
242
- readonly "tabs/updated": import("./jsonrpc.js").NotificationSpec<z.ZodObject<{
243
- tab: z.ZodObject<{
244
- tabId: z.ZodInt;
245
- windowId: z.ZodOptional<z.ZodInt>;
246
- url: z.ZodOptional<z.ZodString>;
247
- title: z.ZodOptional<z.ZodString>;
248
- openerTabId: z.ZodOptional<z.ZodInt>;
249
- active: z.ZodOptional<z.ZodBoolean>;
250
- status: z.ZodOptional<z.ZodString>;
251
- }, z.core.$strip>;
252
- }, z.core.$strip>>;
253
- readonly "tabs/removed": import("./jsonrpc.js").NotificationSpec<z.ZodObject<{
254
- tabId: z.ZodInt;
255
- }, z.core.$strip>>;
256
- readonly "debugger/event": import("./jsonrpc.js").NotificationSpec<z.ZodObject<{
257
- tabId: z.ZodInt;
258
- sessionId: z.ZodOptional<z.ZodString>;
259
- method: z.ZodString;
260
- params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
261
- }, z.core.$strip>>;
262
- readonly "debugger/detached": import("./jsonrpc.js").NotificationSpec<z.ZodObject<{
263
- tabId: z.ZodInt;
264
- reason: z.ZodUnion<readonly [z.ZodEnum<{
265
- target_closed: "target_closed";
266
- canceled_by_user: "canceled_by_user";
267
- not_allowed: "not_allowed";
268
- released: "released";
269
- }>, z.core.$ZodBranded<z.ZodString, "Unknown", "out">]>;
270
- }, z.core.$strip>>;
271
- readonly "bridge/stopped": import("./jsonrpc.js").NotificationSpec<z.ZodObject<{}, z.core.$strip>>;
272
- readonly "bridge/ping": import("./jsonrpc.js").NotificationSpec<z.ZodObject<{}, z.core.$strip>>;
273
- };
274
- /** Why a CDP command is refused, or undefined when it is relayed. */
275
- export declare function refusedCdp(cdpMethod: string): string | undefined;
276
- /** Pages no agent may use: the browser's own, other extensions', the store. */
277
- export declare function usableUrl(url: string | undefined): boolean;
278
- /** One part of a message too large for native messaging. */
279
- export declare const NativePartSchema: z.ZodObject<{
280
- part: z.ZodObject<{
281
- id: z.ZodInt;
282
- index: z.ZodInt;
283
- count: z.ZodInt;
284
- text: z.ZodString;
285
- }, z.core.$strip>;
286
- }, z.core.$strip>;
287
- /** A message as native messaging carries it to the extension: whole, or in parts. */
288
- export declare function splitNative(text: string, nextId: () => number, max?: number): string[];
289
- /** Puts a message sent in parts together again: undefined until its last part. */
290
- export declare class NativeParts {
291
- private readonly pending;
292
- /** A message received: itself when whole, its text once its last part came, or undefined. */
293
- take(message: unknown): unknown;
294
- }
295
- /** An error the other end answered with. */
296
- export declare class BridgeError extends Error {
297
- readonly code: number;
298
- constructor(code: number, message: string);
299
- }
300
- export interface BridgePeerOptions {
301
- /** Sends one message to the other end. */
302
- send(message: unknown): void;
303
- /** Answers a request: its result, or throws (a `BridgeError` keeps its code). */
304
- request?(method: string, params: unknown): Promise<unknown>;
305
- /** Hears a notification. */
306
- notify?(method: string, params: unknown): void;
307
- /** How long a request waits for its answer, by method; default 30 s. */
308
- timeoutMs?(method: string): number;
309
- }
310
- /**
311
- * One end of the bridge: requests both ways, notifications both ways, over
312
- * any transport that carries a message at a time. An answer is handed to
313
- * its caller as it arrives, before any message after it is read, so a CDP
314
- * client sees a command's answer and the events after it in Chrome's
315
- * order (Browser MCP's ordering fix).
316
- */
317
- export declare class BridgePeer {
318
- private readonly o;
319
- private readonly pending;
320
- private next;
321
- private closed;
322
- constructor(options: BridgePeerOptions);
323
- request(method: string, params: unknown): Promise<unknown>;
324
- /**
325
- * A request whose answer is handed to `done` as it is read, before any
326
- * message after it: what a relay uses to keep a command's answer ahead
327
- * of the events Chrome sent after it.
328
- */
329
- call(method: string, params: unknown, done: (error: Error | undefined, result: unknown) => void): void;
330
- notify(method: string, params: unknown): void;
331
- /** A message from the other end. */
332
- receive(message: unknown): void;
333
- /** The transport ended: every request waiting fails. */
334
- close(reason: string): void;
335
- get isClosed(): boolean;
336
- }
337
- //# sourceMappingURL=browser-bridge.d.ts.map
@@ -1,2 +0,0 @@
1
- /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{z as e}from"zod";import{method as d,notification as g}from"./jsonrpc.js";import{known as b,openEnum as l}from"./open.js";export const BRIDGE_PROTOCOL=1,BRIDGE_NATIVE_HOST="com.allyhub.browser",PERSON_BROWSER="person",BRIDGE_PATH="/browser",BRIDGE_EXTENSION_IDS={store:"pmckbhaedjblcbkbkcbmmogpealiaeol",development:"dbmenjkebdgjkhjdcicplkaakmjcjhdp"},BRIDGE_STORE_URL=`https://chromewebstore.google.com/detail/${BRIDGE_EXTENSION_IDS.store}`,BRIDGE_EXTENSION_ORIGINS=Object.values(BRIDGE_EXTENSION_IDS).map(r=>`chrome-extension://${r}`),BRIDGE_WINDOW_ORIGINS=["https://app.allyhub.com","https://app.allyhub-staging.com"],BRIDGE_STUDIO_DOMAINS=["allyhub.studio","allyhub-studio-staging.com"],BridgeWindowMessageSchema=e.discriminatedUnion("type",[e.object({type:e.literal("allyhub/bridge/status")}),e.object({type:e.literal("allyhub/bridge/connect"),url:e.string()})]),BridgeWindowAnswerSchema=e.object({version:e.string(),connected:e.array(e.string()),error:e.string().optional()});export function bridgeTarget(r,o){let t;try{t=new URL(r)}catch{return}if(t.username!==""||t.password!==""||t.pathname!==BRIDGE_PATH||t.hash!=="")return;const n=t.protocol.toLowerCase(),s=t.hostname.toLowerCase();if(n==="wss:"&&BRIDGE_STUDIO_DOMAINS.some(a=>s.endsWith(`.${a}`))||o&&(n==="ws:"||n==="wss:")&&(s==="127.0.0.1"||s==="localhost"||s.endsWith(".localhost")))return t}export const NATIVE_PART_CHARS=128*1024,BROWSER_PRODUCTS=["chrome","edge","brave","arc","opera","vivaldi","chromium"],BrowserProductSchema=l(BROWSER_PRODUCTS),BROWSER_PRODUCT_NAMES={chrome:"Google Chrome",edge:"Microsoft Edge",brave:"Brave",arc:"Arc",opera:"Opera",vivaldi:"Vivaldi",chromium:"Chromium"},browserName=r=>b(BROWSER_PRODUCTS,r)?BROWSER_PRODUCT_NAMES[r]:r,BridgeHelloSchema=e.object({protocol:e.int().min(1),extension:e.object({id:e.string(),version:e.string()}),browser:e.object({id:e.string().min(1).max(100),product:BrowserProductSchema,version:e.string(),userAgent:e.string()})}),BridgeWelcomeSchema=e.object({protocol:e.int().min(1),host:e.object({name:e.string(),remote:e.boolean()})}),BridgeTabSchema=e.object({tabId:e.int(),windowId:e.int().optional(),url:e.string().optional(),title:e.string().optional(),openerTabId:e.int().optional(),active:e.boolean().optional(),status:e.string().optional()}),BridgeGroupSchema=e.object({key:e.string().min(1).max(200),title:e.string().min(1).max(80)}),DETACH_REASONS=["target_closed","canceled_by_user","not_allowed","released"],DetachReasonSchema=l(DETACH_REASONS),BridgeCdpSchema=e.object({tabId:e.int(),sessionId:e.string().optional(),method:e.string().min(1),params:e.record(e.string(),e.unknown()).optional()});const p=e.object({});export const BRIDGE_EXTENSION_METHODS={"tabs/create":d(e.object({group:BridgeGroupSchema,url:e.string().optional()}),BridgeTabSchema,"Opens a tab in the background, in the group, and attaches the debugger to it."),"tabs/close":d(e.object({tabId:e.int()}),p,"Closes a tab."),"tabs/activate":d(e.object({tabId:e.int()}),p,"Shows a tab to the person (a handoff: something only they can do)."),"debugger/attach":d(e.object({tabId:e.int(),group:BridgeGroupSchema}),e.object({targetInfo:e.record(e.string(),e.unknown())}),"Attaches the debugger to a tab and keeps it in the group: its Target.getTargetInfo."),"debugger/detach":d(e.object({tabId:e.int()}),p,"Lets go of a tab; it stays open, in its group."),"debugger/send":d(BridgeCdpSchema,e.record(e.string(),e.unknown()),"Sends a CDP command to an attached tab, refused when it reaches past the tab."),"groups/release":d(e.object({key:e.string()}),p,"Lets go of every tab of a group and ungroups them; they stay open for the person.")},BRIDGE_HOST_METHODS={"bridge/hello":d(BridgeHelloSchema,BridgeWelcomeSchema,"The extension says who it is; the Host who it is.")},BRIDGE_HOST_NOTIFICATIONS={"tabs/added":g(e.object({key:e.string(),tab:BridgeTabSchema}),"A tab joined a group: the person dragged it in, or one of the group's pages opened it."),"tabs/updated":g(e.object({tab:BridgeTabSchema}),"A tab of a group changed: its address, title or loading."),"tabs/removed":g(e.object({tabId:e.int()}),"A tab of a group closed or left it."),"debugger/event":g(BridgeCdpSchema,"A CDP event from an attached tab."),"debugger/detached":g(e.object({tabId:e.int(),reason:DetachReasonSchema}),"Chrome let go of a tab, or the extension did."),"bridge/stopped":g(e.object({}),"The person stopped the agents (Cancel on Chrome's debugging bar): every tab was let go."),"bridge/ping":g(e.object({}),"Keeps a WebSocket, and so the extension's service worker, alive.")};const m=new Set(["Network.getAllCookies","Network.getCookies","Network.setCookie","Network.setCookies","Network.deleteCookies","Network.clearBrowserCookies","Network.clearBrowserCache","Network.loadNetworkResource","Page.setDownloadBehavior","Security.setIgnoreCertificateErrors","Target.attachToTarget","Target.attachToBrowserTarget","Target.activateTarget","Target.closeTarget","Target.createTarget","Target.createBrowserContext","Target.disposeBrowserContext","Target.exposeDevToolsProtocol","Target.getTargets","Target.sendMessageToTarget","Target.setDiscoverTargets","Target.setRemoteLocations"]),f=new Set(["Storage","IndexedDB","CacheStorage","DOMStorage","Browser","SystemInfo"]);export function refusedCdp(r){const o=r.split(".")[0]??"";if(m.has(r)||f.has(o))return`AllyHub's extension does not allow ${r} in the person's browser: it reaches past the tab (other sites, other tabs, or the browser itself).`}export function usableUrl(r){if(r===void 0||r===""||r==="about:blank")return!0;const o=/^https?:\/\/(?:[^@/?#]*@)?(\[[^\]]*\]|[^:/?#]+)(?::\d*)?([^?#]*)/iu.exec(r);if(!o)return!1;const t=(o[1]??"").toLowerCase(),n=o[2]===void 0||o[2]===""?"/":o[2];return!w.some(s=>t===s.host&&n.startsWith(s.path))}const w=[{host:"chromewebstore.google.com",path:"/"},{host:"chrome.google.com",path:"/webstore"},{host:"microsoftedge.microsoft.com",path:"/addons"}];export const NativePartSchema=e.object({part:e.object({id:e.int(),index:e.int().min(0),count:e.int().min(1),text:e.string()})});export function splitNative(r,o,t=NATIVE_PART_CHARS){if(r.length<=t)return[r];const n=o(),s=Math.ceil(r.length/t),a=[];for(let i=0;i<s;i++)a.push(JSON.stringify({part:{id:n,index:i,count:s,text:r.slice(i*t,(i+1)*t)}}));return a}export class NativeParts{pending=new Map;take(o){const t=NativePartSchema.safeParse(o);if(!t.success)return o;const{id:n,index:s,count:a,text:i}=t.data.part;let c=this.pending.get(n);if(c||(c=[],this.pending.set(n,c)),c[s]=i,!(c.filter(u=>typeof u=="string").length<a))return this.pending.delete(n),JSON.parse(c.join(""))}}export class BridgeError extends Error{code;constructor(o,t){super(t),this.name="BridgeError",this.code=o}}const h=globalThis;export class BridgePeer{o;pending=new Map;next=1;closed;constructor(o){this.o=o}request(o,t){return new Promise((n,s)=>{this.call(o,t,(a,i)=>{a?s(a):n(i)})})}call(o,t,n){if(this.closed){n(this.closed,void 0);return}const s=this.next++,a=this.o.timeoutMs?.(o)??3e4,i=h.setTimeout(()=>{this.pending.delete(s),n(new BridgeError(-32005,`${o} had no answer in ${String(a/1e3)} s.`),void 0)},a);this.pending.set(s,{method:o,done:n,timer:i});try{this.o.send({jsonrpc:"2.0",id:s,method:o,params:t})}catch(c){h.clearTimeout(i),this.pending.delete(s),n(c instanceof Error?c:new Error(String(c)),void 0)}}notify(o,t){this.closed||this.o.send({jsonrpc:"2.0",method:o,params:t})}receive(o){if(typeof o!="object"||o===null)return;const t=o;if(typeof t.method=="string"){if(typeof t.id=="number"||typeof t.id=="string"){const s=t.id;(this.o.request?this.o.request(t.method,t.params??{}):Promise.reject(new BridgeError(-32601,`There is no method "${t.method}".`))).then(i=>{this.closed||this.o.send({jsonrpc:"2.0",id:s,result:i??{}})},i=>{this.closed||this.o.send({jsonrpc:"2.0",id:s,error:{code:i instanceof BridgeError?i.code:-32603,message:i instanceof Error?i.message:String(i)}})})}else this.o.notify?.(t.method,t.params??{});return}if(typeof t.id!="number")return;const n=this.pending.get(t.id);n&&(this.pending.delete(t.id),h.clearTimeout(n.timer),t.error!==void 0?n.done(new BridgeError(typeof t.error.code=="number"?t.error.code:-32603,typeof t.error.message=="string"?t.error.message:n.method),void 0):n.done(void 0,t.result))}close(o){if(!this.closed){this.closed=new BridgeError(-32005,o);for(const t of this.pending.values())h.clearTimeout(t.timer),t.done(this.closed,void 0);this.pending.clear()}}get isClosed(){return this.closed!==void 0}}