@agentshouse/app-bridge 0.1.0-ca559eade7c19 → 0.1.0-ca6bf24eae119

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 (55) hide show
  1. package/README.md +9 -9
  2. package/dist/calls.d.ts +676 -69
  3. package/dist/index.d.ts +36 -18
  4. package/dist/mdmodel/condition.d.ts +23 -10
  5. package/dist/mdmodel/definition.d.ts +3 -1
  6. package/dist/mdmodel/document.d.ts +5 -5
  7. package/dist/mdmodel/index.d.ts +9 -7
  8. package/dist/mdmodel/links.d.ts +28 -0
  9. package/dist/mdmodel/paths.d.ts +9 -1
  10. package/dist/mdmodel/project.d.ts +1 -0
  11. package/dist/mdmodel/types.d.ts +28 -4
  12. package/dist/mdmodel/validate.d.ts +27 -3
  13. package/dist/mdruntime/adapter.d.ts +83 -48
  14. package/dist/mdruntime/binary.d.ts +0 -5
  15. package/dist/mdruntime/chain.d.ts +10 -0
  16. package/dist/mdruntime/change-set.d.ts +9 -16
  17. package/dist/mdruntime/change.d.ts +31 -1
  18. package/dist/mdruntime/client.d.ts +13 -5
  19. package/dist/mdruntime/collection.d.ts +10 -21
  20. package/dist/mdruntime/compile.d.ts +15 -0
  21. package/dist/mdruntime/connection.d.ts +25 -13
  22. package/dist/mdruntime/conversation.d.ts +19 -6
  23. package/dist/mdruntime/durability.d.ts +2 -5
  24. package/dist/mdruntime/fulltext.d.ts +26 -0
  25. package/dist/mdruntime/identity.d.ts +6 -0
  26. package/dist/mdruntime/media.d.ts +7 -0
  27. package/dist/mdruntime/messages.d.ts +27 -0
  28. package/dist/mdruntime/model.d.ts +6 -1
  29. package/dist/mdruntime/observation.d.ts +15 -0
  30. package/dist/mdruntime/opened.d.ts +21 -0
  31. package/dist/mdruntime/outcome.d.ts +45 -7
  32. package/dist/mdruntime/overlay.d.ts +2 -5
  33. package/dist/mdruntime/query.d.ts +32 -2
  34. package/dist/mdruntime/reach.d.ts +13 -4
  35. package/dist/mdruntime/readiness.d.ts +14 -15
  36. package/dist/mdruntime/recovery.d.ts +3 -2
  37. package/dist/mdruntime/replica.d.ts +55 -33
  38. package/dist/mdruntime/room-draft.d.ts +21 -3
  39. package/dist/mdruntime/save.d.ts +53 -14
  40. package/dist/mdruntime/search.d.ts +23 -42
  41. package/dist/mdruntime/status.d.ts +4 -3
  42. package/dist/mdruntime/store.d.ts +90 -97
  43. package/dist/mdruntime/stored.d.ts +129 -0
  44. package/dist/mdruntime/tables.d.ts +324 -0
  45. package/dist/mdruntime/wire.d.ts +33 -1
  46. package/dist/test-host.d.ts +7 -4
  47. package/dist/test-host.js +18 -28
  48. package/docs/families.md +50 -49
  49. package/package.json +8 -3
  50. package/dist/mdruntime/acquisition.d.ts +0 -13
  51. package/dist/mdruntime/file.d.ts +0 -19
  52. package/dist/mdruntime/rows.d.ts +0 -37
  53. package/dist/mdruntime/shared.d.ts +0 -10
  54. package/dist/mdruntime/transfer.d.ts +0 -9
  55. package/dist/mdruntime/turn.d.ts +0 -6
package/docs/families.md CHANGED
@@ -13,8 +13,7 @@
13
13
  absolute path, carries its current address as the return target, and the page
14
14
  returns there when it completes. An App names an address House gave it in a
15
15
  reading and composes one only for `/bind/<app_ref>`, where the User binds
16
- its Rooms and connects its account slots, with `?slot=<name>` to open at one
17
- slot.
16
+ its Rooms, with `?slot=<name>` to open at one slot.
18
17
  - **Installation** - `install()` offers the page as a Home-screen app. Where the
19
18
  browser has an install prompt ready the shell shows it and the call resolves
20
19
  `'accepted'` or `'dismissed'` with the User's choice, spending that prompt;
@@ -47,17 +46,21 @@
47
46
  The App reports the visitor's choice with `analyticsConsent('accept')` or
48
47
  `analyticsConsent('decline')`; the shell hands it to House's analytics loader, and
49
48
  the choice never reaches House.
