@agentshouse/app-bridge 0.1.0-alpha.1 → 0.1.0-alpha.2

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  The renderer-side client of the agents.house App bridge. An App served by House
4
4
  receives one message port before its own scripts run; this package is that
5
- port's one listener. It carries three families:
5
+ port's one listener. It carries four families:
6
6
 
7
7
  - **Navigation** - the part of the shell's URL below the App's path, with its
8
8
  query and fragment. The shell delivers it when the App starts and whenever the
@@ -12,8 +12,11 @@ port's one listener. It carries three families:
12
12
  absolute path, carries its current address as the return target, and the page
13
13
  returns there when it completes. An App names an address House gave it in a
14
14
  reading and composes none.
15
- - **Status** - sync state, credential state, release availability and observed
16
- failure.
15
+ - **Status** - the App reference the Runtime port is attached under, sync
16
+ state, credential state, release availability and observed failure.
17
+ - **Site image read** - given a Published Room and an original attachment
18
+ reference, it answers the web copy's path and metadata, or `null` when no
19
+ copy exists. The original bytes never cross this bridge at a Site.
17
20
 
18
21
  The package carries no credential handling and no Runtime family. It surfaces
19
22
  the dedicated Runtime port the worker transfers over the bridge as a plain
package/bridge.d.ts CHANGED
@@ -7,6 +7,12 @@ export declare class HouseNavigationRefused extends Error {
7
7
  readonly address: string | null;
8
8
  constructor(address: string | null);
9
9
  }
10
+ export interface HouseImageCopy {
11
+ readonly attachment: string;
12
+ readonly copy: string;
13
+ readonly name: string;
14
+ readonly media_type: string;
15
+ }
10
16
  export interface HouseBridge {
11
17
  readonly runtime: Promise<HouseMessagePort>;
12
18
  address(): string | null;
@@ -14,6 +20,7 @@ export interface HouseBridge {
14
20
  push(address: string): Promise<string>;
15
21
  replace(address: string): Promise<string>;
16
22
  ceremony(path: string): Promise<never>;
23
+ readAttachment(room: string, attachment: string): Promise<HouseImageCopy | null>;
17
24
  status(): HouseStatus | null;
18
25
  onStatus(listener: (status: HouseStatus) => void): () => void;
19
26
  }
package/bridge.js CHANGED
@@ -31,6 +31,8 @@ export function connectHouseBridge(source = heldBridge()) {
31
31
  const runtime = settled();
32
32
  const ceremonies = [];
33
33
  const navigations = [];
34
+ const attachments = new Map();
35
+ let nextAttachment = 0;
34
36
  const addressListeners = new Set();
35
37
  const statusListeners = new Set();
36
38
  let outbox = [];
@@ -75,6 +77,17 @@ export function connectHouseBridge(source = heldBridge()) {
75
77
  pending?.settle.reject(new HouseNavigationRefused(named));
76
78
  return;
77
79
  }
80
+ if (data.house === 'attachment') {
81
+ const answer = data;
82
+ if (typeof answer.id !== 'number')
83
+ return;
84
+ const pending = attachments.get(answer.id);
85
+ if (pending === undefined)
86
+ return;
87
+ attachments.delete(answer.id);
88
+ pending.resolve(answer.image ?? null);
89
+ return;
90
+ }
78
91
  if (data.house === 'ceremony-refused') {
79
92
  const refused = data.path;
80
93
  const named = typeof refused === 'string' ? refused : null;
@@ -121,6 +134,13 @@ export function connectHouseBridge(source = heldBridge()) {
121
134
  send({ house: 'ceremony', path });
122
135
  return pending.promise;
123
136
  },
137
+ readAttachment(room, attachment) {
138
+ const pending = settled();
139
+ const id = ++nextAttachment;
140
+ attachments.set(id, pending.settle);
141
+ send({ house: 'attachment-read', id, room, attachment });
142
+ return pending.promise;
143
+ },
124
144
  status() {
125
145
  return status;
126
146
  },
package/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { connectHouseBridge, HouseCeremonyRefused, HouseNavigationRefused, type HouseBridge, } from './bridge.js';
1
+ export { connectHouseBridge, HouseCeremonyRefused, HouseNavigationRefused, type HouseBridge, type HouseImageCopy, } from './bridge.js';
2
2
  export { HOUSE_ADDRESS_MAX_CHARS } from './wire.js';
3
3
  export type { HouseBridgeEvent, HouseBridgePort, HouseCredentialState, HouseMessagePort, HouseNavigationMode, HouseStatus, HouseSyncState, } from './wire.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agentshouse/app-bridge",
3
- "version": "0.1.0-alpha.1",
4
- "description": "Renderer-side client of the agents.house App bridge: navigation, ceremonies and status, with an in-page test host.",
3
+ "version": "0.1.0-alpha.2",
4
+ "description": "Renderer-side client of the agents.house App bridge: navigation, ceremonies, status and Site image reads, with an in-page test host.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
7
7
  "sideEffects": false,
package/test-host.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { HouseImageCopy } from './bridge.js';
1
2
  import type { HouseBridgePort, HouseMessagePort, HouseNavigationMode, HouseStatus } from './wire.js';
2
3
  export interface HouseBridgeNavigation {
3
4
  readonly mode: HouseNavigationMode;
@@ -15,5 +16,8 @@ export interface HouseBridgeTestHost {
15
16
  export interface HouseBridgeTestHostOptions {
16
17
  readonly address?: string;
17
18
  readonly status?: HouseStatus;
19
+ readonly images?: readonly (HouseImageCopy & {
20
+ readonly room: string;
21
+ })[];
18
22
  }
19
23
  export declare function createHouseBridgeTestHost(options?: HouseBridgeTestHostOptions): HouseBridgeTestHost;
package/test-host.js CHANGED
@@ -62,6 +62,22 @@ export function createHouseBridgeTestHost(options = {}) {
62
62
  else if (data.house === 'ceremony') {
63
63
  ceremony(data.path);
64
64
  }
65
+ else if (data.house === 'attachment-read') {
66
+ const asked = data;
67
+ const image = options.images?.find((entry) => entry.room === asked.room && entry.attachment === asked.attachment);
68
+ deliver({
69
+ house: 'attachment',
70
+ id: asked.id,
71
+ image: image === undefined
72
+ ? null
73
+ : {
74
+ attachment: image.attachment,
75
+ copy: image.copy,
76
+ name: image.name,
77
+ media_type: image.media_type,
78
+ },
79
+ });
80
+ }
65
81
  }
66
82
  const port = {
67
83
  postMessage(message) {
package/wire.d.ts CHANGED
@@ -17,6 +17,7 @@ export interface HouseCredentialState {
17
17
  readonly expires_at: number | null;
18
18
  }
19
19
  export interface HouseStatus {
20
+ readonly app: string;
20
21
  readonly runtime: string;
21
22
  readonly credential: HouseCredentialState;
22
23
  readonly sync: HouseSyncState | null;