@omem-ai/plugin-sdk 0.0.1 → 0.0.2

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/server.js ADDED
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Slots (docs/v2/flows.md §8, “界面插槽”): a plugin's display block shown on omem's own pages — the item
3
+ * panel, under a flow stage, the today page. Declared in `register(api)`, after the block (and the object
4
+ * kinds a condition names):
5
+ *
6
+ * api.block({ kind: "ci_summary", description: "合并请求的检查结果", display: true, schema, load, view });
7
+ * api.slot("item.panel", { block: "ci_summary", when: { object: "pull-request" } });
8
+ *
9
+ * `load` reads what the block shows, as the person looking at the page and in the item's space (the
10
+ * plugin's own space on the today page); its result must pass the block's `schema`. `view` turns it into
11
+ * display components (the ones `renderView` draws, without `page`). Only code running inside omem can
12
+ * declare slots; they go away when the plugin is turned off or its trust withdrawn.
13
+ *
14
+ * No imports here, so omem's own type checks can compare these with the host's; the main entry
15
+ * (client.ts) fills in the context and component types.
16
+ */
17
+ export type PluginSlotPlace = "item.panel" | "flow.stage" | "today";
18
+ /**
19
+ * When a slot shows; not for `today`. `object`: one of this plugin's object kinds — on `item.panel` linked
20
+ * to the item (one block per object), on `flow.stage` the kind the stage follows (`by` / `done`).
21
+ * `stage`: stage ids (`flow.stage` only); `flow`: flow ids; `space`: the item's space.
22
+ */
23
+ export type PluginSlotWhen = {
24
+ object?: string;
25
+ stage?: string | string[];
26
+ flow?: string | string[];
27
+ space?: string | string[];
28
+ };
29
+ export type PluginSlot = {
30
+ block: string;
31
+ when?: PluginSlotWhen;
32
+ };
33
+ /** What a block in a slot is shown for: the item, the stage and the object it sits by (null where there is none). */
34
+ export type PluginSlotContext = {
35
+ at: PluginSlotPlace;
36
+ item: string | null;
37
+ stage: string | null;
38
+ object: {
39
+ id: string;
40
+ kind: string;
41
+ key: string;
42
+ title: string;
43
+ status: string;
44
+ link: string;
45
+ } | null;
46
+ };
47
+ export type PluginSlotView<C = unknown> = {
48
+ title?: string;
49
+ components: C[];
50
+ };
51
+ /** The parts of a display block a slot uses (its `kind`, `schema`, `description` and `display: true` as usual). */
52
+ export type PluginSlotBlock<T, Ctx = unknown, C = unknown> = {
53
+ load(ctx: Ctx, slot: PluginSlotContext): T | Promise<T>;
54
+ view(data: T): PluginSlotView<C>;
55
+ };
56
+ export type PluginSlotApi = {
57
+ slot(at: PluginSlotPlace, def: PluginSlot): void;
58
+ };
package/package.json CHANGED
@@ -1,18 +1,21 @@
1
1
  {
2
2
  "name": "@omem-ai/plugin-sdk",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "SDK for omem plugin pages and services: talk to omem through the shell, draw its forms and charts, serve HTTP and WebSocket to omem.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  ".": { "types": "./dist/client.d.ts", "default": "./dist/client.js" },
9
+ "./server": { "types": "./dist/server.d.ts", "default": "./dist/server.js" },
9
10
  "./blocks": { "types": "./dist/blocks.d.ts", "default": "./dist/blocks.js" },
11
+ "./charts": { "types": "./dist/charts.d.ts", "default": "./dist/charts.js" },
10
12
  "./service": "./service.mjs"
11
13
  },
12
14
  "files": ["dist", "service.mjs", "README.md"],
13
15
  "scripts": {
14
16
  "build": "vite build && tsc -p tsconfig.json"
15
17
  },
18
+ "dependencies": { "zod": "4.1.12" },
16
19
  "devDependencies": {
17
20
  "typescript": "5.9.3",
18
21
  "vite": "7.3.1"