@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/README.md +126 -1
- package/dist/agent-login.d.ts +69 -0
- package/dist/blocks.d.ts +58 -9
- package/dist/blocks.js +229 -222
- package/dist/charts.d.ts +125 -0
- package/dist/charts.js +686 -0
- package/dist/client.d.ts +18 -1
- package/dist/credential.d.ts +181 -0
- package/dist/hook.d.ts +50 -0
- package/dist/objects.d.ts +85 -0
- package/dist/server.d.ts +355 -0
- package/dist/server.js +1 -0
- package/dist/slots.d.ts +58 -0
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -17,8 +17,9 @@ const { transcript } = await call.stop();
|
|
|
17
17
|
|
|
18
18
|
- `@omem-ai/plugin-sdk`: `connect()` → `get` / `post` (only `/api/plugins/<this plugin>/…`), `on`,
|
|
19
19
|
`navigate`, `openSettings`, `stream`, `voice` / `voiceStatus` (omem holds the microphone and the
|
|
20
|
-
connection; the page gets the transcript only), and `renderBlock` / `renderView` for the agent's questions (forms) and views (tables, charts, comparisons) in a session.
|
|
20
|
+
connection; the page gets the transcript only), and `renderBlock` / `renderView` for the agent's questions (forms) and views (metrics, callouts, tables, charts, comparisons) in a session.
|
|
21
21
|
- `@omem-ai/plugin-sdk/blocks`: `renderBlock` and `renderView` alone, without a framework.
|
|
22
|
+
- `@omem-ai/plugin-sdk/charts`: the charts and figures those blocks draw (`mountChart`, `metricsElement`, `sparkline`), for a page that wants them without a block. Colours come from omem's `--chart-*` tokens (`/plugins/_sdk/omem.css`). A chart draws itself in once when first seen; `setChartMotion(false)`, `data-chart-still` on an ancestor or `prefers-reduced-motion` turn that off.
|
|
22
23
|
- `@omem-ai/plugin-sdk/service`: for a plugin's service (Node): `serve({ http, socket })` on
|
|
23
24
|
`127.0.0.1:OMEM_SERVICE_PORT`, refusing requests without omem's token.
|
|
24
25
|
|
|
@@ -27,3 +28,127 @@ server. Plugins in omem's data directory need not install this package: omem ser
|
|
|
27
28
|
`/plugins/_sdk/omem.js` and passes the service helper's path in `OMEM_SERVICE_SDK`.
|
|
28
29
|
|
|
29
30
|
The plugin format: [docs/v2/plugins.md](https://github.com/lejunyang/omem/blob/main/docs/v2/plugins.md).
|
|
31
|
+
|
|
32
|
+
## 带状态的对象与信号
|
|
33
|
+
|
|
34
|
+
服务端由宿主传入的 `api` 支持 `api.object`,本包从主入口导出 `PluginObject / PluginObjectState / PluginObjectContext / PluginObjectApi / PluginSignal / PluginConnection / PluginHook / PluginHookRequest / PluginHookResult` 类型;沿用页面 SDK 的类型导出和声明构建方式,不把宿主的 App 和完整 PluginApi 带进页面包。
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import type { PluginObject } from "@omem-ai/plugin-sdk";
|
|
38
|
+
|
|
39
|
+
const object: PluginObject = {
|
|
40
|
+
kind: "pull-request",
|
|
41
|
+
label: "合并请求",
|
|
42
|
+
match: (url) => url === "https://github.com/example/shop/pull/7" ? "example/shop#7" : null,
|
|
43
|
+
read: async (ctx, key) => {
|
|
44
|
+
const connection = await ctx.connection("connect-github");
|
|
45
|
+
if (!connection) throw new Error("请先连接 GitHub");
|
|
46
|
+
const response = await connection.fetch("/repos/example/shop/pulls/7");
|
|
47
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
48
|
+
const pr = await response.json();
|
|
49
|
+
return { title: pr.title, status: pr.merged_at ? "merged" : pr.state === "closed" ? "closed" : "open", link: pr.html_url };
|
|
50
|
+
},
|
|
51
|
+
statuses: { open: "进行中", merged: "已合并", closed: "已关闭" },
|
|
52
|
+
final: ["merged", "closed"],
|
|
53
|
+
poll: { minutes: 5 },
|
|
54
|
+
};
|
|
55
|
+
// register(api) 中调用 api.object(object)。
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
完整的链接匹配、读取及字段例子在 `plugins/github/server.ts`。宿主全名为 `<插件 id>:<kind>`;kind 用小写字母开头,后接小写字母、数字或短横线。statuses 非空,final 必须是已声明状态;poll 默认 5 分钟,最短 1 分钟。对象只有事项关联且事项未结束、对象未到终态时才轮询,始终用事项主人的连接,按插件既有的进程内或隔离方式执行。插件停用或卸载后保留最后状态并标记来源已停用,不再轮询。
|
|
59
|
+
|
|
60
|
+
`ctx.emit({ kind: "received", keys: { object: "example/shop#7" }, payload: { note: "状态已读取" } })` 记录 `plugin.<插件 id>.received`,keys 与 payload 序列化后各不超过 4000 字符;本步只记录,不触发规则或流程。对象状态变化由宿主另记 `object.<全名>.<状态>` 并推进关联事项。不提供写平台对象的动作或按钮;界面插槽见下一节。
|
|
61
|
+
|
|
62
|
+
`read` 可以多交 `revision`(你自己定的变化标记,比如头提交加评论数)和 `note`(这次变了什么):状态没变而修订变了,宿主记 `object.<全名>.updated`,流程可以写 `done: { object, status: "updated" }`,规则的对象触发可选“有更新”。`updated` 是保留字,不能当状态名。
|
|
63
|
+
|
|
64
|
+
平台能发 webhook 时声明回调(`PluginHook`),宿主马上重读你说的对象,不用等轮询:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
api.hook({ name: "mr", label: "合并请求有变化", handle(ctx, req) {
|
|
68
|
+
// req.body 是原始文本,平台的签名自己校验
|
|
69
|
+
const e = JSON.parse(req.body);
|
|
70
|
+
return { refresh: [{ kind: "pull-request", key: e.key }] };
|
|
71
|
+
} });
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
地址是 `POST /api/hooks/<插件 id>/mr/<密钥>`,密钥由本人在 设置 → 插件 生成;每分钟最多 60 次,正文最大 1 MB,每次写审计。
|
|
75
|
+
|
|
76
|
+
平台能配置请求头时,优先用不带密钥的 `POST /api/hooks/<插件 id>/mr`,设置 `Authorization: Bearer <密钥>`,或按 `secretHeader` 声明的名字直接传密钥。旧路径仍可用。
|
|
77
|
+
|
|
78
|
+
`PluginHookOptions` 可声明 `ack: "first"`:宿主先持久化、再应答,之后调用 `handle`,失败有限重试,重启继续。不声明就同步处理。`dedup.headers` 可替换常见投递标识头,`dedup.bodyFields` 可取 JSON 正文的点号路径,`dedup.requireMatch` 要求两处都提供并一致,否则 400。`dedup.windowHours` 默认 24;同一标识下用原始正文哈希区分重复和冲突。额外签名头填进 `headers`,认证头不下传;`rateLimit` 可设 `perMinute` 和 `burst`。
|
|
79
|
+
|
|
80
|
+
`req.event` 提供 `format`、`data` 和 `trust: "untrusted"`。原始文本仍在 `req.body`,`req.deliveryId` 是处理重试和发送方重投共用的收件编号,`req.deliveryKey` 是发送方的标识(没提供就是 `null`)。支持 `webhook` 和 `openai-chat`(最后一条用户文本),默认自动识别。异步模式的 2xx 只表示收件。
|
|
81
|
+
|
|
82
|
+
异步回调可用 `accept(req, { duplicate, conflict, deliveryId })` 同步返回 `{ status, headers?, body }`,不做 I/O,不拿插件上下文。只有首次投递返回 2xx 才执行 `handle`;重复和冲突都不执行。默认冲突回 409,抛错或超时回 500。可用 `unauthorizedBody`、`rateLimitedBody`、`unavailableBody` 自定 401、429、503 的 JSON 体。完整示例见 `docs/v2/plugins.md`。
|
|
83
|
+
|
|
84
|
+
### 动作
|
|
85
|
+
|
|
86
|
+
对象可以声明按钮(`PluginObjectAction`)。每个动作是本插件自己的一个工具,宿主把对象的键放进 `arg`(默认 `key`)调用它:
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
api.tool({ name: "shop_merge", description: "合并一个合并请求", schema: api.z.object({ pr: api.z.string() }), write: true,
|
|
90
|
+
handler: async (ctx, a) => { const c = await ctx.connection("connect-github"); /* 用 c.fetch 调平台,令牌由宿主代加 */ return "已合并"; } });
|
|
91
|
+
api.object({ ...object, actions: [{ id: "merge", label: "合并", tool: "shop_merge", arg: "pr", statuses: ["open"], confirm: "检查没过时平台会拒绝。" }] });
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
- `id` 小写字母开头;`label` 不超过 20 字;`tool` 必须以 `<插件 id>_` 开头;`statuses` 必须是已声明的状态,不写是任何状态都显示;`confirm` 是确认框里多说的一句。
|
|
95
|
+
- 事项页对象卡上按当前状态出按钮。本人点了确认后直接执行(不出审批卡片);Agent 调用同一个工具时走它的审批档位,第一次见到时是“每次问”。每次执行写审计,执行完宿主马上重读一次对象。
|
|
96
|
+
- 动作工具放在 `object-actions` 分组,主助手可以用。插件拿不到令牌:工具里照常用 `ctx.connection(...).fetch` 代发;隔离运行的插件同样可以声明动作。GitHub 的“合并”(`github_merge_pull_request`)是完整例子。
|
|
97
|
+
|
|
98
|
+
## 界面插槽
|
|
99
|
+
|
|
100
|
+
服务端的 `api.slot(at, { block, when })` 把一个只展示的内容块放到 omem 自己的页面上:`item.panel`(事项页侧栏)、`flow.stage`(流程阶段下面)、`today`(今日页)。本包从主入口导出 `PluginSlot / PluginSlotWhen / PluginSlotPlace / PluginSlotContext / PluginSlotView / PluginSlotBlock / PluginSlotApi` 类型(`slots.ts`)。
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
import type { PluginSlotBlock } from "@omem-ai/plugin-sdk";
|
|
104
|
+
|
|
105
|
+
type Checks = { passed: number; failed: number };
|
|
106
|
+
const checks: PluginSlotBlock<Checks> = {
|
|
107
|
+
// ctx:看页面的人(ctx.userId)、事项所在的空间(ctx.spaceId);slot:位置、事项、阶段和对象(键、标题、状态、链接)
|
|
108
|
+
load: async (ctx, slot) => {
|
|
109
|
+
const c = await ctx.connection("connect-github");
|
|
110
|
+
if (!c || !slot.object) return { passed: 0, failed: 0 };
|
|
111
|
+
return countChecks(await (await c.fetch(`/repos/example/shop/commits/main/check-runs`)).json());
|
|
112
|
+
},
|
|
113
|
+
view: (d) => ({ title: "检查", components: [{ type: "metric", items: [{ label: "通过", value: d.passed }, { label: "失败", value: d.failed, good: "down" }] }] }),
|
|
114
|
+
};
|
|
115
|
+
// register(api) 里,先声明对象和块,再放插槽:
|
|
116
|
+
// api.block({ kind: "ci_summary", description: "合并请求的检查结果", display: true, schema, ...checks });
|
|
117
|
+
// api.slot("item.panel", { block: "ci_summary", when: { object: "pull-request" } });
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
- `when.object` 是本插件的对象类型:事项页侧栏上要求事项挂着这种对象(一个对象一块),阶段下面要求这一段跟着这种对象;`when.stage`(只用于 `flow.stage`)、`when.flow`、`when.space` 可写一个或一组。今日页不能写条件。
|
|
121
|
+
- `load` 的结果按块的 `schema` 校验,`view` 的结果按展示组件校验(`renderView` 画的那些,不能放交互页 `page`);任何一步出错只是这一块显示错误。15 秒没结果算失败。
|
|
122
|
+
- 声明错了(位置、块、条件、对象类型不对,或块不是 `display: true`、缺 `load` / `view`),插件代码加载失败。只有在 omem 里运行的代码能声明插槽;插件停用或撤销信任时插槽消失。
|
|
123
|
+
|
|
124
|
+
开发插件时可以 `omem plugin link <目录>`:不复制,改了自动重新加载,信任按目录记。包里有 `build` 脚本、清单的 `server`(例如 `dist/server.js`)或服务脚本还没构建时,`omem plugin install` 先列出装依赖和构建的命令,确认后才运行。
|
|
125
|
+
|
|
126
|
+
## AI 账号的登录方式
|
|
127
|
+
|
|
128
|
+
成员用自己的 AI 账号时,插件可以给某个后端提供登录方式:`api.agentLogin(def)`,主入口导出 `AgentLoginDef / AgentLoginContext / AgentLoginResult / AgentLoginApi` 类型。`login(ctx)` 调 `ctx.show({ url, code })` 让 omem 把链接和验证码给这个人(网页上和飞书私聊里),把凭据写到 `ctx.env` 指的位置(他的账号目录里),需要时用 `ctx.secret.set()` 存一份按人保存的秘密,返回 `{ user, expiresAt }`;可选的 `refresh(ctx)` 在到期前 10 分钟被调用,返回新的 `{ expiresAt }` 或 `null`(要重新登录);可选的 `logout(ctx)` 在他退出时清理。清单声明 `permissions.agentLogin: [<后端>]`,只在 omem 进程里运行。完整说明见 [plugins.md](https://github.com/lejunyang/omem/blob/main/docs/v2/plugins.md) 的“AI 账号的登录方式”。
|
|
129
|
+
|
|
130
|
+
## 场景包与聊天渠道
|
|
131
|
+
|
|
132
|
+
插件清单支持 `rules: [名称]`(`rules/<名>.yaml`,首次导入且停用)、`flows: [id]`(`flows/<id>.yaml`,流程定义,启用时补进流程清单,本人已有同 id 的不覆盖,删掉的不再加回来)和 `mcp`(命令 / 网址、变量 / 请求头名字列表,密钥值由本人在 Agent 页填)。`omem plugin pack` 可导出现有档案、完整技能目录、规则、流程和 MCP;默认写到数据目录 `plugins-out/`,拒绝文本中的已存密钥和用户目录绝对路径。安装接受本地目录并复制,命令 MCP 要先信任插件。完整的场景包例子(流程 + 技能 + 对象状态变化规则)在仓库的 `examples/plugins/ghdelivery`。
|
|
133
|
+
|
|
134
|
+
服务端的 `register(api)` 可以调用 `api.channel`,它由 omem 宿主提供;本包当前导出页面 SDK、内容块和服务帮助模块,不单独导出宿主的 `PluginApi` 类型。完整接口见 [plugins.md 的渠道](https://github.com/lejunyang/omem/blob/main/docs/v2/plugins.md#渠道):
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
export default function register(api) {
|
|
138
|
+
const channel = api.channel({
|
|
139
|
+
id: "matrix",
|
|
140
|
+
label: "Matrix",
|
|
141
|
+
owner: (settings) => settings.ownerId,
|
|
142
|
+
maxLength: 4000,
|
|
143
|
+
send: async ({ chatId, topicId }, text) => {
|
|
144
|
+
// text 已按 maxLength 分段,用平台客户端发送。
|
|
145
|
+
},
|
|
146
|
+
// 渠道被停掉时调用一次:关掉自己开的监听、定时器和连接。
|
|
147
|
+
close: () => client.stop(),
|
|
148
|
+
});
|
|
149
|
+
// 平台监听器收到消息时:
|
|
150
|
+
// await channel.receive({ chatId, topicId, isGroup, senderId, text, messageId, addressed: true });
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
清单加 `settings: [{ key: ownerId, label: 本人在这个平台上的 id, type: text }]`。渠道只能在 omem 进程里运行,信任并启用后才注册;不支持隔离模式。宿主管身份和会话,群里只回答 `addressed` 的消息;通知给平台身份 id 对应的私聊。停用或撤销信任后宿主注销发送器和通知 sink,旧 `receive` 失效,发送错误只记录。
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Login methods for members' own AI accounts (docs/v2/agent-accounts.md §6): a plugin lets people log
|
|
3
|
+
* in to a backend (TraeX, Codex…) through its own sign-in, then writes the backend's credentials into
|
|
4
|
+
* that person's account folder. Declared in `register(api)`:
|
|
5
|
+
*
|
|
6
|
+
* api.agentLogin({
|
|
7
|
+
* backend: "traex",
|
|
8
|
+
* id: "company",
|
|
9
|
+
* label: "用公司账号登录",
|
|
10
|
+
* async login(ctx) {
|
|
11
|
+
* const device = await startDeviceFlow(ctx.signal);
|
|
12
|
+
* ctx.show({ url: device.url, code: device.code });
|
|
13
|
+
* const tokens = await waitForTokens(device, ctx.signal);
|
|
14
|
+
* await writeCredentials(ctx.env.TRAE_HOME, tokens);
|
|
15
|
+
* await ctx.secret.set(tokens.refreshToken);
|
|
16
|
+
* return { user: tokens.user, expiresAt: tokens.expiresAt };
|
|
17
|
+
* },
|
|
18
|
+
* async refresh(ctx) { … return { expiresAt } or null },
|
|
19
|
+
* async logout(ctx) { await revoke(await ctx.secret.get()); },
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* The manifest declares the backend (`permissions.agentLogin: [traex]`); omem calls it only once the
|
|
23
|
+
* owner trusts the plugin and runs it inside omem. No imports here, so omem's own type checks can
|
|
24
|
+
* compare these with the host's (src/agents/agent-logins.ts).
|
|
25
|
+
*/
|
|
26
|
+
export type AgentLoginContext = {
|
|
27
|
+
userId: string;
|
|
28
|
+
/** This person's account folder (HOME inside the sandbox their runs start in). */
|
|
29
|
+
home: string;
|
|
30
|
+
/** The backend's `account.env` expanded for this person (TRAE_HOME=<home>/.trae…): write the credentials where they point. */
|
|
31
|
+
env: Record<string, string>;
|
|
32
|
+
/** One secret omem keeps for the plugin per person and backend (in its vault, never in the account folder), such as a refresh token. */
|
|
33
|
+
secret: {
|
|
34
|
+
get(): Promise<string | null>;
|
|
35
|
+
set(value: string | null): Promise<void>;
|
|
36
|
+
};
|
|
37
|
+
/** The plugin's own settings (the owner's values from 设置 → 插件, manifest `settings`, defaults filled in). */
|
|
38
|
+
settings: Record<string, string | number | boolean | string[]>;
|
|
39
|
+
/** Aborted when the login times out (11 minutes) or the person cancels or logs out. */
|
|
40
|
+
signal: AbortSignal;
|
|
41
|
+
};
|
|
42
|
+
export type AgentLoginResult = {
|
|
43
|
+
user: string;
|
|
44
|
+
expiresAt?: number;
|
|
45
|
+
};
|
|
46
|
+
export type AgentLoginDef = {
|
|
47
|
+
backend: string;
|
|
48
|
+
/** Unique within the plugin. */
|
|
49
|
+
id: string;
|
|
50
|
+
label: string;
|
|
51
|
+
/** Call `show` with the link (and code) the person opens; omem puts it on their page and in their Feishu private chat. */
|
|
52
|
+
login(ctx: AgentLoginContext & {
|
|
53
|
+
show(link: {
|
|
54
|
+
url: string;
|
|
55
|
+
code?: string;
|
|
56
|
+
}): void;
|
|
57
|
+
}): Promise<AgentLoginResult>;
|
|
58
|
+
/** 10 minutes before `expiresAt` (at most once a minute) and when the person presses 检查: the new `expiresAt`, or null to ask them to log in again. */
|
|
59
|
+
refresh?(ctx: AgentLoginContext): Promise<{
|
|
60
|
+
expiresAt?: number;
|
|
61
|
+
} | null>;
|
|
62
|
+
/** When they log out (revoke what you hold); omem removes the folder afterwards. */
|
|
63
|
+
logout?(ctx: AgentLoginContext): Promise<void>;
|
|
64
|
+
};
|
|
65
|
+
export type AgentLoginApi = {
|
|
66
|
+
agentLogin(def: AgentLoginDef): void;
|
|
67
|
+
/** The owner's values of this plugin's settings; read when needed so a change takes effect without reloading. In-process plugins only. */
|
|
68
|
+
settings(): Record<string, string | number | boolean | string[]>;
|
|
69
|
+
};
|
package/dist/blocks.d.ts
CHANGED
|
@@ -7,10 +7,12 @@
|
|
|
7
7
|
* question, with a form when it has fields). omem's own pages draw a question's fields with their
|
|
8
8
|
* own controls (web/src/components/UiFields.vue); plugin pages use the plain ones here.
|
|
9
9
|
*
|
|
10
|
+
* Charts and figures are drawn by charts.ts, the one drawing omem's own pages use too.
|
|
11
|
+
*
|
|
10
12
|
* Text goes in through textContent only, unless the caller passes a Markdown renderer that
|
|
11
|
-
* sanitizes. Colors come from omem's tokens;
|
|
12
|
-
* light and dark surfaces.
|
|
13
|
+
* sanitizes. Colors come from omem's tokens (web/src/styles.css; plugin pages load it as omem.css).
|
|
13
14
|
*/
|
|
15
|
+
import { type MetricItem } from "./charts";
|
|
14
16
|
export type BlockView = {
|
|
15
17
|
id: string;
|
|
16
18
|
kind: string;
|
|
@@ -28,6 +30,18 @@ export type Card = {
|
|
|
28
30
|
pros?: string[];
|
|
29
31
|
cons?: string[];
|
|
30
32
|
};
|
|
33
|
+
/** `good`: which way is good news (up by default); `trend` is read off the change's sign when not given; `spark` is its recent course. */
|
|
34
|
+
export type Metric = Omit<MetricItem, "link" | "hint">;
|
|
35
|
+
/** How a callout, a list entry's tag or a card's status reads: a conclusion, done, needs attention, failed, neutral. */
|
|
36
|
+
export type Tone = "info" | "success" | "warning" | "danger" | "neutral";
|
|
37
|
+
/** One entry of a `list`: what it is, a line under it, a short coloured tag (新增, 要你定, 通过) and where it opens. */
|
|
38
|
+
export type ListItem = {
|
|
39
|
+
title: string;
|
|
40
|
+
text?: string;
|
|
41
|
+
tag?: string;
|
|
42
|
+
tone?: Tone;
|
|
43
|
+
url?: string;
|
|
44
|
+
};
|
|
31
45
|
export type ViewComponent = {
|
|
32
46
|
type: "markdown";
|
|
33
47
|
text: string;
|
|
@@ -43,22 +57,27 @@ export type ViewComponent = {
|
|
|
43
57
|
} | {
|
|
44
58
|
type: "chart";
|
|
45
59
|
title: string;
|
|
46
|
-
kind: "bar" | "line" | "pie";
|
|
60
|
+
kind: "bar" | "line" | "area" | "hbar" | "pie";
|
|
47
61
|
labels: string[];
|
|
48
62
|
series: {
|
|
49
63
|
name: string;
|
|
50
64
|
values: number[];
|
|
51
65
|
}[];
|
|
66
|
+
stack?: boolean;
|
|
67
|
+
goal?: number;
|
|
52
68
|
unit?: string;
|
|
53
69
|
note?: string;
|
|
70
|
+
highlight?: string;
|
|
54
71
|
} | {
|
|
55
72
|
type: "metric";
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
73
|
+
title?: string;
|
|
74
|
+
items: Metric[];
|
|
75
|
+
note?: string;
|
|
76
|
+
} | {
|
|
77
|
+
type: "callout";
|
|
78
|
+
tone: "info" | "success" | "warning" | "danger" | "neutral";
|
|
79
|
+
title?: string;
|
|
80
|
+
text: string;
|
|
62
81
|
} | {
|
|
63
82
|
type: "compare";
|
|
64
83
|
title?: string;
|
|
@@ -71,6 +90,34 @@ export type ViewComponent = {
|
|
|
71
90
|
text?: string;
|
|
72
91
|
}[];
|
|
73
92
|
}
|
|
93
|
+
/** Entries one under another (decisions, findings, files, directions), each with an optional tag and link. */
|
|
94
|
+
| {
|
|
95
|
+
type: "list";
|
|
96
|
+
title?: string;
|
|
97
|
+
items: ListItem[];
|
|
98
|
+
}
|
|
99
|
+
/** Name and value pairs, two to a row (state, owner, branch, round). */
|
|
100
|
+
| {
|
|
101
|
+
type: "fields";
|
|
102
|
+
items: {
|
|
103
|
+
label: string;
|
|
104
|
+
value: string;
|
|
105
|
+
}[];
|
|
106
|
+
}
|
|
107
|
+
/** Detail behind a title, closed unless `open`. */
|
|
108
|
+
| {
|
|
109
|
+
type: "fold";
|
|
110
|
+
title: string;
|
|
111
|
+
text: string;
|
|
112
|
+
open?: boolean;
|
|
113
|
+
}
|
|
114
|
+
/** A picture by its https address; `caption` under it. */
|
|
115
|
+
| {
|
|
116
|
+
type: "image";
|
|
117
|
+
url: string;
|
|
118
|
+
alt?: string;
|
|
119
|
+
caption?: string;
|
|
120
|
+
}
|
|
74
121
|
/** An interactive page (`ui_page`): drawn by omem's own pages only; elsewhere a line that says where to open it. */
|
|
75
122
|
| {
|
|
76
123
|
type: "page";
|
|
@@ -84,12 +131,14 @@ type ShowIf = {
|
|
|
84
131
|
equals?: string | number | boolean;
|
|
85
132
|
in?: string[];
|
|
86
133
|
};
|
|
134
|
+
/** `group`: a heading over this field and the following ones with the same group (host-made forms). */
|
|
87
135
|
export type UiField = {
|
|
88
136
|
id: string;
|
|
89
137
|
label: string;
|
|
90
138
|
help?: string;
|
|
91
139
|
required?: boolean;
|
|
92
140
|
show_if?: ShowIf;
|
|
141
|
+
group?: string;
|
|
93
142
|
} & ({
|
|
94
143
|
type: "text" | "textarea";
|
|
95
144
|
placeholder?: string;
|