@sparkelf/dsh-bot-agent 0.0.0-stage → 0.2.9-alpha.127
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.i18n.yaml +34 -0
- package/README.md +68 -2
- package/README.zh.md +69 -0
- package/lib/client.js +3 -0
- package/lib/index.js +675 -0
- package/lib/types/api.d.ts +70 -0
- package/lib/types/builtin.d.ts +12 -0
- package/lib/types/client/BotAvatar.d.ts +26 -0
- package/lib/types/client/BotAvatarPicker.d.ts +20 -0
- package/lib/types/client/BotDetail.d.ts +28 -0
- package/lib/types/client/BotMarket.d.ts +37 -0
- package/lib/types/client/BotPanel.d.ts +34 -0
- package/lib/types/client/BotPanelIcon.d.ts +15 -0
- package/lib/types/client/HueTile.d.ts +27 -0
- package/lib/types/client/SessionRowAvatar.d.ts +21 -0
- package/lib/types/client/api.d.ts +23 -0
- package/lib/types/client/avatars.d.ts +24 -0
- package/lib/types/client/index.d.ts +38 -0
- package/lib/types/client/locales.d.ts +74 -0
- package/lib/types/client/mention.d.ts +31 -0
- package/lib/types/client/store.d.ts +37 -0
- package/lib/types/client/templates.d.ts +65 -0
- package/lib/types/index.d.ts +22 -0
- package/lib/types/policy.d.ts +53 -0
- package/lib/types/presets.d.ts +33 -0
- package/lib/types/routing.d.ts +38 -0
- package/lib/types/storage.d.ts +89 -0
- package/package.json +94 -4
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-bot policy enforcement at session creation.
|
|
3
|
+
*
|
|
4
|
+
* A bot's `toolPolicy` and `kbScope` narrow what an agent running its preset may
|
|
5
|
+
* see and call. The enforcement reuses the harness's own scoped tool seams —
|
|
6
|
+
* `tools.restrict` for the inherited-tool mask and `tools.guard` for an
|
|
7
|
+
* execution-time knowledge-path check — applied on the agent's own scope when the
|
|
8
|
+
* agent is created, so a live session keeps the policy it composed from and only
|
|
9
|
+
* sessions created after an edit pick up the new one. `skillPolicy` is enforced
|
|
10
|
+
* separately through the `tool-skill` row's catalog filter (see `presets.ts`).
|
|
11
|
+
* @module @sparkelf/dsh-bot-agent/policy
|
|
12
|
+
*/
|
|
13
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
14
|
+
import type { ToolRestriction } from '@deepseek-ai/dsh-tools';
|
|
15
|
+
import type { BotKbScopeWire, BotPolicyWire } from './api.ts';
|
|
16
|
+
import type { Bot } from './storage.ts';
|
|
17
|
+
/**
|
|
18
|
+
* Compute the inherited-tool mask a bot's tool policy imposes.
|
|
19
|
+
*
|
|
20
|
+
* `deny` accepts any name (the registry removes a name even before anything offers
|
|
21
|
+
* it), so the list passes through unchanged. `allow` keeps only names an inherited
|
|
22
|
+
* registration can offer, intersected with the live tool universe; an empty result
|
|
23
|
+
* hides every inherited tool, the fail-closed reading of a whitelist. `all` and an
|
|
24
|
+
* empty deny list impose no mask.
|
|
25
|
+
* @param policy - the bot's stored tool policy.
|
|
26
|
+
* @param knownNames - tool names the agent's composition offers before the mask.
|
|
27
|
+
* @returns the restriction to apply, or undefined when the policy narrows nothing.
|
|
28
|
+
*/
|
|
29
|
+
export declare function toolRestrictionFilter(policy: BotPolicyWire, knownNames: ReadonlySet<string>): ToolRestriction | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Compute a guard denial for a knowledge-base file call outside the bot's scope.
|
|
32
|
+
*
|
|
33
|
+
* Only the explicit-path file tools are checked; a narrowed scope cannot admit a
|
|
34
|
+
* whole-tree extract (no path argument). Query-based reads (`kb_search` and the
|
|
35
|
+
* citation/outline tools) carry no path to scope here and stay with the
|
|
36
|
+
* knowledge-base plugin's own authorization.
|
|
37
|
+
* @param kbScope - the bot's stored knowledge scope.
|
|
38
|
+
* @param toolName - the executing tool's name.
|
|
39
|
+
* @param args - the call's parsed arguments.
|
|
40
|
+
* @returns a model-facing denial reason, or undefined when the call is in scope.
|
|
41
|
+
*/
|
|
42
|
+
export declare function kbScopeDenial(kbScope: BotKbScopeWire, toolName: string, args: unknown): string | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Apply each bot's tool and knowledge policies to agents as they are created.
|
|
45
|
+
*
|
|
46
|
+
* The listener reads the agent's composed preset, looks up that bot, and applies
|
|
47
|
+
* the mask and guard on the agent's own scope. Both registrations are owned by the
|
|
48
|
+
* agent's context, so they lift when the agent disposes; nothing is tracked here.
|
|
49
|
+
* @param ctx - host context carrying the agent registry, tool registry, and preset registry.
|
|
50
|
+
* @param lookupBot - resolves a preset id to its stored bot, or undefined.
|
|
51
|
+
*/
|
|
52
|
+
export declare function installPolicyEnforcement(ctx: Context, lookupBot: (presetId: string) => Bot | undefined): void;
|
|
53
|
+
//# sourceMappingURL=policy.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
|
package/package.json
CHANGED
|
@@ -1,6 +1,96 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sparkelf/dsh-bot-agent",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.9-alpha.127",
|
|
4
|
+
"description": "Agent (bot) management for the dsh web client: a sidebar destination with grid cards and a detail form, durable bot entities over storage-domain, a built-in super assistant, and per-bot agent presets that bind a session's composition and avatar",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
|
|
11
|
+
"directory": "packages/plus/bot-agent"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "lib/index.js",
|
|
15
|
+
"types": "lib/types/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./lib/types/index.d.ts",
|
|
19
|
+
"default": "./lib/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./client": {
|
|
22
|
+
"types": "./lib/types/client/index.d.ts",
|
|
23
|
+
"default": "./lib/client.js"
|
|
24
|
+
},
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
},
|
|
27
|
+
"dsh": {
|
|
28
|
+
"client": {
|
|
29
|
+
"inject": [
|
|
30
|
+
"@deepseek-ai/dsh-client-locale",
|
|
31
|
+
"@deepseek-ai/dsh-client-ui-renderer",
|
|
32
|
+
"@deepseek-ai/dsh-client-ui-sidebar",
|
|
33
|
+
"@deepseek-ai/dsh-client-ui-layout",
|
|
34
|
+
"@deepseek-ai/dsh-client-ui-slots",
|
|
35
|
+
"@deepseek-ai/dsh-client-ui-workspace",
|
|
36
|
+
"@deepseek-ai/dsh-client-ui-subagent",
|
|
37
|
+
"@deepseek-ai/dsh-client-ui-input-trigger",
|
|
38
|
+
"@deepseek-ai/dsh-api-session-controller",
|
|
39
|
+
"@deepseek-ai/dsh-api-workspace-controller"
|
|
40
|
+
],
|
|
41
|
+
"platform": "web"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"bundle": "tsdown",
|
|
46
|
+
"watch": "tsdown --watch"
|
|
47
|
+
},
|
|
48
|
+
"files": [
|
|
49
|
+
"lib/index.js",
|
|
50
|
+
"lib/client.js",
|
|
51
|
+
"lib/types/**/*.d.ts"
|
|
52
|
+
],
|
|
53
|
+
"license": "MIT",
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@deepseek-ai/cordis-plugin-include": "workspace:*",
|
|
56
|
+
"@deepseek-ai/dsh-brand": "workspace:*",
|
|
57
|
+
"@deepseek-ai/schemastery": "workspace:~",
|
|
58
|
+
"zod": "4.6.6"
|
|
59
|
+
},
|
|
60
|
+
"peerDependencies": {
|
|
61
|
+
"@deepseek-ai/cordis": "workspace:~",
|
|
62
|
+
"@deepseek-ai/dsh-agent": "workspace:*",
|
|
63
|
+
"@deepseek-ai/dsh-agent-preset-registry": "workspace:*",
|
|
64
|
+
"@deepseek-ai/dsh-host-webserver": "workspace:*",
|
|
65
|
+
"@deepseek-ai/dsh-session": "workspace:*",
|
|
66
|
+
"@deepseek-ai/dsh-storage-domain": "workspace:*",
|
|
67
|
+
"@deepseek-ai/dsh-tools": "workspace:*"
|
|
68
|
+
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"@deepseek-ai/cordis": "workspace:^",
|
|
71
|
+
"@deepseek-ai/dsh-agent": "workspace:^",
|
|
72
|
+
"@deepseek-ai/dsh-agent-preset-registry": "workspace:^",
|
|
73
|
+
"@deepseek-ai/dsh-api-session-controller": "workspace:^",
|
|
74
|
+
"@deepseek-ai/dsh-api-workspace-controller": "workspace:^",
|
|
75
|
+
"@deepseek-ai/dsh-client-locale": "workspace:^",
|
|
76
|
+
"@deepseek-ai/dsh-client-ui-input-trigger": "workspace:^",
|
|
77
|
+
"@deepseek-ai/dsh-client-ui-layout": "workspace:^",
|
|
78
|
+
"@deepseek-ai/dsh-client-ui-primitives": "workspace:^",
|
|
79
|
+
"@deepseek-ai/dsh-client-ui-renderer": "workspace:^",
|
|
80
|
+
"@deepseek-ai/dsh-client-ui-sidebar": "workspace:^",
|
|
81
|
+
"@deepseek-ai/dsh-client-ui-slots": "workspace:^",
|
|
82
|
+
"@deepseek-ai/dsh-client-ui-subagent": "workspace:^",
|
|
83
|
+
"@deepseek-ai/dsh-client-ui-workspace": "workspace:^",
|
|
84
|
+
"@deepseek-ai/dsh-host-webserver": "workspace:^",
|
|
85
|
+
"@deepseek-ai/dsh-session": "workspace:^",
|
|
86
|
+
"@deepseek-ai/dsh-storage-domain": "workspace:^",
|
|
87
|
+
"@deepseek-ai/dsh-tool-subagent": "workspace:^",
|
|
88
|
+
"@deepseek-ai/dsh-tools": "workspace:^",
|
|
89
|
+
"@deepseek-ai/dsh-util-text-search": "workspace:^",
|
|
90
|
+
"@deepseek-ai/dsh-package-manifest": "workspace:^",
|
|
91
|
+
"@types/react": "~19.3.2",
|
|
92
|
+
"@types/react-dom": "~19.3.0",
|
|
93
|
+
"react": "^19.3.1",
|
|
94
|
+
"react-dom": "^19.3.1"
|
|
95
|
+
}
|
|
96
|
+
}
|