@wheatley-ai/cli 0.2.0 → 0.4.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/README.md +37 -3
- package/dist/cli/ask.js +8 -4
- package/dist/cli/chat.js +8 -4
- package/dist/cli/daemon.js +45 -0
- package/dist/cli/io.js +1 -0
- package/dist/cli/main.js +145 -157
- package/dist/cli/session.js +59 -3
- package/dist/cli/status.js +4 -4
- package/dist/cli/tui/app.js +14 -2
- package/dist/cli/tui/controller.js +80 -19
- package/dist/cli/tui/markdown.js +229 -104
- package/dist/cli/tui/model-picker.js +76 -0
- package/dist/cli/tui/picker-panel.js +39 -0
- package/dist/core/agent/agent.js +23 -12
- package/dist/core/config/config-store.js +11 -6
- package/dist/core/config/diagnostics.js +116 -0
- package/dist/core/config/secret-store.js +13 -9
- package/dist/core/deployment.js +19 -1
- package/dist/core/markdown-tokens.js +60 -0
- package/dist/core/model-catalog.js +54 -0
- package/dist/core/rpc/deployment-handlers.js +2 -1
- package/dist/core/server/control-server.js +19 -21
- package/dist/core/server/http-server.js +17 -0
- package/dist/core/server/static-files.js +40 -66
- package/dist/dashboard/assets/index-DGa2Ps9u.js +12 -0
- package/dist/dashboard/assets/index-DeERxJOJ.css +2 -0
- package/dist/dashboard/assets/{sheet-presentation-DMljN0LW.js → sheet-presentation-CZ1dO2kr.js} +1 -1
- package/dist/dashboard/index.html +2 -2
- package/dist/frontends/discord/approvals.js +8 -43
- package/dist/frontends/discord/binding.js +81 -8
- package/dist/frontends/discord/json-file.js +57 -0
- package/dist/frontends/discord/model-picker.js +276 -0
- package/dist/frontends/slack/binding.js +33 -3
- package/dist/frontends/slack/inbound.js +21 -12
- package/dist/frontends/slack/model-picker-blocks.js +147 -0
- package/dist/frontends/slack/outbound.js +27 -2
- package/dist/frontends/slack/schemas.js +9 -2
- package/dist/frontends/telegram/approvals.js +13 -48
- package/dist/frontends/telegram/binding.js +5 -0
- package/dist/frontends/telegram/client.js +7 -0
- package/dist/frontends/telegram/delivery.js +19 -6
- package/dist/frontends/telegram/inbound.js +64 -8
- package/dist/frontends/telegram/markdown.js +120 -83
- package/dist/frontends/telegram/model-picker.js +160 -0
- package/dist/frontends/telegram/token-store.js +73 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/domain.d.ts +13 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/domain.js +11 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/index.d.ts +1 -1
- package/dist/node_modules/@wheatley-ai/protocol/dist/index.js +1 -1
- package/dist/node_modules/@wheatley-ai/protocol/dist/methods.d.ts +20 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/methods.js +9 -1
- package/dist/node_modules/@wheatley-ai/sdk/dist/commands.d.ts +2 -2
- package/dist/node_modules/@wheatley-ai/sdk/dist/commands.js +2 -2
- package/dist/node_modules/@wheatley-ai/sdk/dist/frontend.d.ts +23 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/index.d.ts +1 -1
- package/dist/node_modules/@wheatley-ai/sdk/package.json +1 -1
- package/dist/ops/cli.js +127 -114
- package/dist/ops/command-runner.js +1 -0
- package/dist/ops/install-method.js +189 -0
- package/dist/ops/registry.js +35 -0
- package/dist/ops/service.js +6 -1
- package/dist/ops/update.js +109 -88
- package/dist/triggers/delivery-codec.js +13 -0
- package/dist/triggers/webhook-ingress.js +89 -82
- package/package.json +11 -4
- package/dist/dashboard/assets/index-C9Rul5vE.css +0 -2
- package/dist/dashboard/assets/index-DXzGGAxQ.js +0 -11
|
@@ -2,102 +2,139 @@
|
|
|
2
2
|
* Converts the Markdown of Agent replies to the HTML subset of the Telegram Bot API (`parse_mode: "HTML"`). Telegram
|
|
3
3
|
* rejects unbalanced tags, so the converter only emits tags in matched pairs and escapes all other text.
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const LINK = /\[(?<label>[^\]]+)\]\((?<url>(?:https?|tg|mailto):[^)\s]+)\)/gu;
|
|
11
|
-
const BOLD = /(?:\*\*|__)(?=\S)(?<text>.+?)(?<=\S)(?:\*\*|__)/gu;
|
|
12
|
-
const ITALIC_STAR = /(?<![\w*])\*(?=\S)(?<text>[^*]+?)(?<=\S)\*(?![\w*])/gu;
|
|
13
|
-
const ITALIC_UNDERSCORE = /(?<![\w_])_(?=\S)(?<text>[^_]+?)(?<=\S)_(?![\w_])/gu;
|
|
14
|
-
const STRIKE = /~~(?=\S)(?<text>.+?)(?<=\S)~~/gu;
|
|
15
|
-
const PLACEHOLDER = /\uE000(?<index>\d+)\uE001/gu;
|
|
5
|
+
import { blockTokens, inlineTokens, lexMarkdown, taskBox, } from "../../core/markdown-tokens.js";
|
|
6
|
+
const LINK_SCHEMES = ["http:", "https:", "tg:", "mailto:"];
|
|
7
|
+
const LIST_INDENT = " ";
|
|
8
|
+
const RULE = "———";
|
|
9
|
+
const TASK_BOXES = { checked: "☑ ", unchecked: "☐ " };
|
|
16
10
|
/** Escapes the three characters that Telegram HTML requires escaped, plus `"` for attribute values. */
|
|
17
11
|
export const escapeHtml = (text) => text
|
|
18
12
|
.replaceAll("&", "&")
|
|
19
13
|
.replaceAll("<", "<")
|
|
20
14
|
.replaceAll(">", ">")
|
|
21
15
|
.replaceAll('"', """);
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
const protect = (html) => {
|
|
26
|
-
protectedParts.push(html);
|
|
27
|
-
return `\uE000${protectedParts.length - 1}\uE001`;
|
|
28
|
-
};
|
|
29
|
-
let text = line.replaceAll(INLINE_CODE, (_match, _ticks, code) => protect(`<code>${escapeHtml(code)}</code>`));
|
|
30
|
-
text = text.replaceAll(LINK, (_match, label, url) => protect(`<a href="${escapeHtml(url)}">${escapeHtml(label)}</a>`));
|
|
31
|
-
text = escapeHtml(text)
|
|
32
|
-
.replaceAll(BOLD, "<b>$<text></b>")
|
|
33
|
-
.replaceAll(STRIKE, "<s>$<text></s>")
|
|
34
|
-
.replaceAll(ITALIC_STAR, "<i>$<text></i>")
|
|
35
|
-
.replaceAll(ITALIC_UNDERSCORE, "<i>$<text></i>");
|
|
36
|
-
return text.replaceAll(PLACEHOLDER, (_match, index) => protectedParts[Number(index)] ?? "");
|
|
16
|
+
const isSafeLink = (href) => {
|
|
17
|
+
const lower = href.toLowerCase();
|
|
18
|
+
return LINK_SCHEMES.some((scheme) => lower.startsWith(scheme));
|
|
37
19
|
};
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
20
|
+
const formatInlineToken = (token) => {
|
|
21
|
+
switch (token.type) {
|
|
22
|
+
case "codespan": {
|
|
23
|
+
return `<code>${escapeHtml(token.text)}</code>`;
|
|
24
|
+
}
|
|
25
|
+
case "strong": {
|
|
26
|
+
return `<b>${formatInline(token.tokens)}</b>`;
|
|
27
|
+
}
|
|
28
|
+
case "em": {
|
|
29
|
+
return `<i>${formatInline(token.tokens)}</i>`;
|
|
30
|
+
}
|
|
31
|
+
case "del": {
|
|
32
|
+
return `<s>${formatInline(token.tokens)}</s>`;
|
|
33
|
+
}
|
|
34
|
+
case "link":
|
|
35
|
+
case "image": {
|
|
36
|
+
const label = formatInline(token.tokens);
|
|
37
|
+
return isSafeLink(token.href)
|
|
38
|
+
? `<a href="${escapeHtml(token.href)}">${label}</a>`
|
|
39
|
+
: label;
|
|
40
|
+
}
|
|
41
|
+
case "br": {
|
|
42
|
+
return "\n";
|
|
43
|
+
}
|
|
44
|
+
case "text": {
|
|
45
|
+
return token.tokens === undefined
|
|
46
|
+
? escapeHtml(token.text)
|
|
47
|
+
: formatInline(token.tokens);
|
|
48
|
+
}
|
|
49
|
+
case "escape": {
|
|
50
|
+
return escapeHtml(token.text);
|
|
51
|
+
}
|
|
52
|
+
case "html": {
|
|
53
|
+
return escapeHtml(token.raw);
|
|
54
|
+
}
|
|
55
|
+
default: {
|
|
56
|
+
return "";
|
|
57
|
+
}
|
|
46
58
|
}
|
|
47
|
-
return formatInline(line);
|
|
48
|
-
};
|
|
49
|
-
const isFenceClose = (line, marker) => {
|
|
50
|
-
const trimmed = line.trim();
|
|
51
|
-
return (trimmed.length >= marker.length &&
|
|
52
|
-
trimmed.replaceAll(marker.charAt(0), "") === "");
|
|
53
59
|
};
|
|
54
|
-
const
|
|
60
|
+
const formatInline = (tokens) => inlineTokens(tokens).map(formatInlineToken).join("");
|
|
61
|
+
const TOP = { inQuote: false, listDepth: 0 };
|
|
62
|
+
const codeBlock = (token) => {
|
|
63
|
+
const info = token.lang?.split(" ")[0] ?? "";
|
|
55
64
|
const language = info === "" ? "" : ` class="language-${escapeHtml(info)}"`;
|
|
56
|
-
return `<pre><code${language}>${escapeHtml(
|
|
65
|
+
return `<pre><code${language}>${escapeHtml(token.text)}</code></pre>`;
|
|
57
66
|
};
|
|
58
67
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* Supports fenced code blocks, inline code, links, bold, italic, strikethrough, headings (as bold), bullet lists, and
|
|
62
|
-
* block quotes. Leaves other Markdown as escaped text. The visible text is never longer than the Markdown input, so a
|
|
63
|
-
* chunk that fits the 4096-character limit as Markdown also fits as HTML.
|
|
68
|
+
* The marker of a list item as the Markdown writes it. A computed number, for example `10.` for the tenth `1.`, can be
|
|
69
|
+
* longer than the Markdown marker.
|
|
64
70
|
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
71
|
+
const sourceMarker = (item) => item.raw.trimStart().split(" ", 1)[0] ?? "";
|
|
72
|
+
const formatList = (token, context) => {
|
|
73
|
+
const indent = LIST_INDENT.repeat(context.listDepth);
|
|
74
|
+
const inner = { ...context, listDepth: context.listDepth + 1 };
|
|
75
|
+
return token.items
|
|
76
|
+
.map((item) => {
|
|
77
|
+
const marker = token.ordered ? sourceMarker(item) : "•";
|
|
78
|
+
const check = taskBox(item, TASK_BOXES);
|
|
79
|
+
const content = formatBlocks(item.tokens, inner);
|
|
80
|
+
return `${indent}${marker} ${check}${content}`;
|
|
81
|
+
})
|
|
82
|
+
.join(token.loose ? "\n\n" : "\n");
|
|
83
|
+
};
|
|
84
|
+
const formatBlock = (token, context) => {
|
|
85
|
+
switch (token.type) {
|
|
86
|
+
case "paragraph":
|
|
87
|
+
case "text": {
|
|
88
|
+
return token.tokens === undefined
|
|
89
|
+
? escapeHtml(token.text)
|
|
90
|
+
: formatInline(token.tokens);
|
|
91
|
+
}
|
|
92
|
+
case "heading": {
|
|
93
|
+
return `<b>${formatInline(token.tokens)}</b>`;
|
|
94
|
+
}
|
|
95
|
+
case "code": {
|
|
96
|
+
return codeBlock(token);
|
|
97
|
+
}
|
|
98
|
+
case "list": {
|
|
99
|
+
return formatList(token, context);
|
|
100
|
+
}
|
|
101
|
+
case "blockquote": {
|
|
102
|
+
const content = formatBlocks(token.tokens, { ...context, inQuote: true });
|
|
103
|
+
return context.inQuote ? content : `<blockquote>${content}</blockquote>`;
|
|
104
|
+
}
|
|
105
|
+
case "table": {
|
|
106
|
+
// Telegram has no table tags. Preformatted source text keeps the columns readable.
|
|
107
|
+
return `<pre>${escapeHtml(token.raw.trimEnd())}</pre>`;
|
|
108
|
+
}
|
|
109
|
+
case "hr": {
|
|
110
|
+
return RULE;
|
|
111
|
+
}
|
|
112
|
+
case "space": {
|
|
113
|
+
return "";
|
|
114
|
+
}
|
|
115
|
+
case "def":
|
|
116
|
+
case "checkbox":
|
|
117
|
+
case "list_item": {
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
case "html": {
|
|
121
|
+
return escapeHtml(token.raw.trimEnd());
|
|
122
|
+
}
|
|
123
|
+
default: {
|
|
124
|
+
return undefined;
|
|
99
125
|
}
|
|
100
126
|
}
|
|
101
|
-
endQuote();
|
|
102
|
-
return output.join("\n");
|
|
103
127
|
};
|
|
128
|
+
const formatBlocks = (tokens, context) => blockTokens(tokens)
|
|
129
|
+
.map((token) => formatBlock(token, context))
|
|
130
|
+
.filter((block) => block !== undefined)
|
|
131
|
+
.join("\n");
|
|
132
|
+
/**
|
|
133
|
+
* Converts Markdown to Telegram HTML.
|
|
134
|
+
*
|
|
135
|
+
* Supports fenced code blocks, inline code, links, bold, italic, strikethrough, headings (as bold), lists, block
|
|
136
|
+
* quotes, and tables (as preformatted text). Shows raw HTML and links with other schemes as escaped text. The visible
|
|
137
|
+
* text is never longer than the Markdown input, so a chunk that fits the 4096-character limit as Markdown also fits as
|
|
138
|
+
* HTML.
|
|
139
|
+
*/
|
|
140
|
+
export const markdownToTelegramHtml = (markdown) => formatBlocks(lexMarkdown(markdown), TOP);
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import { escapeHtml } from "./markdown.js";
|
|
3
|
+
import { shortToken, TokenStore } from "./token-store.js";
|
|
4
|
+
const STORE_FILE = "model-pickers.json";
|
|
5
|
+
/** Older pickers stop working once this many newer pickers exist. */
|
|
6
|
+
const STORE_CAPACITY = 50;
|
|
7
|
+
/** Models per page of the model step. */
|
|
8
|
+
const MODEL_PAGE_SIZE = 8;
|
|
9
|
+
const CALLBACK_PREFIX = "mp";
|
|
10
|
+
const CALLBACK_DATA = /^mp:(?<token>[\w-]+):(?:(?<providers>p)|m:(?<provider>\d+):(?<page>\d+)|s:(?<model>\d+))$/u;
|
|
11
|
+
const CURRENT_MARK = "✓ ";
|
|
12
|
+
const ModelRefSchema = Type.Object({
|
|
13
|
+
id: Type.String(),
|
|
14
|
+
provider: Type.String(),
|
|
15
|
+
});
|
|
16
|
+
const PickerSchema = Type.Object({
|
|
17
|
+
/** The Chat key of the picker message. A press in another Chat is stale. */
|
|
18
|
+
chatId: Type.String(),
|
|
19
|
+
current: Type.Optional(ModelRefSchema),
|
|
20
|
+
/** Sorted by provider, then by ID, as `ModelPicker.models`. Callback data refers to models by index. */
|
|
21
|
+
models: Type.Array(Type.Object({
|
|
22
|
+
id: Type.String(),
|
|
23
|
+
name: Type.String(),
|
|
24
|
+
provider: Type.String(),
|
|
25
|
+
})),
|
|
26
|
+
});
|
|
27
|
+
/** Returns the callback token of the picker of an outbox message. */
|
|
28
|
+
export const pickerToken = (messageId) => shortToken(messageId);
|
|
29
|
+
export const toStoredPicker = (chatId, picker) => ({
|
|
30
|
+
chatId,
|
|
31
|
+
current: picker.current === undefined
|
|
32
|
+
? undefined
|
|
33
|
+
: { id: picker.current.id, provider: picker.current.provider },
|
|
34
|
+
models: picker.models.map(({ id, name, provider }) => ({
|
|
35
|
+
id,
|
|
36
|
+
name,
|
|
37
|
+
provider,
|
|
38
|
+
})),
|
|
39
|
+
});
|
|
40
|
+
/** The distinct providers of a picker, in model order. */
|
|
41
|
+
const providersOf = (picker) => [
|
|
42
|
+
...new Set(picker.models.map((model) => model.provider)),
|
|
43
|
+
];
|
|
44
|
+
const isCurrent = (picker, model) => picker.current?.provider === model.provider && picker.current.id === model.id;
|
|
45
|
+
const encode = (token, action) => {
|
|
46
|
+
if (action.kind === "select") {
|
|
47
|
+
return `${CALLBACK_PREFIX}:${token}:s:${action.model}`;
|
|
48
|
+
}
|
|
49
|
+
const { view } = action;
|
|
50
|
+
return view.kind === "providers"
|
|
51
|
+
? `${CALLBACK_PREFIX}:${token}:p`
|
|
52
|
+
: `${CALLBACK_PREFIX}:${token}:m:${view.provider}:${view.page}`;
|
|
53
|
+
};
|
|
54
|
+
const button = (token, text, action) => ({ callbackData: encode(token, action), text });
|
|
55
|
+
/** Parses the callback data of a picker button. Returns `undefined` for other callback data. */
|
|
56
|
+
export const parsePickerCallback = (data) => {
|
|
57
|
+
const groups = CALLBACK_DATA.exec(data)?.groups;
|
|
58
|
+
if (groups?.token === undefined) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
const { token } = groups;
|
|
62
|
+
if (groups.model !== undefined) {
|
|
63
|
+
return { action: { kind: "select", model: Number(groups.model) }, token };
|
|
64
|
+
}
|
|
65
|
+
if (groups.providers !== undefined) {
|
|
66
|
+
return { action: { kind: "show", view: { kind: "providers" } }, token };
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
action: {
|
|
70
|
+
kind: "show",
|
|
71
|
+
view: {
|
|
72
|
+
kind: "models",
|
|
73
|
+
page: Number(groups.page),
|
|
74
|
+
provider: Number(groups.provider),
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
token,
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
const headerOf = (picker) => picker.current === undefined
|
|
81
|
+
? "<b>Choose a model</b>"
|
|
82
|
+
: `<b>Choose a model</b>\nCurrent: <code>${escapeHtml(`${picker.current.provider}/${picker.current.id}`)}</code>`;
|
|
83
|
+
const providersScreen = (token, picker) => {
|
|
84
|
+
const providers = providersOf(picker);
|
|
85
|
+
const keyboard = providers.map((provider, index) => {
|
|
86
|
+
const count = picker.models.filter((model) => model.provider === provider).length;
|
|
87
|
+
const mark = picker.current?.provider === provider ? CURRENT_MARK : "";
|
|
88
|
+
return [
|
|
89
|
+
button(token, `${mark}${provider} (${count})`, {
|
|
90
|
+
kind: "show",
|
|
91
|
+
view: { kind: "models", page: 0, provider: index },
|
|
92
|
+
}),
|
|
93
|
+
];
|
|
94
|
+
});
|
|
95
|
+
return { keyboard, text: `${headerOf(picker)}\nChoose a provider.` };
|
|
96
|
+
};
|
|
97
|
+
const modelsOf = (picker, provider) => [...picker.models.entries()].filter(([, model]) => model.provider === provider);
|
|
98
|
+
const pageCount = (models) => Math.ceil(models / MODEL_PAGE_SIZE);
|
|
99
|
+
const modelsScreen = (token, picker, view) => {
|
|
100
|
+
const providers = providersOf(picker);
|
|
101
|
+
const provider = providers[view.provider] ?? "";
|
|
102
|
+
const entries = modelsOf(picker, provider);
|
|
103
|
+
const pages = pageCount(entries.length);
|
|
104
|
+
const start = view.page * MODEL_PAGE_SIZE;
|
|
105
|
+
const rows = entries
|
|
106
|
+
.slice(start, start + MODEL_PAGE_SIZE)
|
|
107
|
+
.map(([index, model]) => [
|
|
108
|
+
button(token, `${isCurrent(picker, model) ? CURRENT_MARK : ""}${model.name}`, { kind: "select", model: index }),
|
|
109
|
+
]);
|
|
110
|
+
const pageAt = (page) => ({
|
|
111
|
+
kind: "show",
|
|
112
|
+
view: { kind: "models", page, provider: view.provider },
|
|
113
|
+
});
|
|
114
|
+
const navigation = [
|
|
115
|
+
...(view.page > 0
|
|
116
|
+
? [button(token, "Previous", pageAt(view.page - 1))]
|
|
117
|
+
: []),
|
|
118
|
+
...(view.page < pages - 1
|
|
119
|
+
? [button(token, "Next", pageAt(view.page + 1))]
|
|
120
|
+
: []),
|
|
121
|
+
];
|
|
122
|
+
const back = providers.length > 1
|
|
123
|
+
? [
|
|
124
|
+
button(token, "Back", {
|
|
125
|
+
kind: "show",
|
|
126
|
+
view: { kind: "providers" },
|
|
127
|
+
}),
|
|
128
|
+
]
|
|
129
|
+
: [];
|
|
130
|
+
const keyboard = [...rows, navigation, back].filter((row) => row.length > 0);
|
|
131
|
+
const pageText = pages > 1 ? `, page ${view.page + 1} of ${pages}` : "";
|
|
132
|
+
return {
|
|
133
|
+
keyboard,
|
|
134
|
+
text: `${headerOf(picker)}\n<b>${escapeHtml(provider)}</b>${pageText}`,
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
/** The first screen: the provider step, or the model step if only one provider has models. */
|
|
138
|
+
export const openingScreen = (token, picker) => providersOf(picker).length > 1
|
|
139
|
+
? providersScreen(token, picker)
|
|
140
|
+
: modelsScreen(token, picker, { kind: "models", page: 0, provider: 0 });
|
|
141
|
+
/** The screen of a pressed step. Returns `undefined` if `view` points past the picker's providers or pages. */
|
|
142
|
+
export const pickerScreen = (token, picker, view) => {
|
|
143
|
+
if (view.kind === "providers") {
|
|
144
|
+
return providersScreen(token, picker);
|
|
145
|
+
}
|
|
146
|
+
const provider = providersOf(picker)[view.provider];
|
|
147
|
+
const pages = pageCount(modelsOf(picker, provider).length);
|
|
148
|
+
return provider === undefined || view.page >= pages
|
|
149
|
+
? undefined
|
|
150
|
+
: modelsScreen(token, picker, view);
|
|
151
|
+
};
|
|
152
|
+
/** The HTML text that replaces a picker message after a selection. */
|
|
153
|
+
export const pickerSelectedText = (model) => `Selected <code>${escapeHtml(`${model.provider}/${model.id}`)}</code>`;
|
|
154
|
+
/** Creates the picker store of a binding, in `model-pickers.json` of its data directory. */
|
|
155
|
+
export const createPickerStore = (dataDir) => new TokenStore({
|
|
156
|
+
capacity: STORE_CAPACITY,
|
|
157
|
+
dataDir,
|
|
158
|
+
file: STORE_FILE,
|
|
159
|
+
schema: PickerSchema,
|
|
160
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { readFile, rename, writeFile } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { Type } from "typebox";
|
|
5
|
+
import { Value } from "typebox/value";
|
|
6
|
+
import { SerialQueue } from "./serial-queue.js";
|
|
7
|
+
const TOKEN_LENGTH = 16;
|
|
8
|
+
/** Returns a 16-character URL-safe key of `id` for callback data, which Telegram limits to 64 bytes. */
|
|
9
|
+
export const shortToken = (id) => createHash("sha256").update(id).digest("base64url").slice(0, TOKEN_LENGTH);
|
|
10
|
+
/**
|
|
11
|
+
* Values by callback token, kept in one JSON file of the binding's data directory so that a button still works after
|
|
12
|
+
* a restart.
|
|
13
|
+
*
|
|
14
|
+
* Invariant: every write replaces the file atomically, and writes run one at a time.
|
|
15
|
+
*/
|
|
16
|
+
export class TokenStore {
|
|
17
|
+
#path;
|
|
18
|
+
#schema;
|
|
19
|
+
#capacity;
|
|
20
|
+
#values = new Map();
|
|
21
|
+
#writes = new SerialQueue();
|
|
22
|
+
constructor(options) {
|
|
23
|
+
this.#path = path.join(options.dataDir, options.file);
|
|
24
|
+
this.#schema = options.schema;
|
|
25
|
+
this.#capacity = options.capacity ?? Number.POSITIVE_INFINITY;
|
|
26
|
+
}
|
|
27
|
+
/** Reads the file. A missing file is an empty store. Rejects if the file is not a valid store. */
|
|
28
|
+
load = async () => {
|
|
29
|
+
let text;
|
|
30
|
+
try {
|
|
31
|
+
text = await readFile(this.#path, "utf-8");
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
if (error instanceof Error &&
|
|
35
|
+
"code" in error &&
|
|
36
|
+
error.code === "ENOENT") {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
const parsed = JSON.parse(text);
|
|
42
|
+
if (!Value.Check(Type.Record(Type.String(), this.#schema), parsed)) {
|
|
43
|
+
throw new Error(`Invalid Telegram store: ${this.#path}`);
|
|
44
|
+
}
|
|
45
|
+
this.#values = new Map(Object.entries(parsed));
|
|
46
|
+
};
|
|
47
|
+
get = (token) => this.#values.get(token);
|
|
48
|
+
/** Stores a value. Resolves once the file is written. */
|
|
49
|
+
put = async (token, value) => {
|
|
50
|
+
this.#values.delete(token);
|
|
51
|
+
this.#values.set(token, value);
|
|
52
|
+
for (const oldest of this.#values.keys()) {
|
|
53
|
+
if (this.#values.size <= this.#capacity) {
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
this.#values.delete(oldest);
|
|
57
|
+
}
|
|
58
|
+
await this.#persist();
|
|
59
|
+
};
|
|
60
|
+
/** Removes a value. Resolves once the file is written. */
|
|
61
|
+
delete = async (token) => {
|
|
62
|
+
if (this.#values.delete(token)) {
|
|
63
|
+
await this.#persist();
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
#persist = async () => {
|
|
67
|
+
await this.#writes.run(async () => {
|
|
68
|
+
const temporary = `${this.#path}.tmp`;
|
|
69
|
+
await writeFile(temporary, JSON.stringify(Object.fromEntries(this.#values)), "utf-8");
|
|
70
|
+
await rename(temporary, this.#path);
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
}
|
|
@@ -72,6 +72,19 @@ export declare const AgentHealthSchema: Type.TObject<{
|
|
|
72
72
|
state: Type.TUnion<[Type.TLiteral<"starting">, Type.TLiteral<"running">, Type.TLiteral<"degraded">, Type.TLiteral<"stopped">]>;
|
|
73
73
|
}>;
|
|
74
74
|
export type AgentHealth = Static<typeof AgentHealthSchema>;
|
|
75
|
+
/** One model of a provider, for example `anthropic` and `claude-sonnet-5-5`. */
|
|
76
|
+
export declare const ModelRefSchema: Type.TObject<{
|
|
77
|
+
id: Type.TString;
|
|
78
|
+
provider: Type.TString;
|
|
79
|
+
}>;
|
|
80
|
+
export type ModelRef = Static<typeof ModelRefSchema>;
|
|
81
|
+
/** A model that a user can choose, with its display name. */
|
|
82
|
+
export declare const AvailableModelSchema: Type.TObject<{
|
|
83
|
+
id: Type.TString;
|
|
84
|
+
name: Type.TString;
|
|
85
|
+
provider: Type.TString;
|
|
86
|
+
}>;
|
|
87
|
+
export type AvailableModel = Static<typeof AvailableModelSchema>;
|
|
75
88
|
/** Use of one Concurrency Gate key, which is one provider credential. */
|
|
76
89
|
export declare const GatePressureSchema: Type.TObject<{
|
|
77
90
|
credential: Type.TString;
|
|
@@ -65,6 +65,17 @@ export const AgentHealthSchema = Type.Object({
|
|
|
65
65
|
skillWarnings: Type.Array(Type.String()),
|
|
66
66
|
state: AgentStateSchema,
|
|
67
67
|
});
|
|
68
|
+
/** One model of a provider, for example `anthropic` and `claude-sonnet-5-5`. */
|
|
69
|
+
export const ModelRefSchema = Type.Object({
|
|
70
|
+
id: Type.String({ minLength: 1 }),
|
|
71
|
+
provider: Type.String({ minLength: 1 }),
|
|
72
|
+
});
|
|
73
|
+
/** A model that a user can choose, with its display name. */
|
|
74
|
+
export const AvailableModelSchema = Type.Object({
|
|
75
|
+
id: Type.String({ minLength: 1 }),
|
|
76
|
+
name: Type.String(),
|
|
77
|
+
provider: Type.String({ minLength: 1 }),
|
|
78
|
+
});
|
|
68
79
|
/** Use of one Concurrency Gate key, which is one provider credential. */
|
|
69
80
|
export const GatePressureSchema = Type.Object({
|
|
70
81
|
credential: Type.String(),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { type AgentConfig, AgentConfigSchema, type DaemonConfig, DaemonConfigSchema, DEFAULT_WEBHOOK_HOST, DEFAULT_WEBHOOK_PORT, type DeploymentConfig, DeploymentConfigSchema, type FrontendBindingConfig, FrontendBindingConfigSchema, type McpServerConfig, McpServerConfigSchema, type MemoryConfig, MemoryConfigSchema, type ModelChoice, ModelChoiceSchema, type PluginConfig, PluginConfigSchema, type ProviderConfig, ProviderConfigSchema, type SecretRef, SecretRefSchema, type StringOrSecret, StringOrSecretSchema, type WebhooksConfig, WebhooksConfigSchema, webhookTriggerPath, } from "./config.js";
|
|
2
|
-
export { type AgentHealth, AgentHealthSchema, type AgentName, AgentNameSchema, type AgentState, AgentStateSchema, type ApprovalDecision, ApprovalDecisionSchema, type ApprovalOutcome, ApprovalOutcomeSchema, type ApprovalResolution, ApprovalResolutionSchema, type AttachmentInfo, AttachmentInfoSchema, type AttachmentUpload, AttachmentUploadSchema, type BindingStatus, BindingStatusSchema, type ChatKey, ChatKeySchema, type ChatMessage, ChatMessageSchema, type CommandName, CommandNameSchema, type ConfigIssue, ConfigIssueSchema, type ConsolidationLogEntry, ConsolidationLogEntrySchema, type ConversationMode, ConversationModeSchema, type DaemonStatus, DaemonStatusSchema, type DeliveryKind, DeliveryKindSchema, type Duration, DurationSchema, type ExtensionState, ExtensionStateSchema, type ExtensionStatus, ExtensionStatusSchema, type FailedDelivery, FailedDeliverySchema, type GatePressure, GatePressureSchema, type Id, IdSchema, type LogLevel, LogLevelSchema, type LogRecord, LogRecordSchema, type MemoryBudget, MemoryBudgetSchema, type MemoryFile, MemoryFileSchema, type MemoryName, MemoryNameSchema, type MemorySearchHit, MemorySearchHitSchema, type MemorySearchScope, MemorySearchScopeSchema, type PendingApproval, PendingApprovalSchema, type PendingRestart, PendingRestartSchema, type PermissionAction, PermissionActionSchema, type PermissionRule, PermissionRuleSchema, type RunOrigin, RunOriginSchema, type RunStatus, RunStatusSchema, type RunSummary, RunSummarySchema, type RunTimelineItem, RunTimelineItemSchema, type RunUsage, RunUsageSchema, type SecretInfo, SecretInfoSchema, type SecretName, SecretNameSchema, type SecretSource, SecretSourceSchema, type SkillInfo, SkillInfoSchema, type Timestamp, TimestampSchema, type ToolInfo, ToolInfoSchema, type ToolSource, ToolSourceSchema, type Trigger, type TriggerInput, TriggerInputSchema, type TriggerPatch, TriggerPatchSchema, type TriggerSchedule, TriggerScheduleSchema, TriggerSchema, } from "./domain.js";
|
|
2
|
+
export { type AgentHealth, AgentHealthSchema, type AgentName, AgentNameSchema, type AgentState, AgentStateSchema, type ApprovalDecision, ApprovalDecisionSchema, type ApprovalOutcome, ApprovalOutcomeSchema, type ApprovalResolution, ApprovalResolutionSchema, type AttachmentInfo, AttachmentInfoSchema, type AttachmentUpload, AttachmentUploadSchema, type AvailableModel, AvailableModelSchema, type BindingStatus, BindingStatusSchema, type ChatKey, ChatKeySchema, type ChatMessage, ChatMessageSchema, type CommandName, CommandNameSchema, type ConfigIssue, ConfigIssueSchema, type ConsolidationLogEntry, ConsolidationLogEntrySchema, type ConversationMode, ConversationModeSchema, type DaemonStatus, DaemonStatusSchema, type DeliveryKind, DeliveryKindSchema, type Duration, DurationSchema, type ExtensionState, ExtensionStateSchema, type ExtensionStatus, ExtensionStatusSchema, type FailedDelivery, FailedDeliverySchema, type GatePressure, GatePressureSchema, type Id, IdSchema, type LogLevel, LogLevelSchema, type LogRecord, LogRecordSchema, type MemoryBudget, MemoryBudgetSchema, type MemoryFile, MemoryFileSchema, type MemoryName, MemoryNameSchema, type MemorySearchHit, MemorySearchHitSchema, type MemorySearchScope, MemorySearchScopeSchema, type ModelRef, ModelRefSchema, type PendingApproval, PendingApprovalSchema, type PendingRestart, PendingRestartSchema, type PermissionAction, PermissionActionSchema, type PermissionRule, PermissionRuleSchema, type RunOrigin, RunOriginSchema, type RunStatus, RunStatusSchema, type RunSummary, RunSummarySchema, type RunTimelineItem, RunTimelineItemSchema, type RunUsage, RunUsageSchema, type SecretInfo, SecretInfoSchema, type SecretName, SecretNameSchema, type SecretSource, SecretSourceSchema, type SkillInfo, SkillInfoSchema, type Timestamp, TimestampSchema, type ToolInfo, ToolInfoSchema, type ToolSource, ToolSourceSchema, type Trigger, type TriggerInput, TriggerInputSchema, type TriggerPatch, TriggerPatchSchema, type TriggerSchedule, TriggerScheduleSchema, TriggerSchema, } from "./domain.js";
|
|
3
3
|
export { parseDuration } from "./duration.js";
|
|
4
4
|
export { EVENT_NAMES, type EventName, type EventPayload, events, type EventTopic, eventTopic, EventTopicSchema, isEventName, } from "./events.js";
|
|
5
5
|
export { type ClientMessage, decodeClientMessage, decodeServerMessage, encodeError, encodeEvent, encodeRequest, encodeResult, type RpcEvent, type RpcId, RpcIdSchema, type RpcRequest, type RpcResult, type ServerMessage, } from "./json-rpc.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { AgentConfigSchema, DaemonConfigSchema, DEFAULT_WEBHOOK_HOST, DEFAULT_WEBHOOK_PORT, DeploymentConfigSchema, FrontendBindingConfigSchema, McpServerConfigSchema, MemoryConfigSchema, ModelChoiceSchema, PluginConfigSchema, ProviderConfigSchema, SecretRefSchema, StringOrSecretSchema, WebhooksConfigSchema, webhookTriggerPath, } from "./config.js";
|
|
2
|
-
export { AgentHealthSchema, AgentNameSchema, AgentStateSchema, ApprovalDecisionSchema, ApprovalOutcomeSchema, ApprovalResolutionSchema, AttachmentInfoSchema, AttachmentUploadSchema, BindingStatusSchema, ChatKeySchema, ChatMessageSchema, CommandNameSchema, ConfigIssueSchema, ConsolidationLogEntrySchema, ConversationModeSchema, DaemonStatusSchema, DeliveryKindSchema, DurationSchema, ExtensionStateSchema, ExtensionStatusSchema, FailedDeliverySchema, GatePressureSchema, IdSchema, LogLevelSchema, LogRecordSchema, MemoryBudgetSchema, MemoryFileSchema, MemoryNameSchema, MemorySearchHitSchema, MemorySearchScopeSchema, PendingApprovalSchema, PendingRestartSchema, PermissionActionSchema, PermissionRuleSchema, RunOriginSchema, RunStatusSchema, RunSummarySchema, RunTimelineItemSchema, RunUsageSchema, SecretInfoSchema, SecretNameSchema, SecretSourceSchema, SkillInfoSchema, TimestampSchema, ToolInfoSchema, ToolSourceSchema, TriggerInputSchema, TriggerPatchSchema, TriggerScheduleSchema, TriggerSchema, } from "./domain.js";
|
|
2
|
+
export { AgentHealthSchema, AgentNameSchema, AgentStateSchema, ApprovalDecisionSchema, ApprovalOutcomeSchema, ApprovalResolutionSchema, AttachmentInfoSchema, AttachmentUploadSchema, AvailableModelSchema, BindingStatusSchema, ChatKeySchema, ChatMessageSchema, CommandNameSchema, ConfigIssueSchema, ConsolidationLogEntrySchema, ConversationModeSchema, DaemonStatusSchema, DeliveryKindSchema, DurationSchema, ExtensionStateSchema, ExtensionStatusSchema, FailedDeliverySchema, GatePressureSchema, IdSchema, LogLevelSchema, LogRecordSchema, MemoryBudgetSchema, MemoryFileSchema, MemoryNameSchema, MemorySearchHitSchema, MemorySearchScopeSchema, ModelRefSchema, PendingApprovalSchema, PendingRestartSchema, PermissionActionSchema, PermissionRuleSchema, RunOriginSchema, RunStatusSchema, RunSummarySchema, RunTimelineItemSchema, RunUsageSchema, SecretInfoSchema, SecretNameSchema, SecretSourceSchema, SkillInfoSchema, TimestampSchema, ToolInfoSchema, ToolSourceSchema, TriggerInputSchema, TriggerPatchSchema, TriggerScheduleSchema, TriggerSchema, } from "./domain.js";
|
|
3
3
|
export { parseDuration } from "./duration.js";
|
|
4
4
|
export { EVENT_NAMES, events, eventTopic, EventTopicSchema, isEventName, } from "./events.js";
|
|
5
5
|
export { decodeClientMessage, decodeServerMessage, encodeError, encodeEvent, encodeRequest, encodeResult, RpcIdSchema, } from "./json-rpc.js";
|
|
@@ -732,6 +732,26 @@ export declare const methods: {
|
|
|
732
732
|
}>;
|
|
733
733
|
}>;
|
|
734
734
|
};
|
|
735
|
+
/**
|
|
736
|
+
* Lists the chat models of every provider with a configured credential, sorted by provider, then by model ID. With a
|
|
737
|
+
* running `agent`, `current` is the model of its CLI Chat Conversation.
|
|
738
|
+
*/
|
|
739
|
+
readonly "models.list": {
|
|
740
|
+
params: Type.TObject<{
|
|
741
|
+
agent: Type.TOptional<Type.TString>;
|
|
742
|
+
}>;
|
|
743
|
+
result: Type.TObject<{
|
|
744
|
+
current: Type.TOptional<Type.TObject<{
|
|
745
|
+
id: Type.TString;
|
|
746
|
+
provider: Type.TString;
|
|
747
|
+
}>>;
|
|
748
|
+
models: Type.TArray<Type.TObject<{
|
|
749
|
+
id: Type.TString;
|
|
750
|
+
name: Type.TString;
|
|
751
|
+
provider: Type.TString;
|
|
752
|
+
}>>;
|
|
753
|
+
}>;
|
|
754
|
+
};
|
|
735
755
|
readonly "runs.get": {
|
|
736
756
|
params: Type.TObject<{
|
|
737
757
|
agent: Type.TString;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
2
|
import { AgentConfigSchema, DeploymentConfigSchema } from "./config.js";
|
|
3
|
-
import { AgentHealthSchema, AgentNameSchema, AgentStateSchema, ApprovalResolutionSchema, AttachmentUploadSchema, BindingStatusSchema, ChatMessageSchema, CommandNameSchema, ConfigIssueSchema, ConsolidationLogEntrySchema, Count, DaemonStatusSchema, ExtensionStatusSchema, FailedDeliverySchema, IdSchema, LogLevelSchema, LogRecordSchema, MemoryBudgetSchema, MemoryFileSchema, MemoryNameSchema, MemorySearchHitSchema, MemorySearchScopeSchema, PendingApprovalSchema, PendingRestartSchema, RunSummarySchema, RunTimelineItemSchema, SecretInfoSchema, SecretNameSchema, SecretSourceSchema, SkillInfoSchema, ToolInfoSchema, TriggerSchema, TriggerInputSchema, TriggerPatchSchema, } from "./domain.js";
|
|
3
|
+
import { AgentHealthSchema, AgentNameSchema, AgentStateSchema, ApprovalResolutionSchema, AttachmentUploadSchema, AvailableModelSchema, BindingStatusSchema, ChatMessageSchema, CommandNameSchema, ConfigIssueSchema, ConsolidationLogEntrySchema, Count, DaemonStatusSchema, ExtensionStatusSchema, FailedDeliverySchema, IdSchema, LogLevelSchema, LogRecordSchema, MemoryBudgetSchema, MemoryFileSchema, MemoryNameSchema, MemorySearchHitSchema, MemorySearchScopeSchema, ModelRefSchema, PendingApprovalSchema, PendingRestartSchema, RunSummarySchema, RunTimelineItemSchema, SecretInfoSchema, SecretNameSchema, SecretSourceSchema, SkillInfoSchema, ToolInfoSchema, TriggerSchema, TriggerInputSchema, TriggerPatchSchema, } from "./domain.js";
|
|
4
4
|
import { EventTopicSchema } from "./events.js";
|
|
5
5
|
import { DISPLAY_NAME_MAX_LENGTH } from "./limits.js";
|
|
6
6
|
/** The protocol version of this package. The CLI and dashboard compare it in `system.hello`. */
|
|
@@ -157,6 +157,14 @@ export const methods = {
|
|
|
157
157
|
mode: Type.Optional(Type.Union([Type.Literal("replace"), Type.Literal("append")])),
|
|
158
158
|
name: MemoryNameSchema,
|
|
159
159
|
}), Type.Object({ file: MemoryFileSchema })),
|
|
160
|
+
/**
|
|
161
|
+
* Lists the chat models of every provider with a configured credential, sorted by provider, then by model ID. With a
|
|
162
|
+
* running `agent`, `current` is the model of its CLI Chat Conversation.
|
|
163
|
+
*/
|
|
164
|
+
"models.list": method(params({ agent: Type.Optional(AgentNameSchema) }), Type.Object({
|
|
165
|
+
current: Type.Optional(ModelRefSchema),
|
|
166
|
+
models: Type.Array(AvailableModelSchema),
|
|
167
|
+
})),
|
|
160
168
|
"runs.get": method(params({ agent: AgentNameSchema, runId: IdSchema }), Type.Object({
|
|
161
169
|
run: RunSummarySchema,
|
|
162
170
|
timeline: Type.Array(RunTimelineItemSchema),
|
|
@@ -12,8 +12,8 @@ export declare const BUILTIN_COMMANDS: readonly [{
|
|
|
12
12
|
readonly description: "Start a new Conversation in this Chat";
|
|
13
13
|
readonly name: "new";
|
|
14
14
|
}, {
|
|
15
|
-
readonly argument: "<model-id>";
|
|
16
|
-
readonly description: "
|
|
15
|
+
readonly argument: "[<model-id>]";
|
|
16
|
+
readonly description: "List the models, or use another model for this Conversation";
|
|
17
17
|
readonly name: "model";
|
|
18
18
|
}, {
|
|
19
19
|
readonly description: "Compact the current Conversation";
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
export const BUILTIN_COMMANDS = [
|
|
3
3
|
{ description: "Start a new Conversation in this Chat", name: "new" },
|
|
4
4
|
{
|
|
5
|
-
argument: "<model-id>",
|
|
6
|
-
description: "
|
|
5
|
+
argument: "[<model-id>]",
|
|
6
|
+
description: "List the models, or use another model for this Conversation",
|
|
7
7
|
name: "model",
|
|
8
8
|
},
|
|
9
9
|
{ description: "Compact the current Conversation", name: "compact" },
|
|
@@ -34,6 +34,27 @@ export interface ApprovalResolution {
|
|
|
34
34
|
}
|
|
35
35
|
/** Where an outbound `message` comes from. */
|
|
36
36
|
export type MessageSource = "reply" | "command" | "trigger";
|
|
37
|
+
/** One model of a provider, for example `anthropic` and `claude-sonnet-5-5`. */
|
|
38
|
+
export interface ModelRef {
|
|
39
|
+
readonly provider: string;
|
|
40
|
+
readonly id: string;
|
|
41
|
+
}
|
|
42
|
+
/** A model that a Sender can choose, with its display name. */
|
|
43
|
+
export interface AvailableModel extends ModelRef {
|
|
44
|
+
readonly name: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The models of a `/model` reply without an argument. Native chat Frontends can render it as a platform picker.
|
|
48
|
+
*
|
|
49
|
+
* `models` is sorted by provider, then by model ID. A selection calls `FrontendSink.command` with name `model` and
|
|
50
|
+
* args `<provider>/<id>`.
|
|
51
|
+
*/
|
|
52
|
+
export interface ModelPicker {
|
|
53
|
+
/** The model of the Chat's current Conversation, if known. */
|
|
54
|
+
readonly current?: ModelRef;
|
|
55
|
+
/** The models of every provider with a configured credential. Empty if no provider has one. */
|
|
56
|
+
readonly models: readonly AvailableModel[];
|
|
57
|
+
}
|
|
37
58
|
/** A final Agent message for a Chat. */
|
|
38
59
|
export interface MessageDelivery {
|
|
39
60
|
readonly kind: "message";
|
|
@@ -46,6 +67,8 @@ export interface MessageDelivery {
|
|
|
46
67
|
readonly source: MessageSource;
|
|
47
68
|
/** The Run that produced the reply. Streaming adapters use it to finalize their draft instead of a second message. */
|
|
48
69
|
readonly runId?: string;
|
|
70
|
+
/** Present on the reply to `/model` without an argument. `text` holds the same list as Markdown. */
|
|
71
|
+
readonly modelPicker?: ModelPicker;
|
|
49
72
|
}
|
|
50
73
|
/** A tool call that waits for an Approval in this Chat. */
|
|
51
74
|
export interface ApprovalRequestedDelivery {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { chunkMarkdown, MIN_CHUNK_LENGTH } from "./chunk.js";
|
|
2
2
|
export { BUILTIN_COMMANDS, type CommandName, type CommandSpec, type ParsedCommand, parseCommandText, } from "./commands.js";
|
|
3
3
|
export { DeliveryError, type DeliveryErrorOptions, type DeliveryFailureKind, isDeliveryError, } from "./delivery-error.js";
|
|
4
|
-
export type { ApprovalDecision, ApprovalOutcome, ApprovalRequestedDelivery, ApprovalResolution, ApprovalResolvedDelivery, Attachment, Delivery, DeliveryKind, Frontend, FrontendBinding, FrontendContext, FrontendSink, InboundCommand, InboundDecision, InboundMessage, MessageDelivery, MessageSource, RunEvent, WebhookRequest, WebhookResponse, WebhookRoute, WebhookRouteHandler, } from "./frontend.js";
|
|
4
|
+
export type { ApprovalDecision, ApprovalOutcome, ApprovalRequestedDelivery, ApprovalResolution, ApprovalResolvedDelivery, Attachment, AvailableModel, Delivery, DeliveryKind, Frontend, FrontendBinding, FrontendContext, FrontendSink, InboundCommand, InboundDecision, InboundMessage, MessageDelivery, MessageSource, ModelPicker, ModelRef, RunEvent, WebhookRequest, WebhookResponse, WebhookRoute, WebhookRouteHandler, } from "./frontend.js";
|
|
5
5
|
export type { JsonObject, JsonPrimitive, JsonValue } from "./json.js";
|
|
6
6
|
export type { Logger, SecretReader } from "./logger.js";
|
|
7
7
|
export { API_VERSION, definePlugin, type Plugin, type PluginContributions, type PluginSetupContext, } from "./plugin.js";
|