ohpichamber-sdk 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API.md +87 -98
- package/DOCUMENTATION.md +169 -406
- package/GUEST_SERVICES.md +243 -484
- package/README.md +42 -87
- package/dist/api-version.d.ts +4 -4
- package/dist/api-version.js +3 -3
- package/dist/bootstrap.d.ts +2 -2
- package/dist/bootstrap.js +2 -2
- package/dist/contract.d.ts +3 -3
- package/dist/contract.js +6 -6
- package/dist/host-version.d.ts +7 -7
- package/dist/host-version.js +13 -13
- package/dist/host.js +54 -54
- package/dist/index.d.ts +6 -6
- package/dist/index.js +4 -4
- package/dist/manifest.d.ts +17 -17
- package/dist/message-channel-test.js +1 -1
- package/dist/navigation.js +3 -3
- package/dist/parse.d.ts +5 -5
- package/dist/parse.js +22 -22
- package/dist/protocol.d.ts +73 -73
- package/dist/protocol.js +3 -3
- package/dist/schemas.d.ts +1 -1
- package/dist/schemas.js +1 -1
- package/dist/service-host.d.ts +1 -1
- package/dist/service-host.js +3 -3
- package/dist/service-providers.d.ts +2 -2
- package/dist/service-providers.js +9 -9
- package/dist/session-events.js +2 -2
- package/package.json +3 -3
- package/scripts/bundle-guest.ts +1 -1
- package/scripts/check-guest.ts +1 -1
package/API.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# ohpichamber-sdk — developer API reference
|
|
2
2
|
|
|
3
|
-
What third-party guest authors import and call. Source of truth:
|
|
3
|
+
What third-party guest authors import and call. Source of truth: [packages/sdk/src](https://github.com/Shizuku-Yume/ohpichamber/tree/main/packages/sdk/src). Author guides live in the [product docs](https://github.com/Shizuku-Yume/ohpichamber/tree/main/packages/docs/content/docs) (`sdk.mdx`, `sdk/host.mdx`, `sdk/ui.mdx`) and in [GUEST_SERVICES.md](./GUEST_SERVICES.md) for local services.
|
|
4
4
|
|
|
5
5
|
**Package:** `ohpichamber-sdk`
|
|
6
6
|
|
|
7
7
|
**API version:** manifest `apiVersion: 1`, wire envelope `v: 2` (private `MessagePort` bootstrap)
|
|
8
8
|
|
|
9
|
-
**Runtimes that load guests:**
|
|
9
|
+
**Runtimes that load guests:** Web and Electron. `loadGuestCatalog` currently marks mobile surfaces `unsupported`, so mobile opt-in fields (`panel.mobile`, `page.mobile`) are accepted by the SDK schema but inactive in the current mobile shell.
|
|
10
10
|
|
|
11
|
-
Wire `v: 2` is the private bootstrap transport; manifest `apiVersion` stays `1` because the manifest
|
|
11
|
+
Wire `v: 2` is the private bootstrap transport; manifest `apiVersion` stays `1` because the `manifest`/`contributes` schema did not change. The host refuses a `v: 1` window `hello` and names the mismatch in the pane instead of waiting for a timeout; a `v: 1` bootstrap announcement is dropped without granting anything.
|
|
12
12
|
|
|
13
13
|
Two entrypoints:
|
|
14
14
|
|
|
@@ -44,12 +44,12 @@ Two entrypoints:
|
|
|
44
44
|
Bundle with the SDK helper from the guest folder (`--node` targets Node for the service):
|
|
45
45
|
|
|
46
46
|
```bash
|
|
47
|
-
bunx
|
|
48
|
-
bunx
|
|
49
|
-
bunx
|
|
47
|
+
bunx ohpichamber-guest-bundle panel/main.ts panel/main.js
|
|
48
|
+
bunx ohpichamber-guest-bundle --node service/main.ts service/main.js
|
|
49
|
+
bunx ohpichamber-guest-check # says what the host would refuse
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
Zip or folder for install should include at least: `package.json`, `panel/index.html`, `panel/main.js`, and any declared `icon.svg` / `service/main.js`. Skip `node_modules` and TypeScript sources. Zip and git installs land in `{dataDir}/extensions/{id}`. See
|
|
52
|
+
Zip or folder for install should include at least: `package.json`, `panel/index.html`, `panel/main.js`, and any declared `icon.svg` / `service/main.js`. Skip `node_modules` and TypeScript sources. Zip and git installs land in `{dataDir}/extensions/{id}`. See [GUEST_SERVICES.md](./GUEST_SERVICES.md).
|
|
53
53
|
|
|
54
54
|
---
|
|
55
55
|
|
|
@@ -61,7 +61,7 @@ import { connectHost, HostRequestError } from 'ohpichamber-sdk';
|
|
|
61
61
|
const host = connectHost();
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
Throws `HOST_UNAVAILABLE` when there is no `window`. Outside an iframe (`parent === self`) it still returns a client, but every call rejects with `HOST_UNAVAILABLE`. The host bootstrap runs before authored Guest metadata and scripts
|
|
64
|
+
Throws `HOST_UNAVAILABLE` when there is no `window`. Outside an iframe (`parent === self`) it still returns a client, but every call rejects with `HOST_UNAVAILABLE`. The host bootstrap runs before authored Guest metadata and scripts, creating a per-document private `MessageChannel`, transferring one end to the exact parent, and receiving the SDK port over that private channel. `connectHost` consumes that port through an internal same-document event; iframe `load` and window-message envelopes never grant capabilities. Call `dispose()` on teardown; in-flight RPCs reject as `HOST_UNAVAILABLE`. In-flight RPCs time out after 20 s with `HOST_TIMEOUT`.
|
|
65
65
|
|
|
66
66
|
### 1.1 Subscriptions (host pushes)
|
|
67
67
|
|
|
@@ -71,12 +71,12 @@ Each returns an unsubscribe function. State subscriptions replay the last known
|
|
|
71
71
|
| Method | Payload | Notes |
|
|
72
72
|
| ------------------------------ | ----------------------- | ------------------------------------------------------------ |
|
|
73
73
|
| `onReady(listener)` | `HostReadyContext` | First snapshot and later full refreshes |
|
|
74
|
-
| `onDirectory(listener)` | `string
|
|
75
|
-
| `onSession(listener)` | `SessionSnapshot
|
|
74
|
+
| `onDirectory(listener)` | `string \| null` | |
|
|
75
|
+
| `onSession(listener)` | `SessionSnapshot \| null` | |
|
|
76
76
|
| `onSessionLifecycle(listener)` | `SessionLifecycleEvent` | `{ sessionId, phase }` — `started` / `completed` / `failure` |
|
|
77
77
|
| `onConnection(listener)` | `GuestConnection` | `{ connected, account }` |
|
|
78
78
|
| `onSettings(listener)` | `GuestSettings` | Declared integration fields only (`Record<string, string>`) |
|
|
79
|
-
| `onItem(listener)` | `GuestItem
|
|
79
|
+
| `onItem(listener)` | `GuestItem \| null` | The item this surface was opened for: the chip (`AttachIssueRequest`), a message (`GuestMessageItem`), or a session (`GuestSessionItem`); `null` from the rail icon or + menu |
|
|
80
80
|
| `onStatusControl(listener)` | `{ id, value? }` | Host Work Status control activation. Register synchronously; only status frames with advertised status controls receive events |
|
|
81
81
|
| `onPopoverClosed(listener)` | `{ id, reason }` | Dismissal of this frame's anchored popover. Events go to the owner, are not replayed, and identify the opening being closed |
|
|
82
82
|
| `onResolve(handler)` | `{ command, args }` → `Promise<AttachIssueRequest \| null>` | Answers a `contributes.commands` slash command. Return the chip to attach, `null` for nothing (the user sees a short notice), or throw (the message reaches the user). One handler at a time |
|
|
@@ -96,24 +96,21 @@ Each returns an unsubscribe function. State subscriptions replay the last known
|
|
|
96
96
|
|
|
97
97
|
| Field | Type | Meaning |
|
|
98
98
|
| -------------- | ------------------------ | ---------------------------------------------------------------------------------------- |
|
|
99
|
-
| `theme.mode` | `'light'
|
|
99
|
+
| `theme.mode` | `'light' \| 'dark'` | |
|
|
100
100
|
| `theme.tokens` | surfaces, text, interaction states, `primary`, status colors, `font`, `fontSize` (the app's body text in px, follows the interface font size; absent from older hosts), `mono`, `radius` | Pass to `applyHostReady` before mounting UI |
|
|
101
101
|
| `locale` | `string` | Host language tag |
|
|
102
|
-
| `directory` | `string
|
|
102
|
+
| `directory` | `string \| null` | |
|
|
103
103
|
| `session` | snapshot or `null` | Title falls back to `id`. `busy` is live status. `model` is `providerID/id` when present |
|
|
104
104
|
| `surface` | `'panel' \| 'dialog' \| 'page' \| 'background' \| 'status' \| 'file' \| 'popover' \| 'block'` | Where the host mounted this frame |
|
|
105
105
|
| `popover` | optional `{ id, data }` | Present in a host-created popover frame. `data` is bounded JSON from the owning frame |
|
|
106
106
|
| `connection` | `{ connected, account }` | Integration link state; a tracker extension without an integration gets its tracker account |
|
|
107
107
|
| `settings` | `Record<string, string>` | Declared keys only, without `secret` fields |
|
|
108
|
-
| `item` | `GuestItem
|
|
108
|
+
| `item` | `GuestItem \| null` | Set when the user clicked this guest's chip on the composer, or ran one of this guest's `contributes.actions`. Narrow with `isGuestMessageItem` / `isGuestSessionItem` / `isGuestAttachItem` / `isGuestLinkItem` |
|
|
109
109
|
|
|
110
110
|
|
|
111
|
-
`theme.tokens` includes `primaryText`, `successText`, `warningText`, `errorText`, and `infoText
|
|
112
|
-
|
|
113
|
-
`features` is optional and only advertises implemented host operations: `deviceStorage?: true`, `statusControls?: true`, and `popovers?: true`. Optional syntax tokens are `syntaxKeyword`, `syntaxString`, `syntaxNumber`, `syntaxFunction`, `syntaxType`, `syntaxComment`, `syntaxVariable`, and `syntaxOperator`. `applyHostReady` exposes each as `--oc-syntax-*` and the matching legacy `--syntax-*` name, and clears a missing token on a later snapshot. Use a semantic-token fallback in guest CSS when supporting older hosts.
|
|
114
|
-
|
|
115
|
-
`applyHostReady` exposes the computed colors as `--primary-text`, `--success-text`, `--warning-text`, `--error-text`, and `--info-text`, with matching `--oc-*-text` aliases. These are required theme fields. Apply each `onReady` snapshot to update them when the theme changes.
|
|
111
|
+
`theme.tokens` includes `primaryText`, `successText`, `warningText`, `errorText`, and `infoText` for text on neutral surfaces and tinted controls; keep using base colors for fills and `primaryForeground` on a solid primary fill. `applyHostReady` exposes these as `--primary-text`, `--success-text`, `--warning-text`, `--error-text`, `--info-text` (and `--oc-*-text`), plus optional syntax tokens (`syntaxKeyword`, `syntaxString`, `syntaxNumber`, `syntaxFunction`, `syntaxType`, `syntaxComment`, `syntaxVariable`, `syntaxOperator`) as `--oc-syntax-*` and `--syntax-*` (missing tokens clear on later snapshots). Apply each `onReady` snapshot to pick up theme changes.
|
|
116
112
|
|
|
113
|
+
`features` is optional and advertises implemented host capabilities: `deviceStorage?: true`, `statusControls?: true`, `popovers?: true`, `lateGenerateResults?: true`, and `microphone?: true`.
|
|
117
114
|
`GuestItem` is `AttachIssueRequest | GuestMessageItem | GuestSessionItem | GuestSelectionItem | GuestFileItem | GuestDiffItem | GuestLinkItem`:
|
|
118
115
|
|
|
119
116
|
```ts
|
|
@@ -157,9 +154,9 @@ Access tokens never appear in `ready` or in request results.
|
|
|
157
154
|
| ----------------- | --------------------------------- | ------------------------------ | ------------------------------------------------------------------------------------- |
|
|
158
155
|
| `toast` | `{ kind: 'info' \| 'success' \| 'error', message, copy?, dismiss?, persistent? }` | `Promise<void>` | Show a toast, optionally with host-owned Copy and OK buttons; see Toast buttons below |
|
|
159
156
|
| `openUrl` | `url: string` | `Promise<void>` | Open an http(s) URL. In the desktop app with a project open, a local address (`localhost`, `127.0.0.1`, `[::1]`) opens in the browser panel beside the chat, and other links follow the user's setting for chat links; elsewhere the system browser opens it |
|
|
160
|
-
| `openSurface` | `surfaceId: string` | `Promise<void>` | Show that surface; resolves once
|
|
161
|
-
| `writeClipboard` | `text: string` | `Promise<void>` | Copy in the host (1–
|
|
162
|
-
| `compose` | `{ text, mode?: 'append'
|
|
157
|
+
| `openSurface` | `surfaceId: string` | `Promise<void>` | Show that surface; resolves once visible, rejects `NO_DIRECTORY` or `UNSUPPORTED` when it cannot open |
|
|
158
|
+
| `writeClipboard` | `text: string` | `Promise<void>` | Copy in the host (1–32 000 chars) |
|
|
159
|
+
| `compose` | `{ text, mode?: 'append' \| 'replace' }` | `Promise<void>` | Write text into the current composer |
|
|
163
160
|
| `attach` | `AttachIssueRequest` | `Promise<void>` | Composer chip, alongside other attached items |
|
|
164
161
|
| `startSession` | `StartSessionRequest` | `Promise<{ sessionId, sent }>` | Create session (+ optional worktree), write snapshot. `text` can become first message |
|
|
165
162
|
| `prompt` | `{ text, send?: boolean }` | `Promise<{ sent }>` | Current session: omit/`false` = replace-compose; `send: true` = send |
|
|
@@ -169,20 +166,20 @@ Access tokens never appear in `ready` or in request results.
|
|
|
169
166
|
| `oauthDisconnect` | — | `Promise<void>` | Drop guest tokens / Linear connection |
|
|
170
167
|
| `request` | `{ method, path, query?, body? }` | `Promise<{ status, body }>` | HTTPS call on declared `apiOrigin`. Host attaches auth |
|
|
171
168
|
| `serviceRequest` | same shape as `request` | `Promise<{ status, body }>` | Proxy to this guest's local service on loopback |
|
|
172
|
-
| `serviceStatus`
|
|
169
|
+
| `serviceStatus` | — | `Promise<{ status }>` | `'stopped' \| 'starting' \| 'ready' \| 'failed'` |
|
|
173
170
|
| `readFile` | `path: string` | `Promise<{ content }>` | UTF-8 text. Relative = inside the open project (`files`); `/…` or `~/…` = declared `filesystem` pattern |
|
|
174
171
|
| `writeFile` | `path: string, content: string` | `Promise<{ written: true }>` | Atomic (temp + rename), creates parent folders. Same path rules |
|
|
175
172
|
| `listDir` | `path: string` | `Promise<{ entries }>` | `{ name, kind: 'file' \| 'directory' \| 'other' }[]`, sorted, capped at 2 000. Same path rules |
|
|
176
173
|
| `stat` | `path: string` | `Promise<{ kind, size, mtime }>` | `kind` adds `'missing'`; a missing path is not an error. Same path rules |
|
|
177
174
|
| `setBadge` | `count: number \| null` | `Promise<void>` | Number on this guest's rail icon, 0–999 (clamped); `null` clears. Opening the panel clears it too. In memory only |
|
|
178
|
-
| `openCommit` | `sha: string` | `Promise<void>` | Show that commit of the open project in the host's Diff view (commit scope). 7–64 hex
|
|
179
|
-
| `openWalkthrough` | `{ base: string }` | `Promise<void>` | Show Changes Walkthrough on "This branch" of the open project's checked-out branch, compared with `base
|
|
180
|
-
| `setHeight` | `height: number` | `Promise<void>` | Content height in CSS px.
|
|
175
|
+
| `openCommit` | `sha: string` | `Promise<void>` | Show that commit of the open project in the host's Diff view (commit scope). 7–64 hex chars. `NO_DIRECTORY` without a project, `NOT_FOUND` for an unknown commit, `UNSUPPORTED` where the host has no Diff view |
|
|
176
|
+
| `openWalkthrough` | `{ base: string }` | `Promise<void>` | Show Changes Walkthrough on "This branch" of the open project's checked-out branch, compared with `base` (a branch name, a remote-tracking branch of the bound remote like `origin/main`, or `refs/heads/…` / `refs/remotes/…`). A bare name prefers the bound remote's copy when present; a remote ref requires that remote-tracking branch and never falls back to a local branch. Without a bound remote, only local branches qualify. Unknown base/branch or detached HEAD rejects `NOT_FOUND`; `NO_DIRECTORY` without a project; `HOST_UNAVAILABLE` if unreadable or worktree is creating; `UNSUPPORTED` in Mini Chat or mobile. After `openSession` the frames reload, so persist state via `storage` before navigating |
|
|
177
|
+
| `setHeight` | `height: number` | `Promise<void>` | Content height in CSS px. Work Status clamps to 24–480 (taller content scrolls); docked shared surfaces size 24 px up to half the panel; other surfaces ignore it |
|
|
181
178
|
| `setStatusControls` | `GuestStatusControl[]` | `Promise<void>` | Replace host-rendered controls for this mounted status frame. Requires `features.statusControls`; old hosts reject with `UNSUPPORTED` |
|
|
182
179
|
| `openPopover` | `GuestPopoverRequest` | `Promise<void>` | Open a sandboxed frame outside this frame's bounds, anchored to a rectangle in its viewport. Requires `features.popovers` |
|
|
183
180
|
| `closePopover` | `id, reason?: 'closed' \| 'escape'` | `Promise<void>` | Close this frame's matching opening, or the popover frame itself. A stale id cannot close a replacement |
|
|
184
181
|
| `setPopoverAnchorActive` | `id, active: boolean` | `Promise<void>` | Report anchor pointer/focus activity so the host can allow travel between the anchor and popover |
|
|
185
|
-
| `generate` | `{ prompt, system?, maxOutputTokens? }` | `Promise<{ text }>` | One-off text from the user's Small Model (capability `model`). No session
|
|
182
|
+
| `generate` | `{ prompt, system?, maxOutputTokens? }` | `Promise<{ text }>` | One-off text from the user's Small Model (capability `model`). No session or history; waits up to 960 s (`GUEST_GENERATE_TIMEOUT_MS`) |
|
|
186
183
|
| `reportFileChange` | `{ dirty, edited }` | `void` | File editors only. `dirty` against the last saved version; `edited` when the document itself changed, which holds autosave back until edits stop |
|
|
187
184
|
| `requestFileSave` | — | `void` | File editors only. Save now, as Cmd/Ctrl+S does |
|
|
188
185
|
| `reportFileUnsupported` | — | `void` | File editors only. This file cannot be opened here; the host shows its source and a notice |
|
|
@@ -231,11 +228,16 @@ Await subscription registration to handle refusal, then retain its returned unsu
|
|
|
231
228
|
|
|
232
229
|
Snapshots carry `state: 'loading' | 'ready' | 'error'`; session snapshots also carry per-directory `coverage`. Loading/error may retain data. Only `ready` establishes complete empty success. Reads use existing shared stores and hydration, never a git scan per extension request.
|
|
233
230
|
|
|
234
|
-
Projects contain `id`, `name`, `directory`. Worktrees contain `directory`, `name`, `branch`, and `status: 'ready' | 'pending' | 'invalid' | 'missing'`. Session records contain `id`, `title`, `projectId`, `directory`, optional `agent`, `parentId`, `createdAt`, `updatedAt`, `archivedAt`, `worktree`, `activity`, `outcome`, `items`, `links`, `inWork`, and `unread
|
|
231
|
+
Projects contain `id`, `name`, `directory`. Worktrees contain `directory`, `name`, `branch`, and `status: 'ready' | 'pending' | 'invalid' | 'missing'`. Session records contain `id`, `title`, `projectId`, `directory`, optional `agent`, `parentId`, `createdAt`, `updatedAt`, `archivedAt`, `worktree`, `activity`, `outcome`, `items`, `links`, `inWork`, and `unread` (newer optional fields are omitted by older hosts):
|
|
235
232
|
|
|
236
|
-
`
|
|
237
|
-
|
|
238
|
-
|
|
233
|
+
- `items` holds only this extension's `id` and optional `data`.
|
|
234
|
+
- `links` lists every thread linked to the session (`title`, `url`, `kind: 'issue' | 'change'`, `linkedAt`), read-only.
|
|
235
|
+
- `inWork` is `true` when the session sits in the sidebar's In work block (`false` when the setting is off).
|
|
236
|
+
- `unread` is `true` when the last turn ended and nobody has opened the session since (persisted in OMP).
|
|
237
|
+
- `tool` is present while `activity` is `running`: `{ name, target }` for the running or just-finished tool (`target` is relative to `directory` or bare name outside it, `null` when none; shell command text never appears).
|
|
238
|
+
- `context` (`{ tokens, limit }`) and `tokens` hold latest-step context fill and cumulative session usage as described above.
|
|
239
|
+
- `agent` is the session's agent name for top-level sessions and subsessions.
|
|
240
|
+
- `activity` is `unknown`, `idle`, `running`, `retrying`, `waiting-permission`, or `waiting-question`. `outcome` is the last observed `completed` or `failed` turn (`null` when unknown or working), kept in memory for the latest 2,000 observed sessions and reset on runtime switch. An idle event preserves an observed failure until another run starts. Blocking-request contents and approve/reply actions are not exposed.
|
|
239
241
|
|
|
240
242
|
### Running shells
|
|
241
243
|
|
|
@@ -271,20 +273,19 @@ Omit `options`, or pass `{ scope: 'instance' }`, for this existing server-owned
|
|
|
271
273
|
|
|
272
274
|
### Full-screen pages
|
|
273
275
|
|
|
274
|
-
`contributes.page: true` reuses `panel.entry`; `{ entry: 'panel/page.html', title?: 'Board' }` uses separate package HTML and needs no `panel.entry
|
|
276
|
+
`contributes.page: true` reuses `panel.entry`; `{ entry: 'panel/page.html', title?: 'Board' }` uses separate package HTML and needs no `panel.entry` (`page: true`, `attach`, `actions`, and `commands` still need `panel.entry` or `background.entry`). Pages use the same installed/approved/enabled gate as panels, open only from the sidebar's Extension pages menu (`openSurface` does not open them), report `ctx.surface === 'page'`, close via `close()`, and reset to chat on reload or runtime switch.
|
|
275
277
|
|
|
276
278
|
### Work Status sections
|
|
277
279
|
|
|
278
|
-
`contributes.statusSection: true` reuses `panel.entry`; `{ entry: 'status/index.html', title?: 'Recent commits', height?: 160, defaultExpanded?: false, requiresProject?: true }` uses separate package HTML (
|
|
280
|
+
`contributes.statusSection: true` reuses `panel.entry`; `{ entry: 'status/index.html', title?: 'Recent commits', height?: 160, defaultExpanded?: false, requiresProject?: true }` uses separate package HTML (checked at install). The object form needs no `panel.entry`. `title` (1–60 chars) replaces `panel.name` on the header; `height` (24–480, default 120) sets initial height before `setHeight`. Omitted `defaultExpanded` preserves the default (a saved user choice wins). `requiresProject` hides the section when no project is open. `ctx.surface` is `'status'`; frames mount only while the panel is visible and expanded, so keep no state you cannot rebuild.
|
|
279
281
|
|
|
280
|
-
`setStatusControls` accepts
|
|
282
|
+
`setStatusControls` accepts 0–4 declarations (`kind: 'button' | 'select'`, id kebab-case 1–40 chars, label 1–60 chars; selects take 1–16 unique options with values 1–80 chars and a matching `value`). Register `onStatusControl` synchronously after `connectHost` and gate `setStatusControls` on `features.statusControls`. Controls belong to the expanded mounted frame and clear on fold, hide, or project change (re-publish from `onDirectory`). The host rejects stale, unknown, disabled, or invalid controls, and enforces 20 changed publications per second per frame. Keep a fallback body control visible until `setStatusControls` succeeds on older hosts (`UNSUPPORTED`).
|
|
281
283
|
|
|
282
284
|
### File editors
|
|
283
285
|
|
|
284
|
-
`contributes.fileEditors` lists up to 8 editors: `{ id: 'canvas', title: 'Excalidraw', match: ['*.excalidraw', '*.excalidraw.md'], entry: 'editor/index.html' }`. `match` holds 1
|
|
285
|
-
|
|
286
|
-
The host keeps the file. It hands you the text (`onFileOpen`), asks for the edited text when it saves or when the user switches to the source view or fullscreen (`onFileSnapshot`), and tells you which snapshot reached the disk (`onFileSaved`). Saving, autosave, the unsaved-changes prompt, line endings, and external changes are the host's. Your page never reads or writes the file and needs no `files` capability for it. Report every change with `reportFileChange`; `createFileSaveTracker(version)` does the dirty bookkeeping. A file you cannot open goes back with `reportFileUnsupported`. Files over 20 000 000 characters (text) or bytes (binary) stay with the host's own view, and a snapshot over that is refused. An editor that hands back the wrong kind (text from a binary editor or bytes from a text one) fails the save. The page is reloaded, with the file handed over again, when the file changes on disk, the user discards changes, or the editor moves to or from fullscreen. A file-editor-only package may declare `capabilities`, `service`, `integration`, `filesystem`, and a page with its own `entry`; `page: true`, `attach`, `actions`, and `commands` still need `panel.entry` or `background.entry`. Web and desktop only; `examples/checklist-editor` is a complete editor.
|
|
286
|
+
`contributes.fileEditors` lists up to 8 editors: `{ id: 'canvas', title: 'Excalidraw', match: ['*.excalidraw', '*.excalidraw.md'], entry: 'editor/index.html' }`. `match` holds 1–16 case-insensitive filename patterns (no `/`, `*` any run, `?` one char, at least one non-wildcard). `content` is `"text"` (default; text files only, `\n` normalized, host restores original line endings on write) or `"binary"` (`Uint8Array`, no source view; host saves unsaved changes before fullscreen transitions). The first enabled, approved matching editor wins ahead of built-in viewers (`ctx.surface === 'file'`). Web and desktop only; `examples/checklist-editor` is a complete editor.
|
|
287
287
|
|
|
288
|
+
The host owns file I/O, saving, autosave, unsaved prompts, and external change detection (no `files` capability needed). It sends content via `onFileOpen`, requests snapshots via `onFileSnapshot` (`'save' | 'handoff'`), and confirms disk writes via `onFileSaved`. Report edits with `reportFileChange` (`createFileSaveTracker(version)` handles dirty state) and reject unsupported files with `reportFileUnsupported`. Files over 20 000 000 chars/bytes stay with the host view, wrong-kind snapshots fail the save, and external changes, discards, or fullscreen toggles reload the frame.
|
|
288
289
|
`sent` **values** (`startSession` / `prompt`): `sent` | `no-model` | `skipped` | `failed`. After `no-model` / `failed` on `startSession`, the session still exists.
|
|
289
290
|
|
|
290
291
|
**File path rules** (`readFile` / `writeFile` / `listDir` / `stat`): a relative path (`README.md`, `src/x.ts`, `.`) is joined to the project that is open when the call runs and needs the `files` capability; no open project is `NO_DIRECTORY`. A path starting with `/` or `~/` is outside the project, must match one of the package's `contributes.filesystem` globs, and needs the `filesystem` capability. Any `..` segment, a backslash, or a symlink that leads out of the allowed tree is `BAD_PATH`. The host compares canonical (realpath) paths, so `/tmp/x` on macOS is checked as `/private/tmp/x` and a pattern's literal prefix is canonicalized the same way. Content over 2 000 000 characters is `FILE_TOO_LARGE` in both directions; an OS permission refusal is `DENIED`.
|
|
@@ -297,35 +298,29 @@ The host keeps the file. It hands you the text (`onFileOpen`), asks for the edit
|
|
|
297
298
|
|
|
298
299
|
`dismiss: true` adds OK. `persistent: true` disables automatic expiry and always adds OK regardless of `dismiss`, so every persistent toast can be closed. Omitted or false `persistent` retains the host's usual duration.
|
|
299
300
|
|
|
300
|
-
Copy leaves the toast open, reports success on the button, and shows a retryable error when the clipboard fails. OK dismisses only its own toast. Buttons use the host's locale and clipboard helper
|
|
301
|
+
Copy leaves the toast open, reports success on the button, and shows a retryable error when the clipboard fails. OK dismisses only its own toast. Buttons use the host's locale and clipboard helper, retain only the supplied text and toast identity, work after guest disposal or a runtime switch, and never call back into the extension. The `toast` promise resolves after display acknowledgement.
|
|
301
302
|
|
|
302
303
|
### Blocks in the chat
|
|
303
304
|
|
|
304
|
-
`contributes.blocks` adds components agents write in a UI block, drawn by your page with the grants of your panel. `host.onBlock` gives the call. `host.setHeight` sizes the frame, up to `GUEST_BLOCK_HEIGHT_MAX`. Set `answers: true` on a component that answers: agents are told to ask with it, a waiting page adds no Send button, and the block offers a note the agent reads with the answer; a note alone also answers, with `answered` holding its text. `host.answerBlock(text)`, called from a click, hands the agent `text` as a block's button does and starts its next turn; one answer per block, up to `GUEST_BLOCK_ANSWER_MAX` characters, and `answered` shows it after a reload. Without a click, or on a block that cannot take an answer, it rejects with `HOST_REJECTED`.
|
|
305
|
+
`contributes.blocks` adds components agents write in a UI block, drawn by your page with the grants of your panel. `host.onBlock` gives the call. `host.setHeight` sizes the frame, up to `GUEST_BLOCK_HEIGHT_MAX`. Set `answers: true` on a component that answers: agents are told to ask with it, a waiting page adds no Send button, and the block offers a note the agent reads with the answer; a note alone also answers, with `answered` holding its text. `host.answerBlock(text)`, called from a click, hands the agent `text` as a block's button does and starts its next turn; one answer per block, up to `GUEST_BLOCK_ANSWER_MAX` characters, and `answered` shows it after a reload. Without a click, or on a block that cannot take an answer, it rejects with `HOST_REJECTED`.
|
|
305
306
|
|
|
306
307
|
### Background actions
|
|
307
308
|
|
|
308
|
-
`contributes.actions[].mode` accepts `"open"` or `"background"`. Omitted mode keeps
|
|
309
|
+
`contributes.actions[].mode` accepts `"open"` or `"background"`. Omitted mode keeps panel/dialog routing and `onItem` delivery. Background actions load `background.entry` when declared, otherwise `panel.entry` (never attach-dialog HTML).
|
|
309
310
|
|
|
310
|
-
`contributes.background` is `{ entry: "<package-local .html>" }`. It starts on demand for an action or command and adds no
|
|
311
|
+
`contributes.background` is `{ entry: "<package-local .html>" }`. It starts on demand for an action or command and adds no rail icon, attach picker, or full-screen page. Identity remains in `panel.id/name/icon`. Open-mode actions, `page: true`, and enabled `attach` require `panel.entry`; invalid combinations fail as `invalid-panel`. With neither `panel.entry` nor `background.entry`, only `tools` and `providerLogos` are allowed.
|
|
311
312
|
|
|
312
|
-
When both entries exist,
|
|
313
|
+
When both entries exist, `background.entry` handles `onResolve` for slash commands (`surface: "background"`) instead of the visible panel. Clicking an attached chip from a background-only extension shows a no-panel notice; its browser action remains available.
|
|
313
314
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
`ready.surface` is `"background"` and `ready.item` is `null`. Context updates never replay the action. The session and directory context remain scoped to the clicked target; the item itself is the snapshot captured at click time. Calls that explicitly write the composer still write the currently visible composer. `close()` is a no-op in a background frame; returning from the handler completes the action.
|
|
317
|
-
|
|
318
|
-
The 20-second deadline covers loading and execution. At most eight background invocations may run concurrently. Completion, failure, timeout, disabling, lost approval, extension update/removal, runtime switch, and host unmount release the frame and its listeners. Late messages are ignored. Already completed or server-accepted effects are not undone, and the host does not automatically retry actions. A background action has the same declared capabilities as its extension. It does not hide the extension's rail icon.
|
|
315
|
+
Each background click mounts a fresh sandboxed iframe and sends one `action` request (`id`, `GuestActionItem`). `host.onAction` sends `action-result` (`{ ok: true }` or `{ ok: false, error }` capped at `GUEST_RESOLVE_ERROR_MAX` chars); there is no acknowledgement for `action-result`. `ready.surface` is `"background"` and `ready.item` is `null`; context updates never replay the action. The 20 s deadline covers loading and execution, with at most 8 concurrent invocations. Completion, failure, timeout, disabling, lost approval, update/removal, runtime switch, and host unmount release the frame without rolling back completed effects or retrying.
|
|
319
316
|
|
|
320
317
|
See [Actions without opening a panel](./README.md#actions-without-opening-a-panel) for a toast example.
|
|
321
318
|
|
|
322
319
|
### Late generate answers
|
|
323
320
|
|
|
324
|
-
A
|
|
325
|
-
|
|
326
|
-
`request` is the trimmed `{ prompt, system?, maxOutputTokens? }` the frame sent; use it to tell which of your requests this answers. The extension decides what to show; the host shows nothing of its own.
|
|
321
|
+
A `generate` call runs to the server's deadline with no cancellation even if the panel closes, switches projects, or reloads. If the original frame is gone when the answer arrives, the host keeps it for 1 hour (up to 8 per extension, oldest dropped) in memory for the same extension, surface, project, and window, delivering it once via `onLateGenerateResult` as soon as a listener registers (or immediately if one is active). Failed generations are kept as `{ ok: false, code, error }`. Hidden frames (background actions and slash-command resolver frames) do not receive or leave kept answers. Page reload, app restart, another window, disabling/removing/reinstalling, or withdrawing `model` approval drops kept answers. Older hosts omit `features.lateGenerateResults`.
|
|
327
322
|
|
|
328
|
-
|
|
323
|
+
`request` is the trimmed `{ prompt, system?, maxOutputTokens? }` the frame sent; use it to match against your pending requests.
|
|
329
324
|
|
|
330
325
|
```ts
|
|
331
326
|
host.onLateGenerateResult((late) => {
|
|
@@ -341,7 +336,7 @@ host.onLateGenerateResult((late) => {
|
|
|
341
336
|
|
|
342
337
|
The host loads the caller's existing package entry in a fresh `sandbox="allow-scripts"` iframe with `surface: 'popover'`. Render the card from `ready.popover.data` instead of mounting your ordinary page. Apply subsequent theme snapshots without repeating data loads. The child inherits the extension's approved capabilities and existing host APIs. It cannot open another popover or choose an entry, URL or HTML document.
|
|
343
338
|
|
|
344
|
-
Visible
|
|
339
|
+
Visible Web and Electron panel, page, and status frames advertise `features.popovers`; dialogs, background frames, file editors, and popovers do not. `mountPopoverAnchor` opens on mouse hover, keyboard focus, and touch/pen tap (on touch, the tap replaces the element's click). Older hosts reject with `UNSUPPORTED`. Each opening loads a new frame, so cold loading and relay transport can delay the preview.
|
|
345
340
|
|
|
346
341
|
Only one extension popover is active per host document. Opening another retires the previous one. Escape, outside interaction, owner scrolling, resizing, owner removal and changes to project, runtime, installation or authorization dismiss it. A host modal dialog takes precedence and closes previews. Close events name the opening and one of `escape`, `outside`, `anchor`, `owner`, `closed`, or `replaced`. A closing child uses `host.close()` or `closePopover(ready.popover.id)`. The SDK forwards Escape and pointer/focus activity from the child, whose events cannot bubble across the sandbox.
|
|
347
342
|
|
|
@@ -371,7 +366,7 @@ Use `mountPopoverAnchor` from `ohpichamber-sdk/ui` for DOM anchors. It measures
|
|
|
371
366
|
| `DENIED` | The operating system refused the file access |
|
|
372
367
|
| `NO_MODEL` | `generate` with no usable Small Model |
|
|
373
368
|
| `MODEL_FAILED` | The Small Model returned an error |
|
|
374
|
-
| `UNSUPPORTED` | This host surface cannot do that (for example `openCommit` without a Diff view, or `openWalkthrough`
|
|
369
|
+
| `UNSUPPORTED` | This host surface cannot do that (for example `openCommit` without a Diff view, or `openWalkthrough` in Mini Chat) |
|
|
375
370
|
| `SERVICE_FAILED` | Service crashed or never became ready |
|
|
376
371
|
| `REQUEST_FAILED` | `serviceRequest` was sent but got no usable answer; the service may have acted on it |
|
|
377
372
|
| `RESPONSE_TOO_LARGE` | `request` / `serviceRequest` answer over 8 000 000 bytes; the call ran, ask for a smaller page |
|
|
@@ -405,7 +400,7 @@ Use `mountPopoverAnchor` from `ohpichamber-sdk/ui` for DOM anchors. It measures
|
|
|
405
400
|
| `generate` prompt / system | 64 000 / 8 000 |
|
|
406
401
|
| `generate` `maxOutputTokens` | 4 000 |
|
|
407
402
|
| `generate` answer | 256 000 |
|
|
408
|
-
| `generate` timeout |
|
|
403
|
+
| `generate` timeout | 960 000 ms |
|
|
409
404
|
|
|
410
405
|
|
|
411
406
|
---
|
|
@@ -503,9 +498,9 @@ Used by the OhPiChamber host and by tools that validate packages. Guests rarely
|
|
|
503
498
|
{
|
|
504
499
|
"name": "@acme/hello-panel",
|
|
505
500
|
"version": "1.0.0",
|
|
506
|
-
"
|
|
501
|
+
"ohpichamber": {
|
|
507
502
|
"apiVersion": 1,
|
|
508
|
-
"engines": { "
|
|
503
|
+
"engines": { "ohpichamber": ">=1.0.0" },
|
|
509
504
|
"id": "acme-hello",
|
|
510
505
|
"name": "Hello",
|
|
511
506
|
"icon": "window",
|
|
@@ -532,29 +527,29 @@ Used by the OhPiChamber host and by tools that validate packages. Guests rarely
|
|
|
532
527
|
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
533
528
|
| `version` | Semver required on install (`1.0.0`) |
|
|
534
529
|
| `apiVersion` | Must be `1` |
|
|
535
|
-
| `engines.
|
|
530
|
+
| `engines.ohpichamber` | Optional. Only `1.0.0` or `>=1.0.0`. Older host → `host-too-old` |
|
|
536
531
|
| `id`, `name`, `icon` | Beside `contributes`. Older packages keep them in `panel`, and that still works. `id` is kebab-case |
|
|
537
532
|
| `icon` | Remixicon kebab name (`window`) **or** package `.svg` path. Remixicon needs no file. An `.svg` path must exist on disk or install fails (`invalid-manifest`). No URLs/absolute paths |
|
|
538
533
|
| `panel.entry` | Optional visible-panel HTML path inside the package. No `..`, absolute path, or URL. Its scripts must be built. Omitting it removes the rail icon and visible views; `background.entry` can still run code. With neither entry, only `tools` and `providerLogos` plus package identity/version/engines are allowed. `hasGuestPage` means a visible panel, not background execution |
|
|
539
|
-
| `panel.mobile` | Optional `true
|
|
534
|
+
| `panel.mobile` | Optional `true` in manifest schema (inactive while `loadGuestCatalog` marks mobile `unsupported`) |
|
|
540
535
|
| `background.entry` | Optional package-local `.html` path. Loaded on demand for background actions and slash commands, preferred over `panel.entry` for these calls. Adds no rail icon. The file and its built scripts must exist. Malformed declarations are `invalid-background` |
|
|
541
|
-
| `attach` | `true` / `"panel"` → + menu opens rail
|
|
536
|
+
| `attach` | `true` / `"panel"` → + menu opens rail; `"dialog"` → host window; omit/`false` → off menus. Object form `{ "mode": "panel" \| "dialog", "entry"?: "panel/attach.html" }`: `entry` (dialog only, same path rules as `panel.entry`, must exist with built scripts) loads instead of `panel.entry` |
|
|
542
537
|
| `capabilities` | Optional list of `prompt`, `sessions`, `files`, `model`, `shells`, `microphone`. `files` is read **and** write inside the open project; `model` is `generate`; `shells` is the running-shell methods; `microphone` is `openMicrophone`. Approved once at install |
|
|
543
538
|
| `actions` | Optional, 1–8 entries, unique kebab-case `id`, `label` 1–40 chars, optional `icon` with the `panel.icon` rules, `where: "message" \| "session" \| "selection" \| "file" \| "diff"`, optional `display: "label" \| "icon" \| "both"` on a selection, optional `mode: "open" \| "background"`. Message actions may narrow `roles` to `["user"]` / `["assistant"]`, default both. Session actions may request `payload: ["messages"]`, adding the `conversation` capability. Invalid shape is `invalid-actions`. Default `open` mode opens the guest with `ready.item`, using the attach dialog for `attach: "dialog"` and the rail otherwise. `background` calls `onAction` in a temporary hidden frame; see Background actions above |
|
|
544
539
|
| `commands` | Optional, 1–8 entries, unique `name` matching `/^[a-z][a-z0-9-]{0,23}$/`, optional `description` 1–80 chars (`invalid-commands`). `/name args` in the chat box calls `onResolve` instead of the model and attaches what it returns. A name the composer already has (built-in, OMP command, skill) is ignored with a console warning |
|
|
545
|
-
| `tools` | Optional, 1–16 entries
|
|
546
|
-
| `providerLogos` | Optional map of 1–256 OMP provider IDs (`/^[a-z0-9][a-z0-9._-]{0,63}
|
|
540
|
+
| `tools` | Optional, 1–16 entries formatting extension tool calls in chat (`invalid-tools`). `match` is the OMP tool name (`jira_search`), 1–128 chars of `[A-Za-z0-9_.:-]`, with optional trailing `*` (`jira_*`). Exact matches beat wildcards; among equals the first enabled, approved extension wins. Optional `name` (1–40), `icon` (Remixicon or package `.svg`), `title` / `subtitle` templates (1–200, `{input.path}` / `{output.path}` / `{metadata.path}`, missing paths render empty, values capped at 200), `output` (`"auto"` \| `"text"` \| `"json"` \| `"markdown"` \| `"code"` \| `"table"` \| `"card"`), `language` (`code`), `columns` (`table`, 1–16 dotted paths over output array or `output.items`), and `card` (`card`, see Tool cards below). With Code Mode, a finished script making one call matches its direct tool name (`example.findings` → `example_findings`) with the script return value as `output` |
|
|
541
|
+
| `providerLogos` | Optional map of 1–256 OMP provider IDs (`/^[a-z0-9][a-z0-9._-]{0,63}$/`) to package `.svg` or `.png` (up to 1 MiB each). Lookup order: uploaded logo, chosen icon, extension logo, bundled logo, models.dev logo, generic mark. First enabled, approved extension wins; SVG `currentColor` follows the theme. Bad shape is `invalid-provider-logos`; missing/empty/oversized file is `invalid-manifest` |
|
|
547
542
|
| `fileEditors` | Optional, 1–8 editors: unique kebab-case `id`, `title` 1–60 chars, `match` 1–16 file-name patterns (no `/`, not only wildcards), `entry` package `.html` with built scripts, optional `content` `"text"` (default) or `"binary"` (`invalid-file-editors`). See File editors above |
|
|
548
543
|
| `filesystem` | Optional, 1–16 globs, each 1–256 chars, starting with `/` or `~/`; `**` spans folders, `*` / `?` stay in one segment; no `..`, empty segment, or backslash (`invalid-filesystem`). Declaring it adds the `filesystem` capability and the dialog lists the globs |
|
|
549
544
|
| `integration` | Optional. Exactly one of `oauth`, `token`, or `host` (`provider: "linear"` only) |
|
|
550
|
-
| `service` | Optional
|
|
551
|
-
| `sessionEvents` | Optional, needs `service`. `{ "events": [1
|
|
552
|
-
| `marks` | Optional `true`, needs `service` (`invalid-marks`).
|
|
553
|
-
| `notifications` | Required with `provides: ["notifications"]`, refused without it
|
|
554
|
-
| `tracker` | Required with `provides: ["tracker"]`, refused without it
|
|
555
|
-
| `links` | Optional
|
|
556
|
-
| `quota` | Required with `provides: ["quota"]`, refused without it
|
|
557
|
-
| `sourceControl` | Required with `provides: ["source-control"]`, refused without it
|
|
545
|
+
| `service` | Optional local process (`entry` built `.js`, `runtime: "host"`). `provides` supports `"browser"`, `"source-control"` (needs `sourceControl`), `"notifications"` (needs `notifications`), `"tracker"` (needs `tracker`; mutually exclusive with `sourceControl`), and `"quota"` (needs `quota`). `surface: true` adds a host-drawn shared panel. See [GUEST_SERVICES.md](./GUEST_SERVICES.md) |
|
|
546
|
+
| `sessionEvents` | Optional, needs `service`. `{ "events": [1–4 distinct of "turn-finished", "turn-failed", "permission-asked", "question-asked"], "content"?: true }`. Host posts events across all projects to `POST /session-events`; `content: true` adds the `transcript` capability. Errors are `invalid-session-events`. See [GUEST_SERVICES.md](./GUEST_SERVICES.md#session-events-contributessessionevents) |
|
|
547
|
+
| `marks` | Optional `true`, needs `service` (`invalid-marks`). Adds the `marks` capability so `setMark(target, mark)` can set `{ icon, tone, text, url? }` or `null` on sidebar rows (`{ sessionId }`, `{ directory, branch }`, `{ directory }`). Declare `service.keepRunning` so marks persist |
|
|
548
|
+
| `notifications` | Required with `provides: ["notifications"]`, refused without it (`invalid-service`). Declares `label` (1–64), `instances`, and `token`; `panel.id` max 28 chars (`ext-<panel.id>`). See [GUEST_SERVICES.md](./GUEST_SERVICES.md#notification-channel-provides-notifications) |
|
|
549
|
+
| `tracker` | Required with `provides: ["tracker"]`, refused without it or alongside `sourceControl` (`invalid-service`). Declares `wire: 1`, `label` (1–64), `instances`, `auth` (`token` and/or `oauth`), `capabilities`, `stateFilters` (`open`, `all`, plus up to 14), `identifier` (`key-number` \| `number` \| `short-code`), `urls.item` (1–8 templates); `panel.id` max 28 chars (`ext-<panel.id>`). See [GUEST_SERVICES.md](./GUEST_SERVICES.md#tracker-provides-tracker) |
|
|
550
|
+
| `links` | Optional `{ "action": "open" \| "attach", "identifier"?: { "keys": [1–8 uppercase keys] }, "urls"?: { "origin", "identifier", "item": [1–8 templates] } }`, at least one of `identifier` / `urls`. Keys match whole words (`PROJ-123`) outside code/words/paths; `origin` is an exact `https` origin or `https://*.example.com` subdomain wildcard. `open` needs `panel.entry` (`GuestLinkItem`); `attach` adds a composer chip and disallows `{segment}`/`{segments+}` (and `identifier: "number"` with `identifier.keys`). Built-in app links keep priority. Adds `links` capability; edits re-prompt (`invalid-links`). Reference: `examples/tasks-demo` |
|
|
551
|
+
| `quota` | Required with `provides: ["quota"]`, refused without it (`invalid-service`). Lists up to 16 unique OMP provider IDs (`providers`) whose stored credentials the service receives; `panel.id` max 28 chars (`ext-<panel.id>`). See [GUEST_SERVICES.md](./GUEST_SERVICES.md#usage-provider-provides-quota) |
|
|
552
|
+
| `sourceControl` | Required with `provides: ["source-control"]`, refused without it (`invalid-service`). Declares `wire: 1`, `label`, `terminology`, `referencePrefix`, `repositoryPath`, `instances`, `capabilities`, `token`, `transport`, `limits`, `trackedItems`, `presentation`; `panel.id` max 28 chars (`ext-<panel.id>`). See [GUEST_SERVICES.md](./GUEST_SERVICES.md#source-control-provider-provides-source-control) |
|
|
558
553
|
|
|
559
554
|
|
|
560
555
|
Extra keys are dropped, not forwarded.
|
|
@@ -594,7 +589,7 @@ At least one of `label`, `title`, `status`, `fields`. Unknown keys are refused.
|
|
|
594
589
|
- An object output is one card. An array, or an object with an `items` array, is a list: one row per item with its label, title, first field and status, the first 200 items, no link. In a row `{output.path}` reads the item.
|
|
595
590
|
- A path that is absent, or holds `null`, a blank string, an object or an array, is missing. A part with nothing resolved is hidden. When no label, title, status or field resolves, or the output is not JSON, the chat shows the output as it would without the rule.
|
|
596
591
|
- The link shows only for an `https` address without a user name or password, at most 2,048 characters. In a written address every placeholder has to resolve and each value is percent-encoded, so a value cannot change the host or path the manifest wrote; a value that would be a `.` or `..` path step gives no link. In the host a placeholder stands between dots or at either end: `https://tracker.example{output.path}` is refused, and a placeholder that ends the host lets its value choose the host. `https://{settings.site}/browse/{output.key}` works when `site` is a bare host name; a full address, a port or a path in the setting gives no link.
|
|
597
|
-
- `card`
|
|
592
|
+
- `card` requires a host that supports `output: "card"`; older hosts reject it with `invalid-tools`.
|
|
598
593
|
|
|
599
594
|
### 3.2 Parse / version helpers
|
|
600
595
|
|
|
@@ -604,16 +599,16 @@ At least one of `label`, `title`, `status`, `fields`. Unknown keys are refused.
|
|
|
604
599
|
| `parseManifest(document)` (`ohpichamber-sdk/schemas`) | Typed document → success/failure (does not throw on junk) |
|
|
605
600
|
| `parseManifestJson(json)` (`ohpichamber-sdk/schemas`) | String → same result |
|
|
606
601
|
| `guestToolCardSchema` (`ohpichamber-sdk/schemas`) | The zod schema of a tool rule's `card`, for a host that re-reads a catalog row |
|
|
607
|
-
| `resolveAttachMode(attach)` | Normalize to `'panel'
|
|
602
|
+
| `resolveAttachMode(attach)` | Normalize to `'panel' \| 'dialog' \| null` |
|
|
608
603
|
| `resolveAttachEntry(contributes)` | Dialog page from the object form, or `null` when the dialog reuses `panel.entry` |
|
|
609
604
|
| `hasGuestPage(contributes)` | `true` when `panel.entry` is set; background-only and tools-only packages return `false` |
|
|
610
605
|
| `resolveIntegrationAuth` / `resolveIntegrationApi` | Auth kind and API origin |
|
|
611
606
|
| `toPublicIntegration` / `toPublicService` | Catalog-safe public slices |
|
|
612
607
|
| `isGuestPackageSvgIcon` | Whether icon is a package SVG path |
|
|
613
|
-
| `
|
|
614
|
-
| `
|
|
615
|
-
| `
|
|
616
|
-
| `
|
|
608
|
+
| `compareOhPiChamberVersions` | Semver compare |
|
|
609
|
+
| `hostMeetsOhPiChamberEngine` | Host vs `engines.ohpichamber` floor |
|
|
610
|
+
| `ohPiChamberEngineMinimum` | Normalize `>=1.0.0` → floor string |
|
|
611
|
+
| `parseOhPiChamberVersion` | Parse `x.y.z` |
|
|
617
612
|
|
|
618
613
|
|
|
619
614
|
### 3.3 Protocol helpers (host + guest tooling)
|
|
@@ -631,7 +626,7 @@ At least one of `label`, `title`, `status`, `fields`. Unknown keys are refused.
|
|
|
631
626
|
| `isHostRequestErrorCode` / `resolveHostRequestErrorCode` | Error code validation |
|
|
632
627
|
|
|
633
628
|
|
|
634
|
-
Constants: `
|
|
629
|
+
Constants: `OHPICHAMBER_SDK_CHANNEL`, `OHPICHAMBER_SDK_API_VERSION`, `HOST_LINEAR_API_ORIGIN`, `GUEST_*_MAX`, `GUEST_REQUEST_TIMEOUT_MS`, `GUEST_ACTIONS_MAX`, `GUEST_COMMANDS_MAX`, `GUEST_COMMAND_NAME`, `GUEST_TOOLS_MAX`, `GUEST_TOOL_MATCH`, `GUEST_TOOL_OUTPUTS`, `HOST_REQUEST_ERROR_CODES`, `SERVICE_STATUS_VALUES`, `SESSION_LIFECYCLE_PHASES`, `START_SESSION_SENT`.
|
|
635
630
|
|
|
636
631
|
Wire messages added for these: host → guest `resolve` (`{ id, payload: { command, args } }`), guest → host `resolve-result` (`{ id, payload: { item } | { error } }`, no `result` comes back) and `badge` (`{ count }`).
|
|
637
632
|
|
|
@@ -652,30 +647,24 @@ Panel → `serviceRequest` → host → `127.0.0.1:port` → service process →
|
|
|
652
647
|
|
|
653
648
|
Manifest sketch: `service.entry` (path to **built** JS, e.g. `service/main.js`), `runtime: "host"`, `permissions.sockets` and/or `permissions.exec`. Install refuses with `missing-build` when that file is absent. Declaring a service adds `service` to the capabilities the user approves at install; until then `serviceRequest` is `NO_SERVICE`.
|
|
654
649
|
|
|
655
|
-
|
|
650
|
+
Full local-service contracts, provider schemas, outbound proxies, and host callbacks (`createServiceHost`, `contributes.sessionEvents`, `contributes.waits`, `contributes.mentions`, `surface: true`, env vars, `/health`, grants, socket overrides) live in [GUEST_SERVICES.md](./GUEST_SERVICES.md).
|
|
656
651
|
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
A service whose manifest declares `contributes.sessionEvents` is told what happens in the user's sessions: OhPiChamber posts one request per subscribed event (`turn-finished`, `turn-failed`, `permission-asked`, `question-asked`) to `POST /session-events` (`SESSION_EVENTS_PATH`), from every project, whether or not a window is open. Parse the body with `readSessionEventRequest` (`GuestSessionEventRequest`: `event` with identifiers, and `content` only when the user approved the `transcript` capability that `content: true` asks for) and answer `{ ok: true }` or `{ ok: false, error }` (`GuestSessionEventResult`). Filter on `event.project.directory` yourself. Limits are the `SESSION_EVENT*` constants; the host's answer schema is `sessionEventResultSchema` in `ohpichamber-sdk/schemas`. Full contract in [GUEST_SERVICES.md](https://github.com/Shizuku-Yume/ohpichamber/blob/main/packages/sdk/GUEST_SERVICES.md#session-events-contributessessionevents); reference: `examples/session-events-log`.
|
|
668
|
-
|
|
669
|
-
A service with `surface: true` shows a live picture in the extension's rail panel: the host pulls frames from `GET /surface/frame`, draws them, sends the user's input to `POST /surface/input`, and owns who is in control (nobody, the agent, the user). Paths, event types, and the `readSurface*` parsers are exported from `ohpichamber-sdk`; contract in [GUEST_SERVICES.md](https://github.com/Shizuku-Yume/ohpichamber/blob/main/packages/sdk/GUEST_SERVICES.md#shared-surface-surface-true).
|
|
652
|
+
Provider HTTP entrypoints and SDK helpers at a glance:
|
|
653
|
+
- `provides: ["browser"]` → `POST /browser-control`, `readBrowserProviderRequest` ([browser provider](./GUEST_SERVICES.md#browser-provider-provides-browser))
|
|
654
|
+
- `provides: ["source-control"]` → `POST /source-control` (`SOURCE_CONTROL_PROVIDER_PATH`), `readSourceControlProviderRequest`, `createSourceControlForge`, `sourceControlProviderSchemasV1` ([source-control provider](./GUEST_SERVICES.md#source-control-provider-provides-source-control), `examples/source-control-provider`)
|
|
655
|
+
- `provides: ["notifications"]` → `POST /notifications` (`NOTIFICATIONS_PROVIDER_PATH`), `readNotificationsProviderRequest`, `createNotificationsOutbound`, `notificationsProviderSchemasV1` ([notification channel](./GUEST_SERVICES.md#notification-channel-provides-notifications), `examples/notification-webhook`)
|
|
656
|
+
- `provides: ["tracker"]` → `POST /tracker` (`TRACKER_PROVIDER_PATH`), `readTrackerProviderRequest`, `createTrackerOutbound`, `trackerProviderSchemasV1` ([tracker](./GUEST_SERVICES.md#tracker-provides-tracker), `examples/tracker-provider`)
|
|
657
|
+
- `provides: ["quota"]` → `POST /quota` (`QUOTA_PROVIDER_PATH`), `readQuotaProviderRequest`, `quotaProviderSchemasV1` ([usage provider](./GUEST_SERVICES.md#usage-provider-provides-quota), `examples/quota-provider`)
|
|
658
|
+
- Host callbacks, marks, schedules, mentions → `createServiceHost`, `readServiceScheduleRequest`, `POST /schedule`, `MENTIONS_SEARCH_PATH`, `MENTIONS_RESOLVE_PATH` ([calling OhPiChamber](./GUEST_SERVICES.md#calling-ohpichamber))
|
|
659
|
+
- Session events (`contributes.sessionEvents`) → `POST /session-events` (`SESSION_EVENTS_PATH`), `readSessionEventRequest`, `sessionEventResultSchema` ([session events](./GUEST_SERVICES.md#session-events-contributessessionevents), `examples/session-events-log`)
|
|
660
|
+
- Shared surface (`surface: true`) → `GET /surface/frame`, `POST /surface/input`, `readSurface*` ([shared surface](./GUEST_SERVICES.md#shared-surface-surface-true))
|
|
670
661
|
|
|
671
662
|
Bundle the service with the Node target:
|
|
672
663
|
|
|
673
664
|
```bash
|
|
674
|
-
bunx
|
|
665
|
+
bunx ohpichamber-guest-bundle --node service/main.ts service/main.js
|
|
675
666
|
```
|
|
676
667
|
|
|
677
|
-
Full contract (env vars, `/health`, grants, socket overrides): `[GUEST_SERVICES.md](https://github.com/Shizuku-Yume/ohpichamber/blob/main/packages/sdk/GUEST_SERVICES.md)`.
|
|
678
|
-
|
|
679
668
|
---
|
|
680
669
|
|
|
681
670
|
## 5. What this package does not provide
|
|
@@ -744,8 +733,8 @@ host.onReady((ctx) => {
|
|
|
744
733
|
|
|
745
734
|
| File | Audience |
|
|
746
735
|
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- |
|
|
747
|
-
| [README.md](
|
|
748
|
-
| [DOCUMENTATION.md](
|
|
749
|
-
| [GUEST_SERVICES.md](
|
|
750
|
-
| [src/ui/DOCUMENTATION.md](
|
|
751
|
-
| [sdk.mdx](https://github.com/Shizuku-Yume/ohpichamber/blob/main/packages/docs/content/docs/sdk.mdx) / [sdk/host.mdx](https://github.com/Shizuku-Yume/ohpichamber/blob/main/packages/docs/content/docs/sdk/host.mdx) / [sdk/ui.mdx](https://github.com/Shizuku-Yume/ohpichamber/blob/main/packages/docs/content/docs/sdk/ui.mdx) | Author-facing website pages
|
|
736
|
+
| [README.md](./README.md) | Package overview and first extension |
|
|
737
|
+
| [DOCUMENTATION.md](./DOCUMENTATION.md) | Agent / maintainer invariants |
|
|
738
|
+
| [GUEST_SERVICES.md](./GUEST_SERVICES.md) | Local service contract |
|
|
739
|
+
| [src/ui/DOCUMENTATION.md](./src/ui/DOCUMENTATION.md) | UI kit invariants |
|
|
740
|
+
| [sdk.mdx](https://github.com/Shizuku-Yume/ohpichamber/blob/main/packages/docs/content/docs/sdk.mdx) / [sdk/host.mdx](https://github.com/Shizuku-Yume/ohpichamber/blob/main/packages/docs/content/docs/sdk/host.mdx) / [sdk/ui.mdx](https://github.com/Shizuku-Yume/ohpichamber/blob/main/packages/docs/content/docs/sdk/ui.mdx) | Author-facing website pages |
|