50
- - **Handoff** - when House hands its runtime over to a newer build, the App keeps
51
- running, its `runtime` client and observations included: a call it makes
52
- meanwhile waits for the newer runtime, however long that takes, and is
53
- answered once, by it; each observation goes on with the newer runtime's
54
- values; and the status and the address arrive again. A runtime that ended
55
- before answering has its reads answered by the next one; since it may have
56
- applied any other call, an act on House is answered the outcome
57
- `transport-uncertainty`, and every other call, a Save or a draft write among
58
- them, fails with the retryable code `transport-uncertainty`.
59
- - **Site image read** - given a Published Room and an original attachment
60
- reference, it answers the web copy's path and metadata, or `null` when no
49
+ - **Releases and builds** - an open App keeps the release it loaded: a newer
50
+ release, or a newer House build, takes effect at the App's next load, offline
51
+ too once the browser stored it. When one tab loads a newer House build, the
52
+ other House tabs reload into it; Room Drafts, chat drafts and unsent changes
53
+ survive the reload.
54
+ - **A runtime that ends** - when the browser ends House's runtime under an open
55
+ App, the App keeps running, its `runtime` client and observations included:
56
+ each observation goes on with the next runtime's values, and the status and
57
+ the address arrive again. A runtime that ended before answering has its reads
58
+ answered by the next one; since it may have applied any other call, an act on
59
+ House is answered the outcome `transport-uncertainty`, and every other call,
60
+ a Save or a draft write among them, fails with the retryable code
61
+ `transport-uncertainty`.
62
+ - **Site image read** - given a Published Room and the Path of one of its
63
+ binary entries, it answers the web copy's path and metadata, or `null` when no
61
64
  copy exists. The original bytes never cross this bridge at a Site.
62
65
  - **App release code** - `sourceTop(app, release)` answers the top level of
63
66
  the latest successful release of an App the User may use: its folders, its
@@ -69,22 +72,21 @@
69
72
  refusal is House's `{ error: { code, retryable } }`, `app_release_not_found` for an
70
73
  App with no release; a read House does not answer, or one that outlived
71
74
  the browser's signed-in User, is `null`.
72
- - **External calls** - `callExternal({ url, method, headers, body, slot, room_ref })`
75
+ - **External calls** - `callExternal({ url, method, headers, body, room_ref })`
73
76
  has House's server send an HTTPS request to one of the release's declared
74
77
  external origins and resolves with the service's `status`, `headers` and its
75
78
  body as `body` text or `body_base64`, or a refusal as House's
76
79
  `{ error: { code, retryable } }`, or `null` when House does not answer. House fills in the
77
- App and its running release; naming an account slot and one of the App's
78
- bound Rooms places the key of the account that Room connects to the slot,
79
- when the User holds one of the account's roles there, which the App never
80
- sees, and naming neither sends no key. A Site's call names no slot, and the House panel names an
81
- `account` instead. `body_base64` replaces `body` for bytes.
80
+ App and its running release. A `room_ref` names a Room the signed-in User binds to the App
81
+ in a `write` slot, and House adds that Room's Service key for the URL's origin, which App
82
+ code never sees; a call naming no Room carries no key, and a Site's call names no Room.
83
+ `body_base64` replaces `body` for bytes.
82
84
  - **App messages** - `messages(listener)` hands the listener each message
83
85
  another holder of this App sends to this User's running copies, as `from`,
84
86
  the sender's User id, and `body`, the JSON value they sent, until the
85
87
  function it returns is called. App code sends one through the Runtime's
86
88
  `call('message.send', { to, body })` with the recipient's User id and
87
- a body of at most 32 KiB of JSON; House fills in the App and relays it only
89
+ a body of at most 32 kB of JSON; House fills in the App and relays it only
88
90
  to copies running now, storing nothing. The panel sends none.
89
91
  - **App screenshot read** - given an App reference, `readScreenshot(app)`
90
92
  answers the image this browser captured of that App's screen the first time
@@ -96,30 +98,29 @@
96
98
  after its latest release, as a JPEG `Blob`, or `null` when House holds none
97
99
  or does not answer. A Site's own renderer reads none.
98
100
 
