@quartal/messages-client 0.0.0-stage → 0.3.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/LICENSE +21 -0
- package/README.md +37 -3
- package/dist/mod.d.ts +725 -0
- package/dist/mod.js +968 -0
- package/package.json +36 -3
package/dist/mod.d.ts
ADDED
|
@@ -0,0 +1,725 @@
|
|
|
1
|
+
import { ApiCrudItem, ApiListItem, FsContent, FsEncoding, FsEntry, FsWriteResult, ODataQueryOptions, ODataResult, QFsSource, ValidationResult } from "@quartal/core";
|
|
2
|
+
import { Agent, AgentPlugin, CatalogRepositoryInfo, Channel, ChannelAgentAssignment, ChannelAgentSchedule, ChannelAgentTrigger, ChannelCompany, ChannelDefinition, ChannelDefinitionInfo, ChannelMessageFile, ChannelSyncResult, ChannelsStats, ChatMessage, CompanyStats, CompanySummary, ExternalPlugin, HomeView, HostedPlugin, HostedPluginContent, HubConfigurationInfo, HubConfigurationPatch, HubToolSetting, LiveEvent, MessageFileContent, MessageUsage, Model, ModelCatalogRefreshResult, ModelGateway, PluginAgent, PluginCodeAttachment, PluginCodeChat, PluginCodeChatSummary, PluginHostGitCommit, PluginHostGitDiscardResult, PluginHostGitDiscardScope, PluginHostGitFileVersions, PluginHostGitResetMode, PluginHostGitResetResult, PluginHostGitStatus, PluginHostInfo, PluginHostPullResult, PluginHostPushResult, PluginInfo, PluginSyncResult, PluginTestSubject, PluginTestToken, PluginTestTool, ShownHomeView, ThreadSummary, UIFilePart, UIMessagePart, UIWidgetContextPart, UserInfo, WidgetResource, WidgetToolResult } from "@quartal/messages-types";
|
|
3
|
+
|
|
4
|
+
//#region src/ICrudApiBase.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* `ODataQuery<TFilter>` is `@quartal/core`'s `ODataQueryOptions` with the
|
|
7
|
+
* `$filter` field re-typed as a domain-shaped object (per resource) instead
|
|
8
|
+
* of an OData filter *string*.
|
|
9
|
+
*
|
|
10
|
+
* The deviation is deliberate for the Phase 2 spike: typed filter objects
|
|
11
|
+
* give us autocomplete + drift detection at every call site. An
|
|
12
|
+
* OData-string parser (the helper in `@quartal/core`) can be layered later
|
|
13
|
+
* behind the same `getOData` method, without changing this interface.
|
|
14
|
+
*/
|
|
15
|
+
interface ODataQuery<TFilter = unknown> extends Omit<ODataQueryOptions, '$filter'> {
|
|
16
|
+
/** Domain-shaped filter object (per resource), replacing OData's `$filter` string. */
|
|
17
|
+
$filter?: TFilter;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* CRUD API contract for a domain resource. Slimmed copy of `@quartal/core`'s
|
|
21
|
+
* `ICrudApiBase`:
|
|
22
|
+
*
|
|
23
|
+
* - Drops `schemaUrl`, `listType`, `getExample`, `getListItem` for now
|
|
24
|
+
* (we'll add them back as concrete needs surface).
|
|
25
|
+
* - `getOData` takes our typed `ODataQuery<TFilter>` instead of the
|
|
26
|
+
* `string | ODataQueryOptions` union.
|
|
27
|
+
*
|
|
28
|
+
* Everything else matches the upstream contract. Keeping the two type
|
|
29
|
+
* parameters (`TDetail`, `TList`) means resources can split detail/list
|
|
30
|
+
* shapes later without breaking consumers; pass the same type for both
|
|
31
|
+
* when one is enough.
|
|
32
|
+
*
|
|
33
|
+
* Live updates are out of scope here — they come from the event stream
|
|
34
|
+
* (`LiveEvents`). This interface owns reads + writes.
|
|
35
|
+
*/
|
|
36
|
+
interface ICrudApiBase<TDetail extends ApiCrudItem, TList extends ApiListItem> {
|
|
37
|
+
/** Stable resource discriminator, e.g. `'channel'` or `'agent'`. */
|
|
38
|
+
readonly type: string;
|
|
39
|
+
/** A new, empty detail object with default field values, for create forms. */
|
|
40
|
+
getBlank(): TDetail;
|
|
41
|
+
/** Validate a detail item; returns field-level errors and required-field status. */
|
|
42
|
+
validate(item: TDetail): ValidationResult;
|
|
43
|
+
/** Fetch one live (non-archived) row by id; rejects if not found. */
|
|
44
|
+
findById(id: string): Promise<TDetail>;
|
|
45
|
+
/** Query the resource with a typed filter; returns an OData-style result set. */
|
|
46
|
+
getOData<TFilter>(query: ODataQuery<TFilter>): Promise<ODataResult<TList>>;
|
|
47
|
+
/**
|
|
48
|
+
* Cursor follow-up for `$top`-paginated queries. Until an implementation
|
|
49
|
+
* honors `$top`, this method should reject with "not implemented".
|
|
50
|
+
*/
|
|
51
|
+
getNextPage(nextLink: string): Promise<ODataResult<TList>>;
|
|
52
|
+
/** Insert when the row is new, update when it already exists (keyed by id). */
|
|
53
|
+
save(item: TDetail): Promise<TDetail>;
|
|
54
|
+
/** Soft-delete by setting `archived_at`. The row is kept for audit. */
|
|
55
|
+
delete(id: string): Promise<void>;
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/idFormat.d.ts
|
|
59
|
+
/**
|
|
60
|
+
* Stable user-given id format shared by `models`, `tools`,
|
|
61
|
+
* `agents`, and `channels`. Mirrors the CHECK constraint on each table:
|
|
62
|
+
*
|
|
63
|
+
* ^[a-z0-9][a-z0-9._\-]*$ AND length ≤ 80
|
|
64
|
+
*
|
|
65
|
+
* Lowercase letters/digits to start; rest may include `_`, `.`, `-`.
|
|
66
|
+
* Wide enough to fit provider model ids ("gpt-5.4-pro") and route slugs
|
|
67
|
+
* ("payroll", "all-companies"); narrow enough to be URL- and JSON-safe.
|
|
68
|
+
*
|
|
69
|
+
* Validation lives in the API client so the same rule fires on every save
|
|
70
|
+
* regardless of who calls it (Vue UI, server script, future REST surface).
|
|
71
|
+
*/
|
|
72
|
+
/** Human-readable description of the id format, suitable for error messages. */
|
|
73
|
+
declare const ID_FORMAT_PATTERN = "^[a-z0-9][a-z0-9._\\-]*$ (lowercase, \u2264 80 chars)";
|
|
74
|
+
/** True when `id` is a non-empty string ≤ 80 chars matching {@linkcode ID_REGEX}. */
|
|
75
|
+
declare function isValidId(id: string): boolean;
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/config/ClientConfig.d.ts
|
|
78
|
+
/**
|
|
79
|
+
* Browser-side runtime configuration for `@quartal/messages-client`.
|
|
80
|
+
*
|
|
81
|
+
* Loaded from Vite's `import.meta.env`, so callers must run inside a Vite build (the Vue apps,
|
|
82
|
+
* Storybook). The env-var names use Vite's `VITE_` prefix; the returned shape is plain camelCase.
|
|
83
|
+
* Public values only — nothing here is a secret.
|
|
84
|
+
*/
|
|
85
|
+
interface ClientConfig {
|
|
86
|
+
/** Messages API origin (`VITE_MESSAGES_API_URL`), e.g. `http://localhost:8002`. */
|
|
87
|
+
messagesApiUrl: string;
|
|
88
|
+
/** Keycloak realm issuer (`VITE_OIDC_AUTHORITY`). */
|
|
89
|
+
oidcAuthority: string;
|
|
90
|
+
/** OIDC client of the browser apps (`VITE_OIDC_CLIENT_ID`). */
|
|
91
|
+
oidcClientId: string;
|
|
92
|
+
/** Scopes to request (`VITE_OIDC_SCOPE`); each audience scope adds an API's audience. */
|
|
93
|
+
oidcScope: string;
|
|
94
|
+
/** Quartal IAM API origin (`VITE_IAM_API_URL`): the user's companies. */
|
|
95
|
+
iamApiUrl: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Sets the configuration at runtime, over `import.meta.env`: for an app that is not built with the
|
|
99
|
+
* `VITE_*` variables, such as a channel plugin's page that learns the API's address from the Hub.
|
|
100
|
+
* Such an app needs only what it uses: {@link loadClientConfig} then requires `messagesApiUrl` alone.
|
|
101
|
+
* @param config The values to use; a later call adds to and overrides the earlier ones.
|
|
102
|
+
*/
|
|
103
|
+
declare function configureClient(config: Partial<ClientConfig>): void;
|
|
104
|
+
/**
|
|
105
|
+
* Reads `ClientConfig` from `import.meta.env` and the values given with {@link configureClient}.
|
|
106
|
+
* Throws when a required value is missing so the failure surfaces at app startup, not at the first
|
|
107
|
+
* call.
|
|
108
|
+
*/
|
|
109
|
+
declare function loadClientConfig(): ClientConfig;
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/http.d.ts
|
|
112
|
+
/**
|
|
113
|
+
* The HTTP seam to the Messages API: base URL, bearer token, JSON in and out, and errors that keep
|
|
114
|
+
* the API's status and message.
|
|
115
|
+
*
|
|
116
|
+
* @module
|
|
117
|
+
*/
|
|
118
|
+
/** Supplies the current access token, or null when signed out. Called before every request. */
|
|
119
|
+
type TokenProvider = () => string | null | Promise<string | null>;
|
|
120
|
+
/** A failed API call: the HTTP status, the API's `error` text and, for file errors, its `code`. */
|
|
121
|
+
declare class ApiError extends Error {
|
|
122
|
+
/** HTTP status of the response (0 when the request did not reach the API). */
|
|
123
|
+
readonly status: number;
|
|
124
|
+
/** The API's error code when it sends one: the `FsErrorCode` of a file operation (`ENOENT`, `ECONFLICT`, …). */
|
|
125
|
+
readonly code?: string;
|
|
126
|
+
/**
|
|
127
|
+
* @param status HTTP status of the response.
|
|
128
|
+
* @param message The API's `error` text, or the status text.
|
|
129
|
+
* @param code The API's error code, if any.
|
|
130
|
+
*/
|
|
131
|
+
constructor(status: number, message: string, code?: string);
|
|
132
|
+
}
|
|
133
|
+
/** Query-string values; `undefined` and `null` are left out. */
|
|
134
|
+
type Query = Record<string, string | number | boolean | null | undefined>;
|
|
135
|
+
/** Options of one request. */
|
|
136
|
+
interface RequestOptions {
|
|
137
|
+
/** Query-string parameters. */
|
|
138
|
+
query?: Query;
|
|
139
|
+
/** JSON body (POST, PUT). */
|
|
140
|
+
body?: unknown;
|
|
141
|
+
/** Aborts the request. */
|
|
142
|
+
signal?: AbortSignal;
|
|
143
|
+
}
|
|
144
|
+
/** A minimal JSON client for the Messages API. */
|
|
145
|
+
declare class HttpClient {
|
|
146
|
+
readonly baseUrl: string;
|
|
147
|
+
private readonly getToken;
|
|
148
|
+
/**
|
|
149
|
+
* @param baseUrl The API origin, e.g. `http://localhost:8002`.
|
|
150
|
+
* @param getToken Supplies the bearer token for each request.
|
|
151
|
+
*/
|
|
152
|
+
constructor(baseUrl: string, getToken: TokenProvider);
|
|
153
|
+
/** GET `path`; resolves to the parsed JSON body. */
|
|
154
|
+
get<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
155
|
+
/** POST `path` with a JSON body. */
|
|
156
|
+
post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
|
|
157
|
+
/** PUT `path` with a JSON body. */
|
|
158
|
+
put<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
|
|
159
|
+
/** DELETE `path`. */
|
|
160
|
+
delete<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
161
|
+
/** Sends one request. Throws {@link ApiError} on a non-2xx response or a network failure. */
|
|
162
|
+
request<T>(method: string, path: string, options?: RequestOptions): Promise<T>;
|
|
163
|
+
/** The current token (for the event stream). */
|
|
164
|
+
token(): Promise<string | null>;
|
|
165
|
+
}
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region src/agents/AgentsApi.d.ts
|
|
168
|
+
/** What can be changed of an agent: how it is shown. The plugins it uses are in each channel's definition. */
|
|
169
|
+
interface AgentPatch {
|
|
170
|
+
/** Display name. */
|
|
171
|
+
name?: string;
|
|
172
|
+
/** Description; null clears it. */
|
|
173
|
+
description?: string | null;
|
|
174
|
+
/** Agent configuration; null clears it. */
|
|
175
|
+
data?: Record<string, unknown> | null;
|
|
176
|
+
/** Avatar icon; null clears it. */
|
|
177
|
+
icon?: string | null;
|
|
178
|
+
/** Avatar initials; null clears them. */
|
|
179
|
+
initials?: string | null;
|
|
180
|
+
/** Avatar color; null clears it. */
|
|
181
|
+
color?: string | null;
|
|
182
|
+
/** Avatar image URL; null clears it. */
|
|
183
|
+
avatarUrl?: string | null;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* The agents over the Messages API (`/api/agents`). Every agent is defined in a plugin; it gets its
|
|
187
|
+
* row when a channel definition first names it.
|
|
188
|
+
*/
|
|
189
|
+
declare class AgentsApi {
|
|
190
|
+
private readonly http;
|
|
191
|
+
/** @param http The Messages API client. */
|
|
192
|
+
constructor(http: HttpClient);
|
|
193
|
+
/** The live agents, by name; optionally only those a plugin defines. */
|
|
194
|
+
list(filter?: {
|
|
195
|
+
name?: string;
|
|
196
|
+
pluginId?: string;
|
|
197
|
+
}): Promise<Agent[]>;
|
|
198
|
+
/** One agent by id; rejects with a 404 `ApiError` when it is not visible. */
|
|
199
|
+
get(id: string): Promise<Agent>;
|
|
200
|
+
/**
|
|
201
|
+
* The agents an organization can attach to its channels: those its own plugins define, then those
|
|
202
|
+
* of the catalog's plugins.
|
|
203
|
+
*/
|
|
204
|
+
available(owner: string): Promise<PluginAgent[]>;
|
|
205
|
+
/** Changes how an agent is shown. */
|
|
206
|
+
update(id: string, patch: AgentPatch): Promise<Agent>;
|
|
207
|
+
/** Archives an agent: it no longer answers. */
|
|
208
|
+
archive(id: string): Promise<void>;
|
|
209
|
+
}
|
|
210
|
+
//#endregion
|
|
211
|
+
//#region src/channels/IChannelsApi.d.ts
|
|
212
|
+
/**
|
|
213
|
+
* Domain-shaped filter for `IChannelsApi.getOData()`. Phase 2 keeps the
|
|
214
|
+
* filter shape minimal — extend as concrete pages need it. OData-string
|
|
215
|
+
* parsing (via the `@quartal/core` helper) can be added later behind the
|
|
216
|
+
* same method.
|
|
217
|
+
*/
|
|
218
|
+
interface ChannelsFilter {
|
|
219
|
+
/** Exact-match filter on the owning company. */
|
|
220
|
+
owner?: string;
|
|
221
|
+
/** Substring match on `name` (PostgREST `ilike '%…%'`). */
|
|
222
|
+
name?: string;
|
|
223
|
+
/** Only channels that list this company now. */
|
|
224
|
+
company?: string;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* CRUD API for the `channels` table. Detail and list share the same shape
|
|
228
|
+
* (`Channel`) for now; split into `Channel` + `ChannelListItem` if the
|
|
229
|
+
* read-list ever needs to be narrower than the detail page.
|
|
230
|
+
*/
|
|
231
|
+
type IChannelsApi = ICrudApiBase<Channel, Channel>;
|
|
232
|
+
//#endregion
|
|
233
|
+
//#region src/channels/ChannelsApi.d.ts
|
|
234
|
+
/** The outcome of refreshing the channels made from a definition. */
|
|
235
|
+
interface ChannelsRefreshResult {
|
|
236
|
+
/** The channels that follow the definition now. */
|
|
237
|
+
refreshed: string[];
|
|
238
|
+
/** The channels that could not be refreshed, with the reason. */
|
|
239
|
+
failed: {
|
|
240
|
+
channelId: string;
|
|
241
|
+
error: string;
|
|
242
|
+
}[];
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* A new channel and its plugin `ch-<id>` on the organization's plugin host: a new definition
|
|
246
|
+
* (`newDefinition`) or a copy of a catalog channel plugin (`copyOf`), exactly one of them.
|
|
247
|
+
*/
|
|
248
|
+
interface ChannelCreateInput {
|
|
249
|
+
/** Channel id (a DNS label); its plugin is `ch-<id>`. */
|
|
250
|
+
id: string;
|
|
251
|
+
/** The owning company (in practice an advisory). */
|
|
252
|
+
owner: string;
|
|
253
|
+
/** A new definition: the channel plugin starts with this title and look. */
|
|
254
|
+
newDefinition?: {
|
|
255
|
+
/** The channel's name in the definition. */title: string; /** What the channel is for. */
|
|
256
|
+
description?: string; /** Material icon name. */
|
|
257
|
+
icon?: string; /** Theme color. */
|
|
258
|
+
color?: string;
|
|
259
|
+
};
|
|
260
|
+
/** A catalog channel plugin to copy instead. */
|
|
261
|
+
copyOf?: string;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Channels over the Messages API (`/api/channels`). Visibility comes from the API's access rules. `getBlank` and `validate` run locally; the API validates again on write.
|
|
265
|
+
*/
|
|
266
|
+
declare class ChannelsApi implements IChannelsApi {
|
|
267
|
+
private readonly http;
|
|
268
|
+
/** Resource type name. */
|
|
269
|
+
readonly type = "channel";
|
|
270
|
+
/** @param http The Messages API client. */
|
|
271
|
+
constructor(http: HttpClient);
|
|
272
|
+
getBlank(): Channel;
|
|
273
|
+
/** Validate a new channel; requires `id` (valid format) and `owner`. */
|
|
274
|
+
validate(item: Channel): ValidationResult;
|
|
275
|
+
/** One channel by id; rejects with a 404 `ApiError` when it is not visible. */
|
|
276
|
+
findById(id: string): Promise<Channel>;
|
|
277
|
+
/** The channels matching `query.$filter` (the API decides the order). */
|
|
278
|
+
getOData<TFilter>(query: ODataQuery<TFilter>): Promise<ODataResult<Channel>>;
|
|
279
|
+
/** Paging is not offered: every list returns all matching rows. */
|
|
280
|
+
getNextPage(_nextLink: string): Promise<ODataResult<Channel>>;
|
|
281
|
+
/**
|
|
282
|
+
* Creates a channel with a new definition titled with the item's name (its id when empty). A
|
|
283
|
+
* channel's name and look are its definition's: change them with {@link saveDefinition}.
|
|
284
|
+
*/
|
|
285
|
+
save(item: Channel): Promise<Channel>;
|
|
286
|
+
/** Creates a channel and its plugin: a new definition, or a copy of a catalog channel plugin. */
|
|
287
|
+
create(input: ChannelCreateInput): Promise<Channel>;
|
|
288
|
+
/** Commits the channel plugin's files on the plugin host and moves the channel to that commit. */
|
|
289
|
+
refresh(id: string): Promise<Channel>;
|
|
290
|
+
/** The definitions an organization can make channels from: its own channel plugins, then the catalog's. */
|
|
291
|
+
definitions(owner: string): Promise<ChannelDefinitionInfo[]>;
|
|
292
|
+
/** Writes a definition into its plugin on the organization's plugin host, commits it and moves its channels to it. */
|
|
293
|
+
saveDefinition(owner: string, pluginId: string, definition: ChannelDefinition): Promise<{
|
|
294
|
+
definition: ChannelDefinition;
|
|
295
|
+
} & ChannelsRefreshResult>;
|
|
296
|
+
/** Moves every channel made from a definition to its plugin's latest state, after its files changed. */
|
|
297
|
+
refreshDefinition(owner: string, pluginId: string): Promise<ChannelsRefreshResult>;
|
|
298
|
+
/**
|
|
299
|
+
* Syncs the organization's channels with the definitions on its plugin host, without pulling:
|
|
300
|
+
* a definition in `channels/` with no channel gets one, a channel whose plugin is gone is
|
|
301
|
+
* archived, every other channel moves to its plugin's latest commit.
|
|
302
|
+
*/
|
|
303
|
+
sync(owner: string): Promise<ChannelSyncResult>;
|
|
304
|
+
/** Statistics of the visible channels: listed companies and threads per status. */
|
|
305
|
+
stats(): Promise<ChannelsStats>;
|
|
306
|
+
/** Archives the channel. */
|
|
307
|
+
delete(id: string): Promise<void>;
|
|
308
|
+
}
|
|
309
|
+
//#endregion
|
|
310
|
+
//#region src/events.d.ts
|
|
311
|
+
/** Receives each change the signed-in user can see. */
|
|
312
|
+
type LiveEventHandler = (event: LiveEvent) => void;
|
|
313
|
+
/** One shared SSE connection with fan-out to handlers. */
|
|
314
|
+
declare class LiveEvents {
|
|
315
|
+
private readonly http;
|
|
316
|
+
private readonly handlers;
|
|
317
|
+
private controller;
|
|
318
|
+
private retry;
|
|
319
|
+
/** @param http The client whose base URL and token the stream uses. */
|
|
320
|
+
constructor(http: HttpClient);
|
|
321
|
+
/** Calls `handler` for every change until the returned function is called. */
|
|
322
|
+
subscribe(handler: LiveEventHandler): () => void;
|
|
323
|
+
/** Closes the connection (it reopens on the next subscription). */
|
|
324
|
+
close(): void;
|
|
325
|
+
private connect;
|
|
326
|
+
private dispatch;
|
|
327
|
+
}
|
|
328
|
+
//#endregion
|
|
329
|
+
//#region src/models/IModelsApi.d.ts
|
|
330
|
+
/** Filters for {@link IModelsApi.list}. */
|
|
331
|
+
interface ModelsFilter {
|
|
332
|
+
/** Partial, case-insensitive match on the name. */
|
|
333
|
+
name?: string;
|
|
334
|
+
/** Only this provider. */
|
|
335
|
+
provider?: string;
|
|
336
|
+
/** Include the models the settings disable. */
|
|
337
|
+
includeDisabled?: boolean;
|
|
338
|
+
}
|
|
339
|
+
/** The models agents can use: OpenCode Zen's catalog with the product's settings. Read only. */
|
|
340
|
+
interface IModelsApi {
|
|
341
|
+
/** Resource type name. */
|
|
342
|
+
readonly type: 'model';
|
|
343
|
+
/** One model by id. */
|
|
344
|
+
findById(id: string): Promise<Model>;
|
|
345
|
+
/** The models matching the filter, the default first. */
|
|
346
|
+
list(filter?: ModelsFilter): Promise<Model[]>;
|
|
347
|
+
/** The gateway the agents' models are called through. */
|
|
348
|
+
gateway(): Promise<ModelGateway>;
|
|
349
|
+
/** Reads the catalog again from OpenCode Zen. */
|
|
350
|
+
refresh(): Promise<ModelCatalogRefreshResult>;
|
|
351
|
+
}
|
|
352
|
+
//#endregion
|
|
353
|
+
//#region src/models/ModelsApi.d.ts
|
|
354
|
+
/**
|
|
355
|
+
* The models agents can use over the Messages API (`/api/models`): OpenCode Zen's catalog with the
|
|
356
|
+
* product's settings from Git. Read only.
|
|
357
|
+
*/
|
|
358
|
+
declare class ModelsApi implements IModelsApi {
|
|
359
|
+
private readonly http;
|
|
360
|
+
/** Resource type name. */
|
|
361
|
+
readonly type = "model";
|
|
362
|
+
/** @param http The Messages API client. */
|
|
363
|
+
constructor(http: HttpClient);
|
|
364
|
+
/** One model by id; rejects with a 404 `ApiError` when the catalog does not have it. */
|
|
365
|
+
findById(id: string): Promise<Model>;
|
|
366
|
+
/** The models matching the filter, the default first (enabled ones unless `includeDisabled`). */
|
|
367
|
+
list(filter?: ModelsFilter): Promise<Model[]>;
|
|
368
|
+
/** The gateway the agents' models are called through (OpenCode Zen or Amazon Bedrock). */
|
|
369
|
+
gateway(): Promise<ModelGateway>;
|
|
370
|
+
/** Reads the catalog again from OpenCode Zen (the API otherwise reads it once a day). */
|
|
371
|
+
refresh(): Promise<ModelCatalogRefreshResult>;
|
|
372
|
+
}
|
|
373
|
+
//#endregion
|
|
374
|
+
//#region src/MessagesApi.d.ts
|
|
375
|
+
/** Fields of a thread that can change. */
|
|
376
|
+
interface ThreadPatch {
|
|
377
|
+
/** New status: the key of one of the channel's statuses. */
|
|
378
|
+
status?: string;
|
|
379
|
+
/** New creation time (ISO 8601). */
|
|
380
|
+
createdAt?: string;
|
|
381
|
+
/** New manual sort rank; null clears it. */
|
|
382
|
+
orderIndex?: number | null;
|
|
383
|
+
}
|
|
384
|
+
/** Fields of a channel agent attachment that can change. */
|
|
385
|
+
interface ChannelAgentPatch {
|
|
386
|
+
/** Whether the worker answers with the agent. */
|
|
387
|
+
isActive?: boolean;
|
|
388
|
+
/** Events that make the agent respond. */
|
|
389
|
+
triggers?: ChannelAgentTrigger[];
|
|
390
|
+
/** Instructions for this channel; empty removes them. */
|
|
391
|
+
instructions?: string;
|
|
392
|
+
/** Tools that run only after the person approves the call (replaces the list; empty removes it). */
|
|
393
|
+
approve?: string[];
|
|
394
|
+
/** The plugins the agent uses in the channel, its own first (replaces the list). */
|
|
395
|
+
plugins?: AgentPlugin[];
|
|
396
|
+
/** The Hub's own tools, by tool or group (replaces the settings; empty removes them). */
|
|
397
|
+
hubTools?: Record<string, HubToolSetting>;
|
|
398
|
+
/** Time-based runs of the agent (replaces the list; empty removes it). */
|
|
399
|
+
schedules?: ChannelAgentSchedule[];
|
|
400
|
+
/** Move the agent to this place in the definition's list. */
|
|
401
|
+
position?: number;
|
|
402
|
+
}
|
|
403
|
+
/** Every Messages API resource behind one client. */
|
|
404
|
+
declare class MessagesApi {
|
|
405
|
+
/** The underlying HTTP client. */
|
|
406
|
+
readonly http: HttpClient;
|
|
407
|
+
/** Channels (CRUD). */
|
|
408
|
+
readonly channels: ChannelsApi;
|
|
409
|
+
/** The model catalog (CRUD + default/disabled). */
|
|
410
|
+
readonly models: ModelsApi;
|
|
411
|
+
/** The agents: those attached to channels, and the ones plugins offer. */
|
|
412
|
+
readonly agents: AgentsApi;
|
|
413
|
+
/** The shared live event stream. */
|
|
414
|
+
readonly events: LiveEvents;
|
|
415
|
+
/**
|
|
416
|
+
* @param baseUrl The API origin, e.g. `http://localhost:8002`.
|
|
417
|
+
* @param getToken Supplies the signed-in user's access token.
|
|
418
|
+
*/
|
|
419
|
+
constructor(baseUrl: string, getToken: TokenProvider);
|
|
420
|
+
/** The signed-in user: profile, the companies they can act for, and roles. */
|
|
421
|
+
me(): Promise<UserInfo>;
|
|
422
|
+
/** The companies the user can see (their own, and those of the channels they see), by name. */
|
|
423
|
+
companies(): Promise<CompanySummary[]>;
|
|
424
|
+
/** Counts per company the user sees (channels, threads, messages, people, last activity); `ids` limits them. */
|
|
425
|
+
companyStats(ids?: string[]): Promise<CompanyStats[]>;
|
|
426
|
+
/**
|
|
427
|
+
* The Hub configuration of an organization (its skin), kept in Git as `hub-configuration.json`
|
|
428
|
+
* at the root of its plugin repository: read by its members, changed (and committed) by its admins.
|
|
429
|
+
*/
|
|
430
|
+
readonly hubConfiguration: {
|
|
431
|
+
/** The configuration of an organization the user is a direct member of; empty without the file. */get: (companyId: string) => Promise<HubConfigurationInfo>; /** Sets the keys given (null removes one) for an organization the user is a direct admin of. */
|
|
432
|
+
update: (companyId: string, configuration: HubConfigurationPatch) => Promise<HubConfigurationInfo>;
|
|
433
|
+
};
|
|
434
|
+
/** The Quartal Hub plugin catalog. */
|
|
435
|
+
readonly plugins: {
|
|
436
|
+
/** Every plugin: synced ones first, then the placeholders. */list: () => Promise<PluginInfo[]>; /** One plugin by id. */
|
|
437
|
+
get: (id: string) => Promise<PluginInfo>; /** Reads every configured plugin source again; one result per source. */
|
|
438
|
+
sync: () => Promise<PluginSyncResult[]>; /** When the catalog was last synced and how each source went; null before the first sync. */
|
|
439
|
+
lastSync: () => Promise<{
|
|
440
|
+
syncedAt: string;
|
|
441
|
+
results: PluginSyncResult[];
|
|
442
|
+
} | null>; /** The catalog's Git repository: its address (without credentials) and branch. */
|
|
443
|
+
repository: () => Promise<CatalogRepositoryInfo>; /** The text of a file a catalog plugin serves (a skill file), read through the API. */
|
|
444
|
+
getFile: (url: string) => Promise<string>;
|
|
445
|
+
/**
|
|
446
|
+
* Saves the README, skills and agents of a catalog plugin into the catalog's working copy (only
|
|
447
|
+
* with `allowCatalogEdits`); lists left out are not changed. Reaches the repository with `push`.
|
|
448
|
+
*/
|
|
449
|
+
saveContent: (id: string, plugin: Pick<PluginInfo, "readme" | "skills" | "agents">) => Promise<PluginInfo>; /** The catalog's working copy against its repository: commits ahead and behind, and changed files. */
|
|
450
|
+
gitStatus: () => Promise<PluginHostGitStatus>; /** Commits the catalog edits in the user's name and pushes them (409 when the repository is ahead: sync first). */
|
|
451
|
+
push: (message: string) => Promise<PluginHostPushResult>;
|
|
452
|
+
};
|
|
453
|
+
/**
|
|
454
|
+
* The catalog plugins an organization uses as they are, from where they run. The list is kept in
|
|
455
|
+
* the organization's plugin repository. For the organization's direct members.
|
|
456
|
+
*/
|
|
457
|
+
readonly externalPlugins: {
|
|
458
|
+
/** The organization's external plugins, each with the catalog's current entry. */list: (owner: string) => Promise<ExternalPlugin[]>; /** Takes the catalog plugin into use as an external plugin. */
|
|
459
|
+
create: (owner: string, pluginId: string) => Promise<ExternalPlugin>; /** Stops using the plugin. */
|
|
460
|
+
delete: (owner: string, id: string) => Promise<void>;
|
|
461
|
+
};
|
|
462
|
+
/**
|
|
463
|
+
* The organization's own plugins on its plugin host: Quartal Plugin projects in the host's Git
|
|
464
|
+
* repository, each built and served on its own subdomain. For the organization's direct members.
|
|
465
|
+
*/
|
|
466
|
+
readonly hostedPlugins: {
|
|
467
|
+
/** Whether the organization has a plugin host. */host: (owner: string) => Promise<PluginHostInfo>; /** The plugins on the host. */
|
|
468
|
+
list: (owner: string) => Promise<HostedPlugin[]>; /** One plugin with its state and last build. */
|
|
469
|
+
get: (owner: string, id: string) => Promise<HostedPlugin>;
|
|
470
|
+
/**
|
|
471
|
+
* Adds a plugin to a group folder (`folder`, e.g. `logic` or `customers/acme`): an empty project,
|
|
472
|
+
* or a copy of a plugin in another Git repository (`gitUrl`).
|
|
473
|
+
*/
|
|
474
|
+
create: (owner: string, plugin: {
|
|
475
|
+
id: string;
|
|
476
|
+
folder?: string;
|
|
477
|
+
title?: string;
|
|
478
|
+
description?: string;
|
|
479
|
+
gitUrl?: string;
|
|
480
|
+
ref?: string;
|
|
481
|
+
subdir?: string;
|
|
482
|
+
}) => Promise<HostedPlugin>;
|
|
483
|
+
/**
|
|
484
|
+
* Makes a local copy of a catalog plugin: `source` copies its source code from the repository it
|
|
485
|
+
* publishes; `content` copies its skills, agents and README and keeps the original in use for its
|
|
486
|
+
* tools and widgets.
|
|
487
|
+
*/
|
|
488
|
+
copy: (owner: string, pluginId: string, id: string, mode: "source" | "content") => Promise<HostedPlugin>; /** The plugin with what it offers: README, skills and agents from its files, tools from the running plugin. */
|
|
489
|
+
content: (owner: string, id: string) => Promise<HostedPluginContent>; /** Saves the README, skills and agents of `plugin` into the plugin's files. */
|
|
490
|
+
saveContent: (owner: string, id: string, plugin: PluginInfo) => Promise<HostedPluginContent>; /** Removes the plugin from the host: its files, process and secrets. */
|
|
491
|
+
delete: (owner: string, id: string) => Promise<void>; /** Installs and builds the plugin again. */
|
|
492
|
+
build: (owner: string, id: string) => Promise<HostedPlugin>; /** Stops the plugin's process and starts it again. */
|
|
493
|
+
restart: (owner: string, id: string) => Promise<HostedPlugin>; /** Turns the development state (the development server with hot reload) on or off. */
|
|
494
|
+
setDev: (owner: string, id: string, enabled: boolean) => Promise<HostedPlugin>; /** The end of the plugin's install, build and runtime output. */
|
|
495
|
+
logs: (owner: string, id: string, lines?: number) => Promise<string>; /** The names of the plugin's secrets; values are never returned. */
|
|
496
|
+
secrets: (owner: string, id: string) => Promise<string[]>; /** Sets secrets (`null` removes one); they apply from the plugin's next start. Returns the names afterwards. */
|
|
497
|
+
setSecrets: (owner: string, id: string, values: Record<string, string | null>) => Promise<string[]>;
|
|
498
|
+
};
|
|
499
|
+
/**
|
|
500
|
+
* The coding chats: sessions of the plugin host's coding agent, each in one of the organization's
|
|
501
|
+
* plugins (docs/code-agent.md). The host rebuilds a plugin when the agent changes it. Read a chat
|
|
502
|
+
* again while it is `busy`.
|
|
503
|
+
*/
|
|
504
|
+
readonly pluginCoding: {
|
|
505
|
+
/** A one-time, signed-in address of the coding agent's own UI at `path` (a chat's `uiPath`). */uiUrl: (owner: string, path?: string) => Promise<string>; /** The organization's newest coding chats, each with whether a reply is being written now. */
|
|
506
|
+
chats: (owner: string) => Promise<PluginCodeChatSummary[]>;
|
|
507
|
+
/**
|
|
508
|
+
* Starts a coding chat in a plugin's folder (`ch-<channel id>` for a channel), with its first
|
|
509
|
+
* message; without `text` an empty one, to be written in the coding agent's own UI.
|
|
510
|
+
*/
|
|
511
|
+
startChat: (owner: string, input: {
|
|
512
|
+
pluginId: string;
|
|
513
|
+
text?: string;
|
|
514
|
+
agent?: string;
|
|
515
|
+
attachments?: PluginCodeAttachment[];
|
|
516
|
+
}) => Promise<PluginCodeChat>; /** A coding chat by its session. */
|
|
517
|
+
chat: (owner: string, sessionId: string) => Promise<PluginCodeChat>; /** Sends a message to a coding chat. Returns the chat, busy. */
|
|
518
|
+
continueChat: (owner: string, sessionId: string, input: {
|
|
519
|
+
text: string;
|
|
520
|
+
agent?: string;
|
|
521
|
+
attachments?: PluginCodeAttachment[];
|
|
522
|
+
}) => Promise<PluginCodeChat>; /** Stops the reply being written in a coding chat. */
|
|
523
|
+
stopChat: (owner: string, sessionId: string) => Promise<PluginCodeChat>; /** Deletes a coding chat with its messages. */
|
|
524
|
+
deleteChat: (owner: string, sessionId: string) => Promise<void>;
|
|
525
|
+
};
|
|
526
|
+
/** The files of the organization's hosted plugins, addressed as `/{plugin id}/{path}`. */
|
|
527
|
+
readonly hostedPluginFiles: {
|
|
528
|
+
/** The children of a folder, folders first; `/` lists the plugins. */list: (owner: string, path: string, options?: {
|
|
529
|
+
recursive?: boolean;
|
|
530
|
+
}) => Promise<FsEntry[]>; /** One file or folder. */
|
|
531
|
+
stat: (owner: string, path: string) => Promise<FsEntry>; /** A file's content: text as such, anything else as base64. */
|
|
532
|
+
read: (owner: string, path: string) => Promise<FsContent>; /** Writes a file. `ifMatch`: the version last read, or `null` for "must not exist yet". */
|
|
533
|
+
write: (owner: string, path: string, content: string, options?: {
|
|
534
|
+
encoding?: FsEncoding;
|
|
535
|
+
ifMatch?: string | null;
|
|
536
|
+
}) => Promise<FsWriteResult>; /** Creates a folder (and missing parents). */
|
|
537
|
+
mkdir: (owner: string, path: string) => Promise<FsEntry>; /** Renames or moves a file or folder inside one plugin. */
|
|
538
|
+
move: (owner: string, from: string, to: string, options?: {
|
|
539
|
+
overwrite?: boolean;
|
|
540
|
+
}) => Promise<FsEntry>; /** Copies a file or folder inside one plugin. */
|
|
541
|
+
copy: (owner: string, from: string, to: string, options?: {
|
|
542
|
+
overwrite?: boolean;
|
|
543
|
+
}) => Promise<FsEntry>; /** Deletes a file, or a folder with `recursive`. */
|
|
544
|
+
delete: (owner: string, path: string, options?: {
|
|
545
|
+
recursive?: boolean;
|
|
546
|
+
}) => Promise<void>; /** The files as the filesystem of the file components of `@quartal/ui-core` (`QFileExplorer`); root it at `/{plugin id}`. */
|
|
547
|
+
forOwner: (owner: string) => QFsSource;
|
|
548
|
+
};
|
|
549
|
+
/** The Git repository behind the organization's plugin host. */
|
|
550
|
+
readonly pluginHostGit: {
|
|
551
|
+
/** The host's copy against the repository: commits ahead and behind, and changed files. */status: (owner: string) => Promise<PluginHostGitStatus>; /** The commits on the host that are not pushed, newest first, with their files. */
|
|
552
|
+
log: (owner: string) => Promise<PluginHostGitCommit[]>; /** A file before and after a change: in a commit (its id), or not committed yet (`working`). */
|
|
553
|
+
file: (owner: string, commit: string, path: string, from?: string) => Promise<PluginHostGitFileVersions>; /** Cancels a commit that is not pushed, with every commit after it: its changes are kept (not committed) or thrown away. */
|
|
554
|
+
reset: (owner: string, commit: string, mode: PluginHostGitResetMode) => Promise<PluginHostGitResetResult>; /** Throws away the changes not committed, the commits not pushed, or both. */
|
|
555
|
+
discard: (owner: string, scope: PluginHostGitDiscardScope) => Promise<PluginHostGitDiscardResult>; /** Loads the latest from the repository (409 `uncommitted` or `diverged` when it cannot). */
|
|
556
|
+
pull: (owner: string) => Promise<PluginHostPullResult>; /** Commits the host's changes in the user's name and pushes them (409 `rejected` when the repository is ahead). */
|
|
557
|
+
push: (owner: string, message: string) => Promise<PluginHostPushResult>;
|
|
558
|
+
};
|
|
559
|
+
/**
|
|
560
|
+
* Files of a company (`owner`: a company id, or `system` for the read-only product data), addressed
|
|
561
|
+
* as `/{drive}/{path}`. A company's own people use them, and so do the people of an advisory that
|
|
562
|
+
* has it as a customer.
|
|
563
|
+
*/
|
|
564
|
+
readonly files: {
|
|
565
|
+
/** The children of a folder, folders first; `/` lists the drives. */list: (owner: string, path: string, options?: {
|
|
566
|
+
recursive?: boolean;
|
|
567
|
+
}) => Promise<FsEntry[]>; /** One file or folder. */
|
|
568
|
+
stat: (owner: string, path: string) => Promise<FsEntry>; /** A file's content: text as such, anything else as base64. */
|
|
569
|
+
read: (owner: string, path: string) => Promise<FsContent>;
|
|
570
|
+
/**
|
|
571
|
+
* Writes a file. `ifMatch`: the version last read (fails if changed since), or `null` for "must
|
|
572
|
+
* not exist yet".
|
|
573
|
+
*/
|
|
574
|
+
write: (owner: string, path: string, content: string, options?: {
|
|
575
|
+
encoding?: FsEncoding;
|
|
576
|
+
ifMatch?: string | null;
|
|
577
|
+
}) => Promise<FsWriteResult>; /** Creates a folder (and missing parents). */
|
|
578
|
+
mkdir: (owner: string, path: string) => Promise<FsEntry>; /** Renames or moves a file or folder. */
|
|
579
|
+
move: (owner: string, from: string, to: string, options?: {
|
|
580
|
+
overwrite?: boolean;
|
|
581
|
+
}) => Promise<FsEntry>; /** Copies a file or folder (with its contents); `overwrite` replaces an existing destination. */
|
|
582
|
+
copy: (owner: string, from: string, to: string, options?: {
|
|
583
|
+
overwrite?: boolean;
|
|
584
|
+
}) => Promise<FsEntry>; /** Deletes a file, or a folder with `recursive`. */
|
|
585
|
+
delete: (owner: string, path: string, options?: {
|
|
586
|
+
recursive?: boolean;
|
|
587
|
+
}) => Promise<void>; /** Writes demo files into a company's files; files it already has are left as they are. */
|
|
588
|
+
createDemo: (owner: string) => Promise<{
|
|
589
|
+
written: number;
|
|
590
|
+
skipped: number;
|
|
591
|
+
}>; /** The files of one owner as the filesystem of the file components of `@quartal/ui-core` (`QFileExplorer`). */
|
|
592
|
+
forOwner: (owner: string) => QFsSource;
|
|
593
|
+
};
|
|
594
|
+
/** Thread operations. */
|
|
595
|
+
readonly threads: {
|
|
596
|
+
/** The visible live threads of a channel, newest first. */list: (channelId: string) => Promise<ThreadSummary[]>; /** A company's visible live threads across channels, the most recently active first (`limit` 1–200, default 50). */
|
|
597
|
+
recent: (owner: string, limit?: number) => Promise<ThreadSummary[]>; /** One thread. */
|
|
598
|
+
get: (id: string) => Promise<ThreadSummary>;
|
|
599
|
+
/**
|
|
600
|
+
* Starts a thread in a channel for a company (`owner`). Without `owner` the API uses the user's
|
|
601
|
+
* own company when they have exactly one in the channel.
|
|
602
|
+
*/
|
|
603
|
+
create: (channelId: string, subject: string, owner?: string) => Promise<ThreadSummary>; /** Changes status, creation time or sort rank (a status change also posts a status message). */
|
|
604
|
+
update: (id: string, patch: ThreadPatch) => Promise<ThreadSummary>; /** Archives a thread. */
|
|
605
|
+
archive: (id: string) => Promise<void>;
|
|
606
|
+
};
|
|
607
|
+
/** Message operations. */
|
|
608
|
+
readonly messages: {
|
|
609
|
+
/** The live messages of a thread, oldest first. */list: (threadId: string) => Promise<ChatMessage[]>; /** One message. */
|
|
610
|
+
get: (id: string) => Promise<ChatMessage>;
|
|
611
|
+
/**
|
|
612
|
+
* Approves or rejects a tool call an agent's reply waits for (a tool the channel's definition
|
|
613
|
+
* lists in `approve`); only the person the reply answers may. Returns the reply.
|
|
614
|
+
*/
|
|
615
|
+
approveToolCall: (messageId: string, toolCallId: string, approved: boolean, reason?: string) => Promise<ChatMessage>;
|
|
616
|
+
/**
|
|
617
|
+
* Answers an agent's question a reply waits for (its `ask_user` call): the options picked and/or
|
|
618
|
+
* an answer of the person's own; only the person the reply answers may. Returns the reply.
|
|
619
|
+
*/
|
|
620
|
+
answerToolCall: (messageId: string, toolCallId: string, answer: {
|
|
621
|
+
selected?: string[];
|
|
622
|
+
text?: string;
|
|
623
|
+
}) => Promise<ChatMessage>;
|
|
624
|
+
/**
|
|
625
|
+
* Posts the user's message into a thread. `asCompany` writes it as a user of the thread's
|
|
626
|
+
* company (company-facing apps); agents then treat it as the company's message.
|
|
627
|
+
*/
|
|
628
|
+
create: (threadId: string, parts: UIMessagePart[], options?: {
|
|
629
|
+
asCompany?: boolean;
|
|
630
|
+
}) => Promise<ChatMessage>;
|
|
631
|
+
/**
|
|
632
|
+
* Stores a file for a message of the thread (in the files of the thread's company, at most 10 MB)
|
|
633
|
+
* and returns the `file` part to post with the message.
|
|
634
|
+
*/
|
|
635
|
+
uploadFile: (threadId: string, file: Blob & {
|
|
636
|
+
name?: string;
|
|
637
|
+
}) => Promise<UIFilePart>; /** The files the messages of a channel carry, newest first, each with its message and thread. */
|
|
638
|
+
files: (channelId: string) => Promise<ChannelMessageFile[]>;
|
|
639
|
+
/**
|
|
640
|
+
* The AI accounting of the agents' answers in a thread (tokens, model, reasoning, cost), oldest
|
|
641
|
+
* first. Only the channel owner's people get rows.
|
|
642
|
+
*/
|
|
643
|
+
usage: (threadId: string) => Promise<MessageUsage[]>; /** The content of a message's file. */
|
|
644
|
+
getFile: (messageId: string, partId: string) => Promise<MessageFileContent>; /** A message's file as a `Blob`, e.g. for an object URL to show or download it. */
|
|
645
|
+
getFileBlob: (messageId: string, partId: string) => Promise<Blob>;
|
|
646
|
+
};
|
|
647
|
+
/** Widgets of tool calls in messages: MCP Apps served by the plugins agents use. */
|
|
648
|
+
readonly widgets: {
|
|
649
|
+
/** The widget document of a tool call. */get: (messageId: string, toolCallId: string) => Promise<WidgetResource>; /** Calls a tool of the widget's plugin for the widget. */
|
|
650
|
+
callTool: (messageId: string, toolCallId: string, name: string, args?: Record<string, unknown>) => Promise<WidgetToolResult>;
|
|
651
|
+
/**
|
|
652
|
+
* Keeps what a widget told the conversation (`ui/update-model-context`) with the tool call's
|
|
653
|
+
* message: the widget's state and a text for the agent.
|
|
654
|
+
*/
|
|
655
|
+
updateContext: (messageId: string, toolCallId: string, context: {
|
|
656
|
+
text?: string;
|
|
657
|
+
structuredContent?: Record<string, unknown>;
|
|
658
|
+
}) => Promise<UIWidgetContextPart>;
|
|
659
|
+
};
|
|
660
|
+
/** The companies listed on a channel. */
|
|
661
|
+
readonly channelCompanies: {
|
|
662
|
+
/** The companies a channel lists now. */list: (channelId: string) => Promise<ChannelCompany[]>; /** The owner's customers (in Quartal IAM) that can still be listed on the channel. */
|
|
663
|
+
candidates: (channelId: string) => Promise<CompanySummary[]>; /** Lists a company on a channel. */
|
|
664
|
+
add: (channelId: string, companyId: string) => Promise<ChannelCompany>; /** Ends a listing now (soft expiry). */
|
|
665
|
+
end: (id: string) => Promise<void>;
|
|
666
|
+
};
|
|
667
|
+
/** Channel agent operations. */
|
|
668
|
+
readonly channelAgents: {
|
|
669
|
+
/** The agents attached to a channel. */list: (channelId: string) => Promise<ChannelAgentAssignment[]>; /** Attaches an agent a plugin defines (`agents/{agentName}.md` of `pluginId`) to a channel. */
|
|
670
|
+
attach: (channelId: string, pluginId: string, agentName: string) => Promise<ChannelAgentAssignment>; /** Changes an agent of the channel's definition (every channel made from it follows). */
|
|
671
|
+
update: (channelId: string, agentId: string, patch: ChannelAgentPatch) => Promise<ChannelAgentAssignment>; /** Detaches an agent. */
|
|
672
|
+
detach: (channelId: string, agentId: string) => Promise<void>; /** Runs one of the agent's schedules now, as if it were due; the replies come in the threads. */
|
|
673
|
+
runSchedule: (channelId: string, agentId: string, scheduleId: string) => Promise<void>;
|
|
674
|
+
};
|
|
675
|
+
/**
|
|
676
|
+
* Tests of the plugins a channel's agents use, as one of the channel's customers: the API calls
|
|
677
|
+
* them with the agent's token for that company, as in a scheduled run.
|
|
678
|
+
*/
|
|
679
|
+
readonly pluginTests: {
|
|
680
|
+
/** Makes the agent's token for the company and shows what it says (never the token). */createToken: (subject: PluginTestSubject) => Promise<PluginTestToken>; /** The tools the agent may use in its plugins. */
|
|
681
|
+
listTools: (subject: PluginTestSubject) => Promise<{
|
|
682
|
+
tools: PluginTestTool[];
|
|
683
|
+
problems: string[];
|
|
684
|
+
}>; /** Calls a tool as the agent would (or, with `forWidget`, as the tool's widget does). */
|
|
685
|
+
callTool: (subject: PluginTestSubject, pluginId: string, name: string, args?: Record<string, unknown>, forWidget?: boolean) => Promise<WidgetToolResult>; /** The widget document of a tool. */
|
|
686
|
+
getWidget: (subject: PluginTestSubject, pluginId: string, uri: string) => Promise<WidgetResource>;
|
|
687
|
+
};
|
|
688
|
+
/**
|
|
689
|
+
* The views of the Hub's front page besides the chats: the saved dashboards of the dashboards
|
|
690
|
+
* plugins the organization's channels use, each shown with its plugin's widget as the person.
|
|
691
|
+
*/
|
|
692
|
+
readonly homeViews: {
|
|
693
|
+
/** The organization's views, and the channels whose agents design them. */list: (owner: string, language?: string) => Promise<{
|
|
694
|
+
views: HomeView[];
|
|
695
|
+
channelIds: string[];
|
|
696
|
+
problems: string[];
|
|
697
|
+
}>; /** A view with its data now and its widget. */
|
|
698
|
+
show: (owner: string, pluginId: string, name: string, language?: string) => Promise<ShownHomeView>; /** The widget document of a view's plugin. */
|
|
699
|
+
getWidget: (owner: string, pluginId: string, uri: string) => Promise<WidgetResource>; /** Calls a tool of a view's plugin for its widget. */
|
|
700
|
+
callTool: (owner: string, pluginId: string, name: string, args?: Record<string, unknown>) => Promise<WidgetToolResult>;
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
//#endregion
|
|
704
|
+
//#region src/files/filesSource.d.ts
|
|
705
|
+
/** An API error as an {@link FsError}, so components branch on codes, not statuses. Anything else as is. */
|
|
706
|
+
declare function toFsError(e: unknown, address: string): unknown;
|
|
707
|
+
/** Bytes as base64 (chunked, so large files do not overflow the call stack). */
|
|
708
|
+
declare function bytesToBase64(bytes: Uint8Array): string;
|
|
709
|
+
/** Base64 as bytes. */
|
|
710
|
+
declare function base64ToBytes(base64: string): Uint8Array<ArrayBuffer>;
|
|
711
|
+
/** A blob's bytes as base64. */
|
|
712
|
+
declare function blobToBase64(blob: Blob): Promise<string>;
|
|
713
|
+
/** The file operations {@link filesSource} needs: those of a company's files, or of an organization's hosted plugins. */
|
|
714
|
+
type FilesResource = Omit<MessagesApi['files'], 'forOwner' | 'createDemo'>;
|
|
715
|
+
/**
|
|
716
|
+
* The files of one owner (a company id, or `system`) as a {@link QFsSource}, the filesystem the
|
|
717
|
+
* file components of `@quartal/ui-core` work on. Every failure is an {@link FsError}. The API has no
|
|
718
|
+
* `watch` or `glob` yet, so the components fall back to a refresh button and to searching the loaded
|
|
719
|
+
* folders.
|
|
720
|
+
* @param files The files resource of the API client.
|
|
721
|
+
* @param owner The owner: a company id, or `system`.
|
|
722
|
+
*/
|
|
723
|
+
declare function filesSource(files: FilesResource, owner: string): QFsSource;
|
|
724
|
+
//#endregion
|
|
725
|
+
export { type AgentPatch, AgentsApi, ApiError, type ChannelAgentPatch, type ChannelCreateInput, ChannelsApi, type ChannelsFilter, type ChannelsRefreshResult, type ClientConfig, type FilesResource, HttpClient, type IChannelsApi, type ICrudApiBase, ID_FORMAT_PATTERN, type IModelsApi, type LiveEventHandler, LiveEvents, MessagesApi, ModelsApi, type ModelsFilter, type ODataQuery, type Query, type RequestOptions, type ThreadPatch, type TokenProvider, base64ToBytes, blobToBase64, bytesToBase64, configureClient, filesSource, isValidId, loadClientConfig, toFsError };
|