@frockbot/applet-sdk 0.7.40 → 0.7.41
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/README.md +1 -1
- package/package.json +1 -1
- package/plugin/index.d.ts +55 -0
- package/src/build/plugin.ts +3 -0
package/README.md
CHANGED
|
@@ -44,7 +44,7 @@ which `applet_create` writes through the Workspace.
|
|
|
44
44
|
|
|
45
45
|
A Plugin (ADR 0026) is written against `@frockbot/applet-sdk/plugin`, which
|
|
46
46
|
is declarations only: `plugin.ts` exports `tools` and `execute`, and may
|
|
47
|
-
export `hooks`, `services` and `
|
|
47
|
+
export `hooks`, `services`, `triggers` and `views`, beside a `plugin.json` descriptor.
|
|
48
48
|
`tools` may be empty — a Plugin that only serves hooks is admissible, because
|
|
49
49
|
the kernel's own descriptor contract admits one.
|
|
50
50
|
`runPluginBuildV1(directory, { mode, id })` is four stages — `descriptor`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frockbot/applet-sdk",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.41",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Authoring SDK for FrockBot Applets: schema-first Durable Object server, TanStack DB client, component kit, linter, and the build pipeline.",
|
package/plugin/index.d.ts
CHANGED
|
@@ -379,6 +379,56 @@ export type PluginTrigger = (
|
|
|
379
379
|
/** Every trigger the module exports, by the name `plugin.json` declares. */
|
|
380
380
|
export type PluginTriggers = Record<string, PluginTrigger>;
|
|
381
381
|
|
|
382
|
+
/**
|
|
383
|
+
* One node of a section a Plugin renders on its card. The host draws it with
|
|
384
|
+
* its own widgets; a Plugin ships no markup. `field` and `embed` nodes are
|
|
385
|
+
* not accepted from a Plugin and are left out when the card is drawn.
|
|
386
|
+
*/
|
|
387
|
+
export type PluginViewNode =
|
|
388
|
+
| {
|
|
389
|
+
type: "text";
|
|
390
|
+
text: string;
|
|
391
|
+
style?: "body" | "heading" | "label" | "status";
|
|
392
|
+
}
|
|
393
|
+
| {
|
|
394
|
+
type: "group";
|
|
395
|
+
orientation: "row" | "column";
|
|
396
|
+
title?: string;
|
|
397
|
+
collapsed?: boolean;
|
|
398
|
+
children: PluginViewNode[];
|
|
399
|
+
}
|
|
400
|
+
| {
|
|
401
|
+
/**
|
|
402
|
+
* A control. `actionId` names one of this Plugin's tools; pressing it
|
|
403
|
+
* runs that tool with `input`, outside any Turn, and the section is
|
|
404
|
+
* rendered again.
|
|
405
|
+
*/
|
|
406
|
+
type: "action";
|
|
407
|
+
actionId: string;
|
|
408
|
+
label: string;
|
|
409
|
+
style?: "primary" | "secondary" | "danger";
|
|
410
|
+
input?: { [key: string]: unknown };
|
|
411
|
+
}
|
|
412
|
+
| {
|
|
413
|
+
type: "list";
|
|
414
|
+
empty?: string;
|
|
415
|
+
rows: { id: string; node: PluginViewNode; selected?: boolean }[];
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
/** What a view returns: the section's tree. Return nothing to show no section. */
|
|
419
|
+
export interface PluginViewDocument {
|
|
420
|
+
root: PluginViewNode;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/** A view: renders one declared surface with the same `ctx` a tool call gets. */
|
|
424
|
+
export type PluginView = (
|
|
425
|
+
ctx: PluginContext,
|
|
426
|
+
) =>
|
|
427
|
+
| Promise<PluginViewDocument | undefined | void>
|
|
428
|
+
| PluginViewDocument
|
|
429
|
+
| undefined
|
|
430
|
+
| void;
|
|
431
|
+
|
|
382
432
|
/**
|
|
383
433
|
* A tool call's answer. A string is handed to the Bot as it is; anything else
|
|
384
434
|
* is JSON-serialized. Throw to answer with an error the Bot can read — the
|
|
@@ -409,4 +459,9 @@ export interface PluginModule {
|
|
|
409
459
|
/** Values other Plugins that `consume` a service of the same name receive. */
|
|
410
460
|
services?: Record<string, unknown>;
|
|
411
461
|
triggers?: PluginTriggers;
|
|
462
|
+
/**
|
|
463
|
+
* One view per surface id declared under `views` in `plugin.json`, each
|
|
464
|
+
* with slot `settings.sections`: a section drawn on this Plugin's card.
|
|
465
|
+
*/
|
|
466
|
+
views?: Record<string, PluginView>;
|
|
412
467
|
}
|
package/src/build/plugin.ts
CHANGED
|
@@ -51,6 +51,7 @@ export interface PluginDescriptionV1 {
|
|
|
51
51
|
hooks: string[];
|
|
52
52
|
services: string[];
|
|
53
53
|
triggers: string[];
|
|
54
|
+
views: string[];
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
export interface PluginBuildManifestV1 extends PluginDescriptionV1 {
|
|
@@ -301,6 +302,7 @@ function describe() {
|
|
|
301
302
|
hooks: names(plugin.hooks, "hooks"),
|
|
302
303
|
services: names(plugin.services, "services"),
|
|
303
304
|
triggers: names(plugin.triggers, "triggers"),
|
|
305
|
+
views: names(plugin.views, "views"),
|
|
304
306
|
};
|
|
305
307
|
}
|
|
306
308
|
|
|
@@ -393,6 +395,7 @@ function validateDescription(input: PluginDescriptionV1): PluginDescriptionV1 {
|
|
|
393
395
|
hooks: [...input.hooks],
|
|
394
396
|
services: [...input.services],
|
|
395
397
|
triggers: [...input.triggers],
|
|
398
|
+
views: [...input.views],
|
|
396
399
|
};
|
|
397
400
|
}
|
|
398
401
|
|