@openchamber/sdk 1.23.2-preview.1
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 +529 -0
- package/DOCUMENTATION.md +81 -0
- package/GUEST_SERVICES.md +166 -0
- package/LICENSE +21 -0
- package/README.md +186 -0
- package/dist/api-version.d.ts +6 -0
- package/dist/api-version.js +5 -0
- package/dist/contract.d.ts +471 -0
- package/dist/contract.js +256 -0
- package/dist/host-version.d.ts +16 -0
- package/dist/host-version.js +50 -0
- package/dist/host.d.ts +101 -0
- package/dist/host.js +606 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +7 -0
- package/dist/manifest.d.ts +298 -0
- package/dist/manifest.js +224 -0
- package/dist/parse.d.ts +279 -0
- package/dist/parse.js +379 -0
- package/dist/protocol.d.ts +1092 -0
- package/dist/protocol.js +450 -0
- package/dist/schemas.d.ts +4 -0
- package/dist/schemas.js +6 -0
- package/dist/ui/badge.d.ts +10 -0
- package/dist/ui/badge.js +26 -0
- package/dist/ui/banner.d.ts +13 -0
- package/dist/ui/banner.js +48 -0
- package/dist/ui/button.d.ts +14 -0
- package/dist/ui/button.js +49 -0
- package/dist/ui/checkbox.d.ts +12 -0
- package/dist/ui/checkbox.js +45 -0
- package/dist/ui/dom.d.ts +15 -0
- package/dist/ui/dom.js +60 -0
- package/dist/ui/empty.d.ts +11 -0
- package/dist/ui/empty.js +44 -0
- package/dist/ui/field.d.ts +18 -0
- package/dist/ui/field.js +49 -0
- package/dist/ui/icons.d.ts +10 -0
- package/dist/ui/icons.js +23 -0
- package/dist/ui/index.d.ts +35 -0
- package/dist/ui/index.js +17 -0
- package/dist/ui/list.d.ts +26 -0
- package/dist/ui/list.js +90 -0
- package/dist/ui/menu.d.ts +20 -0
- package/dist/ui/menu.js +111 -0
- package/dist/ui/navigation.d.ts +18 -0
- package/dist/ui/navigation.js +38 -0
- package/dist/ui/option.d.ts +16 -0
- package/dist/ui/option.js +35 -0
- package/dist/ui/popup.d.ts +5 -0
- package/dist/ui/popup.js +43 -0
- package/dist/ui/progress.d.ts +11 -0
- package/dist/ui/progress.js +44 -0
- package/dist/ui/search.d.ts +11 -0
- package/dist/ui/search.js +62 -0
- package/dist/ui/select.d.ts +22 -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 +8 -0
- package/dist/ui/spinner.js +29 -0
- package/dist/ui/style.d.ts +1 -0
- package/dist/ui/style.js +190 -0
- package/dist/ui/tabs.d.ts +15 -0
- package/dist/ui/tabs.js +61 -0
- package/dist/ui/text.d.ts +23 -0
- package/dist/ui/text.js +89 -0
- package/dist/ui/theme.d.ts +22 -0
- package/dist/ui/theme.js +69 -0
- package/dist/workspace-schemas.d.ts +136 -0
- package/dist/workspace-schemas.js +44 -0
- package/dist/workspace.d.ts +109 -0
- package/dist/workspace.js +4 -0
- package/package.json +55 -0
- package/scripts/bundle-guest.ts +44 -0
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
import { OPENCHAMBER_SDK_API_VERSION, OPENCHAMBER_SDK_CHANNEL } from './api-version.ts';
|
|
2
|
+
import type { GuestSessionWorktree, GuestStorageRequest, GuestStorageResult, GuestWorkspaceQuery, GuestWorkspaceSnapshot, GuestWorkspaceSubscription, GuestWorkspaceUpdate, GuestWorktree } from './workspace.ts';
|
|
3
|
+
export type HostThemeMode = 'light' | 'dark';
|
|
4
|
+
export type HostThemeTokens = {
|
|
5
|
+
background: string;
|
|
6
|
+
elevated: string;
|
|
7
|
+
foreground: string;
|
|
8
|
+
muted: string;
|
|
9
|
+
subtle: string;
|
|
10
|
+
border: string;
|
|
11
|
+
hover: string;
|
|
12
|
+
selection: string;
|
|
13
|
+
focus: string;
|
|
14
|
+
primary: string;
|
|
15
|
+
/** Secondary surface (sidebars, muted rows). */
|
|
16
|
+
mutedSurface: string;
|
|
17
|
+
/** Text on `elevated`. */
|
|
18
|
+
elevatedForeground: string;
|
|
19
|
+
/** Pressed state of a clickable. */
|
|
20
|
+
active: string;
|
|
21
|
+
/** Text on `selection`. */
|
|
22
|
+
selectionForeground: string;
|
|
23
|
+
/** Text on `primary`. */
|
|
24
|
+
primaryForeground: string;
|
|
25
|
+
success: string;
|
|
26
|
+
warning: string;
|
|
27
|
+
error: string;
|
|
28
|
+
info: string;
|
|
29
|
+
font: string;
|
|
30
|
+
/** Monospace stack for code and identifiers. */
|
|
31
|
+
mono: string;
|
|
32
|
+
radius: string;
|
|
33
|
+
};
|
|
34
|
+
export type HostTheme = {
|
|
35
|
+
mode: HostThemeMode;
|
|
36
|
+
tokens: HostThemeTokens;
|
|
37
|
+
};
|
|
38
|
+
export declare const START_SESSION_SENT: readonly ["sent", "no-model", "skipped", "failed"];
|
|
39
|
+
export type StartSessionSent = (typeof START_SESSION_SENT)[number];
|
|
40
|
+
export type SessionSnapshot = {
|
|
41
|
+
id: string;
|
|
42
|
+
title: string;
|
|
43
|
+
busy: boolean;
|
|
44
|
+
model?: string;
|
|
45
|
+
agent?: string;
|
|
46
|
+
};
|
|
47
|
+
/** Which host chrome mounted this iframe. Not `openSurface`. */
|
|
48
|
+
export type GuestHostSurface = 'panel' | 'dialog' | 'page';
|
|
49
|
+
export type GuestConnection = {
|
|
50
|
+
connected: boolean;
|
|
51
|
+
account: string;
|
|
52
|
+
};
|
|
53
|
+
export type GuestSettings = Record<string, string>;
|
|
54
|
+
export type GuestRequestMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
55
|
+
export type GuestRequest = {
|
|
56
|
+
method: GuestRequestMethod;
|
|
57
|
+
path: string;
|
|
58
|
+
query?: Record<string, string>;
|
|
59
|
+
body?: string;
|
|
60
|
+
};
|
|
61
|
+
export type GuestRequestResult = {
|
|
62
|
+
status: number;
|
|
63
|
+
body: string;
|
|
64
|
+
};
|
|
65
|
+
export type StartSessionResult = {
|
|
66
|
+
sessionId: string;
|
|
67
|
+
sent: StartSessionSent;
|
|
68
|
+
directory?: string;
|
|
69
|
+
worktree?: GuestWorktree;
|
|
70
|
+
linked?: boolean;
|
|
71
|
+
} | {
|
|
72
|
+
sessionId: null;
|
|
73
|
+
sent: 'skipped';
|
|
74
|
+
directory: string;
|
|
75
|
+
worktree: GuestWorktree;
|
|
76
|
+
failure: 'bootstrap-failed' | 'session-create-failed';
|
|
77
|
+
};
|
|
78
|
+
export type PromptRequest = {
|
|
79
|
+
text: string;
|
|
80
|
+
send?: boolean;
|
|
81
|
+
};
|
|
82
|
+
export type PromptResult = {
|
|
83
|
+
sent: StartSessionSent;
|
|
84
|
+
};
|
|
85
|
+
export declare const SESSION_LIFECYCLE_PHASES: readonly ["started", "completed", "failure"];
|
|
86
|
+
export type SessionLifecyclePhase = (typeof SESSION_LIFECYCLE_PHASES)[number];
|
|
87
|
+
export type SessionLifecycleEvent = {
|
|
88
|
+
sessionId: string;
|
|
89
|
+
phase: SessionLifecyclePhase;
|
|
90
|
+
};
|
|
91
|
+
export declare const GUEST_FILE_ENTRY_KINDS: readonly ["file", "directory", "other"];
|
|
92
|
+
/** What a directory entry or an existing path is. */
|
|
93
|
+
export type GuestFileEntryKind = (typeof GUEST_FILE_ENTRY_KINDS)[number];
|
|
94
|
+
export declare const GUEST_FILE_STAT_KINDS: readonly ["file", "directory", "other", "missing"];
|
|
95
|
+
/** `stat` answer: an entry kind, or `missing` when nothing is at that path. */
|
|
96
|
+
export type GuestFileStatKind = (typeof GUEST_FILE_STAT_KINDS)[number];
|
|
97
|
+
/**
|
|
98
|
+
* Where a guest file path points. A relative path is inside the open project
|
|
99
|
+
* (capability `files`). A path starting with `/` or `~/` is outside it and
|
|
100
|
+
* must match one of the manifest's `contributes.filesystem` patterns
|
|
101
|
+
* (capability `filesystem`).
|
|
102
|
+
*/
|
|
103
|
+
export type GuestFileScope = 'project' | 'filesystem';
|
|
104
|
+
export type FileReadRequest = {
|
|
105
|
+
path: string;
|
|
106
|
+
};
|
|
107
|
+
export type FileWriteRequest = {
|
|
108
|
+
path: string;
|
|
109
|
+
content: string;
|
|
110
|
+
};
|
|
111
|
+
export type FileListRequest = {
|
|
112
|
+
path: string;
|
|
113
|
+
};
|
|
114
|
+
export type FileStatRequest = {
|
|
115
|
+
path: string;
|
|
116
|
+
};
|
|
117
|
+
export type FileReadResult = {
|
|
118
|
+
content: string;
|
|
119
|
+
};
|
|
120
|
+
export type FileWriteResult = {
|
|
121
|
+
written: true;
|
|
122
|
+
};
|
|
123
|
+
export type FileListEntry = {
|
|
124
|
+
name: string;
|
|
125
|
+
kind: GuestFileEntryKind;
|
|
126
|
+
};
|
|
127
|
+
export type FileListResult = {
|
|
128
|
+
entries: FileListEntry[];
|
|
129
|
+
};
|
|
130
|
+
export type FileStatResult = {
|
|
131
|
+
kind: GuestFileStatKind;
|
|
132
|
+
size: number;
|
|
133
|
+
mtime: number;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* One-off text generation with the user's Small Model (capability `model`).
|
|
137
|
+
* No session, no history, no tools: `prompt` in, `text` out. The app picks
|
|
138
|
+
* the model the same way it does for its own background actions.
|
|
139
|
+
*/
|
|
140
|
+
export type GenerateRequest = {
|
|
141
|
+
prompt: string;
|
|
142
|
+
system?: string;
|
|
143
|
+
/** Upper bound on the answer, 1 to `GUEST_GENERATE_OUTPUT_TOKENS_MAX`. */
|
|
144
|
+
maxOutputTokens?: number;
|
|
145
|
+
};
|
|
146
|
+
export type GenerateResult = {
|
|
147
|
+
text: string;
|
|
148
|
+
};
|
|
149
|
+
export type HostResultPayload = GuestStorageResult | GuestWorkspaceSnapshot | GuestRequestResult | StartSessionResult | PromptResult | ServiceStatusResult | FileReadResult | FileWriteResult | FileListResult | FileStatResult | GenerateResult;
|
|
150
|
+
export declare const isStartSessionResult: (value: HostResultPayload | undefined) => value is StartSessionResult;
|
|
151
|
+
export declare const isPromptResult: (value: HostResultPayload | undefined) => value is PromptResult;
|
|
152
|
+
export declare const EMPTY_GUEST_CONNECTION: GuestConnection;
|
|
153
|
+
export type HostReadyContext = {
|
|
154
|
+
theme: HostTheme;
|
|
155
|
+
locale: string;
|
|
156
|
+
directory: string | null;
|
|
157
|
+
session: SessionSnapshot | null;
|
|
158
|
+
surface: GuestHostSurface;
|
|
159
|
+
connection: GuestConnection;
|
|
160
|
+
settings: GuestSettings;
|
|
161
|
+
/**
|
|
162
|
+
* The item this surface was opened for: the chip the user clicked on the
|
|
163
|
+
* composer (`AttachIssueRequest`), or the message / session a declared
|
|
164
|
+
* action ran on (`GuestMessageItem` / `GuestSessionItem`). `null` when
|
|
165
|
+
* opened from the rail icon or the composer + menu.
|
|
166
|
+
*/
|
|
167
|
+
item: GuestItem | null;
|
|
168
|
+
};
|
|
169
|
+
export type GuestItemRole = 'user' | 'assistant';
|
|
170
|
+
/** A `contributes.actions` entry with `where: "message"` ran on this message. */
|
|
171
|
+
export type GuestMessageItem = {
|
|
172
|
+
kind: 'message';
|
|
173
|
+
/** The action id from the manifest. */
|
|
174
|
+
action: string;
|
|
175
|
+
sessionId: string;
|
|
176
|
+
sessionTitle: string;
|
|
177
|
+
/** The session's project directory, or `null` for a session without one. */
|
|
178
|
+
directory: string | null;
|
|
179
|
+
messageId: string;
|
|
180
|
+
role: GuestItemRole;
|
|
181
|
+
/** Message text as the Markdown export renders it, capped at `GUEST_ITEM_MESSAGE_TEXT_MAX`. */
|
|
182
|
+
text: string;
|
|
183
|
+
};
|
|
184
|
+
export type GuestSessionItemMessage = {
|
|
185
|
+
id: string;
|
|
186
|
+
role: GuestItemRole;
|
|
187
|
+
text: string;
|
|
188
|
+
createdAt: number;
|
|
189
|
+
};
|
|
190
|
+
/** A `contributes.actions` entry with `where: "session"` ran on this session. */
|
|
191
|
+
export type GuestSessionItem = {
|
|
192
|
+
kind: 'session';
|
|
193
|
+
/** The action id from the manifest. */
|
|
194
|
+
action: string;
|
|
195
|
+
sessionId: string;
|
|
196
|
+
sessionTitle: string;
|
|
197
|
+
/** The session's project directory, or `null` for a session without one. */
|
|
198
|
+
directory: string | null;
|
|
199
|
+
/** Present only when the action declared `payload: ["messages"]` and the user granted `conversation`. Oldest first. */
|
|
200
|
+
messages?: GuestSessionItemMessage[];
|
|
201
|
+
/** Set when the oldest messages were dropped to stay within `GUEST_ITEM_SESSION_MAX`. */
|
|
202
|
+
truncated?: boolean;
|
|
203
|
+
};
|
|
204
|
+
export type GuestItem = AttachIssueRequest | GuestMessageItem | GuestSessionItem;
|
|
205
|
+
export declare const isGuestMessageItem: (item: GuestItem | null) => item is GuestMessageItem;
|
|
206
|
+
export declare const isGuestSessionItem: (item: GuestItem | null) => item is GuestSessionItem;
|
|
207
|
+
/** The composer chip: what the guest handed to `attach`, with `text` filled from the chip. */
|
|
208
|
+
export declare const isGuestAttachItem: (item: GuestItem | null) => item is AttachIssueRequest;
|
|
209
|
+
/** What the host asks a guest that declared `contributes.commands` when the user submits `/name args`. */
|
|
210
|
+
export type ResolveRequest = {
|
|
211
|
+
command: string;
|
|
212
|
+
args: string;
|
|
213
|
+
};
|
|
214
|
+
/** The guest's answer to `resolve`: the chip to attach, `null` for nothing, or why it failed. */
|
|
215
|
+
export type ResolveResultPayload = {
|
|
216
|
+
item: AttachIssueRequest | null;
|
|
217
|
+
} | {
|
|
218
|
+
error: string;
|
|
219
|
+
};
|
|
220
|
+
export type BadgeRequest = {
|
|
221
|
+
/** 0 to `GUEST_BADGE_MAX`; `null` clears the badge. */
|
|
222
|
+
count: number | null;
|
|
223
|
+
};
|
|
224
|
+
export type ToastKind = 'info' | 'success' | 'error';
|
|
225
|
+
export type ToastRequest = {
|
|
226
|
+
kind: ToastKind;
|
|
227
|
+
message: string;
|
|
228
|
+
};
|
|
229
|
+
export type ComposeRequest = {
|
|
230
|
+
text: string;
|
|
231
|
+
mode?: 'replace' | 'append';
|
|
232
|
+
};
|
|
233
|
+
export type AttachThreadKind = 'issue' | 'pull';
|
|
234
|
+
export type AttachBranches = {
|
|
235
|
+
head: string;
|
|
236
|
+
base: string;
|
|
237
|
+
};
|
|
238
|
+
/** Plain JSON: what survives `JSON.stringify` / `JSON.parse` unchanged. */
|
|
239
|
+
export type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
240
|
+
[key: string]: JsonValue;
|
|
241
|
+
};
|
|
242
|
+
export type AttachIssueRequest = {
|
|
243
|
+
providerId: string;
|
|
244
|
+
id: string;
|
|
245
|
+
title: string;
|
|
246
|
+
url: string;
|
|
247
|
+
text?: string;
|
|
248
|
+
kind?: AttachThreadKind;
|
|
249
|
+
author?: string;
|
|
250
|
+
branches?: AttachBranches;
|
|
251
|
+
/**
|
|
252
|
+
* Opaque payload the guest chose. The host stores it with the chip and the
|
|
253
|
+
* session snapshot and hands it back unchanged as `ready.item.data`; it
|
|
254
|
+
* never reaches the model or the chip text. Serialized size is capped at
|
|
255
|
+
* `GUEST_ATTACH_DATA_MAX`; `clampAttachRequest` drops a larger value.
|
|
256
|
+
*/
|
|
257
|
+
data?: JsonValue;
|
|
258
|
+
};
|
|
259
|
+
export type StartSessionRequest = AttachIssueRequest & {
|
|
260
|
+
projectId?: string;
|
|
261
|
+
worktree?: GuestSessionWorktree;
|
|
262
|
+
/** Preserve the current page/chat by default. */
|
|
263
|
+
navigation?: 'preserve' | 'open';
|
|
264
|
+
};
|
|
265
|
+
export declare const GUEST_TOAST_MAX = 500;
|
|
266
|
+
export declare const GUEST_CLIPBOARD_TEXT_MAX = 32000;
|
|
267
|
+
export declare const GUEST_COMPOSE_TEXT_MAX = 16000;
|
|
268
|
+
export declare const GUEST_ATTACH_ID_MAX = 128;
|
|
269
|
+
export declare const GUEST_ATTACH_TITLE_MAX = 200;
|
|
270
|
+
export declare const GUEST_ATTACH_URL_MAX = 2000;
|
|
271
|
+
export declare const GUEST_ATTACH_TEXT_MAX = 16000;
|
|
272
|
+
export declare const GUEST_ATTACH_AUTHOR_MAX = 80;
|
|
273
|
+
export declare const GUEST_ATTACH_BRANCH_MAX = 200;
|
|
274
|
+
/** `JSON.stringify(data).length` ceiling for `AttachIssueRequest.data`. */
|
|
275
|
+
export declare const GUEST_ATTACH_DATA_MAX = 16000;
|
|
276
|
+
export declare const GUEST_ACCOUNT_MAX = 200;
|
|
277
|
+
export declare const GUEST_SESSION_MODEL_MAX = 200;
|
|
278
|
+
export declare const GUEST_SESSION_AGENT_MAX = 80;
|
|
279
|
+
export declare const GUEST_SETTING_VALUE_MAX = 2000;
|
|
280
|
+
export declare const GUEST_REQUEST_PATH_MAX = 2000;
|
|
281
|
+
export declare const GUEST_REQUEST_BODY_MAX = 64000;
|
|
282
|
+
export declare const GUEST_REQUEST_RESPONSE_MAX = 256000;
|
|
283
|
+
export declare const GUEST_REQUEST_TIMEOUT_MS = 20000;
|
|
284
|
+
/** Guest file path, in characters. */
|
|
285
|
+
export declare const GUEST_FILE_PATH_MAX = 1024;
|
|
286
|
+
/** File content in characters, read and write alike. */
|
|
287
|
+
export declare const GUEST_FILE_CONTENT_MAX = 2000000;
|
|
288
|
+
/** Entries a `listDir` answer carries; longer directories are truncated. */
|
|
289
|
+
export declare const GUEST_FILE_LIST_MAX = 2000;
|
|
290
|
+
/** Characters in a `generate` prompt. */
|
|
291
|
+
export declare const GUEST_GENERATE_PROMPT_MAX = 64000;
|
|
292
|
+
/** Characters in a `generate` system prompt. */
|
|
293
|
+
export declare const GUEST_GENERATE_SYSTEM_MAX = 8000;
|
|
294
|
+
/** Largest `maxOutputTokens` a guest may ask for. */
|
|
295
|
+
export declare const GUEST_GENERATE_OUTPUT_TOKENS_MAX = 4000;
|
|
296
|
+
/** Characters in a `generate` answer. */
|
|
297
|
+
export declare const GUEST_GENERATE_TEXT_MAX = 256000;
|
|
298
|
+
/** How long `generate` waits for the model before `HOST_TIMEOUT`. */
|
|
299
|
+
export declare const GUEST_GENERATE_TIMEOUT_MS = 90000;
|
|
300
|
+
/** Characters of one message's text on a `GuestMessageItem` or a `GuestSessionItem` message. */
|
|
301
|
+
export declare const GUEST_ITEM_MESSAGE_TEXT_MAX = 200000;
|
|
302
|
+
/** `JSON.stringify` length ceiling for a `GuestSessionItem`; the host drops the oldest messages to stay under it. */
|
|
303
|
+
export declare const GUEST_ITEM_SESSION_MAX = 2000000;
|
|
304
|
+
/** Largest count a rail badge shows. */
|
|
305
|
+
export declare const GUEST_BADGE_MAX = 999;
|
|
306
|
+
/** Characters in a `resolve-result` error string. */
|
|
307
|
+
export declare const GUEST_RESOLVE_ERROR_MAX = 500;
|
|
308
|
+
export declare const HOST_REQUEST_ERROR_CODES: readonly ["HOST_UNAVAILABLE", "HOST_TIMEOUT", "HOST_REJECTED", "DISCONNECTED", "DISABLED", "BAD_PATH", "NO_INTEGRATION", "NO_SERVICE", "SERVICE_FAILED", "NO_SESSION", "SESSION_BUSY", "NOT_GRANTED", "NO_DIRECTORY", "NOT_FOUND", "FILE_TOO_LARGE", "DENIED", "NO_MODEL", "MODEL_FAILED"];
|
|
309
|
+
export declare const SERVICE_STATUS_VALUES: readonly ["stopped", "starting", "ready", "failed"];
|
|
310
|
+
export type ServiceStatus = (typeof SERVICE_STATUS_VALUES)[number];
|
|
311
|
+
export type ServiceStatusResult = {
|
|
312
|
+
status: ServiceStatus;
|
|
313
|
+
};
|
|
314
|
+
export type HostRequestErrorCode = (typeof HOST_REQUEST_ERROR_CODES)[number];
|
|
315
|
+
export declare const isHostRequestErrorCode: (value: string) => value is HostRequestErrorCode;
|
|
316
|
+
/** Unknown or omitted wire codes become HOST_REJECTED. */
|
|
317
|
+
export declare const resolveHostRequestErrorCode: (value: string | undefined) => HostRequestErrorCode;
|
|
318
|
+
export declare const isJsonValue: (value: JsonValue | undefined) => value is JsonValue;
|
|
319
|
+
/** Whether `data` is plain JSON that serializes within `GUEST_ATTACH_DATA_MAX`. */
|
|
320
|
+
export declare const isAttachData: (value: JsonValue | undefined) => value is JsonValue;
|
|
321
|
+
/** Guest attach is dropped by the host schema if these limits overflow. */
|
|
322
|
+
export declare const clampAttachRequest: (request: AttachIssueRequest) => AttachIssueRequest;
|
|
323
|
+
/** Same attach clamp. `worktree` stays only when the guest asked for one. */
|
|
324
|
+
export declare const clampStartSessionRequest: (request: StartSessionRequest) => StartSessionRequest;
|
|
325
|
+
/** Prompt text uses the compose limit. `send` stays only when the guest asked. */
|
|
326
|
+
export declare const clampPromptRequest: (request: PromptRequest) => PromptRequest;
|
|
327
|
+
/** Badge counts are whole numbers from 0 to `GUEST_BADGE_MAX`; anything else clears. */
|
|
328
|
+
export declare const clampBadgeCount: (count: number | null) => number | null;
|
|
329
|
+
/**
|
|
330
|
+
* Which grant a file path needs. `/…` and `~/…` are outside the project and
|
|
331
|
+
* go through the declared `filesystem` patterns; anything else is joined to
|
|
332
|
+
* the open project directory.
|
|
333
|
+
*/
|
|
334
|
+
export declare const guestFileScope: (path: string) => GuestFileScope;
|
|
335
|
+
/**
|
|
336
|
+
* What the host schema accepts as a file path. Semantics (`..`, symlinks,
|
|
337
|
+
* declared patterns) are the server's call and come back as `BAD_PATH`; this
|
|
338
|
+
* only keeps a message from being dropped unanswered.
|
|
339
|
+
*/
|
|
340
|
+
export declare const isGuestFilePath: (value: string) => boolean;
|
|
341
|
+
export declare const ATTACH_PROVIDER_ID: RegExp;
|
|
342
|
+
export declare const SETTING_KEY: RegExp;
|
|
343
|
+
export declare const isGuestRequestPath: (value: string) => boolean;
|
|
344
|
+
type Envelope = {
|
|
345
|
+
channel: typeof OPENCHAMBER_SDK_CHANNEL;
|
|
346
|
+
v: typeof OPENCHAMBER_SDK_API_VERSION;
|
|
347
|
+
};
|
|
348
|
+
export type HostReadyMessage = Envelope & {
|
|
349
|
+
type: 'ready';
|
|
350
|
+
payload: HostReadyContext;
|
|
351
|
+
};
|
|
352
|
+
export type HostDirectoryMessage = Envelope & {
|
|
353
|
+
type: 'directory';
|
|
354
|
+
payload: {
|
|
355
|
+
directory: string | null;
|
|
356
|
+
};
|
|
357
|
+
};
|
|
358
|
+
export type HostSessionMessage = Envelope & {
|
|
359
|
+
type: 'session';
|
|
360
|
+
payload: {
|
|
361
|
+
session: SessionSnapshot | null;
|
|
362
|
+
};
|
|
363
|
+
};
|
|
364
|
+
export type HostConnectionMessage = Envelope & {
|
|
365
|
+
type: 'connection';
|
|
366
|
+
payload: {
|
|
367
|
+
connection: GuestConnection;
|
|
368
|
+
};
|
|
369
|
+
};
|
|
370
|
+
export type HostSettingsMessage = Envelope & {
|
|
371
|
+
type: 'settings';
|
|
372
|
+
payload: {
|
|
373
|
+
settings: GuestSettings;
|
|
374
|
+
};
|
|
375
|
+
};
|
|
376
|
+
export type HostSessionLifecycleMessage = Envelope & {
|
|
377
|
+
type: 'session-lifecycle';
|
|
378
|
+
payload: SessionLifecycleEvent;
|
|
379
|
+
};
|
|
380
|
+
export type HostItemMessage = Envelope & {
|
|
381
|
+
type: 'item';
|
|
382
|
+
payload: {
|
|
383
|
+
item: GuestItem | null;
|
|
384
|
+
};
|
|
385
|
+
};
|
|
386
|
+
/** Host → guest request. The guest answers with `resolve-result` carrying the same `id`. */
|
|
387
|
+
export type HostResolveMessage = Envelope & {
|
|
388
|
+
type: 'resolve';
|
|
389
|
+
id: string;
|
|
390
|
+
payload: ResolveRequest;
|
|
391
|
+
};
|
|
392
|
+
export type HostResultMessage = Envelope & {
|
|
393
|
+
type: 'result';
|
|
394
|
+
id: string;
|
|
395
|
+
} & ({
|
|
396
|
+
ok: true;
|
|
397
|
+
payload?: HostResultPayload;
|
|
398
|
+
} | {
|
|
399
|
+
ok: false;
|
|
400
|
+
error: string;
|
|
401
|
+
code: HostRequestErrorCode;
|
|
402
|
+
});
|
|
403
|
+
export type HostMessage = (Envelope & {
|
|
404
|
+
type: 'workspace';
|
|
405
|
+
payload: GuestWorkspaceUpdate;
|
|
406
|
+
}) | HostReadyMessage | HostDirectoryMessage | HostSessionMessage | HostConnectionMessage | HostSettingsMessage | HostSessionLifecycleMessage | HostItemMessage | HostResolveMessage | HostResultMessage;
|
|
407
|
+
type GuestCall<Type extends string, Payload = never> = Envelope & {
|
|
408
|
+
type: Type;
|
|
409
|
+
id: string;
|
|
410
|
+
} & ([
|
|
411
|
+
Payload
|
|
412
|
+
] extends [never] ? object : {
|
|
413
|
+
payload: Payload;
|
|
414
|
+
});
|
|
415
|
+
export type GuestHelloMessage = Envelope & {
|
|
416
|
+
type: 'hello';
|
|
417
|
+
};
|
|
418
|
+
export type GuestToastMessage = GuestCall<'toast', ToastRequest>;
|
|
419
|
+
export type GuestOpenUrlMessage = GuestCall<'open-url', {
|
|
420
|
+
url: string;
|
|
421
|
+
}>;
|
|
422
|
+
export type GuestOpenSurfaceMessage = GuestCall<'open-surface', {
|
|
423
|
+
surfaceId: string;
|
|
424
|
+
}>;
|
|
425
|
+
export type GuestClipboardWriteMessage = GuestCall<'clipboard-write', {
|
|
426
|
+
text: string;
|
|
427
|
+
}>;
|
|
428
|
+
export type GuestComposeMessage = GuestCall<'compose', ComposeRequest>;
|
|
429
|
+
export type GuestAttachMessage = GuestCall<'attach', AttachIssueRequest>;
|
|
430
|
+
export type GuestStartSessionMessage = GuestCall<'start-session', StartSessionRequest>;
|
|
431
|
+
export type GuestPromptMessage = GuestCall<'prompt', PromptRequest>;
|
|
432
|
+
export type GuestSessionLinkMessage = GuestCall<'session-link', AttachIssueRequest>;
|
|
433
|
+
export type GuestCloseMessage = GuestCall<'close'>;
|
|
434
|
+
export type GuestOauthStartMessage = GuestCall<'oauth-start'>;
|
|
435
|
+
export type GuestOauthDisconnectMessage = GuestCall<'oauth-disconnect'>;
|
|
436
|
+
export type GuestRequestMessage = GuestCall<'request', GuestRequest>;
|
|
437
|
+
export type GuestServiceRequestMessage = GuestCall<'service-request', GuestRequest>;
|
|
438
|
+
export type GuestServiceStatusMessage = GuestCall<'service-status'>;
|
|
439
|
+
export type GuestFileReadMessage = GuestCall<'file-read', FileReadRequest>;
|
|
440
|
+
export type GuestFileWriteMessage = GuestCall<'file-write', FileWriteRequest>;
|
|
441
|
+
export type GuestFileListMessage = GuestCall<'file-list', FileListRequest>;
|
|
442
|
+
export type GuestFileStatMessage = GuestCall<'file-stat', FileStatRequest>;
|
|
443
|
+
export type GuestGenerateMessage = GuestCall<'generate', GenerateRequest>;
|
|
444
|
+
export type GuestBadgeMessage = GuestCall<'badge', BadgeRequest>;
|
|
445
|
+
/** Answers a host `resolve` by `id`. The host sends no `result` back for it. */
|
|
446
|
+
export type GuestResolveResultMessage = Envelope & {
|
|
447
|
+
type: 'resolve-result';
|
|
448
|
+
id: string;
|
|
449
|
+
payload: ResolveResultPayload;
|
|
450
|
+
};
|
|
451
|
+
export type GuestMessage = GuestCall<'workspace-read', GuestWorkspaceQuery> | GuestCall<'workspace-subscribe', GuestWorkspaceSubscription> | GuestCall<'workspace-unsubscribe', {
|
|
452
|
+
subscriptionId: string;
|
|
453
|
+
}> | GuestCall<'storage', GuestStorageRequest> | GuestCall<'open-session', {
|
|
454
|
+
sessionId: string;
|
|
455
|
+
}> | GuestHelloMessage | GuestToastMessage | GuestOpenUrlMessage | GuestOpenSurfaceMessage | GuestClipboardWriteMessage | GuestComposeMessage | GuestAttachMessage | GuestStartSessionMessage | GuestPromptMessage | GuestSessionLinkMessage | GuestCloseMessage | GuestOauthStartMessage | GuestOauthDisconnectMessage | GuestRequestMessage | GuestServiceRequestMessage | GuestServiceStatusMessage | GuestFileReadMessage | GuestFileWriteMessage | GuestFileListMessage | GuestFileStatMessage | GuestGenerateMessage | GuestBadgeMessage | GuestResolveResultMessage;
|
|
456
|
+
export declare const isServiceStatusResult: (value: HostResultPayload | undefined) => value is ServiceStatusResult;
|
|
457
|
+
export declare const isGuestRequestResult: (value: HostResultPayload | undefined) => value is GuestRequestResult;
|
|
458
|
+
export declare const isFileReadResult: (value: HostResultPayload | undefined) => value is FileReadResult;
|
|
459
|
+
export declare const isFileWriteResult: (value: HostResultPayload | undefined) => value is FileWriteResult;
|
|
460
|
+
export declare const isFileListResult: (value: HostResultPayload | undefined) => value is FileListResult;
|
|
461
|
+
export declare const isFileStatResult: (value: HostResultPayload | undefined) => value is FileStatResult;
|
|
462
|
+
export declare const isGenerateResult: (value: HostResultPayload | undefined) => value is GenerateResult;
|
|
463
|
+
/**
|
|
464
|
+
* The guest's read of a host message. The host is the trusted parent frame
|
|
465
|
+
* (the client only listens to `event.source === parent`), so this checks the
|
|
466
|
+
* envelope and the discriminant rather than every field, and the guest bundle
|
|
467
|
+
* carries no schema library for it. The host side parses guest input with
|
|
468
|
+
* `guestMessageSchema` in `@openchamber/sdk/schemas`.
|
|
469
|
+
*/
|
|
470
|
+
export declare const readHostMessage: (data: MessageEvent["data"]) => HostMessage | null;
|
|
471
|
+
export {};
|