ohpichamber-sdk 0.0.0-stage → 1.0.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 +751 -0
- package/DOCUMENTATION.md +506 -0
- package/GUEST_SERVICES.md +784 -0
- package/LICENSE +21 -0
- package/README.md +280 -2
- package/dist/api-version.d.ts +17 -0
- package/dist/api-version.js +16 -0
- package/dist/bootstrap.d.ts +14 -0
- package/dist/bootstrap.js +87 -0
- package/dist/contract.d.ts +595 -0
- package/dist/contract.js +239 -0
- package/dist/file-editor.d.ts +57 -0
- package/dist/file-editor.js +60 -0
- package/dist/frame-policy.d.ts +1 -0
- package/dist/frame-policy.js +18 -0
- package/dist/host-version.d.ts +17 -0
- package/dist/host-version.js +50 -0
- package/dist/host.d.ts +102 -0
- package/dist/host.js +1103 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +23 -0
- package/dist/links.d.ts +5 -0
- package/dist/links.js +19 -0
- package/dist/manifest.d.ts +554 -0
- package/dist/manifest.js +363 -0
- package/dist/message-channel-test.d.ts +25 -0
- package/dist/message-channel-test.js +62 -0
- package/dist/microphone.d.ts +23 -0
- package/dist/microphone.js +46 -0
- package/dist/navigation.d.ts +15 -0
- package/dist/navigation.js +15 -0
- package/dist/parse.d.ts +1040 -0
- package/dist/parse.js +1051 -0
- package/dist/popover-schemas.d.ts +33 -0
- package/dist/popover-schemas.js +70 -0
- package/dist/popover.d.ts +36 -0
- package/dist/popover.js +54 -0
- package/dist/protocol.d.ts +1808 -0
- package/dist/protocol.js +703 -0
- package/dist/schemas.d.ts +13 -0
- package/dist/schemas.js +10 -0
- package/dist/scrollbar-style.d.ts +3 -0
- package/dist/scrollbar-style.js +58 -0
- package/dist/service-host-schemas.d.ts +110 -0
- package/dist/service-host-schemas.js +75 -0
- package/dist/service-host.d.ts +240 -0
- package/dist/service-host.js +108 -0
- package/dist/service-provider-schemas.d.ts +1726 -0
- package/dist/service-provider-schemas.js +433 -0
- package/dist/service-providers.d.ts +865 -0
- package/dist/service-providers.js +420 -0
- package/dist/service-surface-schemas.d.ts +169 -0
- package/dist/service-surface-schemas.js +54 -0
- package/dist/service-surface.d.ts +81 -0
- package/dist/service-surface.js +129 -0
- package/dist/session-events.d.ts +115 -0
- package/dist/session-events.js +87 -0
- package/dist/shells.d.ts +49 -0
- package/dist/shells.js +4 -0
- package/dist/source-control-capabilities.d.ts +70 -0
- package/dist/source-control-capabilities.js +36 -0
- package/dist/source-control-draft-schemas.d.ts +69 -0
- package/dist/source-control-draft-schemas.js +62 -0
- package/dist/source-control-reviewers.d.ts +11 -0
- package/dist/source-control-reviewers.js +1 -0
- package/dist/source-control-reviews.d.ts +11 -0
- package/dist/source-control-reviews.js +7 -0
- package/dist/source-control-urls.d.ts +6 -0
- package/dist/source-control-urls.js +9 -0
- package/dist/status-control-schemas.d.ts +21 -0
- package/dist/status-control-schemas.js +29 -0
- package/dist/status-controls.d.ts +27 -0
- package/dist/status-controls.js +43 -0
- package/dist/status-view-schemas.d.ts +165 -0
- package/dist/status-view-schemas.js +110 -0
- package/dist/status-view.d.ts +101 -0
- package/dist/status-view.js +12 -0
- package/dist/ui/badge.d.ts +9 -0
- package/dist/ui/badge.js +25 -0
- package/dist/ui/banner.d.ts +13 -0
- package/dist/ui/banner.js +48 -0
- package/dist/ui/button.d.ts +13 -0
- package/dist/ui/button.js +49 -0
- package/dist/ui/checkbox.d.ts +11 -0
- package/dist/ui/checkbox.js +45 -0
- package/dist/ui/dom.d.ts +11 -0
- package/dist/ui/dom.js +59 -0
- package/dist/ui/empty.d.ts +11 -0
- package/dist/ui/empty.js +44 -0
- package/dist/ui/field.d.ts +16 -0
- package/dist/ui/field.js +49 -0
- package/dist/ui/icons.d.ts +9 -0
- package/dist/ui/icons.js +25 -0
- package/dist/ui/index.d.ts +38 -0
- package/dist/ui/index.js +19 -0
- package/dist/ui/list.d.ts +23 -0
- package/dist/ui/list.js +90 -0
- package/dist/ui/menu.d.ts +19 -0
- package/dist/ui/menu.js +112 -0
- package/dist/ui/navigation.d.ts +12 -0
- package/dist/ui/navigation.js +32 -0
- package/dist/ui/option.d.ts +14 -0
- package/dist/ui/option.js +41 -0
- package/dist/ui/popover-anchor.d.ts +15 -0
- package/dist/ui/popover-anchor.js +219 -0
- package/dist/ui/popup.d.ts +1 -0
- package/dist/ui/popup.js +38 -0
- package/dist/ui/progress.d.ts +10 -0
- package/dist/ui/progress.js +51 -0
- package/dist/ui/search.d.ts +10 -0
- package/dist/ui/search.js +62 -0
- package/dist/ui/select.d.ts +19 -0
- package/dist/ui/select.js +164 -0
- package/dist/ui/separator.d.ts +6 -0
- package/dist/ui/separator.js +26 -0
- package/dist/ui/spinner.d.ts +7 -0
- package/dist/ui/spinner.js +29 -0
- package/dist/ui/style.d.ts +3 -0
- package/dist/ui/style.js +310 -0
- package/dist/ui/tabs.d.ts +14 -0
- package/dist/ui/tabs.js +61 -0
- package/dist/ui/text.d.ts +21 -0
- package/dist/ui/text.js +88 -0
- package/dist/ui/theme.d.ts +16 -0
- package/dist/ui/theme.js +88 -0
- package/dist/waits-schemas.d.ts +28 -0
- package/dist/waits-schemas.js +42 -0
- package/dist/waits.d.ts +90 -0
- package/dist/waits.js +95 -0
- package/dist/workspace-schemas.d.ts +192 -0
- package/dist/workspace-schemas.js +63 -0
- package/dist/workspace.d.ts +150 -0
- package/dist/workspace.js +5 -0
- package/package.json +56 -4
- package/scripts/bundle-guest.ts +44 -0
- package/scripts/check-guest.ts +72 -0
package/API.md
ADDED
|
@@ -0,0 +1,751 @@
|
|
|
1
|
+
# ohpichamber-sdk — developer API reference
|
|
2
|
+
|
|
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)`. Longer 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](https://github.com/Shizuku-Yume/ohpichamber/blob/main/packages/sdk/GUEST_SERVICES.md)` for local services.
|
|
4
|
+
|
|
5
|
+
**Package:** `ohpichamber-sdk`
|
|
6
|
+
|
|
7
|
+
**API version:** manifest `apiVersion: 1`, wire envelope `v: 2` (private `MessagePort` bootstrap)
|
|
8
|
+
|
|
9
|
+
**Runtimes that load guests:** web, desktop, and mobile. Mobile panels and pages need their manifest opt-in.
|
|
10
|
+
|
|
11
|
+
Wire `v: 2` is the private bootstrap transport; manifest `apiVersion` stays `1` because the manifest/`contributes` schema did not change. SDK 3 refuses the pre-M3 window `hello` and names the mismatch in the pane instead of waiting for a timeout; a v1 bootstrap announcement is dropped without granting anything.
|
|
12
|
+
|
|
13
|
+
Two entrypoints:
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
| Import | Role |
|
|
17
|
+
| --------------------- | -------------------------------------------------------------- |
|
|
18
|
+
| `ohpichamber-sdk` | Manifest parse, iframe protocol, `connectHost` |
|
|
19
|
+
| `ohpichamber-sdk/ui` | Optional DOM drawing kit (buttons, fields, lists, popups) |
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Ship checklist (install fails without these)
|
|
25
|
+
|
|
26
|
+
`inspectGuestPackage` (Settings → Extensions install) checks the folder or zip **on disk**. Parse alone is not enough. No OhPiChamber runtime compiles TypeScript: packaged desktop, `ohpichamber serve`, and the dev server all serve the built `.js` files as they sit in the package.
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
| Must exist | When | Failure code |
|
|
30
|
+
| -------------------------------------------------------------------------------- | ----------------------------------------------- | ------------------ |
|
|
31
|
+
| Semver `version` on `package.json` (`1.0.0`) | Always on install | `invalid-manifest` |
|
|
32
|
+
| `panel.entry` or `background.entry` HTML file | Every declared entry | `invalid-manifest` |
|
|
33
|
+
| Every relative `<script src="…">` `.js` from that HTML | Every declared entry | `missing-build` |
|
|
34
|
+
| File named by `panel.icon` | Only when icon ends in `.svg` (e.g. `icon.svg`) | `invalid-manifest` |
|
|
35
|
+
| File named by `service.entry` (e.g. `service/main.js`) | When `contributes.service` is set | `missing-build` |
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
**Icon.** Remixicon kebab name (`window`) needs no file. A package SVG path (`icon.svg`) must sit inside the package. URLs and absolute paths fail parse as `invalid-panel-icon`. Missing SVG on disk fails install as `invalid-manifest`.
|
|
39
|
+
|
|
40
|
+
**Panel JS.** Classic IIFE. The iframe cannot load ESM. Point `panel/index.html` at `./main.js` and ship that file.
|
|
41
|
+
|
|
42
|
+
**Service JS.** Same rule as the panel: `service.entry` must be compiled JS already in the package. `.ts` alone fails as `missing-build`.
|
|
43
|
+
|
|
44
|
+
Bundle with the SDK helper from the guest folder (`--node` targets Node for the service):
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
bunx openchamber-guest-bundle panel/main.ts panel/main.js
|
|
48
|
+
bunx openchamber-guest-bundle --node service/main.ts service/main.js
|
|
49
|
+
bunx openchamber-guest-check # says what the host would refuse
|
|
50
|
+
```
|
|
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 also `[GUEST_SERVICES.md](https://github.com/Shizuku-Yume/ohpichamber/blob/main/packages/sdk/GUEST_SERVICES.md)`.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## 1. `connectHost` — iframe client
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { connectHost, HostRequestError } from 'ohpichamber-sdk';
|
|
60
|
+
|
|
61
|
+
const host = connectHost();
|
|
62
|
+
```
|
|
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. It creates a per-document private `MessageChannel`, transfers one end to the exact parent, and receives the normal SDK port over that private channel. `connectHost` consumes that port through an internal same-document event; iframe `load` and window-message connect-port envelopes never grant capabilities. Call `dispose()` on teardown; in-flight RPCs then reject as `HOST_UNAVAILABLE`. Silent host for 20s → …
|
|
65
|
+
|
|
66
|
+
### 1.1 Subscriptions (host pushes)
|
|
67
|
+
|
|
68
|
+
Each returns an unsubscribe function. State subscriptions replay the last known value from `ready` or the last dedicated push. Control activations and popover-close events are delivered only to current listeners.
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
| Method | Payload | Notes |
|
|
72
|
+
| ------------------------------ | ----------------------- | ------------------------------------------------------------ |
|
|
73
|
+
| `onReady(listener)` | `HostReadyContext` | First snapshot and later full refreshes |
|
|
74
|
+
| `onDirectory(listener)` | `string | null` |
|
|
75
|
+
| `onSession(listener)` | `SessionSnapshot | null` |
|
|
76
|
+
| `onSessionLifecycle(listener)` | `SessionLifecycleEvent` | `{ sessionId, phase }` — `started` / `completed` / `failure` |
|
|
77
|
+
| `onConnection(listener)` | `GuestConnection` | `{ connected, account }` |
|
|
78
|
+
| `onSettings(listener)` | `GuestSettings` | Declared integration fields only (`Record<string, string>`) |
|
|
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
|
+
| `onStatusControl(listener)` | `{ id, value? }` | Host Work Status control activation. Register synchronously; only status frames with advertised status controls receive events |
|
|
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
|
+
| `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 |
|
|
83
|
+
| `onBlock(listener)` | `GuestBlockCall` | The call a `block` frame draws: `{ name, args, answered }`. Replays, and again once answered. The arguments are written by a model: treat them as untrusted |
|
|
84
|
+
| `onServiceEvent(listener)` | `{ topic, data }` | What the extension's service sent with `emit`. Nothing replays: read the current state from the service first |
|
|
85
|
+
| `onAction(handler)` | `GuestActionItem` → `void \| Promise<void>` | Runs a `mode: "background"` message or session action. Register synchronously after `connectHost`. Await every operation; the frame is removed when the handler settles. Throw to report an error. One handler at a time; returns an unsubscribe function |
|
|
86
|
+
| `onFileOpen(listener)` | `FileEditorDocument` | File editors only: `{ path, name, readOnly, encoding: 'text', content }` or `{ ..., encoding: 'binary', bytes }` (a `Uint8Array`) of the file this frame edits. Replays the last file; the same file pushed again is not repeated. Registering also sends Cmd/Ctrl+S inside the frame to the host's save |
|
|
87
|
+
| `onFileSnapshot(handler)` | `'save' \| 'handoff'` → `FileEditorSnapshot \| Promise<FileEditorSnapshot>` | File editors only: return the whole edited file (`{ content, version }` for a text editor, `{ bytes, version }` for a binary one) and a version of the state it came from. `save` writes it; `handoff` moves it into the host's source view. Throwing fails that save. One handler at a time |
|
|
88
|
+
| `onFileSaved(listener)` | `version: string` | File editors only: the snapshot with that version is on disk. Answer with `reportFileChange({ dirty, edited: false })` so edits made during the write stay unsaved |
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
`ready.session` and `onSession` return the current session with optional `context` and `tokens` fields. `context` is `{ tokens, limit }` for the latest measured context fill: `tokens` counts the most recent assistant step, while `limit` is the context window of the model that answered that step, or `null` if unknown. It is `null` before a measured reply or after a compaction until another reply. `tokens` contains `{ prompt, output, reasoning, cacheRead, cacheWrite, cacheHitPercent }`, the cumulative session totals shown in the app. `prompt` includes uncached input and cache reads/writes; `cacheHitPercent` is `null` without prompt tokens. `tokens` is `null` before the session reports usage. Both fields update with the session and are optional for older hosts.
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
`HostReadyContext`
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
| Field | Type | Meaning |
|
|
98
|
+
| -------------- | ------------------------ | ---------------------------------------------------------------------------------------- |
|
|
99
|
+
| `theme.mode` | `'light' | 'dark'` |
|
|
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
|
+
| `locale` | `string` | Host language tag |
|
|
102
|
+
| `directory` | `string | null` |
|
|
103
|
+
| `session` | snapshot or `null` | Title falls back to `id`. `busy` is live status. `model` is `providerID/id` when present |
|
|
104
|
+
| `surface` | `'panel' \| 'dialog' \| 'page' \| 'background' \| 'status' \| 'file' \| 'popover' \| 'block'` | Where the host mounted this frame |
|
|
105
|
+
| `popover` | optional `{ id, data }` | Present in a host-created popover frame. `data` is bounded JSON from the owning frame |
|
|
106
|
+
| `connection` | `{ connected, account }` | Integration link state; a tracker extension without an integration gets its tracker account |
|
|
107
|
+
| `settings` | `Record<string, string>` | Declared keys only, without `secret` fields |
|
|
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
|
+
|
|
110
|
+
|
|
111
|
+
`theme.tokens` includes `primaryText`, `successText`, `warningText`, `errorText`, and `infoText`. The host computes these for text on neutral surfaces and the UI kit's tinted controls. Keep using the base colors for fills and `primaryForeground` for text on a solid primary fill.
|
|
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.
|
|
116
|
+
|
|
117
|
+
`GuestItem` is `AttachIssueRequest | GuestMessageItem | GuestSessionItem | GuestSelectionItem | GuestFileItem | GuestDiffItem | GuestLinkItem`:
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
type GuestMessageItem = {
|
|
121
|
+
kind: 'message';
|
|
122
|
+
action: string; // the action id from the manifest
|
|
123
|
+
sessionId: string;
|
|
124
|
+
sessionTitle: string;
|
|
125
|
+
directory: string | null; // the session's project directory
|
|
126
|
+
messageId: string;
|
|
127
|
+
role: 'user' | 'assistant';
|
|
128
|
+
text: string; // what the Markdown export renders for that message, at most 200 000 chars
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
type GuestSessionItem = {
|
|
132
|
+
kind: 'session';
|
|
133
|
+
action: string;
|
|
134
|
+
sessionId: string;
|
|
135
|
+
sessionTitle: string;
|
|
136
|
+
directory: string | null; // the session's project directory
|
|
137
|
+
messages?: Array<{ id: string; role: 'user' | 'assistant'; text: string; createdAt: number }>; // oldest first; only with payload ["messages"] and the conversation grant. Same messages the Markdown export writes: the conversation plus context the user attached (`user`); OMP's own plumbing messages are left out
|
|
138
|
+
truncated?: boolean; // the oldest messages were dropped so the item stays under 2 000 000 serialized chars
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
type GuestLinkItem = {
|
|
142
|
+
kind: 'link'; // the user clicked an identifier or link `contributes.links` claims, with action "open"
|
|
143
|
+
identifier: string; // what the key or `{id}` matched, e.g. "DEMO-12"
|
|
144
|
+
url?: string; // the clicked link without its fragment and other query parameters; for an identifier in text, the link the first fillable template names; absent without one, or when the identifier lacks `urls.identifier`'s shape
|
|
145
|
+
};
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
Access tokens never appear in `ready` or in request results.
|
|
150
|
+
|
|
151
|
+
**Session lifecycle phases:** live `busy` / `retry` → `started`; `idle` → `completed`; unknown status → `failure` (not abort/crash).
|
|
152
|
+
|
|
153
|
+
### 1.2 Actions (RPC)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
| Method | Arguments | Returns | Behavior |
|
|
157
|
+
| ----------------- | --------------------------------- | ------------------------------ | ------------------------------------------------------------------------------------- |
|
|
158
|
+
| `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
|
+
| `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 it is on screen, rejects `NO_DIRECTORY` or `UNSUPPORTED` when it cannot open. On the phone it opens the matching workspace tab (Changes, Files, Terminal, Notes, or an extension panel that opted into the phone) and rejects `UNSUPPORTED` for anything else |
|
|
161
|
+
| `writeClipboard` | `text: string` | `Promise<void>` | Copy in the host (1–32000 chars) |
|
|
162
|
+
| `compose` | `{ text, mode?: 'append' | 'replace' }` | `Promise<void>` |
|
|
163
|
+
| `attach` | `AttachIssueRequest` | `Promise<void>` | Composer chip, alongside other attached items |
|
|
164
|
+
| `startSession` | `StartSessionRequest` | `Promise<{ sessionId, sent }>` | Create session (+ optional worktree), write snapshot. `text` can become first message |
|
|
165
|
+
| `prompt` | `{ text, send?: boolean }` | `Promise<{ sent }>` | Current session: omit/`false` = replace-compose; `send: true` = send |
|
|
166
|
+
| `sessionLink` | `AttachIssueRequest` | `Promise<void>` | Write snapshot on **current** session. Does not create one |
|
|
167
|
+
| `close` | — | `Promise<void>` | Dismiss an attach dialog or the calling popover. No-op on the rail |
|
|
168
|
+
| `oauthStart` | — | `Promise<void>` | Open provider authorize URL (or first-party Linear) |
|
|
169
|
+
| `oauthDisconnect` | — | `Promise<void>` | Drop guest tokens / Linear connection |
|
|
170
|
+
| `request` | `{ method, path, query?, body? }` | `Promise<{ status, body }>` | HTTPS call on declared `apiOrigin`. Host attaches auth |
|
|
171
|
+
| `serviceRequest` | same shape as `request` | `Promise<{ status, body }>` | Proxy to this guest's local service on loopback |
|
|
172
|
+
| `serviceStatus` | — | `Promise<{ status }>` | `stopped` |
|
|
173
|
+
| `readFile` | `path: string` | `Promise<{ content }>` | UTF-8 text. Relative = inside the open project (`files`); `/…` or `~/…` = declared `filesystem` pattern |
|
|
174
|
+
| `writeFile` | `path: string, content: string` | `Promise<{ written: true }>` | Atomic (temp + rename), creates parent folders. Same path rules |
|
|
175
|
+
| `listDir` | `path: string` | `Promise<{ entries }>` | `{ name, kind: 'file' \| 'directory' \| 'other' }[]`, sorted, capped at 2 000. Same path rules |
|
|
176
|
+
| `stat` | `path: string` | `Promise<{ kind, size, mtime }>` | `kind` adds `'missing'`; a missing path is not an error. Same path rules |
|
|
177
|
+
| `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 characters; the host reads the commit itself. `NO_DIRECTORY` without a project, `NOT_FOUND` for an unknown commit, `UNSUPPORTED` where the host has no Diff view. On the phone it opens the Changes tab on that commit |
|
|
179
|
+
| `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 repository's bound remote (`origin/main`), or a full `refs/heads/…` / `refs/remotes/…` ref. A bare name takes the bound remote's copy when it has one, as the view's base picker does; a base written as a remote ref (`origin/main`, `refs/remotes/…`) must be that remote-tracking branch and never falls back to a local branch of the same name. Without a bound remote only local branches qualify, so a remote ref rejects there. The base becomes the branch's chosen base; the user can still change it or the scope, and nothing is generated until they click Generate. A base the repository does not have, another remote's branch, or the branch itself rejects `NOT_FOUND` and changes nothing. `NO_DIRECTORY` without a project, `NOT_FOUND` outside a repository or on a detached HEAD, `HOST_UNAVAILABLE` when the repository could not be read or its worktree is still being created, `UNSUPPORTED` on the phone, in Mini Chat and in VS Code. It works in the repository the view shows for the frame's folder, a nested one when that is selected. After `openSession` the extension's frames load again for the new chat, so save what to open with `storage` first and call it from the new frame once `onDirectory` reports the session's directory |
|
|
180
|
+
| `setHeight` | `height: number` | `Promise<void>` | Content height in CSS px. The Work Status section sizes its frame to it, clamped to 24–480; taller content scrolls inside. A page docked to a shared surface grows or shrinks its dock to it (a width for a `left`/`right` dock), from 24 px up to half the panel. Other surfaces ignore it |
|
|
181
|
+
| `setStatusControls` | `GuestStatusControl[]` | `Promise<void>` | Replace host-rendered controls for this mounted status frame. Requires `features.statusControls`; old hosts reject with `UNSUPPORTED` |
|
|
182
|
+
| `openPopover` | `GuestPopoverRequest` | `Promise<void>` | Open a sandboxed frame outside this frame's bounds, anchored to a rectangle in its viewport. Requires `features.popovers` |
|
|
183
|
+
| `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
|
+
| `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, no history; the host picks the model. Waits up to 90 s |
|
|
186
|
+
| `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
|
+
| `requestFileSave` | — | `void` | File editors only. Save now, as Cmd/Ctrl+S does |
|
|
188
|
+
| `reportFileUnsupported` | — | `void` | File editors only. This file cannot be opened here; the host shows its source and a notice |
|
|
189
|
+
| `dispose` | — | `void` | Remove listener, reject pending RPCs |
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
`AttachIssueRequest`
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
{
|
|
196
|
+
providerId: string; // usually panel id
|
|
197
|
+
id: string; // guest identifier, not a GitHub number
|
|
198
|
+
title: string;
|
|
199
|
+
url: string;
|
|
200
|
+
text?: string; // optional model context
|
|
201
|
+
kind?: 'issue' | 'pull'; // default issue
|
|
202
|
+
author?: string;
|
|
203
|
+
branches?: { head: string; base: string }; // for pull
|
|
204
|
+
data?: JsonValue; // opaque, comes back as ready.item.data; not sent to the model
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
`data` is plain JSON (`string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue }`). It is stored with the chip and the session snapshot and returned unchanged when the user clicks the chip. `JSON.stringify(data).length` must stay within `GUEST_ATTACH_DATA_MAX` (16 000): `clampAttachRequest` silently drops a larger `data`, and the host schema refuses the whole message if it arrives over the limit.
|
|
209
|
+
|
|
210
|
+
`StartSessionRequest` adds `projectId?`, `navigation?: 'preserve' | 'open'`, and `worktree?` to the attach fields. Navigation defaults to `preserve`. Without `projectId`, the current directory is used. With one, creation targets that registered project without switching the app first.
|
|
211
|
+
|
|
212
|
+
`worktree` is `false` or omitted for the target directory, `true` for a generated new worktree, `{ kind: 'existing', directory }` for a known worktree belonging to the project, or `{ kind: 'new', name?, baseBranch? }`. `name` names both the branch and worktree. Omitted name/base use the host's normal defaults. First-message model/agent/variant selection is captured when the call starts.
|
|
213
|
+
|
|
214
|
+
A created session returns `{ sessionId, directory, sent, linked, worktree? }`. `linked: false` means the session exists but saving the attached item failed. If a worktree was created but bootstrap or session creation failed, the result is `{ sessionId: null, sent: 'skipped', directory, worktree, failure }`, where `failure` is `bootstrap-failed` or `session-create-failed`. The worktree is retained. Inspect the result before offering Retry, which would otherwise create another worktree. The call waits up to 180 seconds; a timeout does not prove the server rolled back.
|
|
215
|
+
|
|
216
|
+
### Workspace lists and subscriptions
|
|
217
|
+
|
|
218
|
+
These methods extend the existing `sessions` capability. They expose registered projects on the connected server, session metadata and live state, and known worktrees. They do not grant conversation content or file access.
|
|
219
|
+
|
|
220
|
+
| Method | Result |
|
|
221
|
+
| --- | --- |
|
|
222
|
+
| `listProjects()` | `Promise<GuestProjectsSnapshot>` |
|
|
223
|
+
| `listWorktrees(projectId)` | `Promise<GuestWorktreesSnapshot>` |
|
|
224
|
+
| `listSessions(projectId)` | `Promise<GuestSessionsSnapshot>` including known archived sessions |
|
|
225
|
+
| `onProjects(listener)` | `Promise<() => void>` |
|
|
226
|
+
| `onWorktrees(projectId, listener)` | `Promise<() => void>` |
|
|
227
|
+
| `onSessions(projectId, listener)` | `Promise<() => void>` |
|
|
228
|
+
| `openSession(sessionId)` | `Promise<void>`, explicitly opens the chat and closes the page |
|
|
229
|
+
|
|
230
|
+
Await subscription registration to handle refusal, then retain its returned unsubscribe function. Each subscription sends an initial snapshot, then changes. At most 32 subscriptions per iframe. `dispose()` releases them all. Unmount, disable, uninstall and runtime switch also release host subscriptions.
|
|
231
|
+
|
|
232
|
+
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
|
+
|
|
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`. Item references contain only this extension's `id` and optional `data`. `links` is every thread linked to the session, whoever linked it (the user, the agent through `session.link`, this extension or another), each with `title`, `url`, `kind: 'issue' | 'change'` (`change` is a pull, merge or change request) and `linkedAt`; read-only, and a change to it sends a new snapshot. Hosts older than this field omit it. `inWork` is `true` when the session sits in the sidebar's In work block and always `false` while the user has In work turned off; turning the setting on or off sends a new snapshot. Hosts older than this field omit it. `unread` is `true` when the session's last turn ended and nobody has opened the session since, the mark the sidebar shows; OMP keeps it, so it survives restarts and clears on every device the user reads it on. Hosts older than this field omit it. `tool` is what the session works with while `activity` is `running`: the tool call running now, or the one that ended last while the agent thinks about its result. It has `name` as OMP calls it (`read`, `edit`, `bash`) and `target`, the file or folder the call names relative to the session's `directory` (the bare name for one outside it), or `null` when it names none; a shell command's text never appears. It is `null` whenever the session does not run. `context` is how full the context window was after the session's latest step: `tokens` it held and `limit`, the model's window, or `null` when the host does not know it. It is `null` before the host has seen a step and after a compaction until the next step measures the window. Hosts older than these fields omit them. `tokens` is the cumulative session usage described above, or `null` before any nonzero usage; older hosts omit it.
|
|
235
|
+
|
|
236
|
+
`agent` is the session's agent name, available for both top-level sessions and subsessions with the `sessions` capability. It is omitted when the host has no agent name or predates this field. Agent changes send a new snapshot.
|
|
237
|
+
|
|
238
|
+
`activity` is `unknown`, `idle`, `running`, `retrying`, `waiting-permission`, or `waiting-question` (the agent put a form, a page or a secret card to the user and is waiting on the answer). `outcome` is the last observed `completed` or `failed` turn, or `null` when unknown or working. Outcomes are in memory for the latest 2,000 observed sessions, reset on runtime switch, and are not reconstructed from persisted history. A later idle event preserves an observed failure until another run starts. `completed` never means the extension's task is Done. Blocking-request contents and approve/reply actions are not exposed.
|
|
239
|
+
|
|
240
|
+
### Running shells
|
|
241
|
+
|
|
242
|
+
These methods need the `shells` capability. They expose the running shell commands in a scope — one session and its subagents, a registered project, or every session — and let the extension read their output and stop them. OhPiChamber answers from its local store; no network read happens per request.
|
|
243
|
+
|
|
244
|
+
| Method | Result |
|
|
245
|
+
| --- | --- |
|
|
246
|
+
| `onRunningShells(scope, listener)` | subscription: the running shell commands in scope — one session and its subagents (`{ kind: 'session', sessionId }`), a registered project (`{ kind: 'project', projectId }`), or every session (`{ kind: 'global' }`) — oldest first, with each command's `background` flag, plus the ones that ended since OhPiChamber started watching |
|
|
247
|
+
| `readShellOutput(shellId, { cursor?, tailBytes? })` | one page of a running or ended command's output; `tailBytes` is capped at 65536 |
|
|
248
|
+
| `stopShell(shellId)` | sends the agent the stop note first, then removes the command |
|
|
249
|
+
|
|
250
|
+
Await subscription registration to handle refusal, then retain its returned unsubscribe function. Each subscription sends an initial snapshot, then changes, and counts against the same 32-subscription limit as the workspace subscriptions. The snapshot is `{ kind: 'shells', scope, shells, ended }`, where `scope` echoes the subscription's scope; each shell is `{ id, sessionID, command, startedAt, background }`, at most 200, oldest first. `background` is `true` for a job the turn does not wait for, and `false` while the turn that ran it is blocked on it.
|
|
251
|
+
|
|
252
|
+
`ended` holds the commands in scope that OhPiChamber saw running and saw end, oldest end first, at most 200 with the newest kept. Each adds `status`, `endedAt`, and `exit` when the command exited with a code. `status` is `exited`, `timeout`, `killed` (a signal), `stopped` (by a user: Stop in the app, `stopShell`, or aborting the turn that waited on it), or `unknown` (the end fell into a reconnect and OhPiChamber only saw the command gone). The list lives in memory: it starts empty when the app loads and resets on a runtime switch, so keep anything you show across reloads in extension storage.
|
|
253
|
+
|
|
254
|
+
`readShellOutput` returns `{ output, cursor, skipped }`; omit `cursor` to start `tailBytes` before the end, and `skipped` says earlier output was dropped. OMP keeps an ended command's output until it evicts the command (the latest 25 ended commands per directory); a stopped command's output is removed with it. A shell OhPiChamber has not seen, a stopped one, and one whose output OMP no longer keeps are `NOT_FOUND`; `stopShell` on a shell that is not running is `NOT_FOUND` too. An unapproved `shells` capability is `NOT_GRANTED`.
|
|
255
|
+
|
|
256
|
+
### Microphone
|
|
257
|
+
|
|
258
|
+
`openMicrophone()` needs the `microphone` capability and resolves to `{ stream, close, onEnded }`. `stream` is a `MediaStream` with one mono audio track carrying the user's microphone; hand it to an `RTCPeerConnection`, a `MediaRecorder` or an `AudioContext` as you would one from `getUserMedia`. The frame cannot call `getUserMedia` itself: its origin is opaque and the browser refuses it, so OhPiChamber captures and streams the audio in.
|
|
259
|
+
|
|
260
|
+
Call it from a click inside your frame, because the audio inside the frame starts only from the user's gesture. Check `features.microphone` on `onReady` first; older hosts and hidden background frames answer `UNSUPPORTED`. One microphone is open per frame at a time, and a second call while it is open is `HOST_REJECTED`. The user or the system refusing access is `DENIED`, no input device is `NOT_FOUND`, an unapproved capability is `NOT_GRANTED`. The open waits up to 120 s, since the system may be showing its permission prompt.
|
|
261
|
+
|
|
262
|
+
`close()` stops the capture and ends the track; calling it twice is safe. `onEnded(listener)` hears the host stop on its own, with `revoked` when the user withdrew the grant or paused the extension and `device-lost` when the input device went away; the handle is closed by then. Reloading or removing the frame stops the capture too. Echo cancellation, noise suppression and auto gain are on.
|
|
263
|
+
|
|
264
|
+
### Extension storage
|
|
265
|
+
|
|
266
|
+
`host.storage.get(key, options?)` returns JSON or `undefined` for a missing key. JSON `null` is a stored value. `set(key, value, options?)` and `delete(key, options?)` return `Promise<void>`; `keys(options?)` returns `Promise<string[]>` in sorted order.
|
|
267
|
+
|
|
268
|
+
Storage belongs to the extension on the connected server and needs no extra capability. Keys contain 1 to 128 characters, each serialized value is at most 64 KiB UTF-8, and the complete namespace is at most 2 MiB and 2,000 keys. Use a project ID in your key when data belongs to one project. Concurrent operations serialize on the server, writes are atomic, and read/write failures preserve existing data. Uninstall deletes the namespace, including for folder installs.
|
|
269
|
+
|
|
270
|
+
Omit `options`, or pass `{ scope: 'instance' }`, for this existing server-owned storage. `{ scope: 'device' }` stores data in the current browser profile, scoped by the host runtime, guest ID, and server-issued installation identity. Use it only after `onReady` reports `features.deviceStorage: true`. Older hosts reject device requests with `UNSUPPORTED`; the SDK never changes them into instance requests. Different runtime identities keep separate preferences even when a server copies an installation identity. URL aliases are not guaranteed to share data; saved host and relay connections follow the host's existing runtime identity rules. Device namespaces have the same 2 MiB and 2,000-key limits, and serialized preference content across the browser database has a 16 MiB limit; browser metadata has separate overhead. A successful uninstall makes an installation namespace inaccessible, but an offline profile may retain those bytes until site data is removed. Device storage is for preferences, not secrets, credentials, or SSO state.
|
|
271
|
+
|
|
272
|
+
### Full-screen pages
|
|
273
|
+
|
|
274
|
+
`contributes.page: true` reuses `panel.entry`; `{ entry: 'panel/page.html', title?: 'Board' }` uses separate package HTML and needs no `panel.entry`, so a package can be only a full-screen page; like a status section it then only hosts itself, and `page: true`, `attach`, `actions`, and `commands` still need `panel.entry` or `background.entry`. A page needs the same installed/approved/enabled state as a panel. The sidebar's Extension pages menu is the only page opener; `openSurface` does not open it. `ctx.surface` is `page`, `close()` closes it, and reload or runtime switch returns to chat. Pages use the existing sandbox and capabilities on web/desktop. On the phone a page shows when it opts in (`page: { …, mobile: true }`, or `page: true` with `panel.mobile: true`): it is listed in the sessions list's More menu and opens full screen with a back arrow, so lay it out for about 360px and touch. VS Code remains unsupported.
|
|
275
|
+
|
|
276
|
+
### Work Status sections
|
|
277
|
+
|
|
278
|
+
`contributes.statusSection: true` reuses `panel.entry`; `{ entry: 'status/index.html', title?: 'Recent commits', height?: 160, defaultExpanded?: false, requiresProject?: true }` uses separate package HTML (`.html`, inside the package, built scripts checked at install). The object form needs no `panel.entry`, so an extension can ship only a section and no rail icon. `title` is 1 to 60 characters and replaces `panel.name` on the section header; the icon is `panel.icon`. `height` (24 to 480, default 120) is the frame height before your page calls `setHeight`. Omitted `defaultExpanded` preserves the existing expanded default; a saved user expansion choice still wins. `requiresProject` uses the actual Work Status directory and hides the section when no project is open. The section appears in the chat's Work Status panel and in its section chooser, where the user can hide it or move it. `ctx.surface` is `status`. The frame runs only while the panel is shown and the section is expanded, so keep no state in it that you cannot rebuild. It gets the same sandbox, directory, session, theme, grants, and service as a panel. A status-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, desktop and the phone, which shows the section in its Status tab without any opt-in; the frame is then the phone's width and `ready.device` says so. `apiVersion` remains 1; VS Code remains unsupported.
|
|
279
|
+
|
|
280
|
+
`setStatusControls` accepts zero to four declarations. A button is `{ kind: 'button', id, label, disabled? }`; a select is `{ kind: 'select', id, label, value, options, disabled? }`, with one to 16 unique options and a selected value in that list. IDs are kebab-case and at most 40 characters; labels are 1 to 60 characters; option values are 1 to 80 characters. Register `onStatusControl` synchronously after `connectHost`, then feature-gate `setStatusControls` with `features.statusControls`. Buttons receive no `value`; select events carry a declared value. The host rejects stale, unknown, disabled, or invalid controls. It accepts at most 20 changed control publications per second per frame and avoids semantic no-op updates. Controls exist only for the expanded, mounted status frame that registered them. Folding or hiding the section removes controls and listeners. A project change clears header controls; publish them again from `onDirectory`. Workspace subscriptions remain active. Old hosts return `UNSUPPORTED`; keep a body control visible until `setStatusControls` succeeds.
|
|
281
|
+
|
|
282
|
+
### File editors
|
|
283
|
+
|
|
284
|
+
`contributes.fileEditors` lists up to 8 editors: `{ id: 'canvas', title: 'Excalidraw', match: ['*.excalidraw', '*.excalidraw.md'], entry: 'editor/index.html' }`. `match` holds 1 to 16 file-name patterns, compared case-insensitively with the name only (no `/`); `*` is any run of characters, `?` one, and a pattern must have at least one character that is not a wildcard. `entry` is package `.html` with built scripts, checked at install. `content` is `"text"` (the default) or `"binary"`: a text editor claims only text files and gets the text with `\n` line endings (the host restores the file's own on write); a binary editor claims any matching file, gets its bytes as a `Uint8Array`, returns bytes, and has no source view, and the host saves its unsaved changes before it moves to or from fullscreen. When the user opens a matching file in Files, the viewer loads your page instead of its own preview; the first enabled, approved extension in the list wins, ahead of the built-in viewers. `ctx.surface` is `file`. The phone's Files tab opens your editor too, without an opt-in, at the phone's width.
|
|
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.
|
|
287
|
+
|
|
288
|
+
`sent` **values** (`startSession` / `prompt`): `sent` | `no-model` | `skipped` | `failed`. After `no-model` / `failed` on `startSession`, the session still exists.
|
|
289
|
+
|
|
290
|
+
**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`.
|
|
291
|
+
|
|
292
|
+
`request` **/** `serviceRequest` **rules:** `method` is `GET` | `POST` | `PUT` | `PATCH` | `DELETE`. `path` must start with `/`, no scheme, stay on the declared origin (cloud API or service loopback). Guest parses `body` as JSON when needed.
|
|
293
|
+
|
|
294
|
+
### Toast buttons
|
|
295
|
+
|
|
296
|
+
`ToastRequest.copy` is an optional boolean or `{ text: string }`. `true` copies the displayed message; an object supplies the clipboard value. `false` or omission adds no Copy button. The custom text must contain 1 to `GUEST_CLIPBOARD_TEXT_MAX` characters, with whitespace preserved. The displayed message is trimmed and must contain 1 to `GUEST_TOAST_MAX` characters. The client rejects invalid text lengths as `HOST_REJECTED` before sending; the host independently validates the wire payload.
|
|
297
|
+
|
|
298
|
+
`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
|
+
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. They 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, without waiting for a click. Web and desktop use the same behavior; extension support on other runtimes is unchanged.
|
|
301
|
+
|
|
302
|
+
### Blocks in the chat
|
|
303
|
+
|
|
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`. The phone draws blocks too, without any opt-in, at the reply's width (about 360px).
|
|
305
|
+
|
|
306
|
+
### Background actions
|
|
307
|
+
|
|
308
|
+
`contributes.actions[].mode` accepts `"open"` or `"background"`. Omitted mode keeps the existing panel/dialog routing and `onItem` delivery. Background actions load `background.entry` when declared, otherwise `panel.entry`. They never use separate attach-dialog HTML. They run on web, desktop and the phone, including connections through the private relay; VS Code does not load extensions. On the phone an open-mode action needs `panel.mobile: true`, a background action does not.
|
|
309
|
+
|
|
310
|
+
`contributes.background` is `{ entry: "<package-local .html>" }`. It starts on demand for an action or command and adds no visible UI. With a background entry, `panel.entry` may be omitted: there is no rail icon, attach picker, or full-screen page, but background actions, slash commands, storage and granted APIs work. Identity remains in `panel.id/name/icon`. Open-mode actions, `page: true`, and enabled `attach` require `panel.entry`; a page with its own `entry` does not; invalid combinations fail as `invalid-panel`. Without either entry, the extension may declare only `tools` and `providerLogos`. Invalid background paths or a missing entry field fail as `invalid-background`.
|
|
311
|
+
|
|
312
|
+
When both entries exist, the visible panel cannot register the slash-command resolver: the hidden background entry handles `onResolve` and receives `surface: "background"`. Existing panel-only commands retain their current behavior. Clicking an attached chip from a background-only extension shows a no-panel notice; its browser action remains available.
|
|
313
|
+
|
|
314
|
+
Every background click mounts a fresh sandboxed iframe and sends one `action` request with an invocation `id` and a `GuestActionItem` payload. `host.onAction` receives that message or session item and sends `action-result` with `{ ok: true }` when the handler finishes, or `{ ok: false, error }` when it throws. The error is limited to `GUEST_RESOLVE_ERROR_MAX` characters. The host validates the reply and accepts only the matching invocation from that frame. It sends no acknowledgement for `action-result`.
|
|
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.
|
|
319
|
+
|
|
320
|
+
See [Actions without opening a panel](./README.md#actions-without-opening-a-panel) for a toast example.
|
|
321
|
+
|
|
322
|
+
### Late generate answers
|
|
323
|
+
|
|
324
|
+
A model can take minutes, and the user may close the panel, switch to another project, or reload the frame before `generate` answers. The request still runs to the server's deadline; there is no cancellation. When the answer arrives and the frame that asked is gone, the host keeps it. The next frame of the same extension on the same surface, in the same project and the same window, receives it through `onLateGenerateResult` as soon as it registers a listener; an answer that lands while such a frame already listens arrives at once. Each answer is handed over once. One that reaches the frame after its last listener was removed waits in the SDK for the next listener in that frame. A failed generation is kept as `{ ok: false, code, error }`, so the extension can say what happened. Hidden frames (background actions, and a panel entry the host loads only to answer a slash command) do not advertise the feature: they neither receive kept answers nor leave their own behind.
|
|
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.
|
|
327
|
+
|
|
328
|
+
The host keeps answers in memory for one hour, at most 8 per extension, the oldest dropped first. A page reload, an app restart or another window starts empty: the request belongs to the window that sent it. Disabling, removing or reinstalling the extension, or withdrawing its `model` approval, drops its kept answers. Older hosts do not advertise `features.lateGenerateResults` and never deliver them; the SDK then sends nothing. Extension frames load on web, desktop and the phone, directly or through the private relay; VS Code does not load extensions.
|
|
329
|
+
|
|
330
|
+
```ts
|
|
331
|
+
host.onLateGenerateResult((late) => {
|
|
332
|
+
if (late.request.system !== SUMMARY_SYSTEM) return;
|
|
333
|
+
if (late.ok) showSummary(late.result.text);
|
|
334
|
+
else showError(late.error);
|
|
335
|
+
});
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### Anchored popovers
|
|
339
|
+
|
|
340
|
+
`openPopover` accepts `{ id, anchor: { x, y, width, height }, width, height, side?, focus?, data }`. The anchor uses CSS pixels relative to the calling iframe's viewport. Width is 160..640 pixels, height is 48..480 pixels, and `data` is JSON limited to 16,000 serialized characters. IDs contain 1..80 ASCII letters, digits, underscores or hyphens. Use a new id for each opening. `side` is `left`, `right`, `top` or `bottom`, defaulting to `left`; the host flips or shifts the card to fit the viewport. `focus` defaults to false, so pointer previews do not take keyboard focus.
|
|
341
|
+
|
|
342
|
+
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
|
+
|
|
344
|
+
Visible web and desktop panel, page and status frames can advertise this feature, and so can the phone's. Dialogs, background frames, file editors, popovers and VS Code do not. On the phone the popover opens in the app's bottom sheet instead of beside its anchor: the sheet's width, the requested height within the sheet's limit, `setHeight` as usual. The sheet stays until the user closes it, so anchor activity does not close it; closing reports `outside`. `mountPopoverAnchor` opens on mouse hover, on keyboard focus, and on a touch or pen tap. The tap opens the preview in place of the element's own click (your click handler does not run for it; a mouse or keyboard click is unchanged), so put what the click did into the preview when a touch user needs it. Dialogs retain their own modal focus boundary. Older hosts reject opening with `UNSUPPORTED`; retain an inline or click-based detail view for them. Each opening loads a new frame, so cold loading and relay transport can delay the preview.
|
|
345
|
+
|
|
346
|
+
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
|
+
|
|
348
|
+
A `focus: true` request requires the source frame to have focus. Non-focusing previews are constrained to a visible anchor in the source frame; the host cannot verify pointer activity inside an opaque-origin guest document. The child can use `host.setHeight` to fit its content within the popover height limit; this resizes only that child and includes the host border. Scrolling an unrelated host panel does not dismiss the preview.
|
|
349
|
+
|
|
350
|
+
Use `mountPopoverAnchor` from `ohpichamber-sdk/ui` for DOM anchors. It measures the element, handles hover and keyboard opening, reports activity while the pointer crosses between frames, and retires the preview when the anchor scrolls away or is removed. Retain and call its `dispose()` when replacing rows. Low-level callers must perform those lifecycle steps themselves. The host can validate the source iframe and rectangle but cannot inspect an element inside its sandbox.
|
|
351
|
+
|
|
352
|
+
### 1.3 Error codes (`HostRequestError.code`)
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
| Code | When |
|
|
356
|
+
| ------------------ | --------------------------------------------- |
|
|
357
|
+
| `HOST_UNAVAILABLE` | No window, not in iframe, or disposed |
|
|
358
|
+
| `HOST_TIMEOUT` | No answer for 20s |
|
|
359
|
+
| `HOST_REJECTED` | Host refusal, or unknown wire code |
|
|
360
|
+
| `DISCONNECTED` | No token / Linear connection |
|
|
361
|
+
| `DISABLED` | Extension paused in Settings |
|
|
362
|
+
| `BAD_PATH` | Path left origin or malformed |
|
|
363
|
+
| `NO_INTEGRATION` | Manifest has no `integration` |
|
|
364
|
+
| `NO_SESSION` | `prompt` / `sessionLink` with no open session |
|
|
365
|
+
| `SESSION_BUSY` | `prompt({ send: true })` while busy |
|
|
366
|
+
| `NO_SERVICE` | No service, not approved, or not running |
|
|
367
|
+
| `NOT_GRANTED` | The user has not approved this capability |
|
|
368
|
+
| `NO_DIRECTORY` | Relative file path with no open project |
|
|
369
|
+
| `NOT_FOUND` | `readFile` / `listDir` on a path that does not exist |
|
|
370
|
+
| `FILE_TOO_LARGE` | File or content over 2 000 000 characters |
|
|
371
|
+
| `DENIED` | The operating system refused the file access |
|
|
372
|
+
| `NO_MODEL` | `generate` with no usable Small Model |
|
|
373
|
+
| `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` on the phone or in Mini Chat) |
|
|
375
|
+
| `SERVICE_FAILED` | Service crashed or never became ready |
|
|
376
|
+
| `REQUEST_FAILED` | `serviceRequest` was sent but got no usable answer; the service may have acted on it |
|
|
377
|
+
| `RESPONSE_TOO_LARGE` | `request` / `serviceRequest` answer over 8 000 000 bytes; the call ran, ask for a smaller page |
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
### 1.4 Field limits (client clamps before send)
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
| Field | Max |
|
|
384
|
+
| -------------------------------- | --------- |
|
|
385
|
+
| Clipboard text | 32 000 |
|
|
386
|
+
| Compose / prompt / attach `text` | 16 000 |
|
|
387
|
+
| Attach `data` (serialized) | 16 000 |
|
|
388
|
+
| Attach `id` | 128 |
|
|
389
|
+
| Attach `title` | 200 |
|
|
390
|
+
| Attach `url` | 2 000 |
|
|
391
|
+
| Attach `author` | 80 |
|
|
392
|
+
| Branch name | 200 |
|
|
393
|
+
| Request path | 2 000 |
|
|
394
|
+
| Request body | 64 000 |
|
|
395
|
+
| Request response (bytes) | 8 000 000 |
|
|
396
|
+
| Request timeout | 20 000 ms |
|
|
397
|
+
| `resolve` answer (host waits) | 20 000 ms |
|
|
398
|
+
| Background action loading and execution | 20 000 ms |
|
|
399
|
+
| Badge count | 999 |
|
|
400
|
+
| Message item `text` | 200 000 |
|
|
401
|
+
| Session item (serialized) | 2 000 000 |
|
|
402
|
+
| File path | 1 024 |
|
|
403
|
+
| File content (read and write) | 2 000 000 |
|
|
404
|
+
| `listDir` entries | 2 000 |
|
|
405
|
+
| `generate` prompt / system | 64 000 / 8 000 |
|
|
406
|
+
| `generate` `maxOutputTokens` | 4 000 |
|
|
407
|
+
| `generate` answer | 256 000 |
|
|
408
|
+
| `generate` timeout | 90 000 ms |
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
---
|
|
412
|
+
|
|
413
|
+
## 2. `ohpichamber-sdk/ui` — drawing kit
|
|
414
|
+
|
|
415
|
+
DOM building blocks that use host tokens. They do **not** call the provider or `connectHost`. You compose the screen and wire callbacks yourself.
|
|
416
|
+
|
|
417
|
+
Always call theme first:
|
|
418
|
+
|
|
419
|
+
```ts
|
|
420
|
+
import { applyHostReady, mountList } from 'ohpichamber-sdk/ui';
|
|
421
|
+
|
|
422
|
+
let mounted = false;
|
|
423
|
+
host.onReady((ctx) => {
|
|
424
|
+
applyHostReady(ctx, document.documentElement);
|
|
425
|
+
if (mounted) return;
|
|
426
|
+
mounted = true;
|
|
427
|
+
// then mount…
|
|
428
|
+
});
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
Every mount returns `{ update(partial), dispose() }`. `update` merges the fields you pass and repaints; `dispose` removes the node and its listeners.
|
|
432
|
+
|
|
433
|
+
Selection controls report a proposed value; the caller commits it with `update`. Use `activeId` for tabs, `value` for selects, and `checked` for checkboxes and switches. Text and search inputs display typing immediately, but call `update({ value })` too so later updates do not restore stale props. Button clicks do not change `variant`; use tabs for mode selection. Preserve input state across tab changes instead of remounting empty fields.
|
|
434
|
+
|
|
435
|
+
```ts
|
|
436
|
+
import { mountTabs } from 'ohpichamber-sdk/ui';
|
|
437
|
+
|
|
438
|
+
let activeId = 'convert';
|
|
439
|
+
const tabs = mountTabs(root, {
|
|
440
|
+
items: [{ id: 'convert', label: 'Convert' }, { id: 'format', label: 'Format' }],
|
|
441
|
+
activeId,
|
|
442
|
+
onChange: (next) => {
|
|
443
|
+
activeId = next;
|
|
444
|
+
tabs.update({ activeId });
|
|
445
|
+
// Show the matching panel while preserving its draft values.
|
|
446
|
+
},
|
|
447
|
+
});
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
### 2.1 Theme
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
| Function | Role |
|
|
454
|
+
| ----------------------------- | --------------------------------------------------------- |
|
|
455
|
+
| `applyHostReady(ctx, root)` | Writes theme tokens + `data-oc-surface` / `data-oc-theme` |
|
|
456
|
+
| `applyHostTheme(theme, root)` | Tokens only |
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
### 2.2 Mount functions
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
| Function | Use for | Main props |
|
|
463
|
+
| --------------------------------- | -------------------------- | ----------------------------------------------------------------------------------------------------------- |
|
|
464
|
+
| `mountButton(root, props)` | Button | `label`, `onClick`, `variant?` (`default` / `secondary` / `outline` / `ghost` / `destructive`), `size?` (`default` / `sm` / `xs`), `disabled?`, `loading?` |
|
|
465
|
+
| `mountTextField(root, props)` | Input or textarea | `value`, `onChange`, `label?`, `placeholder?`, `password?`, `multiline?`, `rows?`, `disabled?`, `error?`, `helper?`, `mono?` |
|
|
466
|
+
| `mountSearchField(root, props)` | Search box | `value`, `onChange`, `placeholder?`, `label?`, `autofocus?` |
|
|
467
|
+
| `mountSelect(root, props)` | Dropdown | `value`, `options: { id, label, hint? }[]`, `onChange`, `label?`, `placeholder?`, `searchable?`, `searchPlaceholder?`, `disabled?` |
|
|
468
|
+
| `mountCheckbox` / `mountSwitch` | Checkbox / toggle | `label`, `checked`, `onChange`, `disabled?`, `description?` |
|
|
469
|
+
| `mountTabs(root, props)` | Pill tabs | `items: { id, label, count? }[]`, `activeId`, `onChange`, `trackBackground?` |
|
|
470
|
+
| `mountBadge(root, props)` | Pill | `label`, `tone?` (`neutral` / `primary` / `success` / `warning` / `error` / `info`) |
|
|
471
|
+
| `mountList(root, props)` | Keyboard list | `items: { id, title, subtitle?, leading?, meta?, badge?, disabled? }[]`, `onSelect`, `selectedId?`, `emptyText?`, `ariaLabel?` |
|
|
472
|
+
| `mountEmpty(root, props)` | Empty / disconnected state | `title`, `body?`, `action?: { label, onClick }` |
|
|
473
|
+
| `mountSpinner(root, props?)` | Loading ring | `size?` (`sm` / `default`), `label?` |
|
|
474
|
+
| `mountBanner(root, props)` | Notice | `tone` (`info` / `success` / `warning` / `error`), `title`, `body?`, `action?` |
|
|
475
|
+
| `mountSeparator(root, props?)` | Divider | `label?` |
|
|
476
|
+
| `mountProgress(root, props)` | Progress bar | `value` (0..100), `tone?`, `label?` |
|
|
477
|
+
| `mountMenu(root, props)` | Action dropdown | `label`, `items: ({ id, label, destructive?, disabled? } \| { separator: true })[]`, `onSelect`, `variant?`, `size?` |
|
|
478
|
+
| `mountText(root, props)` | Provider text | `text`, `onOpenUrl?` |
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
### 2.3 Helpers
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
| Function | Role |
|
|
485
|
+
| ------------------------------------------ | --------------------------------------------------------------------------- |
|
|
486
|
+
| `filterSelectOptions(options, query)` | Same case-insensitive label / id match `mountSelect` uses |
|
|
487
|
+
| `moveListSelection(items, currentId, key)` | Keyboard step (`next` / `previous` / `first` / `last`) that skips disabled items |
|
|
488
|
+
| `navigationKey(event, axis?)` | Maps arrows, Home, End, Ctrl+N / Ctrl+P to a step |
|
|
489
|
+
| `splitTextMedia(text)` | Splits text into runs, `` images, and `[label](https://…)` links |
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
`mountText` keeps everything as text except `http(s)` markdown images and links. A sandboxed iframe cannot open a link itself, so pass `onOpenUrl` and forward the URL to `host.openUrl`.
|
|
493
|
+
|
|
494
|
+
---
|
|
495
|
+
|
|
496
|
+
## 3. Manifest and host-side parse (`ohpichamber-sdk`)
|
|
497
|
+
|
|
498
|
+
Used by the OhPiChamber host and by tools that validate packages. Guests rarely call these from the iframe.
|
|
499
|
+
|
|
500
|
+
### 3.1 Manifest block (inside `package.json`)
|
|
501
|
+
|
|
502
|
+
```json
|
|
503
|
+
{
|
|
504
|
+
"name": "@acme/hello-panel",
|
|
505
|
+
"version": "1.0.0",
|
|
506
|
+
"openchamber": {
|
|
507
|
+
"apiVersion": 1,
|
|
508
|
+
"engines": { "openchamber": ">=1.0.0" },
|
|
509
|
+
"id": "acme-hello",
|
|
510
|
+
"name": "Hello",
|
|
511
|
+
"icon": "window",
|
|
512
|
+
"contributes": {
|
|
513
|
+
"panel": { "entry": "panel/index.html" },
|
|
514
|
+
"attach": "dialog",
|
|
515
|
+
"capabilities": ["prompt", "sessions", "files", "shells"],
|
|
516
|
+
"filesystem": ["~/.config/example/settings.json", "/tmp/acme/**"],
|
|
517
|
+
"actions": [
|
|
518
|
+
{ "id": "create-task", "label": "Create task from message", "icon": "add-circle", "where": "message", "roles": ["assistant"] },
|
|
519
|
+
{ "id": "summarize", "label": "Summarize session", "where": "session", "payload": ["messages"] }
|
|
520
|
+
],
|
|
521
|
+
"commands": [{ "name": "task", "description": "Attach a task by id" }],
|
|
522
|
+
"tools": [{ "match": "tasks_*", "name": "Tasks", "icon": "checkbox-circle", "title": "{input.id}", "output": "table", "columns": ["id", "title", "status"] }],
|
|
523
|
+
"integration": { /* oauth | token | host */ },
|
|
524
|
+
"service": { /* optional local process */ }
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
| Key | Rules |
|
|
532
|
+
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
533
|
+
| `version` | Semver required on install (`1.0.0`) |
|
|
534
|
+
| `apiVersion` | Must be `1` |
|
|
535
|
+
| `engines.openchamber` | Optional. Only `1.0.0` or `>=1.0.0`. Older host → `host-too-old` |
|
|
536
|
+
| `id`, `name`, `icon` | Beside `contributes`. Older packages keep them in `panel`, and that still works. `id` is kebab-case |
|
|
537
|
+
| `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
|
+
| `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`. Shows the panel on the phone, as a tab of the workspace drawer, with its live-screen dock and attach. Lay the page out for about 360px wide and touch (`ready.device` says the form factor). Absent: the phone shows no panel, attach or open-mode action, and a link or chip that would open it keeps its usual meaning or says the extension does not open on the phone. `page: true` follows it; the page object takes its own `mobile: true` |
|
|
540
|
+
| `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 (on the phone, the extension's workspace tab); `"dialog"` → host window (full screen on the phone); omit/`false` → off menus. The phone lists it only with `panel.mobile: true`. Object form `{ "mode": "panel" \| "dialog", "entry"?: "panel/attach.html" }`: `entry` (dialog only, same path rules as `panel.entry`, must exist with built scripts) is the page the dialog loads instead of `panel.entry` |
|
|
542
|
+
| `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
|
+
| `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
|
+
| `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 that say how the extension's tool calls look in the chat. `match` is the full tool name OMP reports (`jira_search`), 1–128 chars of `[A-Za-z0-9_.:-]`, with `*` allowed once at the end as a suffix wildcard (`jira_*`). Optional `name` (1–40, the header title when `title` is absent or renders empty), `icon` (Remixicon name or package `.svg` path, same rules as `panel.icon`; the SVG is drawn in the text colour at the glyph size), `title` / `subtitle` templates (1–200, `{input.path}` / `{output.path}` / `{metadata.path}` placeholders, a missing path renders empty, values are cut at 200), `output` `"auto"` (default) \| `"text"` \| `"json"` \| `"markdown"` \| `"code"` \| `"table"` \| `"card"`, `language` (code only), `columns` (table only, 1–16 dotted paths; rows are the output array or `output.items`), `card` (card only, see Tool cards below). Bad shape is `invalid-tools`. An exact `match` beats a wildcard from any extension; among equals the first extension wins. Only an enabled, fully approved extension's rules apply. With Code Mode, a finished script that made one call is matched under the tool's direct name (`example.findings` in the script is `example_findings`) and shows as that tool's row, with `output` being what the script returned; a running script, a script with several calls, and a failed call or a failed script keep the script row |
|
|
546
|
+
| `providerLogos` | Optional map of 1–256 OMP provider IDs (`/^[a-z0-9][a-z0-9._-]{0,63}$/`, the ID OMP reports; IDs the app draws with the same bundled logo follow it, like `claude` for `anthropic`) to a package `.svg` or `.png`, up to 1 MiB each. An alias is another key with the same file. Bad shape is `invalid-provider-logos`; a missing, empty or larger file fails install as `invalid-manifest`. Order for one provider: uploaded logo, chosen icon, extension logo, bundled logo, models.dev logo, generic mark. The first enabled, fully approved extension wins a provider. The image keeps its colours; `currentColor` in an SVG follows the theme. No capability and no page needed. Web, desktop and the phone: VS Code loads no extensions |
|
|
547
|
+
| `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
|
+
| `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
|
+
| `integration` | Optional. Exactly one of `oauth`, `token`, or `host` (`provider: "linear"` only) |
|
|
550
|
+
| `service` | Optional. `entry` must be a built `.js` file on disk. `provides: ["browser"]` makes it the agent's browser when the user selects it; `provides: ["source-control"]` makes it a Git host and needs `sourceControl`; `provides: ["notifications"]` makes it a notification channel and needs `notifications`; `provides: ["tracker"]` makes it a work item tracker next to Linear and needs `tracker` (a service is a Git host or a tracker, never both); `provides: ["quota"]` makes it a usage provider next to the built-in ones and needs `quota`; `surface: true` gives it a host-drawn live panel the user can take over (no `panel.entry` then). None of these needs a panel or background entry. See [GUEST_SERVICES.md](https://github.com/openchamber/openchamber/blob/main/packages/sdk/GUEST_SERVICES.md) |
|
|
551
|
+
| `sessionEvents` | Optional, needs `service`. `{ "events": [1 to 4 distinct of "turn-finished", "turn-failed", "permission-asked", "question-asked"], "content"?: true }`. OhPiChamber posts each listed event, from every project, to the service at `POST /session-events`, with no window open; the service needs no panel or background entry for it. `content: true` adds the `transcript` capability (the reply, the question, the permission's detail). Bad shape or no `service` is `invalid-session-events`. Older hosts drop the key and send nothing, so set an `engines.openchamber` floor. See [GUEST_SERVICES.md](https://github.com/openchamber/openchamber/blob/main/packages/sdk/GUEST_SERVICES.md#session-events-contributessessionevents) |
|
|
552
|
+
| `marks` | Optional `true`, needs `service` (`invalid-marks`). The service puts icons on sidebar rows with `setMark(target, mark)`: `target` is `{ sessionId }`, `{ directory, branch }` (a branch of the repository the folder belongs to) or `{ directory }`; `mark` is `{ icon, tone, text, url? }` or `null`. Adds the `marks` capability, a line of its own in the approval dialog. A mark lasts as long as the service process, so declare `service.keepRunning`. Ships in OhPiChamber 1.0.0, the fork's first release; an upstream host that predates it ignores the key |
|
|
553
|
+
| `notifications` | Required with `provides: ["notifications"]`, refused without it. The notification channel the service delivers to: `label` (1 to 64), `instances` (`{ kind: "fixed", origin }` or `{ kind: "user", label, placeholder? }`), `token` (the Git host's token block: `header`, `scheme`, `username?`, `scopes?`, `createPath?`). Strict. `panel.id` is at most 28 characters (the channel id is `ext-<panel.id>`). Errors are `invalid-service`. See [GUEST_SERVICES.md](https://github.com/openchamber/openchamber/blob/main/packages/sdk/GUEST_SERVICES.md#notification-channel-provides-notifications) |
|
|
554
|
+
| `tracker` | Required with `provides: ["tracker"]`, refused without it, and refused beside `sourceControl`. The work item tracker the service is: `wire: 1`, `label` (1 to 64), `instances` (`{ kind: "fixed", origin }` or `{ kind: "user", label, placeholder? }`), `auth` (`token` block and/or `oauth` `{ authorizeUrl, tokenUrl, scopes? }`, at least one), `capabilities` (flags, each off by default), `stateFilters` (`open`, `all`, then up to 14 of yours), `identifier` (`key-number`, `number` or `short-code`), `urls.item` (1 to 8 link templates with `{id}`, `{segment}`, `{segments+}` and `?name={id}`). Strict. `panel.id` is at most 28 characters (the tracker id is `ext-<panel.id>`). Errors are `invalid-service`. See [GUEST_SERVICES.md](https://github.com/openchamber/openchamber/blob/main/packages/sdk/GUEST_SERVICES.md#tracker-provides-tracker) |
|
|
555
|
+
| `links` | Optional. Identifiers and links in chat messages a click hands to the extension: `{ "action": "open" \| "attach", "identifier"?: { "keys": [1 to 8 unique upper-case keys like "PROJ"] }, "urls"?: { "origin": "https://…", "identifier": "key-number" \| "number" \| "short-code", "item": [1 to 8 link templates] } }`, at least one of `identifier` and `urls`. Keys match as whole words `PROJ-123`, never in code or inside a word or path. `origin` is one public https origin matched exactly, or a subdomain wildcard `https://*.example.com` that matches any subdomain of the domain, never the apex or another port; templates use the tracker's grammar (`{id}` once, in the path or as `?name={id}`, `{segment}`, at most one `{segments+}`), never a regular expression. `open` needs `panel.entry` and opens the extension (its rail panel, or its dialog with `attach: "dialog"`) with a `GuestLinkItem`; `attach` puts a chip on the composer and needs a template without `{segment}` or `{segments+}` so the chip names its link, and with `identifier.keys` an `identifier` other than `number`, since `PROJ-12` never fills a number. Links the app reads itself (tracker items, repository issues and change requests, commits) keep their route. Adds the `links` capability; a version that changes the action, keys, origin or templates asks again (`invalid-links`). Reference: `examples/tasks-demo` |
|
|
556
|
+
| `quota` | Required with `provides: ["quota"]`, refused without it. The usage provider the service is: `providers`, up to 16 unique OMP provider ids by shape (`openrouter`, `zai-coding-plan`), the ones whose stored credentials the service receives on every read; may be empty. Strict. `panel.id` is at most 28 characters (the provider id is `ext-<panel.id>`). Errors are `invalid-service`. See [GUEST_SERVICES.md](https://github.com/Shizuku-Yume/ohpichamber/blob/main/packages/sdk/GUEST_SERVICES.md#usage-provider-provides-quota) |
|
|
557
|
+
| `sourceControl` | Required with `provides: ["source-control"]`, refused without it. The Git host the service implements: `wire: 1`, `label`, `terminology`, `referencePrefix`, `repositoryPath`, `instances`, `capabilities`, `token`, `transport`, `limits`, `trackedItems`, `presentation`. Strict; URL templates use only `{owner}`, `{namespace+}`, `{repo}`, `{number}`. `panel.id` is at most 28 characters (the host id is `ext-<panel.id>`). Change-based hosts may add the `change` term, `capabilities.reviewModel` and `capabilities.revisions`, the `submit` merge method (alone), `presentation.features.submitRequirements`, and `token.scheme: "basic"` with `token.username: true`; older hosts refuse these, so set an `engines.openchamber` floor. Errors are `invalid-service`. See [GUEST_SERVICES.md](https://github.com/Shizuku-Yume/ohpichamber/blob/main/packages/sdk/GUEST_SERVICES.md#source-control-provider-provides-source-control) |
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
Extra keys are dropped, not forwarded.
|
|
561
|
+
|
|
562
|
+
#### Tool cards
|
|
563
|
+
|
|
564
|
+
`output: "card"` draws a tool's JSON output as a card, from the output alone: no extension code runs.
|
|
565
|
+
|
|
566
|
+
```json
|
|
567
|
+
{
|
|
568
|
+
"match": "jira_get_issue",
|
|
569
|
+
"name": "Jira issue",
|
|
570
|
+
"title": "{input.key}",
|
|
571
|
+
"output": "card",
|
|
572
|
+
"card": {
|
|
573
|
+
"label": "{output.key} · {output.fields.issuetype.name}",
|
|
574
|
+
"title": "{output.fields.summary}",
|
|
575
|
+
"status": { "value": "{output.fields.status.name}", "tones": { "In Progress": "info", "Blocked": "error", "Done": "success" } },
|
|
576
|
+
"fields": [
|
|
577
|
+
{ "label": "Assignee", "value": "{output.fields.assignee.displayName}" },
|
|
578
|
+
{ "label": "Priority", "value": "{output.fields.priority.name}" }
|
|
579
|
+
],
|
|
580
|
+
"link": { "label": "Open in Jira", "url": "{output.url}" }
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
| Part | Rules |
|
|
586
|
+
| ---- | ----- |
|
|
587
|
+
| `label`, `title` | Optional templates, 1–200 chars, at least one `{output.path}` placeholder; `{input.…}` and `{metadata.…}` are refused |
|
|
588
|
+
| `status` | Optional `{ value, tones? }`. `value` is a template like the above. `tones` maps up to 16 status texts (1–64 chars, matched exactly) to `"neutral"` \| `"info"` \| `"success"` \| `"warning"` \| `"error"`; a status without an entry is neutral |
|
|
589
|
+
| `fields` | Optional, 1–8 of `{ label, value }`: `label` plain text 1–40, `value` a template |
|
|
590
|
+
| `link` | Optional `{ label, url }`: `label` plain text 1–40. `url` is `{output.path}` alone (the output holds the address), or an `https://` address written around `{output.path}` placeholders, which may also read `{settings.<id>}`: a `contributes.integration.settings` field declared without `secret` |
|
|
591
|
+
|
|
592
|
+
At least one of `label`, `title`, `status`, `fields`. Unknown keys are refused. `card` without `output: "card"`, or the reverse, is `invalid-tools`, and the message names the place (`contributes.tools[0].card.link.url: …`).
|
|
593
|
+
|
|
594
|
+
- 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
|
+
- 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
|
+
- 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` ships in OhPiChamber 1.0.0, the fork's first release. An upstream host that predates it refuses the package with `invalid-tools`, whatever `engines.openchamber` says.
|
|
598
|
+
|
|
599
|
+
### 3.2 Parse / version helpers
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
| Export | Role |
|
|
603
|
+
| -------------------------------------------------- | --------------------------------------------------------- |
|
|
604
|
+
| `parseManifest(document)` (`ohpichamber-sdk/schemas`) | Typed document → success/failure (does not throw on junk) |
|
|
605
|
+
| `parseManifestJson(json)` (`ohpichamber-sdk/schemas`) | String → same result |
|
|
606
|
+
| `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' |
|
|
608
|
+
| `resolveAttachEntry(contributes)` | Dialog page from the object form, or `null` when the dialog reuses `panel.entry` |
|
|
609
|
+
| `hasGuestPage(contributes)` | `true` when `panel.entry` is set; background-only and tools-only packages return `false` |
|
|
610
|
+
| `resolveIntegrationAuth` / `resolveIntegrationApi` | Auth kind and API origin |
|
|
611
|
+
| `toPublicIntegration` / `toPublicService` | Catalog-safe public slices |
|
|
612
|
+
| `isGuestPackageSvgIcon` | Whether icon is a package SVG path |
|
|
613
|
+
| `compareOpenChamberVersions` | Semver compare |
|
|
614
|
+
| `hostMeetsOpenChamberEngine` | Host vs `engines.openchamber` floor |
|
|
615
|
+
| `openChamberEngineMinimum` | Normalize `>=1.0.0` → floor string |
|
|
616
|
+
| `parseOpenChamberVersion` | Parse `x.y.z` |
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
### 3.3 Protocol helpers (host + guest tooling)
|
|
620
|
+
|
|
621
|
+
|
|
622
|
+
| Export | Role |
|
|
623
|
+
| ----------------------------------------------------------------------------------------------------------------- | ---------------------------------- |
|
|
624
|
+
| `readHostMessage` (`ohpichamber-sdk`) | Guest-side read of a host push; no schema library |
|
|
625
|
+
| `parseHostMessage` / `parseGuestMessage` (`ohpichamber-sdk/schemas`) | Host-side typed parse |
|
|
626
|
+
| `hostMessageSchema` / `guestMessageSchema` (`ohpichamber-sdk/schemas`) | Zod schemas for `postMessage` data |
|
|
627
|
+
| `clampAttachRequest` / `clampStartSessionRequest` / `clampPromptRequest` | Enforce field max lengths |
|
|
628
|
+
| `isGuestRequestPath` / `isGuestRequestResult` / `isStartSessionResult` / `isPromptResult` / `isServiceStatusResult` | Narrow result payloads |
|
|
629
|
+
| `isGuestAttachItem` / `isGuestMessageItem` / `isGuestSessionItem` / `isGuestLinkItem` | Narrow `ready.item` |
|
|
630
|
+
| `clampBadgeCount` / `guestActionsNeedConversation` | Badge range; whether declared actions need `conversation` |
|
|
631
|
+
| `isHostRequestErrorCode` / `resolveHostRequestErrorCode` | Error code validation |
|
|
632
|
+
|
|
633
|
+
|
|
634
|
+
Constants: `OPENCHAMBER_SDK_CHANNEL`, `OPENCHAMBER_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
|
+
|
|
636
|
+
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
|
+
|
|
638
|
+
---
|
|
639
|
+
|
|
640
|
+
## 4. Local services (`contributes.service`)
|
|
641
|
+
|
|
642
|
+
For Docker sockets, CLI binaries, kubectl, and similar. The sandboxed iframe cannot dial Unix sockets; the host spawns a package entry and proxies HTTP.
|
|
643
|
+
|
|
644
|
+
Panel → `serviceRequest` → host → `127.0.0.1:port` → service process → socket/CLI.
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
| Panel call | Role |
|
|
648
|
+
| ----------------------------------------------- | -------------------------------- |
|
|
649
|
+
| `serviceRequest({ method, path, query?, body? })` | Proxy to this guest's service only |
|
|
650
|
+
| `serviceStatus()` | Lifecycle state |
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
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
|
+
|
|
655
|
+
A service with `provides: ["browser"]` answers the agent's `browser.*` actions at `POST /browser-control` instead of the desktop app's browser panel, once the user selects it in Settings → OhPiChamber Tools. The host starts it on the first action and stops it when idle. Parse the body with `readBrowserProviderRequest`; request and answer types (`BrowserProviderRequest`, `BrowserProviderResult`, per-action `Browser*Parameters` / `Browser*Data`) and the limits (`BROWSER_PROVIDER_*`) are exported from `ohpichamber-sdk`. Full contract in [GUEST_SERVICES.md](https://github.com/Shizuku-Yume/ohpichamber/blob/main/packages/sdk/GUEST_SERVICES.md#browser-provider-provides-browser).
|
|
656
|
+
|
|
657
|
+
A service with `provides: ["source-control"]` is a Git host next to GitHub, GitLab, Gitea and Gerrit, described by `contributes.sourceControl`. OhPiChamber keeps the accounts and tokens and forwards reads and mutation steps to `POST /source-control` (`SOURCE_CONTROL_PROVIDER_PATH`); parse the body with `readSourceControlProviderRequest` and answer `{ ok, data }` or `{ ok: false, error }` (`SourceControlProviderResult`). The service reaches the forge only through `createSourceControlForge({ env: process.env }).request(handle, request)`, which goes through OhPiChamber's outbound proxy (`OPENCHAMBER_HOST_CALLBACK_URL`); OhPiChamber adds the token and keeps the request on the instance. Methods (`SOURCE_CONTROL_PROVIDER_METHODS`), inputs (`SourceControlProviderInputs`), deadlines (`sourceControlProviderTimeoutMs`) and caps (`SOURCE_CONTROL_*`) are exported from `ohpichamber-sdk`; the host's answer schemas are `sourceControlProviderSchemasV1` in `ohpichamber-sdk/schemas`. Full contract in [GUEST_SERVICES.md](https://github.com/Shizuku-Yume/ohpichamber/blob/main/packages/sdk/GUEST_SERVICES.md#source-control-provider-provides-source-control); reference: `examples/source-control-provider`.
|
|
658
|
+
|
|
659
|
+
A service with `provides: ["notifications"]` delivers the user's notifications next to the desktop and the phone, described by `contributes.notifications`. OhPiChamber keeps the account the user connects in Settings → Integrations and forwards three calls to `POST /notifications` (`NOTIFICATIONS_PROVIDER_PATH`): `auth.probe`, `auth.verify` and `notify` (`NOTIFICATIONS_PROVIDER_METHODS`, deadlines in `notificationsProviderTimeoutMs`); parse the body with `readNotificationsProviderRequest` and answer `{ ok, data }` or `{ ok: false, error }` (`NotificationsProviderResult`). The service reaches the channel's server only through `createNotificationsOutbound({ env: process.env }).request(handle, request)`, which goes through OhPiChamber's outbound proxy; OhPiChamber adds the token and keeps the request on the account's origin. The notification shape is `GuestNotification`, its kinds `GUEST_NOTIFICATION_KINDS`; the host's answer schemas are `notificationsProviderSchemasV1` in `ohpichamber-sdk/schemas`. Full contract in [GUEST_SERVICES.md](https://github.com/Shizuku-Yume/ohpichamber/blob/main/packages/sdk/GUEST_SERVICES.md#notification-channel-provides-notifications); reference: `examples/notification-webhook`.
|
|
660
|
+
|
|
661
|
+
A service with `provides: ["tracker"]` is a work item tracker next to Linear, described by `contributes.tracker`. OhPiChamber keeps the accounts the user connects on the tracker's card under Extension accounts in Settings → Integrations (a pasted token, or a browser sign-in it runs itself with the client the user enters) and forwards nine calls to `POST /tracker` (`TRACKER_PROVIDER_PATH`): `auth.probe`, `auth.verify`, `items.list`, `items.get`, `items.updateState`, `items.liveSummaries`, `states.list`, `containers.list` and `comments.create` (`TRACKER_PROVIDER_METHODS`, deadlines in `trackerProviderTimeoutMs`); parse the body with `readTrackerProviderRequest` and answer `{ ok, data }` in the neutral item shapes (`TrackerProviderItemSummary`, `TrackerProviderItem`) or `{ ok: false, error }` (`TrackerProviderResult`). A query that is a link your templates claim, or an identifier of your declared shape, is read through `items.get` first; a bare word `items.get` answers null for reaches `items.list` as a search after all. The service reaches the tracker's server only through `createTrackerOutbound({ env: process.env }).request(handle, request)`, which goes through OhPiChamber's outbound proxy; OhPiChamber adds the credential and keeps the request on the account's origin, and a read's handle sends `GET` only (`isTrackerProviderWriteMethod`). The host's answer schemas are `trackerProviderSchemasV1` in `ohpichamber-sdk/schemas`. Full contract in [GUEST_SERVICES.md](https://github.com/Shizuku-Yume/ohpichamber/blob/main/packages/sdk/GUEST_SERVICES.md#tracker-provides-tracker); reference: `examples/tracker-provider`.
|
|
662
|
+
|
|
663
|
+
A service with `provides: ["quota"]` is a usage provider next to the built-in ones, described by `contributes.quota`. OhPiChamber lists it from the manifest, asks it for usage the way it asks a built-in, one `usage.read` per refresh at `POST /quota` (`QUOTA_PROVIDER_PATH`, deadline `QUOTA_PROVIDER_TIMEOUT_MS`), with `input.credentials` holding the credential OMP stores for each listed provider (`QuotaProviderCredential`) and nothing else; parse the body with `readQuotaProviderRequest` and answer `{ ok, data }` with the result a built-in computes (`QuotaProviderUsageData`: `ok`, `configured`, `error`, `planLabel`, `usage.windows` and `usage.models` of `QuotaProviderWindow`) or `{ ok: false, error }` (`QuotaProviderResult`). OhPiChamber derives the remaining share and the formatted strings itself. The host's answer schema is `quotaProviderSchemasV1` in `ohpichamber-sdk/schemas`. Full contract in [GUEST_SERVICES.md](https://github.com/Shizuku-Yume/ohpichamber/blob/main/packages/sdk/GUEST_SERVICES.md#usage-provider-provides-quota); reference: `examples/quota-provider`.
|
|
664
|
+
|
|
665
|
+
A service calls OhPiChamber on its own through `createServiceHost({ env: process.env })`: `sessions.start`, `sessions.send`, `sessions.retry`, `sessions.status`, `sessions.lastReply`, `sessions.stop`, and with `sessionControl: { answers: true }` `sessions.answerPermission` and `sessions.answerForm`, which answer the agent's requests for the user; `setInstructions`, `emit`, `readSettings`, `needsConfiguration`, and with `contributes.marks` `setMark`, which puts an icon with a tooltip on the sidebar rows of a session, a branch or a folder (`ServiceMark`, `ServiceMarkTarget`, limits in the `SERVICE_MARK*` constants). `service.keepRunning` keeps it up with nobody asking, and `service.schedule` wakes it on a clock at `POST /schedule`; parse the body with `readServiceScheduleRequest`. `contributes.mentions` adds its rows to the composer's `@` menu through `MENTIONS_SEARCH_PATH` and `MENTIONS_RESOLVE_PATH`. Full contract in [GUEST_SERVICES.md](https://github.com/openchamber/openchamber/blob/main/packages/sdk/GUEST_SERVICES.md#calling-openchamber).
|
|
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).
|
|
670
|
+
|
|
671
|
+
Bundle the service with the Node target:
|
|
672
|
+
|
|
673
|
+
```bash
|
|
674
|
+
bunx openchamber-guest-bundle --node service/main.ts service/main.js
|
|
675
|
+
```
|
|
676
|
+
|
|
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
|
+
---
|
|
680
|
+
|
|
681
|
+
## 5. What this package does not provide
|
|
682
|
+
|
|
683
|
+
Frozen on `apiVersion` 1 — named in docs, no host hole yet:
|
|
684
|
+
|
|
685
|
+
- Host-side `issues.search` / `issues.get` (guest draws the list; chip is `attach`)
|
|
686
|
+
- Public OAuth broker
|
|
687
|
+
- Keyboard shortcuts for commands, raw git remotes, magic prompts
|
|
688
|
+
- Second `host.provider` beyond Linear
|
|
689
|
+
- Arbitrary filesystem access from the page (only the open project with `files`, or declared `contributes.filesystem` globs), terminal, pairing, or host React components. A declared `service` is outside these limits: it is a process with the user's rights and no sandbox
|
|
690
|
+
- Network access from the page. Pages run under a Content Security Policy: scripts, styles, images, fonts, media and workers come from the package itself or `data:`/`blob:`, and `fetch` reaches only the package's own files. Ship fonts and images inside the package. To talk to an outside service, use `request` (the integration's `apiOrigin`) or declare up to 8 https origins in `contributes.origins`, for example `"origins": ["https://fonts.example.com"]`. The user approves that list at install, and again when an update adds to it. Approved origins are open to `fetch`, images, fonts, styles and media, never to scripts or workers. A `fetch` whose response you read also needs that server to allow CORS for the `null` origin, since the page's origin is opaque
|
|
691
|
+
|
|
692
|
+
A self-navigation is refused by Electron's main-process guard when the destination falls outside that window's allowed app origins. Web/PWA has no equivalent navigation hook. Do not use guest navigation to transfer data or assume the browser host blocks it.
|
|
693
|
+
|
|
694
|
+
Do not go around the guest contract through `RuntimeAPIs`.
|
|
695
|
+
|
|
696
|
+
---
|
|
697
|
+
|
|
698
|
+
## 6. Minimal panel sketch
|
|
699
|
+
|
|
700
|
+
Mount once and keep the handles. `onReady` can repeat when the session or theme changes. Field listeners replay their current values too; compare relevant fields before fetching data again. For a complete request example with stale-response handling, see [the extension example](https://github.com/Shizuku-Yume/ohpichamber/tree/main/packages/sdk).
|
|
701
|
+
|
|
702
|
+
```ts
|
|
703
|
+
import { connectHost } from 'ohpichamber-sdk';
|
|
704
|
+
import { applyHostReady, mountList, mountEmpty } from 'ohpichamber-sdk/ui';
|
|
705
|
+
|
|
706
|
+
const host = connectHost();
|
|
707
|
+
const root = document.querySelector('#root')!;
|
|
708
|
+
|
|
709
|
+
let mounted = false;
|
|
710
|
+
host.onReady((ctx) => {
|
|
711
|
+
applyHostReady(ctx, document.documentElement);
|
|
712
|
+
if (mounted) return;
|
|
713
|
+
mounted = true;
|
|
714
|
+
|
|
715
|
+
const signInRoot = root.appendChild(document.createElement('div'));
|
|
716
|
+
const listRoot = root.appendChild(document.createElement('div'));
|
|
717
|
+
mountEmpty(signInRoot, {
|
|
718
|
+
title: 'Connect Acme',
|
|
719
|
+
action: { label: 'Sign in', onClick: () => { void host.oauthStart(); } },
|
|
720
|
+
});
|
|
721
|
+
|
|
722
|
+
mountList(listRoot, {
|
|
723
|
+
items: [], // fill from host.request
|
|
724
|
+
onSelect: (id) => {
|
|
725
|
+
void host.attach({
|
|
726
|
+
providerId: 'acme-hello',
|
|
727
|
+
id,
|
|
728
|
+
title: id,
|
|
729
|
+
url: '',
|
|
730
|
+
});
|
|
731
|
+
},
|
|
732
|
+
});
|
|
733
|
+
host.onConnection((connection) => {
|
|
734
|
+
signInRoot.hidden = connection.connected;
|
|
735
|
+
listRoot.hidden = !connection.connected;
|
|
736
|
+
});
|
|
737
|
+
});
|
|
738
|
+
```
|
|
739
|
+
|
|
740
|
+
---
|
|
741
|
+
|
|
742
|
+
## Related files
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
| File | Audience |
|
|
746
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- |
|
|
747
|
+
| [README.md](https://github.com/Shizuku-Yume/ohpichamber/blob/main/packages/sdk/README.md) | Package overview and first hole |
|
|
748
|
+
| [DOCUMENTATION.md](https://github.com/Shizuku-Yume/ohpichamber/blob/main/packages/sdk/DOCUMENTATION.md) | Agent / maintainer invariants |
|
|
749
|
+
| [GUEST_SERVICES.md](https://github.com/Shizuku-Yume/ohpichamber/blob/main/packages/sdk/GUEST_SERVICES.md) | Local service contract |
|
|
750
|
+
| [src/ui/DOCUMENTATION.md](https://github.com/Shizuku-Yume/ohpichamber/blob/main/packages/sdk/src/ui/DOCUMENTATION.md) | UI kit invariants |
|
|
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 |
|