@free-lzj/dsh-browser-use 0.0.0-stage → 0.1.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 +113 -2
- package/cordis.patch.yml +11 -0
- package/lib/client.js +193 -0
- package/lib/index.js +743 -0
- package/lib/types/browser-mention.d.ts +18 -0
- package/lib/types/bsk.d.ts +80 -0
- package/lib/types/client/index.d.ts +41 -0
- package/lib/types/client/locales.d.ts +19 -0
- package/lib/types/index.d.ts +58 -0
- package/lib/types/mcp-tabs.d.ts +35 -0
- package/lib/types/mention.d.ts +65 -0
- package/lib/types/protocol.d.ts +53 -0
- package/lib/types/routes.d.ts +33 -0
- package/lib/types/skill.d.ts +20 -0
- package/lib/types/tools.d.ts +35 -0
- package/package.json +90 -4
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The browser tab provider: the first, and for now the only, mentionable thing.
|
|
3
|
+
*
|
|
4
|
+
* Everything specific to browsers lives here — the query match, the row text,
|
|
5
|
+
* the ref shape. The registry above and the routes beside it stay ignorant of
|
|
6
|
+
* what a tab is, which is what lets the next provider be a new file alone.
|
|
7
|
+
*
|
|
8
|
+
* @module @free-lzj/dsh-browser-use/browser-mention
|
|
9
|
+
*/
|
|
10
|
+
import type { BskMcpChannel } from './mcp-tabs.ts';
|
|
11
|
+
import type { MentionProvider } from './mention.ts';
|
|
12
|
+
/**
|
|
13
|
+
* Build the browser provider over one CLI handle.
|
|
14
|
+
* @param cli - the shared `bsk` session.
|
|
15
|
+
* @returns the provider the registry holds.
|
|
16
|
+
*/
|
|
17
|
+
export declare function browserMentionProvider(cli: BskMcpChannel): MentionProvider;
|
|
18
|
+
//# sourceMappingURL=browser-mention.d.ts.map
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `bsk` CLI, as this plugin drives it.
|
|
3
|
+
*
|
|
4
|
+
* Everything below is one process per command: no long-lived pipe, no protocol of
|
|
5
|
+
* our own. `bsk` already owns the browser side — the daemon, the extension, the
|
|
6
|
+
* borrowed-tab lifecycle — so the only thing worth building here is (a) one
|
|
7
|
+
* session reused across calls, and (b) the borrow/act/return bracket, which is
|
|
8
|
+
* what keeps a user tab from staying borrowed after a single read.
|
|
9
|
+
*
|
|
10
|
+
* @module @free-lzj/dsh-browser-use/bsk
|
|
11
|
+
*/
|
|
12
|
+
import type { BrowserTab, TabAction } from './protocol.ts';
|
|
13
|
+
/** How to reach the CLI. */
|
|
14
|
+
export interface BskConfig {
|
|
15
|
+
/** Executable name or absolute path; `bsk` on PATH by default. */
|
|
16
|
+
readonly path: string;
|
|
17
|
+
/** Name the browser's own control overlay shows, so the user knows who is driving. */
|
|
18
|
+
readonly agentName: string;
|
|
19
|
+
/** Per-command ceiling; starting a session opens a window, reading a page does not. */
|
|
20
|
+
readonly timeoutMs: number;
|
|
21
|
+
}
|
|
22
|
+
/** One action asked of one borrowed tab. */
|
|
23
|
+
export interface TabRequest {
|
|
24
|
+
readonly tabId: number;
|
|
25
|
+
readonly action: TabAction;
|
|
26
|
+
/** Element ref (`@e3`) for click/fill, URL for navigate; unused elsewhere. */
|
|
27
|
+
readonly target?: string;
|
|
28
|
+
/** Text to type, for fill. */
|
|
29
|
+
readonly value?: string;
|
|
30
|
+
}
|
|
31
|
+
/** What one action produced. */
|
|
32
|
+
export interface TabActionResult {
|
|
33
|
+
/** The command's own output, already trimmed. */
|
|
34
|
+
readonly text: string;
|
|
35
|
+
/** Where a screenshot landed, when the action was one. */
|
|
36
|
+
readonly path?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* One `bsk` session, started on first use.
|
|
40
|
+
*
|
|
41
|
+
* Reused rather than per-call: `session start` opens a window, which is a visible
|
|
42
|
+
* interruption and takes seconds. The session lives as long as this plugin does
|
|
43
|
+
* and is stopped in its disposer.
|
|
44
|
+
*/
|
|
45
|
+
export declare class BskCli {
|
|
46
|
+
#private;
|
|
47
|
+
/**
|
|
48
|
+
* @param config - executable, overlay label, and per-command ceiling.
|
|
49
|
+
*/
|
|
50
|
+
constructor(config?: Partial<BskConfig>);
|
|
51
|
+
/**
|
|
52
|
+
* The active session id, starting one when there is none.
|
|
53
|
+
*
|
|
54
|
+
* A failed start is dropped instead of cached: a browser that was closed and
|
|
55
|
+
* reopened must be able to answer the next `@` without a restart of DSH.
|
|
56
|
+
* @returns the session id.
|
|
57
|
+
*/
|
|
58
|
+
ensureSession(): Promise<string>;
|
|
59
|
+
/**
|
|
60
|
+
* Every tab in the user's own windows.
|
|
61
|
+
*
|
|
62
|
+
* `--scope user` and not `all`: the agent's own Agent Window is a tool this
|
|
63
|
+
* plugin drives, never something the user meant to mention.
|
|
64
|
+
* @returns the tabs, most useful first (active tabs lead within a window).
|
|
65
|
+
*/
|
|
66
|
+
listUserTabs(): Promise<readonly BrowserTab[]>;
|
|
67
|
+
/**
|
|
68
|
+
* Run one action against a user tab, borrowing it for exactly that long.
|
|
69
|
+
*
|
|
70
|
+
* The bracket is not optional: `bsk` protects user tabs, so an unborrowed tab
|
|
71
|
+
* answers nothing, and a borrowed one left behind keeps the browser's control
|
|
72
|
+
* marker on a tab nobody is using.
|
|
73
|
+
* @param request - tab, action, and the action's own argument.
|
|
74
|
+
* @returns the action's output.
|
|
75
|
+
*/
|
|
76
|
+
act(request: TabRequest): Promise<TabActionResult>;
|
|
77
|
+
/** Stop the session this instance started, if any. */
|
|
78
|
+
dispose(): Promise<void>;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=bsk.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mentionable things in the `@` menu — browser half.
|
|
3
|
+
*
|
|
4
|
+
* The harness already owns `@`: `ui-input-trigger` renders the grouped menu and
|
|
5
|
+
* routes a pick to whichever source registered the row. Files and sessions come
|
|
6
|
+
* from `ui-reference`; this source adds everything that is neither, and the
|
|
7
|
+
* Host's provider registry decides what that is today.
|
|
8
|
+
*
|
|
9
|
+
* A pick inserts one atomic chip whose serialized form is the same
|
|
10
|
+
* `@[label](scheme:id)` mention the harness uses for a session. That is not
|
|
11
|
+
* decoration: the model reads the chip as text, so the mention has to carry the
|
|
12
|
+
* id the `browser_tab` tool can act on.
|
|
13
|
+
*
|
|
14
|
+
* @module @free-lzj/dsh-browser-use/client
|
|
15
|
+
*/
|
|
16
|
+
import type { Context as ClientContext } from '@deepseek-ai/cordis';
|
|
17
|
+
import { type BrowserUseKey } from './locales.ts';
|
|
18
|
+
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
19
|
+
interface LocaleNamespaceMap {
|
|
20
|
+
/** `@` menu section headings. */
|
|
21
|
+
browserUse: BrowserUseKey;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** Required services: the trigger registry and the copy. */
|
|
25
|
+
export declare const inject: string[];
|
|
26
|
+
/**
|
|
27
|
+
* The mention scheme a ref is rewritten to.
|
|
28
|
+
*
|
|
29
|
+
* `browser:299872133` becomes `dsh-browser:299872133` so every scheme this menu
|
|
30
|
+
* produces looks alike (`dsh-session:` already does), and nothing mistakes a tab
|
|
31
|
+
* id for a path.
|
|
32
|
+
* @param ref - provider-qualified ref, as the Host returned it.
|
|
33
|
+
* @returns the mention's own address.
|
|
34
|
+
*/
|
|
35
|
+
export declare function mentionAddress(ref: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Register the mention source.
|
|
38
|
+
* @param ctx - client root context.
|
|
39
|
+
*/
|
|
40
|
+
export declare function apply(ctx: ClientContext): void;
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `@` menu's copy for this plugin.
|
|
3
|
+
*
|
|
4
|
+
* Only the section heading needs translating: every row's text is the user's own
|
|
5
|
+
* page title, which no dictionary can hold.
|
|
6
|
+
*
|
|
7
|
+
* @module @free-lzj/dsh-browser-use/client/locales
|
|
8
|
+
*/
|
|
9
|
+
/** Dictionary namespace owned by this plugin. */
|
|
10
|
+
export declare const NS = "browserUse";
|
|
11
|
+
/** Simplified Chinese dictionary (the key-set source of truth). */
|
|
12
|
+
export declare const zh: {
|
|
13
|
+
readonly sectionBrowser: "浏览器";
|
|
14
|
+
};
|
|
15
|
+
/** English dictionary, key-identical to the Chinese source of truth. */
|
|
16
|
+
export declare const en: Record<BrowserUseKey, string>;
|
|
17
|
+
/** Key domain of the `browserUse` namespace. */
|
|
18
|
+
export type BrowserUseKey = keyof typeof zh;
|
|
19
|
+
//# sourceMappingURL=locales.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser use for DSH — Host half.
|
|
3
|
+
*
|
|
4
|
+
* Two halves of one idea, and they are deliberately different in kind:
|
|
5
|
+
*
|
|
6
|
+
* - **Mentioning** is ours. Nothing in the harness lists what a person has open,
|
|
7
|
+
* so this plugin contributes that: a provider registry, one read-only route,
|
|
8
|
+
* and a browser provider on top of `bsk tab list`.
|
|
9
|
+
* - **Operating** is BrowserSkill's. Its CLI already ships an MCP server with the
|
|
10
|
+
* full action set, and the harness already knows how to give one MCP server to
|
|
11
|
+
* one Session — `mountSessionMcp` is what the official Chrome DevTools and
|
|
12
|
+
* Playwright providers use. Rebuilding those tools here would mean shipping a
|
|
13
|
+
* copy that drifts from upstream on every release.
|
|
14
|
+
*
|
|
15
|
+
* The skill body travels with the plugin for the same reason: installing this is
|
|
16
|
+
* meant to be enough, so the separate `browser-skill` agent skill is not needed.
|
|
17
|
+
*
|
|
18
|
+
* @module @free-lzj/dsh-browser-use
|
|
19
|
+
*/
|
|
20
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
21
|
+
export { BskMcpChannel } from './mcp-tabs.ts';
|
|
22
|
+
export { browserMentionProvider } from './browser-mention.ts';
|
|
23
|
+
export { MentionRegistry, type CollectedMentions, type MentionProvider } from './mention.ts';
|
|
24
|
+
export * from './protocol.ts';
|
|
25
|
+
export { isSameOrigin, registerRoutes, respond } from './routes.ts';
|
|
26
|
+
export { BROWSER_SKILL, SKILL_NAME } from './skill.ts';
|
|
27
|
+
/**
|
|
28
|
+
* MCP server name; every tool this plugin contributes is `mcp__<name>__*`.
|
|
29
|
+
*
|
|
30
|
+
* Not `bsk` and not `browser`: the name is a namespace the model reads on every
|
|
31
|
+
* call, so it should say whose tools these are and never collide with a server
|
|
32
|
+
* the person wired up themselves.
|
|
33
|
+
*/
|
|
34
|
+
export declare const MCP_SERVER_NAME = "browser-skill";
|
|
35
|
+
/**
|
|
36
|
+
* Mount BrowserSkill's MCP server once, for the whole Host.
|
|
37
|
+
*
|
|
38
|
+
* The harness's experimental browser-use runtime would mount one server per
|
|
39
|
+
* Session, but it ships outside the dsh installation and needs a provider
|
|
40
|
+
* registry (`ctx.browserUse`) that not every profile carries. This plugin mounts
|
|
41
|
+
* one server instead: every Agent sees `mcp__browser-skill__*`, and the cost is
|
|
42
|
+
* that two Sessions driving the browser at once share a single BrowserSkill
|
|
43
|
+
* session — and therefore one Agent Window. For one person in one conversation
|
|
44
|
+
* that is the honest trade; a per-Session server would need the runtime package.
|
|
45
|
+
* @param ctx - the Host plugin context.
|
|
46
|
+
*/
|
|
47
|
+
export declare function mountBrowserTools(ctx: Context): void;
|
|
48
|
+
/**
|
|
49
|
+
* Register the skill body that makes a separate `browser-skill` install unnecessary.
|
|
50
|
+
* @param ctx - the Host plugin context.
|
|
51
|
+
*/
|
|
52
|
+
export declare function registerSkill(ctx: Context): void;
|
|
53
|
+
/**
|
|
54
|
+
* Mount the mention route, the provider, the bundled skill, and the browser tools.
|
|
55
|
+
* @param ctx - the Host plugin context.
|
|
56
|
+
*/
|
|
57
|
+
export declare function apply(ctx: Context): void;
|
|
58
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BrowserSkill's own MCP server, driven from the Host.
|
|
3
|
+
*
|
|
4
|
+
* Why not call the `bsk` CLI: a short-lived `bsk` cannot own a daemon inside a
|
|
5
|
+
* desktop application. It tries to start one, the process inherits Electron's
|
|
6
|
+
* outer Job Object, and `bsk` gives up ("still belongs to a Job Object after
|
|
7
|
+
* breakaway"). A long-lived `bsk mcp` does work — it keeps the daemon as its own
|
|
8
|
+
* child — which is also why the tools this plugin exposes to the model function
|
|
9
|
+
* while a one-shot `bsk tab list` does not.
|
|
10
|
+
*
|
|
11
|
+
* So the mention menu speaks the same protocol the tools do: one `bsk mcp`
|
|
12
|
+
* child, newline-delimited JSON-RPC, tools called by name.
|
|
13
|
+
*
|
|
14
|
+
* @module @free-lzj/dsh-browser-use/mcp-tabs
|
|
15
|
+
*/
|
|
16
|
+
import type { BrowserTab } from './protocol.ts';
|
|
17
|
+
/**
|
|
18
|
+
* A minimal MCP stdio client, scoped to the two calls the menu needs.
|
|
19
|
+
*
|
|
20
|
+
* Deliberately not `@deepseek-ai/dsh-mcp-client`: that one exists to publish a
|
|
21
|
+
* server's tools to an Agent, and the menu needs a private request/response
|
|
22
|
+
* channel instead. Two children is the price of the two jobs being independent.
|
|
23
|
+
*/
|
|
24
|
+
export declare class BskMcpChannel {
|
|
25
|
+
#private;
|
|
26
|
+
/**
|
|
27
|
+
* Tabs in the user's own windows, most useful first.
|
|
28
|
+
* @param signal - caller cancellation; a cancelled call stops waiting, not the server.
|
|
29
|
+
* @returns the tabs, or none when the browser is unreachable.
|
|
30
|
+
*/
|
|
31
|
+
listUserTabs(signal: AbortSignal): Promise<readonly BrowserTab[]>;
|
|
32
|
+
/** Stop the child this channel owns. */
|
|
33
|
+
dispose(): void;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=mcp-tabs.d.ts.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The mention-provider seam.
|
|
3
|
+
*
|
|
4
|
+
* `@` itself belongs to the harness: `dsh-client-ui-input-trigger` owns the menu
|
|
5
|
+
* and `dsh-client-ui-reference` registers one source into it for files and
|
|
6
|
+
* sessions. This package registers a second source for things that are neither,
|
|
7
|
+
* and the provider registry below is where "things" are listed. Adding a kind of
|
|
8
|
+
* thing later (an application, a plugin) means writing one provider — nothing in
|
|
9
|
+
* this file or in the routes learns its name.
|
|
10
|
+
*
|
|
11
|
+
* @module @free-lzj/dsh-browser-use/mention
|
|
12
|
+
*/
|
|
13
|
+
import type { MentionGroup, MentionItem } from './protocol.ts';
|
|
14
|
+
/**
|
|
15
|
+
* One source of mentionable things.
|
|
16
|
+
*
|
|
17
|
+
* A provider answers candidates only. It does not render, does not decide the
|
|
18
|
+
* menu order beyond its own registration order, and never sees the draft — the
|
|
19
|
+
* client half hands the widened menu straight to the harness.
|
|
20
|
+
*/
|
|
21
|
+
export interface MentionProvider {
|
|
22
|
+
/** Stable id; also the prefix of every {@link MentionItem.ref} this provider returns. */
|
|
23
|
+
readonly id: string;
|
|
24
|
+
/** Menu section heading, in the user's language. */
|
|
25
|
+
readonly label: string;
|
|
26
|
+
/**
|
|
27
|
+
* List candidates matching one query.
|
|
28
|
+
* @param query - text after `@`, already trimmed by the caller.
|
|
29
|
+
* @param signal - caller cancellation; providers must stop their own work.
|
|
30
|
+
* @returns the matching items; an unreachable provider returns none rather than failing the menu.
|
|
31
|
+
*/
|
|
32
|
+
candidates(query: string, signal: AbortSignal): Promise<readonly MentionItem[]>;
|
|
33
|
+
}
|
|
34
|
+
/** What one candidate request produced, plus the failures worth logging. */
|
|
35
|
+
export interface CollectedMentions {
|
|
36
|
+
readonly groups: readonly MentionGroup[];
|
|
37
|
+
/** Providers that threw, as `id: message`; the menu is still served without them. */
|
|
38
|
+
readonly failures: readonly string[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Holds every registered provider, in registration order.
|
|
42
|
+
*
|
|
43
|
+
* A provider that fails is dropped from the answer, the way the harness's own
|
|
44
|
+
* reference source drops a domain that cannot load: the rest of the menu stays
|
|
45
|
+
* usable, and one dead backend never costs the user their `@`.
|
|
46
|
+
*/
|
|
47
|
+
export declare class MentionRegistry {
|
|
48
|
+
#private;
|
|
49
|
+
/**
|
|
50
|
+
* Add one provider.
|
|
51
|
+
* @param provider - the source of one group of candidates.
|
|
52
|
+
* @returns the disposer removing it; duplicate ids are refused.
|
|
53
|
+
*/
|
|
54
|
+
register(provider: MentionProvider): () => void;
|
|
55
|
+
/** @returns the registered ids, for diagnostics. */
|
|
56
|
+
ids(): readonly string[];
|
|
57
|
+
/**
|
|
58
|
+
* Collect every provider's answer for one query.
|
|
59
|
+
* @param query - text after `@`.
|
|
60
|
+
* @param signal - caller cancellation.
|
|
61
|
+
* @returns the non-empty groups, plus one line per provider that failed.
|
|
62
|
+
*/
|
|
63
|
+
collect(query: string, signal: AbortSignal): Promise<CollectedMentions>;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=mention.d.ts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shapes and routes both halves agree on.
|
|
3
|
+
*
|
|
4
|
+
* The browser half never imports the Host half's runtime values — only these
|
|
5
|
+
* types and the small amount of shared protocol they carry — so this module must
|
|
6
|
+
* stay free of `node:*` imports and of anything that only exists on one side.
|
|
7
|
+
*
|
|
8
|
+
* @module @free-lzj/dsh-browser-use/protocol
|
|
9
|
+
*/
|
|
10
|
+
/** Where the browser half asks for mention candidates. */
|
|
11
|
+
export declare const MENTIONS_PATH = "/dsh-browser-use/mentions";
|
|
12
|
+
/**
|
|
13
|
+
* One offerable thing, independent of what kind of thing it is.
|
|
14
|
+
*
|
|
15
|
+
* `ref` is `<provider>:<local id>`; the part after the colon belongs to that
|
|
16
|
+
* provider alone, so the Host can resolve it without a second lookup table and
|
|
17
|
+
* the browser half can hand it back verbatim.
|
|
18
|
+
*/
|
|
19
|
+
export interface MentionItem {
|
|
20
|
+
readonly ref: string;
|
|
21
|
+
readonly label: string;
|
|
22
|
+
readonly description?: string;
|
|
23
|
+
}
|
|
24
|
+
/** Candidates of one provider, rendered as one menu section. */
|
|
25
|
+
export interface MentionGroup {
|
|
26
|
+
readonly id: string;
|
|
27
|
+
readonly label: string;
|
|
28
|
+
readonly items: readonly MentionItem[];
|
|
29
|
+
}
|
|
30
|
+
/** One answer to a candidate request: every reachable group, in menu order. */
|
|
31
|
+
export interface MentionsResult {
|
|
32
|
+
readonly groups: readonly MentionGroup[];
|
|
33
|
+
/**
|
|
34
|
+
* Providers that could not answer, as `id: message`.
|
|
35
|
+
*
|
|
36
|
+
* Returned rather than only logged: an empty menu has to be able to say why,
|
|
37
|
+
* and the caller is often the only place a person can see it.
|
|
38
|
+
*/
|
|
39
|
+
readonly failures?: readonly string[];
|
|
40
|
+
}
|
|
41
|
+
/** Refusal shape every route uses instead of a bare status. */
|
|
42
|
+
export interface FailureResult {
|
|
43
|
+
readonly error: string;
|
|
44
|
+
}
|
|
45
|
+
/** One open tab, as `bsk` reports it. */
|
|
46
|
+
export interface BrowserTab {
|
|
47
|
+
readonly tabId: number;
|
|
48
|
+
readonly title: string;
|
|
49
|
+
readonly url: string;
|
|
50
|
+
/** The tab the browser currently shows; a tab in a background window is not active. */
|
|
51
|
+
readonly active: boolean;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The HTTP surface the browser's `@` menu reads.
|
|
3
|
+
*
|
|
4
|
+
* One read-only route. `dsh-host-webserver` adds no middleware, body parsing or
|
|
5
|
+
* origin policy of its own, so the same-origin guard is stated here by hand, and
|
|
6
|
+
* the method is pinned: a menu lookup has no business writing anything.
|
|
7
|
+
*
|
|
8
|
+
* @module @free-lzj/dsh-browser-use/routes
|
|
9
|
+
*/
|
|
10
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
11
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
12
|
+
import type { MentionRegistry } from './mention.ts';
|
|
13
|
+
/**
|
|
14
|
+
* Whether a request came from the page this server sent, so a document on
|
|
15
|
+
* another origin cannot enumerate the user's tabs through their browser.
|
|
16
|
+
* @param req - the incoming request.
|
|
17
|
+
* @returns true when the request comes from this server's own page.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isSameOrigin(req: IncomingMessage): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Answer one request with a JSON document.
|
|
22
|
+
* @param res - the response to write.
|
|
23
|
+
* @param status - HTTP status.
|
|
24
|
+
* @param body - the document.
|
|
25
|
+
*/
|
|
26
|
+
export declare function respond(res: ServerResponse, status: number, body: unknown): void;
|
|
27
|
+
/**
|
|
28
|
+
* Mount the mention route.
|
|
29
|
+
* @param ctx - the Host plugin context.
|
|
30
|
+
* @param registry - providers to collect from.
|
|
31
|
+
*/
|
|
32
|
+
export declare function registerRoutes(ctx: Context, registry: MentionRegistry): void;
|
|
33
|
+
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The browser skill, shipped inside the plugin.
|
|
3
|
+
*
|
|
4
|
+
* BrowserSkill's own MCP server already delivers a one-paragraph workflow in its
|
|
5
|
+
* `initialize` instructions, but that text is a reminder, not a procedure: it
|
|
6
|
+
* cannot say when to stop, what to do when refs go stale, or where the boundary
|
|
7
|
+
* between the user's tabs and ours sits. Those rules live here so installing
|
|
8
|
+
* this plugin is enough — the separate `browser-skill` agent skill is not needed.
|
|
9
|
+
*
|
|
10
|
+
* The body is written for this plugin against BrowserSkill's public CLI
|
|
11
|
+
* contract; it is not a copy of upstream skill text.
|
|
12
|
+
*
|
|
13
|
+
* @module @free-lzj/dsh-browser-use/skill
|
|
14
|
+
*/
|
|
15
|
+
import type { SkillRegistration } from '@deepseek-ai/dsh-skill';
|
|
16
|
+
/** Kebab-case skill id; also the name the model calls. */
|
|
17
|
+
export declare const SKILL_NAME = "browser-use";
|
|
18
|
+
/** The skill this plugin registers, so a separate skill install is unnecessary. */
|
|
19
|
+
export declare const BROWSER_SKILL: SkillRegistration;
|
|
20
|
+
//# sourceMappingURL=skill.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The agent tool: read and drive one mentioned tab.
|
|
3
|
+
*
|
|
4
|
+
* A mention alone is only text. Without this tool the model would have to
|
|
5
|
+
* assemble `bsk` command lines by hand, which is both slow and a prompt-injection
|
|
6
|
+
* surface (a page title could become flags). One tool with a closed action set
|
|
7
|
+
* keeps every invocation to argv this file built.
|
|
8
|
+
*
|
|
9
|
+
* @module @free-lzj/dsh-browser-tabs/tools
|
|
10
|
+
*/
|
|
11
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
12
|
+
import type { BskCli } from './bsk.ts';
|
|
13
|
+
/** What one tool call produced. */
|
|
14
|
+
export interface TabToolResult {
|
|
15
|
+
readonly text: string;
|
|
16
|
+
readonly path?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Recover a tab id from whatever the model copied out of the mention.
|
|
20
|
+
*
|
|
21
|
+
* The chip serializes as `@[页面标题](dsh-browser:299872133)`, so the id usually
|
|
22
|
+
* arrives wrapped; a bare id arrives when the model read it off the candidate
|
|
23
|
+
* row instead. Both are the same tab.
|
|
24
|
+
* @param value - the `tab` argument.
|
|
25
|
+
* @returns the numeric id.
|
|
26
|
+
*/
|
|
27
|
+
export declare function tabIdOf(value: string): number;
|
|
28
|
+
/**
|
|
29
|
+
* Register the tab tool.
|
|
30
|
+
* @param ctx - the Host plugin context.
|
|
31
|
+
* @param cli - the shared `bsk` session.
|
|
32
|
+
* @returns the disposer, for the caller's `ctx.effect`.
|
|
33
|
+
*/
|
|
34
|
+
export declare function registerTabTool(ctx: Context, cli: BskCli): () => void;
|
|
35
|
+
//# sourceMappingURL=tools.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,92 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@free-lzj/dsh-browser-use",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Drive the browser you are already signed into: mention an open tab with @, then read and operate it through BrowserSkill's own tools",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/Free-LZJ/free-dsh-plugins.git",
|
|
8
|
+
"directory": "packages/browser-use"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/Free-LZJ/free-dsh-plugins#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/Free-LZJ/free-dsh-plugins/issues"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "lib/index.js",
|
|
16
|
+
"types": "lib/types/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./lib/types/index.d.ts",
|
|
20
|
+
"default": "./lib/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./client": {
|
|
23
|
+
"types": "./lib/types/client/index.d.ts",
|
|
24
|
+
"default": "./lib/client.js"
|
|
25
|
+
},
|
|
26
|
+
"./src/*": "./src/*",
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"lib/index.js",
|
|
31
|
+
"lib/client.js",
|
|
32
|
+
"lib/types/**/*.d.ts",
|
|
33
|
+
"cordis.patch.yml",
|
|
34
|
+
"README.md"
|
|
35
|
+
],
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"keywords": [
|
|
41
|
+
"dsh",
|
|
42
|
+
"deepseek-harness",
|
|
43
|
+
"cordis-plugin",
|
|
44
|
+
"dsh-client-plugin",
|
|
45
|
+
"browser",
|
|
46
|
+
"browser-use",
|
|
47
|
+
"browser-skill",
|
|
48
|
+
"mcp"
|
|
49
|
+
],
|
|
50
|
+
"dsh": {
|
|
51
|
+
"bundle": {
|
|
52
|
+
"patch": "./cordis.patch.yml"
|
|
53
|
+
},
|
|
54
|
+
"client": {
|
|
55
|
+
"platform": "web",
|
|
56
|
+
"inject": [
|
|
57
|
+
"@deepseek-ai/dsh-client-locale",
|
|
58
|
+
"@deepseek-ai/dsh-client-ui-input-trigger"
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"build": "tsc -p tsconfig.build.json && tsdown",
|
|
64
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
65
|
+
"test": "vitest run",
|
|
66
|
+
"prepublishOnly": "npm run build"
|
|
67
|
+
},
|
|
68
|
+
"peerDependencies": {
|
|
69
|
+
"@deepseek-ai/cordis": "^4.0.3",
|
|
70
|
+
"@deepseek-ai/dsh-client-locale": ">=0.2.0-rc.1 <0.3.0-0",
|
|
71
|
+
"@deepseek-ai/dsh-client-ui-conversation": ">=0.2.0-rc.1 <0.3.0-0",
|
|
72
|
+
"@deepseek-ai/dsh-client-ui-input-trigger": ">=0.2.0-rc.1 <0.3.0-0",
|
|
73
|
+
"@deepseek-ai/dsh-client-ui-slots": ">=0.2.0-rc.1 <0.3.0-0",
|
|
74
|
+
"@deepseek-ai/dsh-host-webserver": ">=0.2.0-rc.1 <0.3.0-0",
|
|
75
|
+
"@deepseek-ai/dsh-mcp-client": ">=0.2.0-rc.1 <0.3.0-0",
|
|
76
|
+
"@deepseek-ai/dsh-skill": ">=0.2.0-rc.1 <0.3.0-0"
|
|
77
|
+
},
|
|
78
|
+
"devDependencies": {
|
|
79
|
+
"@deepseek-ai/cordis": "4.0.5",
|
|
80
|
+
"@deepseek-ai/dsh-client-locale": "0.2.1-rc.3",
|
|
81
|
+
"@deepseek-ai/dsh-client-ui-conversation": "0.2.1-rc.3",
|
|
82
|
+
"@deepseek-ai/dsh-client-ui-input-trigger": "0.2.1-rc.3",
|
|
83
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.2.1-rc.3",
|
|
84
|
+
"@deepseek-ai/dsh-host-webserver": "0.2.1-rc.3",
|
|
85
|
+
"@deepseek-ai/dsh-mcp-client": "0.2.1-rc.3",
|
|
86
|
+
"@deepseek-ai/dsh-skill": "0.2.1-rc.3",
|
|
87
|
+
"@types/node": "^22.20.0",
|
|
88
|
+
"tsdown": "^0.22.2",
|
|
89
|
+
"typescript": "^6.0.3",
|
|
90
|
+
"vitest": "^4.1.8"
|
|
91
|
+
}
|
|
92
|
+
}
|