99
- - **Cooperation** - `cooperate({ checkpoint, persist, capture, restore,
100
- ready, settle })` lets House activate a newer release of the App while it
101
- runs, keeping the User's task; the function it returns withdraws it.
102
- Register it in the entry script, before the first draw, or House treats the
103
- page as not cooperating and the newer release waits for the App's next
104
- open. When a newer release is stored, House calls `checkpoint()`, which
105
- resolves at the App's next safe checkpoint and may never resolve, then
106
- `persist()`, which makes authored work durable, then `capture()`, which
107
- answers the meaningful task the App owns, such as the selected record,
108
- filters, cursor, selection and scroll position, as JSON of at most 65,536
109
- characters; House keeps the address itself. In the newer release House
110
- calls `restore(task)` once its document has drawn, so the scroll position
111
- and focus it sets hold, or `restore(null)` when it opens the release without
112
- a task, then `ready()`, the App's own check that its local data and
113
- capabilities work, and finally `settle('committed')` once the release is
114
- active or `settle('abandoned')` when House returns to the release before
115
- it, restoring the same task there. A release House opens already active is
116
- settled `'committed'` at once, after `restore(task)` when House hands it a
117
- task, and a cooperation registered after House settled is settled at its
118
- registration. Until `settle('committed')` House fails the release's outside
119
- calls at once, as offline, those of the workers it starts included, and
120
- refuses its Saves, write acts and external calls with the retryable code
121
- `house_trial_withheld`, so a start-up effect is not repeated; run start-up
122
- effects after `settle('committed')`.
101
+ - **Chat** - `chat.mount(element, options)` places House's Chat, the one chat
102
+ in which the User's Agent conversations show, in `element` over the page's
103
+ `runtime` client, and resolves to a handle: `update(options)` replaces its
104
+ options and `unmount()` removes it. House serves the Chat with the page and
105
+ keeps it current, so the App installs and bundles nothing for it. The
106
+ options: `conversation` opens one, `null` for a new chat, `agent` is the
107
+ Agent a new chat goes to, `showChats` adds its conversation list, `width` is
108
+ `full`, the element, or `3/4`, `1/2` or `1/3` of the window docked at its
109
+ right edge, `onOpen` hears each conversation it opens as
110
+ `{ conversation, agent }`, and `onLink` takes a link without a scheme in
111
+ place of the browser. CSS custom properties named `--chat-*` on the element
112
+ or an ancestor set its look. It shows conversations only to a release that
113
+ declares them. A Site and the House panel have none: their call rejects with
114
+ an error named and coded `NotSupportedError`, with `retryable` false.
115
+
116
+ - **First place** - `cooperate({ placed })` tells House when the page has
117
+ drawn the place it opened on; the function it returns withdraws it. Register
118
+ it in the entry script, before the first draw. `placed()` resolves once the
119
+ page has drawn that place with what it shows: House keeps its
120
+ first-preparation surface over a page registered by its first draw until
121
+ then, and lifts it at the first draw of a page that registered none, so the
122
+ User goes from the surface to a drawn place in one change. House asks the
123
+ page for nothing else.
123
124
 
124
125
  ## The test host
125
126
 
@@ -141,9 +142,9 @@ records in `tabs` each `setTab`, answers a release code read from the
141
142
  by App reference and `readSiteScreenshot` from the `siteScreenshots` it was
142
143
  given by Site identifier, answers every `install()` `'manual'`, as a browser
143
144
  with no install prompt does, answers every `notifications()` `'unavailable'`,
144
- as a browser without push does, settles every `setBadge`, delivers each App
145
+ as a browser without push does, settles every `setBadge`, records in `chats`
146
+ each Chat `chat.mount` places, with its `element`, the `options` it was last
147
+ given and whether it is still `mounted`, drawing nothing, delivers each App
145
148
  message `message({ from, body })` plays, and hands `bridge.runtime` the MD
146
- Runtime client `attachRuntime(client)` gives it. `checkpoint()` runs the
147
- registered cooperation's checkpoint, persist and capture and answers the task,
148
- `restore(task)` runs its restore and answers its readiness check, and
149
- `settle(activation)` hands it the outcome.
149
+ Runtime client `attachRuntime(client)` gives it. It takes a `cooperate` and
150
+ never calls `placed()`.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agentshouse/app-bridge",
3
- "version": "0.1.0-ca559eade7c19",
4
- "description": "Types of the agents.house App bridge House hands every App: navigation, the tab title and icon, ceremonies, installation, notifications and the icon badge, status, Site image reads, App release code, App and Site screenshot reads, and App messages, with an accessor and an in-page test host.",
3
+ "version": "0.1.0-ca6bf24eae119",
4
+ "description": "Types of the agents.house App bridge House hands every App: navigation, the tab title and icon, ceremonies, installation, notifications and the icon badge, status, Site image reads, App release code, App and Site screenshot reads, App messages and the Chat, with an accessor and an in-page test host.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "sideEffects": false,
@@ -23,5 +23,10 @@
23
23
  "docs",
24
24
  "README.md",
25
25
  "LICENSE"
26
- ]
26
+ ],
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/agentshouse/core.git",
30
+ "directory": "client"
31
+ }
27
32
  }
