@quartal/hub-plugin 0.0.0-stage → 0.2.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/dist/mod.d.ts ADDED
@@ -0,0 +1,683 @@
1
+ //#region src/agentRef.d.ts
2
+ /**
3
+ * Agent references of a channel definition: `<name>` (an agent of the channel's own plugin) or
4
+ * `<plugin id>/<name>` (an agent of another plugin).
5
+ *
6
+ * @module
7
+ */
8
+ /** An agent reference resolved to its plugin and file name. */
9
+ interface ResolvedAgentRef {
10
+ /** The plugin the agent is defined in. */
11
+ pluginId: string;
12
+ /** The agent's name: `agents/<name>.md` of the plugin. */
13
+ agentName: string;
14
+ }
15
+ /**
16
+ * Resolves an agent reference of a channel definition.
17
+ * @param ref `<name>` or `<plugin id>/<name>`.
18
+ * @param ownPluginId The id of the plugin the definition is in.
19
+ * @returns The plugin and the agent, or undefined for a reference that is not well formed.
20
+ */
21
+ declare function resolveAgentRef(ref: string, ownPluginId: string): ResolvedAgentRef | undefined;
22
+ //#endregion
23
+ //#region src/hubTools.d.ts
24
+ /**
25
+ * The Hub's own agent tools: the tools every agent in a channel gets from the Hub itself,
26
+ * independent of plugins (thread, files, memory, plan, company context, web). A channel definition
27
+ * turns them on, off or behind the person's approval per agent (`hubTools` of an agent entry); each tool has a default.
28
+ *
29
+ * @module
30
+ */
31
+ /**
32
+ * What a Hub tool does when the model calls it.
33
+ *
34
+ * - `allow` — runs.
35
+ * - `ask` — runs only after the person the agent answers approves the call.
36
+ * - `off` — not offered to the model.
37
+ */
38
+ type HubToolLevel = 'allow' | 'ask' | 'off';
39
+ /**
40
+ * A setting of a Hub tool or a group of them in a channel definition: a level, or `on` for the
41
+ * tool's own level when switched on (e.g. reads `allow`, writes `ask`).
42
+ */
43
+ type HubToolSetting = HubToolLevel | 'on';
44
+ /** Every setting value. */
45
+ declare const HUB_TOOL_SETTINGS: readonly HubToolSetting[];
46
+ /**
47
+ * A group of Hub tools, which a definition can switch as one.
48
+ *
49
+ * - `thread` — the thread and its people: status, questions, hand-over, posts, other threads.
50
+ * - `files` — the company's file store.
51
+ * - `memory` — what the agent remembers of the company, as files.
52
+ * - `plan` — a visible checklist of a multi-step run.
53
+ * - `context` — the company and the channel, read only.
54
+ * - `web` — reading pages on the web.
55
+ */
56
+ type HubToolGroup = 'thread' | 'files' | 'memory' | 'plan' | 'context' | 'web';
57
+ /** Every group. */
58
+ declare const HUB_TOOL_GROUPS: readonly HubToolGroup[];
59
+ /** A Hub tool in the catalogue. */
60
+ interface HubToolInfo {
61
+ /** The name the model calls it by. */
62
+ name: string;
63
+ /** Its group. */
64
+ group: HubToolGroup;
65
+ /** Its level when the definition says nothing. */
66
+ level: HubToolLevel;
67
+ /** Its level when switched `on`; {@link level} when unset (or `allow` for a tool that is off by default). */
68
+ onLevel?: HubToolLevel;
69
+ /** Only reads. */
70
+ readOnly?: boolean;
71
+ }
72
+ /** Every Hub tool, by group. */
73
+ declare const HUB_TOOLS: readonly HubToolInfo[];
74
+ /** The catalogue entry of a Hub tool; undefined for a name that is not one. */
75
+ declare function hubTool(name: string): HubToolInfo | undefined;
76
+ /** True for a Hub tool's or a group's name: a valid key of `hubTools`. */
77
+ declare function isHubToolKey(key: string): boolean;
78
+ /**
79
+ * The level of every Hub tool for an agent: each tool's default, then its group's setting, then its
80
+ * own; a tool in `approve` asks.
81
+ * @param settings `hubTools` of the agent's entry in the definition.
82
+ * @param approve `approve` of the entry: tools that ask.
83
+ * @returns The level by tool name, for every tool in the catalogue.
84
+ */
85
+ declare function resolveHubTools(settings: Record<string, HubToolSetting> | undefined, approve?: readonly string[]): Map<string, HubToolLevel>;
86
+ //#endregion
87
+ //#region src/LocalizedText.d.ts
88
+ /**
89
+ * A text in a channel definition: one string for every language, or a string per language.
90
+ *
91
+ * @module
92
+ */
93
+ /** The languages of Quartal Hub. */
94
+ type HubLanguage = 'fi' | 'en' | 'sv';
95
+ /** The languages of Quartal Hub, the fallback first. */
96
+ declare const HUB_LANGUAGES: readonly HubLanguage[];
97
+ /** A text: the same in every language, or per language (`{ fi, en, sv }`, `fi` is the fallback). */
98
+ type LocalizedText = string | Partial<Record<HubLanguage, string>>;
99
+ /**
100
+ * The text in a language: the language's own, else Finnish, else the first one there is.
101
+ * @param text The text.
102
+ * @param language The wanted language (`fi`, `en`, `sv`; a longer tag such as `en-GB` works too).
103
+ * @returns The text, or an empty string when there is none.
104
+ */
105
+ declare function localize(text: LocalizedText | undefined, language?: string): string;
106
+ /**
107
+ * Whether a value is a localized text: a string, or an object of known languages with strings.
108
+ * @param value The value to test.
109
+ */
110
+ declare function isLocalizedText(value: unknown): value is LocalizedText;
111
+ //#endregion
112
+ //#region src/ChannelDefinition.d.ts
113
+ /**
114
+ * What a thread status means to the product, whatever the channel calls it. Statistics are counted
115
+ * by base status, and it gives a status its default icon and color.
116
+ *
117
+ * - `unread` — nobody has taken the thread yet.
118
+ * - `in_progress` — someone is working on it.
119
+ * - `handled` — the work is done.
120
+ * - `archived` — put aside; kept, not worked on.
121
+ * - `error` — something failed and needs attention.
122
+ * - `warning` — needs a look, but nothing has failed.
123
+ */
124
+ type ChannelBaseStatus = 'unread' | 'in_progress' | 'handled' | 'archived' | 'error' | 'warning';
125
+ /** Every base status, in the order statistics show them. */
126
+ declare const CHANNEL_BASE_STATUSES: readonly ChannelBaseStatus[];
127
+ /**
128
+ * An event that makes an agent answer in a thread.
129
+ *
130
+ * - `manual` — never automatically; only when invoked from the UI or API.
131
+ * - `create_thread` — the first message of a new thread.
132
+ * - `company_message` — a message by a user of the customer company.
133
+ * - `advisor_message` — a message by an advisor.
134
+ * - `assign` — the message mentions the agent (`@agent-id`).
135
+ * - `status_change` — a person changed the thread's status.
136
+ * - `schedule` — time-based: the agent's `schedules` (implied by them).
137
+ */
138
+ type ChannelAgentTrigger = 'manual' | 'create_thread' | 'company_message' | 'advisor_message' | 'assign' | 'status_change' | 'schedule';
139
+ /** Every trigger. */
140
+ declare const CHANNEL_AGENT_TRIGGERS: readonly ChannelAgentTrigger[];
141
+ /**
142
+ * What kind of conversation a channel's threads are.
143
+ *
144
+ * - `multi-party` — several people (advisors, company users) and agents in one thread, in Quartal's
145
+ * own chat.
146
+ * - `copilot` — one person and one agent per thread; the person's client can be any AG-UI
147
+ * client (`POST /ag-ui/{channel}` of the Messages API). Advisors still see the threads in the Hub.
148
+ */
149
+ type ChannelKind = 'multi-party' | 'copilot';
150
+ /** Every channel kind; the first is the default. */
151
+ declare const CHANNEL_KINDS: readonly ChannelKind[];
152
+ /** A status the threads of the channel can be in. The first is a new thread's. */
153
+ interface ChannelStatusDefinition {
154
+ /** What a thread stores; unique in the definition. */
155
+ key: string;
156
+ /** The status' name. */
157
+ text: LocalizedText;
158
+ /** A longer description, for pickers and tooltips. */
159
+ description?: LocalizedText;
160
+ /** What the status means to the product. */
161
+ baseStatus: ChannelBaseStatus;
162
+ /** A Material Symbols icon name; the base status' icon when unset. */
163
+ icon?: string;
164
+ /** A Bootstrap theme color name or a CSS color; the base status' color when unset. */
165
+ color?: string;
166
+ }
167
+ /**
168
+ * How an agent calls a plugin.
169
+ *
170
+ * - `none` — anonymously.
171
+ * - `token` — with a token: in an agent's reply the agent's own token for the thread's company
172
+ * (Quartal IAM's agent token), in a widget of the chat the viewer's token.
173
+ */
174
+ type ChannelPluginAuth = 'none' | 'token';
175
+ /** A plugin an agent of the channel uses, besides its own plugin. */
176
+ interface ChannelAgentPlugin {
177
+ /** The plugin's id: a plugin on the organization's plugin host or in the catalog. */
178
+ id: string;
179
+ /** The tools the agent may use; unset for every tool the plugin offers. */
180
+ tools?: string[];
181
+ /** The skills the agent may use; unset for every skill the plugin offers. */
182
+ skills?: string[];
183
+ /** Whether the plugin's widgets are shown in the chat (default true). */
184
+ widgets?: boolean;
185
+ /** How the agent calls the plugin (default `none`). */
186
+ auth?: ChannelPluginAuth;
187
+ }
188
+ /** Where a schedule's runs go in each company: a new message in the schedule's one thread, or a new thread each time. */
189
+ type ChannelScheduleTarget = 'message' | 'thread';
190
+ /** Every schedule target, in the order they are offered. */
191
+ declare const CHANNEL_SCHEDULE_TARGETS: readonly ChannelScheduleTarget[];
192
+ /**
193
+ * A time-based run of an agent: at the times of `cron`, the agent gets `message` in every customer
194
+ * company the schedule names (e.g. on the 5th of each month, "ask for the receipts missing from
195
+ * last month"). The agent acts for each company with its own agent token: nobody started the run.
196
+ */
197
+ interface ChannelAgentSchedule {
198
+ /** Names the schedule in the definition; unique per agent. */
199
+ id: string;
200
+ /** Five-field cron expression (`minute hour day-of-month month day-of-week`), e.g. `0 9 5 * *`. */
201
+ cron: string;
202
+ /** IANA time zone the expression is read in (default `Europe/Helsinki`). */
203
+ timeZone?: string;
204
+ /** What the agent is asked to do on each run: the first message of the thread it opens. */
205
+ message: string;
206
+ /** The thread's title; the schedule's id when unset. */
207
+ threadTitle?: string;
208
+ /**
209
+ * The companies it runs for: `all` (default) for every customer the channel lists, or the
210
+ * directory ids of some of them (ids the channel no longer lists are skipped).
211
+ */
212
+ companies?: 'all' | string[];
213
+ /**
214
+ * Where each run goes (default `message`): `message` answers in the schedule's one thread per
215
+ * company (opened on the first run), `thread` opens a new thread for every run.
216
+ */
217
+ target?: ChannelScheduleTarget;
218
+ }
219
+ /** An agent of the channel. */
220
+ interface ChannelAgentDefinition {
221
+ /**
222
+ * The agent: `<name>` for `agents/<name>.md` of this plugin, `<plugin id>/<name>` for an agent of
223
+ * another plugin.
224
+ */
225
+ agent: string;
226
+ /** The events the agent answers. */
227
+ triggers: ChannelAgentTrigger[];
228
+ /** Whether the agent answers at all (default true). */
229
+ active?: boolean;
230
+ /** Instructions for this channel, added to the agent's prompt (e.g. when to set which status). */
231
+ instructions?: string;
232
+ /**
233
+ * Tools that run only after the person the agent answers approves the call, by the names the
234
+ * model sees (e.g. `thread_set_status`, a plugin's `bookReceipt`). The reply pauses until they answer.
235
+ */
236
+ approve?: string[];
237
+ /**
238
+ * The other plugins the agent uses. Its own plugin is always the first, called with a token when
239
+ * it is the channel's own plugin; the agent's file narrows its tools and skills.
240
+ */
241
+ plugins?: ChannelAgentPlugin[];
242
+ /**
243
+ * The Hub's own tools for this agent, by tool or group name (`files`, `files_write`, `web`…):
244
+ * `allow`, `ask` (the `approve` flow), `off`, or `on` for the tool's own level when switched on.
245
+ * Unset tools keep their defaults (`HUB_TOOLS`).
246
+ */
247
+ hubTools?: Record<string, HubToolSetting>;
248
+ /** Time-based runs of the agent. */
249
+ schedules?: ChannelAgentSchedule[];
250
+ }
251
+ /** The definition of a channel: `com.quartal.hub/channel.json`. */
252
+ interface ChannelDefinition {
253
+ /** The JSON Schema of the file. */
254
+ $schema?: string;
255
+ /** The name a channel made from the definition gets. */
256
+ title: LocalizedText;
257
+ /** What kind of conversation the threads are (default `multi-party`). A copilot channel has one agent. */
258
+ kind?: ChannelKind;
259
+ /** What the channel is for. */
260
+ description?: LocalizedText;
261
+ /** A Material Symbols icon name. */
262
+ icon?: string;
263
+ /** A Bootstrap theme color name or a CSS color. */
264
+ color?: string;
265
+ /** A picture shown instead of the icon: a path in the plugin (`public/avatar.png`) or a URL. */
266
+ avatar?: string;
267
+ /** The statuses of the threads, in the order the views show them; none for the default three. */
268
+ statuses: ChannelStatusDefinition[];
269
+ /** The agents, in the order they are tried. */
270
+ agents: ChannelAgentDefinition[];
271
+ }
272
+ //#endregion
273
+ //#region src/channelDefinitionSchema.d.ts
274
+ /** The JSON Schema (draft 2020-12) of a channel definition. */
275
+ declare const channelDefinitionSchema: {
276
+ readonly $schema: "https://json-schema.org/draft/2020-12/schema";
277
+ readonly $id: "https://hub.quartal.com/schemas/channel-1.0.schema.json";
278
+ readonly title: "Quartal Hub channel definition";
279
+ readonly type: "object";
280
+ readonly required: readonly ["title"];
281
+ readonly properties: {
282
+ readonly $schema: {
283
+ readonly type: "string";
284
+ };
285
+ readonly title: {
286
+ readonly description: "The name a channel made from the definition gets.";
287
+ readonly oneOf: ({
288
+ type: string;
289
+ properties?: undefined;
290
+ additionalProperties?: undefined;
291
+ } | {
292
+ type: string;
293
+ properties: {
294
+ fi: {
295
+ type: string;
296
+ };
297
+ en: {
298
+ type: string;
299
+ };
300
+ sv: {
301
+ type: string;
302
+ };
303
+ };
304
+ additionalProperties: boolean;
305
+ })[];
306
+ };
307
+ readonly description: {
308
+ oneOf: ({
309
+ type: string;
310
+ properties?: undefined;
311
+ additionalProperties?: undefined;
312
+ } | {
313
+ type: string;
314
+ properties: {
315
+ fi: {
316
+ type: string;
317
+ };
318
+ en: {
319
+ type: string;
320
+ };
321
+ sv: {
322
+ type: string;
323
+ };
324
+ };
325
+ additionalProperties: boolean;
326
+ })[];
327
+ };
328
+ readonly kind: {
329
+ readonly enum: readonly ChannelKind[];
330
+ readonly description: "multi-party (default): people and agents in Quartal's chat; copilot: one person and one agent per thread, open to AG-UI clients.";
331
+ };
332
+ readonly icon: {
333
+ readonly type: "string";
334
+ readonly description: "A Material Symbols icon name.";
335
+ };
336
+ readonly color: {
337
+ readonly type: "string";
338
+ readonly description: "A Bootstrap theme color name or a CSS color.";
339
+ };
340
+ readonly avatar: {
341
+ readonly type: "string";
342
+ readonly description: "A picture shown instead of the icon: a path in the plugin or a URL.";
343
+ };
344
+ readonly statuses: {
345
+ readonly type: "array";
346
+ readonly description: "The thread statuses, in view order; the first is a new thread's.";
347
+ readonly items: {
348
+ readonly type: "object";
349
+ readonly required: readonly ["key", "text", "baseStatus"];
350
+ readonly properties: {
351
+ readonly key: {
352
+ readonly type: "string";
353
+ readonly pattern: "^[a-z0-9][a-z0-9_-]*$";
354
+ };
355
+ readonly text: {
356
+ oneOf: ({
357
+ type: string;
358
+ properties?: undefined;
359
+ additionalProperties?: undefined;
360
+ } | {
361
+ type: string;
362
+ properties: {
363
+ fi: {
364
+ type: string;
365
+ };
366
+ en: {
367
+ type: string;
368
+ };
369
+ sv: {
370
+ type: string;
371
+ };
372
+ };
373
+ additionalProperties: boolean;
374
+ })[];
375
+ };
376
+ readonly description: {
377
+ oneOf: ({
378
+ type: string;
379
+ properties?: undefined;
380
+ additionalProperties?: undefined;
381
+ } | {
382
+ type: string;
383
+ properties: {
384
+ fi: {
385
+ type: string;
386
+ };
387
+ en: {
388
+ type: string;
389
+ };
390
+ sv: {
391
+ type: string;
392
+ };
393
+ };
394
+ additionalProperties: boolean;
395
+ })[];
396
+ };
397
+ readonly baseStatus: {
398
+ readonly enum: readonly ChannelBaseStatus[];
399
+ };
400
+ readonly icon: {
401
+ readonly type: "string";
402
+ };
403
+ readonly color: {
404
+ readonly type: "string";
405
+ };
406
+ };
407
+ readonly additionalProperties: false;
408
+ };
409
+ };
410
+ readonly agents: {
411
+ readonly type: "array";
412
+ readonly items: {
413
+ readonly type: "object";
414
+ readonly required: readonly ["agent", "triggers"];
415
+ readonly properties: {
416
+ readonly agent: {
417
+ readonly type: "string";
418
+ readonly pattern: "^[a-z0-9][a-z0-9._-]*(/[a-z0-9][a-z0-9._-]*)?$";
419
+ readonly description: "<name> or <plugin id>/<name>";
420
+ };
421
+ readonly triggers: {
422
+ readonly type: "array";
423
+ readonly items: {
424
+ readonly enum: readonly ChannelAgentTrigger[];
425
+ };
426
+ readonly uniqueItems: true;
427
+ };
428
+ readonly active: {
429
+ readonly type: "boolean";
430
+ };
431
+ readonly instructions: {
432
+ readonly type: "string";
433
+ };
434
+ readonly approve: {
435
+ readonly type: "array";
436
+ readonly items: {
437
+ readonly type: "string";
438
+ readonly minLength: 1;
439
+ };
440
+ readonly uniqueItems: true;
441
+ readonly description: "Tools that run only after the person the agent answers approves the call.";
442
+ };
443
+ readonly plugins: {
444
+ readonly type: "array";
445
+ readonly items: {
446
+ readonly type: "object";
447
+ readonly required: readonly ["id"];
448
+ readonly properties: {
449
+ readonly id: {
450
+ readonly type: "string";
451
+ readonly minLength: 1;
452
+ };
453
+ readonly tools: {
454
+ readonly type: "array";
455
+ readonly items: {
456
+ readonly type: "string";
457
+ };
458
+ };
459
+ readonly skills: {
460
+ readonly type: "array";
461
+ readonly items: {
462
+ readonly type: "string";
463
+ };
464
+ };
465
+ readonly widgets: {
466
+ readonly type: "boolean";
467
+ };
468
+ readonly auth: {
469
+ readonly enum: readonly ["none", "token"];
470
+ };
471
+ };
472
+ readonly additionalProperties: false;
473
+ };
474
+ };
475
+ readonly hubTools: {
476
+ readonly type: "object";
477
+ readonly description: "The Hub's own tools for this agent, by tool or group: allow, ask (approval), off, or on (the tool's own level).";
478
+ readonly propertyNames: {
479
+ readonly enum: readonly string[];
480
+ };
481
+ readonly additionalProperties: {
482
+ readonly enum: readonly HubToolSetting[];
483
+ };
484
+ };
485
+ readonly schedules: {
486
+ readonly type: "array";
487
+ readonly description: "Time-based runs: at each time, the agent gets the message in each customer company the schedule names, acting for the company with its own agent token.";
488
+ readonly items: {
489
+ readonly type: "object";
490
+ readonly required: readonly ["id", "cron", "message"];
491
+ readonly properties: {
492
+ readonly id: {
493
+ readonly type: "string";
494
+ readonly pattern: "^[a-z0-9][a-z0-9_-]*$";
495
+ };
496
+ readonly cron: {
497
+ readonly type: "string";
498
+ readonly description: "minute hour day-of-month month day-of-week, e.g. \"0 9 5 * *\".";
499
+ };
500
+ readonly timeZone: {
501
+ readonly type: "string";
502
+ readonly description: "IANA time zone (default Europe/Helsinki).";
503
+ };
504
+ readonly message: {
505
+ readonly type: "string";
506
+ readonly minLength: 1;
507
+ };
508
+ readonly threadTitle: {
509
+ readonly type: "string";
510
+ };
511
+ readonly companies: {
512
+ readonly description: "The companies it runs for: \"all\" (default) for every customer the channel lists, or their directory ids.";
513
+ readonly oneOf: readonly [{
514
+ readonly const: "all";
515
+ }, {
516
+ readonly type: "array";
517
+ readonly items: {
518
+ readonly type: "string";
519
+ readonly pattern: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
520
+ };
521
+ readonly uniqueItems: true;
522
+ }];
523
+ };
524
+ readonly target: {
525
+ readonly enum: readonly ChannelScheduleTarget[];
526
+ readonly description: "Where each run goes (default message): a new message in one thread per company, or a new thread each time.";
527
+ };
528
+ };
529
+ readonly additionalProperties: false;
530
+ };
531
+ };
532
+ };
533
+ readonly additionalProperties: false;
534
+ };
535
+ };
536
+ };
537
+ readonly additionalProperties: false;
538
+ };
539
+ //#endregion
540
+ //#region src/channelPluginFiles.d.ts
541
+ /** What a new channel plugin starts with. */
542
+ interface ChannelPluginOptions {
543
+ /** The channel's name. */
544
+ title: LocalizedText;
545
+ /** What the channel is for. */
546
+ description?: LocalizedText;
547
+ /** A Material Symbols icon name. */
548
+ icon?: string;
549
+ /** A Bootstrap theme color name or a CSS color. */
550
+ color?: string;
551
+ /** The thread statuses; none for the default three. */
552
+ statuses?: ChannelDefinition['statuses'];
553
+ /** The default agent's system prompt. */
554
+ prompt?: string;
555
+ /** The default agent's model (`<provider>/<id>`); the Hub's default model when unset. */
556
+ model?: string;
557
+ /** The events the default agent answers (default: the customers' messages). */
558
+ triggers?: ChannelAgentTrigger[];
559
+ /** Instructions for the default agent in this channel. */
560
+ instructions?: string;
561
+ /** The other plugins the default agent uses. */
562
+ plugins?: ChannelAgentPlugin[];
563
+ /** The plugin's `qrtl.config.json` as the scaffold wrote it; title and description are kept from the options. */
564
+ baseConfig?: Record<string, unknown>;
565
+ }
566
+ /**
567
+ * The files of a new channel plugin, by path: `com.quartal.hub/channel.json`, `agents/default.md`,
568
+ * `qrtl.config.json` (Hub sign-in, the start page in the Hub) and `README.md`.
569
+ * @param options What the channel starts with.
570
+ */
571
+ declare function channelPluginFiles(options: ChannelPluginOptions): Record<string, string>;
572
+ //#endregion
573
+ //#region src/constants.d.ts
574
+ /**
575
+ * Where Quartal Hub's extension lives in a plugin.
576
+ *
577
+ * @module
578
+ */
579
+ /** The Agent Plugins extension namespace of Quartal Hub: the folder and the `plugin.json` key. */
580
+ declare const HUB_EXTENSION_NAMESPACE = "com.quartal.hub";
581
+ /** The channel definition's path in a plugin. */
582
+ declare const CHANNEL_DEFINITION_FILE = "com.quartal.hub/channel.json";
583
+ /** The JSON Schema of the channel definition. */
584
+ declare const CHANNEL_DEFINITION_SCHEMA_URL = "https://hub.quartal.com/schemas/channel-1.0.schema.json";
585
+ /** The agent a new channel plugin starts with (`agents/default.md`). */
586
+ declare const DEFAULT_CHANNEL_AGENT = "default";
587
+ //#endregion
588
+ //#region src/cron.d.ts
589
+ /**
590
+ * Five-field cron expressions (`minute hour day-of-month month day-of-week`) for the schedules of
591
+ * channel agents. Fields take `*`, numbers, ranges `a-b`, lists `a,b` and steps `* /n` or `a-b/n`
592
+ * (written without the space). Day of week is 0–6 from Sunday (7 is Sunday too). When both day of
593
+ * month and day of week are restricted, either one matching is enough (as in cron).
594
+ *
595
+ * @module
596
+ */
597
+ /** The time zone schedules are read in when the definition names none. */
598
+ declare const DEFAULT_SCHEDULE_TIME_ZONE = "Europe/Helsinki";
599
+ /** A parsed cron expression. */
600
+ interface CronSchedule {
601
+ /** True when the expression matches the minute `date` falls in, read in `timeZone`. */
602
+ matches(date: Date, timeZone?: string): boolean;
603
+ }
604
+ /**
605
+ * Parses a five-field cron expression.
606
+ * @param expression E.g. `0 9 5 * *` (09:00 on the 5th of every month).
607
+ * @throws When the expression is not valid; the message says which field.
608
+ */
609
+ declare function parseCron(expression: string): CronSchedule;
610
+ /** The reason a cron expression is not valid; undefined when it is. */
611
+ declare function cronError(expression: string): string | undefined;
612
+ /** True when `timeZone` is a time zone the runtime knows. */
613
+ declare function isTimeZone(timeZone: string): boolean;
614
+ //#endregion
615
+ //#region src/hubSite.d.ts
616
+ /**
617
+ * The Hub settings of a plugin's `qrtl.config.json`: sign-in with Quartal Hub, and what the
618
+ * plugin's web site serves. Docs are shown in the Hub, not on the plugin's own site.
619
+ *
620
+ * @module
621
+ */
622
+ /**
623
+ * What a Hub plugin's web site is.
624
+ *
625
+ * - `hub` — no pages of its own: `/` sends the browser to the plugin's page in the Hub
626
+ * ({@link HUB_PLUGIN_PAGE}).
627
+ * - `app` — end-user pages (`src/pages/**`, container pages for widgets); every page needs a sign-in
628
+ * with a Hub account, except the `publicPages`.
629
+ */
630
+ type HubSiteKind = 'hub' | 'app';
631
+ /** The `auth` and `site` settings of a Hub plugin (the subset of `qrtl.config` they set). */
632
+ interface HubPluginSettings {
633
+ /** Sign-in is always Quartal Hub. */
634
+ auth: 'quartal-hub';
635
+ /** The web site (`qrtl.config` `site`). */
636
+ site: {
637
+ /** What `/` serves. */root: 'pages' | {
638
+ redirect: string;
639
+ }; /** Who may open the pages. */
640
+ access?: 'user'; /** Pages anyone may open (path globs). */
641
+ public?: string[];
642
+ };
643
+ }
644
+ /**
645
+ * The placeholder of the Hub's address in a plugin's settings. The plugin host replaces it with the
646
+ * address of the Hub it serves (`HOST_HUB_URL`), so the same plugin works from any Hub and moves
647
+ * between repositories as it is.
648
+ */
649
+ declare const HUB_URL_PLACEHOLDER = "{hub}";
650
+ /**
651
+ * A plugin's page in the Hub, as the start page of a `hub` plugin: `{hub}` is the Hub's address
652
+ * (filled by the plugin host), `{name}` the plugin's id (filled by the plugin runtime).
653
+ */
654
+ declare const HUB_PLUGIN_PAGE = "{hub}/app/plugins/hosted/{name}";
655
+ /** Options of {@link hubPluginSettings}. */
656
+ interface HubPluginSettingsOptions {
657
+ /** For `app`: the pages anyone may open, as path globs (`/register/**`), e.g. a registration form. */
658
+ publicPages?: string[];
659
+ }
660
+ /**
661
+ * The `auth` and `site` settings for a Hub plugin's `qrtl.config.json`.
662
+ * @param kind What the web site is.
663
+ * @param options The public pages.
664
+ */
665
+ declare function hubPluginSettings(kind: HubSiteKind, options?: HubPluginSettingsOptions): HubPluginSettings;
666
+ //#endregion
667
+ //#region src/parseChannelDefinition.d.ts
668
+ /** The outcome of {@link parseChannelDefinition}. */
669
+ type ChannelDefinitionResult = {
670
+ /** The definition is valid. */ok: true; /** The definition, normalized: `statuses` and `agents` always set, unknown fields dropped. */
671
+ definition: ChannelDefinition;
672
+ } | {
673
+ /** The definition is not valid. */ok: false; /** What is wrong, each with the JSON path of the field (`agents[0].triggers`). */
674
+ errors: string[];
675
+ };
676
+ /**
677
+ * Parses and checks a channel definition.
678
+ * @param input The file's text or its parsed JSON.
679
+ * @param ownPluginId The id of the plugin the definition is in (resolves `<name>` agent references).
680
+ */
681
+ declare function parseChannelDefinition(input: string | unknown, ownPluginId: string): ChannelDefinitionResult;
682
+ //#endregion
683
+ export { CHANNEL_AGENT_TRIGGERS, CHANNEL_BASE_STATUSES, CHANNEL_DEFINITION_FILE, CHANNEL_DEFINITION_SCHEMA_URL, CHANNEL_KINDS, CHANNEL_SCHEDULE_TARGETS, ChannelAgentDefinition, ChannelAgentPlugin, ChannelAgentSchedule, ChannelAgentTrigger, ChannelBaseStatus, ChannelDefinition, ChannelDefinitionResult, ChannelKind, ChannelPluginAuth, ChannelPluginOptions, ChannelScheduleTarget, ChannelStatusDefinition, CronSchedule, DEFAULT_CHANNEL_AGENT, DEFAULT_SCHEDULE_TIME_ZONE, HUB_EXTENSION_NAMESPACE, HUB_LANGUAGES, HUB_PLUGIN_PAGE, HUB_TOOLS, HUB_TOOL_GROUPS, HUB_TOOL_SETTINGS, HUB_URL_PLACEHOLDER, HubLanguage, HubPluginSettings, HubPluginSettingsOptions, HubSiteKind, HubToolGroup, HubToolInfo, HubToolLevel, HubToolSetting, LocalizedText, ResolvedAgentRef, channelDefinitionSchema, channelPluginFiles, cronError, hubPluginSettings, hubTool, isHubToolKey, isLocalizedText, isTimeZone, localize, parseChannelDefinition, parseCron, resolveAgentRef, resolveHubTools };