@sparkelf/dsh-bot-agent 0.0.0-stage → 0.2.9-alpha.125

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.
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Bot detail form: name, avatar, the four persona fields, and the retrieval
3
+ * summary. The parent keys this component by bot id, so the draft seeds from the
4
+ * bot on mount and a selection change remounts a fresh form.
5
+ *
6
+ * @module @sparkelf/dsh-bot-agent/client/BotDetail
7
+ */
8
+ import { type ReactNode } from 'react';
9
+ import type { BotDraftWire, BotWire } from '../api.ts';
10
+ import type { BotLocaleKey } from './locales.ts';
11
+ /** Props of the detail form. */
12
+ export interface BotDetailProps {
13
+ /** The bot being edited, or null for a new one. */
14
+ bot: BotWire | null;
15
+ t: (key: BotLocaleKey) => string;
16
+ saving: boolean;
17
+ onSave: (draft: BotDraftWire) => void;
18
+ onDelete: () => void;
19
+ onStartSession: () => void;
20
+ onBack: () => void;
21
+ }
22
+ /**
23
+ * Render the detail form.
24
+ * @param props - the bot, copy resolver, and action callbacks.
25
+ * @returns the detail form.
26
+ */
27
+ export declare function BotDetail({ bot, t, saving, onSave, onDelete, onStartSession, onBack }: BotDetailProps): ReactNode;
28
+ //# sourceMappingURL=BotDetail.d.ts.map
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Agent marketplace: discover built-in template bots and copy one into the
3
+ * user's own agents. Design-referenced from LobeHub (featured horizontal row,
4
+ * category groups with a preview cap, filter pills, debounced search, and the
5
+ * add state machine) with original components, glyphs, and copy.
6
+ *
7
+ * Search follows the client search rule through TextSearchIndex: name matches
8
+ * fuzzily across every language, summary and retrieval text match as substrings.
9
+ * A category facet or a non-empty query collapses the grouped browse into one
10
+ * complete list. Adding copies the template through the host create route and
11
+ * records its template id, so the card then reads as added.
12
+ *
13
+ * @module @sparkelf/dsh-bot-agent/client/BotMarket
14
+ */
15
+ import { type ReactNode } from 'react';
16
+ import type { BotWire } from '../api.ts';
17
+ import { type BotTemplate, type TemplateText } from './templates.ts';
18
+ import type { BotLocaleKey } from './locales.ts';
19
+ /** Props of the marketplace surface. */
20
+ export interface BotMarketProps {
21
+ t: (key: BotLocaleKey) => string;
22
+ /** Resolve a bilingual template string to the active locale. */
23
+ resolveText: (text: TemplateText) => string;
24
+ /** The user's bots, used to mark a template already copied. */
25
+ bots: BotWire[];
26
+ /** Copy a template into a new bot; resolves the draft and refreshes the store. */
27
+ addTemplate: (template: BotTemplate) => Promise<BotWire>;
28
+ /** Open an already-added bot in the My Agents detail form. */
29
+ onOpenBot: (id: string) => void;
30
+ }
31
+ /**
32
+ * Render the marketplace.
33
+ * @param props - copy resolver, locale text resolver, the user's bots, and the add/open callbacks.
34
+ * @returns the featured row and category groups, or one complete list when filtering.
35
+ */
36
+ export declare function BotMarket({ t, resolveText, bots, addTemplate, onOpenBot }: BotMarketProps): ReactNode;
37
+ //# sourceMappingURL=BotMarket.d.ts.map
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Bot management page: a view switcher between the user's agents (a grid of
3
+ * cards and the detail form one opens) and the agent marketplace. Reads the
4
+ * shared bot store; the host fetch and mutation callbacks arrive through the
5
+ * inject face, and selection and view through the store's own actions.
6
+ *
7
+ * @module @sparkelf/dsh-bot-agent/client/BotPanel
8
+ */
9
+ import { type ReactNode } from 'react';
10
+ import type { PropsLocale, PropsRuntime, PropsStore } from '@deepseek-ai/dsh-client-ui-slots/client';
11
+ import type { BotDraftWire, BotWire } from '../api.ts';
12
+ import type { BotTemplate, TemplateText } from './templates.ts';
13
+ import type { BotStoreHandle } from './SessionRowAvatar.tsx';
14
+ /** The host callbacks the page drives. */
15
+ export interface BotPanelInjected {
16
+ refresh: () => Promise<void>;
17
+ createBot: (draft: BotDraftWire) => Promise<BotWire>;
18
+ updateBot: (id: string, draft: BotDraftWire) => Promise<BotWire>;
19
+ removeBot: (id: string) => Promise<void>;
20
+ startSession: (presetId: string) => void;
21
+ /** Resolve a bilingual template string to the active locale. */
22
+ resolveText: (text: TemplateText) => string;
23
+ /** Copy a marketplace template into a new bot and refresh the store. */
24
+ addTemplate: (template: BotTemplate) => Promise<BotWire>;
25
+ }
26
+ /** Full page props: the main seat, the shared store, the locale seat, and the host callbacks. */
27
+ export type BotPanelProps = PropsRuntime<'main'> & PropsStore<BotStoreHandle> & PropsLocale<'botAgent'> & BotPanelInjected;
28
+ /**
29
+ * Render the management page.
30
+ * @param props - the seat shares and host callbacks.
31
+ * @returns the marketplace, the grid, or the detail form.
32
+ */
33
+ export declare function BotPanel({ t, useStore, actions, refresh, createBot, updateBot, removeBot, startSession, resolveText, addTemplate }: BotPanelProps): ReactNode;
34
+ //# sourceMappingURL=BotPanel.d.ts.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The sidebar's Agents glyph, from the shared primitives library so the row
3
+ * matches every other sidebar entry.
4
+ *
5
+ * @module @sparkelf/dsh-bot-agent/client/BotPanelIcon
6
+ */
7
+ import type { ReactNode } from 'react';
8
+ import type { PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots/client';
9
+ /**
10
+ * Render the glyph at the size the sidebar asks for.
11
+ * @param props - the sidebar's icon share.
12
+ * @returns the icon element.
13
+ */
14
+ export declare function BotPanelIcon({ size }: PropsRuntime<'sidebar.panellist'>): ReactNode;
15
+ //# sourceMappingURL=BotPanelIcon.d.ts.map
@@ -0,0 +1,27 @@
1
+ /**
2
+ * One hue tile: a rounded SVG square with a vertical hue gradient, a top
3
+ * highlight, a hairline, and a white glyph. Self-written and offline-safe; the
4
+ * shared recipe behind both the bot avatar catalog and the marketplace category
5
+ * color table, following the Plus design reference (radius, hairline, highlight).
6
+ *
7
+ * @module @sparkelf/dsh-bot-agent/client/HueTile
8
+ */
9
+ import { type ReactNode } from 'react';
10
+ /** Props of one hue-tile render. */
11
+ export interface HueTileProps {
12
+ /** Tile hue in degrees. */
13
+ hue: number;
14
+ /** SVG path data drawn in a 24×24 viewBox, filled white over the tile. */
15
+ glyph: string;
16
+ /** Edge length in pixels. */
17
+ size: number;
18
+ /** Accessible name; omitted renders a decorative glyph. */
19
+ label?: string | undefined;
20
+ }
21
+ /**
22
+ * Render the hue tile.
23
+ * @param props - hue, glyph path, edge size, and optional accessible name.
24
+ * @returns the tile SVG.
25
+ */
26
+ export declare function HueTile({ hue, glyph, size, label }: HueTileProps): ReactNode;
27
+ //# sourceMappingURL=HueTile.d.ts.map
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The session-row avatar seat occupant: draws the bot avatar for a session whose
3
+ * recorded preset names a bot this plugin owns, and nothing otherwise. Reading
4
+ * the shared bot store activates no session.
5
+ *
6
+ * @module @sparkelf/dsh-bot-agent/client/SessionRowAvatar
7
+ */
8
+ import type { ReactNode } from 'react';
9
+ import type { PropsRuntime, PropsStore } from '@deepseek-ai/dsh-client-ui-slots/client';
10
+ import type { createBotStore } from './store.ts';
11
+ /** The shared bot store handle type. */
12
+ export type BotStoreHandle = ReturnType<typeof createBotStore>;
13
+ /** Props of one avatar seat occurrence. */
14
+ export type SessionRowAvatarProps = PropsRuntime<'sidebar.session.row.avatar'> & PropsStore<BotStoreHandle>;
15
+ /**
16
+ * Render the row's bot avatar, or nothing for a preset this plugin does not own.
17
+ * @param props - the row's session identity and preset, plus the shared bot store.
18
+ * @returns the avatar element, or null.
19
+ */
20
+ export declare function SessionRowAvatar({ agentPreset, useStore }: SessionRowAvatarProps): ReactNode;
21
+ //# sourceMappingURL=SessionRowAvatar.d.ts.map
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Bot-agent API client: same-origin fetch over the host route family. The host
3
+ * owns the trust fence; this half only calls the shared method names.
4
+ *
5
+ * @module @sparkelf/dsh-bot-agent/client/api
6
+ */
7
+ import { type BotDraftWire, type BotWire } from '../api.ts';
8
+ /** One thrown API error carrying the host's message. */
9
+ export declare class BotApiError extends Error {
10
+ }
11
+ /** Bot CRUD client. */
12
+ export declare class BotApi {
13
+ /** Every bot, built-in first. */
14
+ list(): Promise<BotWire[]>;
15
+ /** Create a custom bot. */
16
+ create(draft: BotDraftWire): Promise<BotWire>;
17
+ /** Update a bot's editable fields. */
18
+ update(id: string, draft: BotDraftWire): Promise<BotWire>;
19
+ /** Delete a custom bot; the host refuses the built-in. */
20
+ remove(id: string): Promise<void>;
21
+ private request;
22
+ }
23
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Self-written SVG avatar catalog. Each key maps to a hue and a glyph; the
3
+ * renderer draws a rounded tile with a top highlight and a hairline, following
4
+ * the Plus design reference. No external image dependency, so avatars render
5
+ * offline. Unknown keys derive a stable hue from the key text.
6
+ *
7
+ * @module @sparkelf/dsh-bot-agent/client/avatars
8
+ */
9
+ /** One avatar definition: a catalog key, its hue, and a 24×24 glyph path. */
10
+ export interface AvatarDef {
11
+ key: string;
12
+ hue: number;
13
+ /** SVG path data drawn in a 24×24 viewBox, filled white over the tile. */
14
+ glyph: string;
15
+ }
16
+ /** The curated picker set. `super` is the built-in assistant's avatar. */
17
+ export declare const AVATARS: readonly AvatarDef[];
18
+ /**
19
+ * Resolve an avatar key to its definition.
20
+ * @param key - the stored avatar key.
21
+ * @returns the catalog definition, or a derived tile for an unknown key.
22
+ */
23
+ export declare function avatarDef(key: string): AvatarDef;
24
+ //# sourceMappingURL=avatars.d.ts.map
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Bot agent management — browser half.
3
+ *
4
+ * Contributes the official sidebar entry and the keyed main page it opens, plus
5
+ * the session-row avatar seat occupant. One shared bot store feeds both the page
6
+ * and every row, so a created or edited bot reaches the session list without a
7
+ * second fetch. New sessions bind a bot through the existing preset navigation:
8
+ * the bot's preset id is the durable session binding.
9
+ *
10
+ * @module @sparkelf/dsh-bot-agent/client
11
+ */
12
+ import type { Context } from '@deepseek-ai/cordis';
13
+ import type { MainPanelId } from '@deepseek-ai/dsh-client-ui-layout/client';
14
+ import { type BotLocaleKey } from './locales.ts';
15
+ declare module '@deepseek-ai/dsh-client-ui-slots/client' {
16
+ interface LocaleNamespaceMap {
17
+ /** Bot-agent surface copy. */
18
+ 'botAgent': BotLocaleKey;
19
+ }
20
+ }
21
+ /** Dictionary namespace owned by this plugin. */
22
+ export declare const NS = "botAgent";
23
+ /** The id shared by the sidebar entry and the main panel it opens. */
24
+ export declare const PANEL_ID: MainPanelId;
25
+ /** Services required by the registrations and the new-session hop. */
26
+ export declare const inject: string[];
27
+ /**
28
+ * Contribute the Agents entry, the management page, and the session-row avatar.
29
+ * @param ctx - the browser plugin context.
30
+ */
31
+ export declare function apply(ctx: Context): void;
32
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Locale-owned copy for the bot-agent surfaces, Chinese and English.
3
+ *
4
+ * @module @sparkelf/dsh-bot-agent/client/locales
5
+ */
6
+ /** Chinese dictionary; its keys type the namespace. */
7
+ export declare const zh: {
8
+ readonly panel: "智能体";
9
+ readonly title: "智能体";
10
+ readonly subtitle: "为会话配置身份、职责与回复风格";
11
+ readonly empty: "还没有智能体";
12
+ readonly create: "新建智能体";
13
+ readonly builtin: "内置";
14
+ readonly fieldName: "名字";
15
+ readonly fieldAvatar: "头像";
16
+ readonly fieldIdentity: "身份";
17
+ readonly fieldDuties: "职责";
18
+ readonly fieldWorkStyle: "工作方式";
19
+ readonly fieldReplyStyle: "回复风格";
20
+ readonly fieldRetrievalSummary: "检索摘要";
21
+ readonly presetSection: "预设";
22
+ readonly retrievalSection: "检索";
23
+ readonly identityPlaceholder: "这个智能体是谁";
24
+ readonly dutiesPlaceholder: "它负责什么";
25
+ readonly workStylePlaceholder: "它如何工作";
26
+ readonly replyStylePlaceholder: "它如何回复";
27
+ readonly retrievalSummaryPlaceholder: "用于路由匹配的场景与能力摘要";
28
+ readonly save: "保存";
29
+ readonly saving: "保存中…";
30
+ readonly cancel: "取消";
31
+ readonly delete: "删除";
32
+ readonly deleteConfirm: "删除该智能体?已有会话保留,但不再显示其头像。";
33
+ readonly startSession: "新建会话";
34
+ readonly back: "返回";
35
+ readonly loading: "加载中…";
36
+ readonly error: "加载失败";
37
+ readonly retry: "重试";
38
+ readonly avatarPicker: "选择头像";
39
+ readonly dutiesFallback: "通用助手";
40
+ readonly saved: "已保存";
41
+ readonly deleted: "已删除";
42
+ readonly nameRequired: "名字不能为空";
43
+ readonly readonlyPolicy: "知识库、技能与工具范围将在后续版本生效";
44
+ readonly tabMine: "我的智能体";
45
+ readonly tabMarket: "智能体市场";
46
+ readonly viewSwitcher: "智能体视图";
47
+ readonly marketSubtitle: "发现预设智能体,一键复制为我的智能体";
48
+ readonly searchPlaceholder: "搜索智能体";
49
+ readonly searchClear: "清除搜索";
50
+ readonly filterAll: "全部";
51
+ readonly featured: "精选";
52
+ readonly viewAll: "查看全部";
53
+ readonly add: "添加";
54
+ readonly adding: "添加中…";
55
+ readonly added: "已添加";
56
+ readonly addFailed: "添加失败";
57
+ readonly marketEmpty: "没有匹配的智能体";
58
+ readonly openInMine: "去我的智能体配置";
59
+ readonly close: "关闭";
60
+ readonly categoryCoding: "编程开发";
61
+ readonly categoryDesign: "设计";
62
+ readonly categoryResearch: "研究调研";
63
+ readonly categoryProduct: "产品";
64
+ readonly categoryOperations: "运营";
65
+ readonly categoryWriting: "写作翻译";
66
+ };
67
+ /** English dictionary, keyed identically. */
68
+ export declare const en: Record<keyof typeof zh, string>;
69
+ /** One copy key of the bot-agent namespace. */
70
+ export type BotLocaleKey = keyof typeof zh;
71
+ //# sourceMappingURL=locales.d.ts.map
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Shared bot viewing store: the loaded bot list plus the page's selection and
3
+ * active view. The management page and the session-row avatar seat read the same
4
+ * handle, so a created or edited bot reaches every row without a second fetch.
5
+ * The view and selection survive a panel remount, so switching away and back
6
+ * returns the user to the same place.
7
+ *
8
+ * @module @sparkelf/dsh-bot-agent/client/store
9
+ */
10
+ import { type EngineStoreHandle } from '@deepseek-ai/dsh-client-store';
11
+ import type { BotWire } from '../api.ts';
12
+ /** Load lifecycle of the bot list. */
13
+ export type BotStatus = 'idle' | 'loading' | 'ready' | 'error';
14
+ /** Which surface the management page shows: the user's agents or the marketplace. */
15
+ export type BotView = 'mine' | 'market';
16
+ /** Shared bot viewing state. */
17
+ export interface BotState {
18
+ bots: BotWire[];
19
+ status: BotStatus;
20
+ error: string | null;
21
+ selectedId: string | null;
22
+ view: BotView;
23
+ }
24
+ /** The complete mutation API of the bot store. */
25
+ export type BotActions = {
26
+ setBots: (draft: BotState, bots: BotWire[]) => void;
27
+ setLoading: (draft: BotState) => void;
28
+ setError: (draft: BotState, error: string) => void;
29
+ select: (draft: BotState, id: string | null) => void;
30
+ setView: (draft: BotState, view: BotView) => void;
31
+ };
32
+ /**
33
+ * Create the bot viewing store handle.
34
+ * @returns the store handle shared by the page and the avatar seat.
35
+ */
36
+ export declare function createBotStore(): EngineStoreHandle<BotState, BotActions>;
37
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Agent marketplace catalog: a self-written category color table and the
3
+ * built-in template bots a user copies into their own agents.
4
+ *
5
+ * The marketplace is design-referenced from LobeHub (layout, grouping, and the
6
+ * add state machine) but every glyph, hue, and string here is original; no
7
+ * LobeHub application code is copied. Template text is bilingual so the card
8
+ * reads in the active locale and the search index matches every language. The
9
+ * category tile reuses the avatar hue-tile recipe (gradient, top highlight,
10
+ * hairline) through {@link HueTile}.
11
+ *
12
+ * @module @sparkelf/dsh-bot-agent/client/templates
13
+ */
14
+ import type { BotDraftWire } from '../api.ts';
15
+ /** One bilingual template string; resolved to the active locale on display and on add. */
16
+ export type TemplateText = {
17
+ zh: string;
18
+ en: string;
19
+ };
20
+ /** The marketplace categories, each owning a hue and a glyph in the color table. */
21
+ export type TemplateCategory = 'coding' | 'design' | 'research' | 'product' | 'operations' | 'writing';
22
+ /** One category's tile appearance: a hue and a 24×24 white glyph path. */
23
+ export interface CategoryMeta {
24
+ hue: number;
25
+ glyph: string;
26
+ }
27
+ /**
28
+ * Category → hue + glyph color table, the marketplace's own classification
29
+ * palette (coding indigo, design purple, research blue, product orange,
30
+ * operations green, writing amber). Glyphs are self-written SVG paths.
31
+ */
32
+ export declare const CATEGORY_META: Record<TemplateCategory, CategoryMeta>;
33
+ /** One marketplace template: a copyable agent configuration with bilingual prose. */
34
+ export interface BotTemplate {
35
+ /** Stable template id; recorded on the copied bot as its `templateId`. */
36
+ id: string;
37
+ category: TemplateCategory;
38
+ /** Avatar catalog key the template renders and copies. */
39
+ avatar: string;
40
+ /** Whether the template appears in the featured horizontal row. */
41
+ featured: boolean;
42
+ name: TemplateText;
43
+ /** Duty summary shown on the card and matched by search. */
44
+ summary: TemplateText;
45
+ /** Scenario/capability summary copied into the bot for delegation routing. */
46
+ retrievalSummary: TemplateText;
47
+ preset: {
48
+ identity: TemplateText;
49
+ duties: TemplateText;
50
+ workStyle: TemplateText;
51
+ replyStyle: TemplateText;
52
+ };
53
+ }
54
+ /** The built-in template bots, in display order within each category. */
55
+ export declare const BOT_TEMPLATES: readonly BotTemplate[];
56
+ /**
57
+ * Copy a template into a create draft, resolving every bilingual field through
58
+ * the active locale and recording the template id so the marketplace can mark
59
+ * the copy as added.
60
+ * @param template - the template being added.
61
+ * @param resolve - resolves a bilingual string to the active locale.
62
+ * @returns the draft the create route accepts.
63
+ */
64
+ export declare function templateToDraft(template: BotTemplate, resolve: (text: TemplateText) => string): BotDraftWire;
65
+ //# sourceMappingURL=templates.d.ts.map
@@ -0,0 +1,22 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import z from '@deepseek-ai/schemastery';
3
+ /** Stable cordis plugin name. */
4
+ export declare const name = "bot-agent";
5
+ /** Services required before the domain, routes, and presets can mount. */
6
+ export declare const inject: string[];
7
+ /** Plugin configuration. */
8
+ export interface Config {
9
+ /** Preset whose composition each bot copies; the registry's default when omitted. */
10
+ basePreset?: string;
11
+ /** Minimum retrievalSummary coverage (0..1) for routing a delegation to a bot preset. */
12
+ routingMinCoverage?: number;
13
+ }
14
+ /** Runtime schema for the plugin config. */
15
+ export declare const Config: z<Config>;
16
+ /**
17
+ * Mount the bot domain, built-in seed, presets, and CRUD routes.
18
+ * @param ctx - host context carrying storage, the web server, and the preset registry.
19
+ * @param config - resolved plugin config.
20
+ */
21
+ export declare function apply(ctx: Context, config?: Config): void;
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,33 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import type { PresetDefinition } from '@deepseek-ai/dsh-agent-preset-registry';
3
+ import type { AgentPresetDocument } from '@deepseek-ai/dsh-agent-preset-registry/types';
4
+ import type { Bot } from './storage.ts';
5
+ /**
6
+ * Compose the bot's persona prefix from its four prose fields.
7
+ *
8
+ * An empty identity keeps the base composition's own prefix, so a bot that only
9
+ * sets duties still runs the deployment's coding-agent prompt. The non-empty
10
+ * fields append as labelled sections.
11
+ * @param bot - the bot whose prose composes the prefix.
12
+ * @param basePrefix - the base composition's persona prefix, the identity fallback.
13
+ * @returns the persona prefix template.
14
+ */
15
+ export declare function botPersonaPrefix(bot: Bot, basePrefix: string): string;
16
+ /**
17
+ * Read the base preset's document, waiting out the boot ordering where the base
18
+ * declaration registers after this plugin activates.
19
+ * @param ctx - host context carrying the preset registry.
20
+ * @param baseId - the preset identity to copy.
21
+ * @param deadlineMs - how long to wait for the declaration to appear.
22
+ * @returns the base document.
23
+ * @throws the last read failure once the deadline passes.
24
+ */
25
+ export declare function readBaseDocument(ctx: Context, baseId: string, deadlineMs: number): Promise<AgentPresetDocument>;
26
+ /**
27
+ * Build the bot's preset definition from the base composition.
28
+ * @param document - the base preset's declared document.
29
+ * @param bot - the bot whose persona and metadata the preset carries.
30
+ * @returns a definition ready for `agentPresets.register`.
31
+ */
32
+ export declare function buildBotPreset(document: AgentPresetDocument, bot: Bot): PresetDefinition;
33
+ //# sourceMappingURL=presets.d.ts.map
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Task→bot routing: match a delegation's task text against each bot's
3
+ * retrievalSummary and pick the best-covering bot preset.
4
+ *
5
+ * The business rule lives here, not in the delegation tool: `dsh-tool-subagent`
6
+ * offers the task text through the `subagent/preset-proposal` waterfall, and this
7
+ * package's host half answers with a bot id. Matching is token coverage — the
8
+ * fraction of a summary's tokens that appear in the task — over ASCII words and
9
+ * CJK character bigrams, so Chinese summaries match without a segmenter.
10
+ * @module @sparkelf/dsh-bot-agent/routing
11
+ */
12
+ /** A bot offered for routing: its identity and configurable scenario summary. */
13
+ export interface RoutableBot {
14
+ /** The bot id, which is also its agent preset id. */
15
+ id: string;
16
+ /** The configurable scenario/capability summary matched against the task. */
17
+ retrievalSummary: string;
18
+ }
19
+ /**
20
+ * Tokenize text for coverage matching: lowercase ASCII words plus CJK character
21
+ * bigrams. Bigrams approximate Chinese word boundaries without a segmenter; a
22
+ * one-character CJK run yields no bigram and contributes nothing.
23
+ * @param text - the task or summary text.
24
+ * @returns the distinct match tokens.
25
+ */
26
+ export declare function matchTokens(text: string): Set<string>;
27
+ /**
28
+ * Pick the bot whose retrievalSummary best covers the task text. Coverage is the
29
+ * fraction of the summary's tokens present in the task; a bot is eligible only
30
+ * when its coverage reaches `minCoverage`. The highest-coverage eligible bot wins;
31
+ * ties keep the caller's order. A bot with an empty summary is never eligible.
32
+ * @param bots - candidate bots, in the caller's preference order.
33
+ * @param taskText - the delegation's task text (description and prompt).
34
+ * @param minCoverage - the minimum coverage in [0,1] a bot must reach.
35
+ * @returns the selected bot id, or undefined when no bot reaches the threshold.
36
+ */
37
+ export declare function matchBotPreset(bots: readonly RoutableBot[], taskText: string, minCoverage: number): string | undefined;
38
+ //# sourceMappingURL=routing.d.ts.map
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Durable bot entities over the storage-domain `agents` domain.
3
+ *
4
+ * One `bots` table holds every agent configuration record. The schema is the
5
+ * single authority for a record's layout: the domain validates every stored row
6
+ * at the durable read boundary, and the same inference types the Host handle.
7
+ * @module @sparkelf/dsh-bot-agent/storage
8
+ */
9
+ import { z } from 'zod';
10
+ import { type Branded } from '@deepseek-ai/dsh-brand';
11
+ /** Opaque bot identity; also the id of the agent preset the bot composes. */
12
+ export type BotId = Branded<'bot-id'>;
13
+ /** One stored bot record. New optional fields default so older rows stay readable. */
14
+ export declare const botSchema: z.ZodObject<{
15
+ id: z.ZodPipe<z.ZodString, z.ZodTransform<BotId, string>>;
16
+ name: z.ZodString;
17
+ avatar: z.ZodString;
18
+ preset: z.ZodObject<{
19
+ identity: z.ZodDefault<z.ZodString>;
20
+ duties: z.ZodDefault<z.ZodString>;
21
+ workStyle: z.ZodDefault<z.ZodString>;
22
+ replyStyle: z.ZodDefault<z.ZodString>;
23
+ }, z.core.$strict>;
24
+ retrievalSummary: z.ZodDefault<z.ZodString>;
25
+ kbScope: z.ZodDefault<z.ZodObject<{
26
+ mode: z.ZodDefault<z.ZodEnum<{
27
+ all: "all";
28
+ include: "include";
29
+ exclude: "exclude";
30
+ }>>;
31
+ paths: z.ZodDefault<z.ZodArray<z.ZodString>>;
32
+ }, z.core.$strict>>;
33
+ skillPolicy: z.ZodDefault<z.ZodObject<{
34
+ mode: z.ZodDefault<z.ZodEnum<{
35
+ all: "all";
36
+ allow: "allow";
37
+ deny: "deny";
38
+ }>>;
39
+ list: z.ZodDefault<z.ZodArray<z.ZodString>>;
40
+ }, z.core.$strict>>;
41
+ toolPolicy: z.ZodDefault<z.ZodObject<{
42
+ mode: z.ZodDefault<z.ZodEnum<{
43
+ all: "all";
44
+ allow: "allow";
45
+ deny: "deny";
46
+ }>>;
47
+ list: z.ZodDefault<z.ZodArray<z.ZodString>>;
48
+ }, z.core.$strict>>;
49
+ createdAt: z.ZodNumber;
50
+ builtin: z.ZodDefault<z.ZodBoolean>;
51
+ templateId: z.ZodOptional<z.ZodString>;
52
+ }, z.core.$strict>;
53
+ /** One bot entity, typed by its storage schema. */
54
+ export type Bot = z.infer<typeof botSchema>;
55
+ /** The authoritative `agents` domain: one `bots` table, whole-unit layout. */
56
+ export declare const agentsDomain: {
57
+ name: string;
58
+ version: number;
59
+ tables: {
60
+ bots: import("@deepseek-ai/dsh-storage-domain").DomainTableSpec<BotId, {
61
+ id: BotId;
62
+ name: string;
63
+ avatar: string;
64
+ preset: {
65
+ identity: string;
66
+ duties: string;
67
+ workStyle: string;
68
+ replyStyle: string;
69
+ };
70
+ retrievalSummary: string;
71
+ kbScope: {
72
+ mode: "all" | "include" | "exclude";
73
+ paths: string[];
74
+ };
75
+ skillPolicy: {
76
+ mode: "all" | "allow" | "deny";
77
+ list: string[];
78
+ };
79
+ toolPolicy: {
80
+ mode: "all" | "allow" | "deny";
81
+ list: string[];
82
+ };
83
+ createdAt: number;
84
+ builtin: boolean;
85
+ templateId?: string | undefined;
86
+ }>;
87
+ };
88
+ };
89
+ //# sourceMappingURL=storage.d.ts.map