@@ -1,13 +0,0 @@
1
- export type RuntimeDemand = {
2
- readonly whole: boolean;
3
- readonly rooms: readonly string[];
4
- readonly handles: readonly string[];
5
- readonly conversations: boolean;
6
- };
7
- export declare const WHOLE_DEMAND: RuntimeDemand;
8
- export declare function demanded(demand: RuntimeDemand, room: {
9
- readonly locator: string;
10
- readonly handle: string;
11
- }): boolean;
12
- export declare function wider(next: RuntimeDemand, current: RuntimeDemand): boolean;
13
- export declare function narrower(next: RuntimeDemand, current: RuntimeDemand): boolean;
@@ -1,19 +0,0 @@
1
- export type ChatDraftFile = {
2
- name: string;
3
- blob: Blob;
4
- };
5
- export type FileDeclaration = {
6
- name: string;
7
- mediaType: string;
8
- byteLength: number;
9
- contentHash: string;
10
- width?: number;
11
- height?: number;
12
- };
13
- export type Extent = {
14
- width: number;
15
- height: number;
16
- };
17
- export declare function extentOf(bytes: Uint8Array): Extent | null;
18
- export declare function hexDigest(digest: ArrayBuffer): string;
19
- export declare function declaredFile(file: ChatDraftFile): Promise<FileDeclaration>;
@@ -1,37 +0,0 @@
1
- import { type Frontmatter } from '../mdmodel/index.js';
2
- import type { HeadChange } from './adapter.js';
3
- import type { BinaryFileRecord } from './binary.js';
4
- import { type Composition } from './collection.js';
5
- type Fields = Readonly<Record<string, unknown>>;
6
- export type DocumentRow = {
7
- key: string;
8
- kind: 'document';
9
- room: string;
10
- path: string;
11
- type: string | null;
12
- fields: Fields;
13
- values: Fields;
14
- reached: Readonly<Record<string, readonly unknown[]>>;
15
- directories: readonly string[];
16
- text: string | null;
17
- change: HeadChange | null;
18
- fileId: string | null;
19
- binary: BinaryFileRecord | null;
20
- };
21
- export type ReferenceRow = {
22
- key: string;
23
- kind: 'reference';
24
- room: string;
25
- source: string;
26
- target: string;
27
- field: string;
28
- forms: readonly string[];
29
- path: string;
30
- type: string;
31
- };
32
- export type Row = DocumentRow | ReferenceRow;
33
- export declare function documentKey(room: string, path: string): string;
34
- export declare function roomOfKey(key: string): string;
35
- export declare function markdownPath(path: string): boolean;
36
- export declare function rowsOf(room: string, path: string, document: Frontmatter | null, composition: Composition, change: HeadChange | null, fileId: string | null, binary: BinaryFileRecord | null): readonly Row[];
37
- export {};
@@ -1,10 +0,0 @@
1
- export type Paths<V> = Readonly<Record<string, V>>;
2
- type Weigh<V> = (key: string, value: V) => number;
3
- export declare function shared<V>(map: Paths<V>): Paths<V>;
4
- export declare function patched<V>(base: Paths<V>, set: Iterable<readonly [string, V]>, removed?: Iterable<string>): Paths<V>;
5
- export declare function tally<V>(map: Paths<V>, weigh: Weigh<V>): number;
6
- export declare function sizeOf<V>(map: Paths<V>): number;
7
- export declare function differing<V>(left: Paths<V>, right: Paths<V>, same?: (left: V, right: V) => boolean): ReadonlySet<string>;
8
- export declare function drafted<V>(base: Paths<V>): Record<string, V>;
9
- export declare function settled<V>(draft: Record<string, V>): Paths<V>;
10
- export {};
@@ -1,9 +0,0 @@
1
- import type { Refusal } from '../mdmodel/index.js';
2
- export type Unconfirmed = {
3
- kind: 'unconfirmed';
4
- };
5
- export type Refused = {
6
- kind: 'refused';
7
- refusal: Refusal;
8
- };
9
- export declare const unconfirmed: Unconfirmed;
@@ -1,6 +0,0 @@
1
- export declare function yielded(): Promise<void>;
2
- export declare const ROW_WEIGHT = 256;
3
- export type Later<T> = T | Promise<T>;
4
- export declare function after<T, R>(value: Later<T>, next: (value: T) => R): Later<R>;
5
- export declare function inUnits<T>(items: Iterable<T>, each: (item: T) => number): Later<void>;
6
- export declare function inChunks<T>(items: readonly T[], weigh: (item: T) => number, each: (chunk: readonly T[]) => void): Promise<void>;