@deepseek-ai/dsh-tool-web 0.0.1-rc.1

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,23 @@
1
+ //#region lib/types/invariant.js
2
+ /**
3
+ * Package-owned invariant companion for `@deepseek-ai/dsh-tool-web`.
4
+ * @module @deepseek-ai/dsh-tool-web/invariant
5
+ */
6
+ const PACKAGE_NAME = "@deepseek-ai/dsh-tool-web";
7
+ /** Cordis companion plugin name. */
8
+ const name = "tool-web-invariant";
9
+ /** Service required before the companion can reserve package ownership. */
10
+ const inject = ["invariants"];
11
+ /**
12
+ * No runtime invariant: this model-facing adapter has no independent lifecycle stream; execution
13
+ * relations are owned by the capability seam it calls.
14
+ */
15
+ const install = () => {};
16
+ /**
17
+ * Register this package's invariant companion.
18
+ * @param ctx - Cordis context carrying the invariant service.
19
+ * @returns the installed registration's disposer after setup succeeds.
20
+ */
21
+ const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
22
+ //#endregion
23
+ export { apply, inject, name };
@@ -0,0 +1,108 @@
1
+ /**
2
+ * The model-facing `web_fetch` tool. This module owns its schema, validation, and presentation;
3
+ * `ctx.web` owns retrieval. Timeout is deployment policy, not a model argument: config becomes
4
+ * `ToolDefinition.timeoutMs`, timeout policy enforces it, and this tool forwards the resulting
5
+ * signal. A provider timeout remains a backstop for direct service callers.
6
+ */
7
+ import type { Context } from '@deepseek-ai/cordis';
8
+ import type { GenericCallView, JsonValue, ToolResult, WebFetchResultView } from '@deepseek-ai/dsh-tools';
9
+ import type { WebFetchResult } from '@deepseek-ai/dsh-web';
10
+ /**
11
+ * Validate value constraints the schema DSL can't express: a non-blank `url`.
12
+ * Throws a plain `Error` otherwise. No timeout parameter — the tool-call budget
13
+ * is deployment policy declared via `fetchTimeoutMs` config and enforced by
14
+ * `@deepseek-ai/dsh-timeout-policy`, not a model argument.
15
+ *
16
+ * @param args - the schema-validated `web_fetch` arguments.
17
+ * @returns the arguments as the seam's request fields.
18
+ */
19
+ export declare function parseFetchArgs(args: {
20
+ url: string;
21
+ }): {
22
+ url: string;
23
+ };
24
+ /**
25
+ * Format a fetch result as one model-facing text block, bounded as a whole.
26
+ *
27
+ * @param result - the seam's fetch outcome.
28
+ * @param maxOutputChars - cap on the complete returned string.
29
+ * @returns the complete text from {@link renderFetchOutput}.
30
+ */
31
+ export declare function formatFetchOutput(result: WebFetchResult, maxOutputChars: number): string;
32
+ /**
33
+ * Pending-call presentation: a fetch card titled by the URL.
34
+ *
35
+ * @param args - the raw tool arguments; only `url` feeds the view.
36
+ * @returns the generic card view (`kind: 'fetch'`) shown while the call runs.
37
+ */
38
+ export declare function presentFetchCall(args: {
39
+ url: string;
40
+ }): GenericCallView;
41
+ /**
42
+ * The `web_fetch` tool's private `tool/result` `meta` payload: the fetch summary
43
+ * a UI cannot recover from the model-facing render text without reparsing its
44
+ * header line. Attached opaquely (as `JsonValue`) on the tool result and
45
+ * persisted with the session log, so `presentResult` reproduces the fetch card
46
+ * on replay. The body itself is already markdown in the result content, so it is
47
+ * not duplicated here. `truncated` is the effective truncation the render text
48
+ * reflects, which a client cannot recompute (it does not know the deployment's
49
+ * `fetchMaxOutputChars`); this is why fetch meta is carried, not derived from the
50
+ * header line (see the web-result-card Agent Note).
51
+ */
52
+ export interface WebFetchMeta {
53
+ /** The final URL after allowed redirects. */
54
+ url: string;
55
+ /** HTTP status code of the fetched response. */
56
+ statusCode: number;
57
+ /** True when the provider, a source cut, or the output cap trimmed the content. */
58
+ truncated: boolean;
59
+ }
60
+ /**
61
+ * Project a validated `web_fetch` output value into its replayable presentation
62
+ * meta ({@link WebFetchMeta} as opaque JSON). `truncated` is the effective
63
+ * truncation the model-facing text reflects (via {@link renderFetchOutput}), not
64
+ * the provider-only `WebFetchResult.truncated`, so the fetch card never disagrees
65
+ * with the returned text.
66
+ *
67
+ * @param value - the canonical `web_fetch` output value (the seam's result shape).
68
+ * @param maxOutputChars - the deployment's output cap, the same one
69
+ * {@link formatFetchOutput} applies to the render text.
70
+ * @returns the URL, status code, and effective truncation flag.
71
+ */
72
+ export declare function fetchMetaFromValue(value: WebFetchResult, maxOutputChars: number): JsonValue;
73
+ /**
74
+ * Narrow opaque live or replayed result metadata to a {@link WebFetchMeta}.
75
+ * Malformed metadata returns `undefined` so presentation can fall back to the
76
+ * generic card instead of throwing during replay.
77
+ *
78
+ * @param meta - result metadata.
79
+ * @returns the validated fetch meta, or `undefined` for absent or malformed data.
80
+ */
81
+ export declare function fetchMetaFromResult(meta: unknown): WebFetchMeta | undefined;
82
+ /**
83
+ * Completed-call presentation: a `web` fetch card carrying the retrieval summary
84
+ * from `meta`. It sets no `content` copy — a UI without the `web` capability
85
+ * falls back to the raw `tool/result` content, the already-markdown body (see the
86
+ * web-result-card Agent Note).
87
+ *
88
+ * @param args - the raw tool arguments; `url` becomes the result-state title so a
89
+ * window-truncated replay that dropped the call head still has one.
90
+ * @param result - the final model-facing tool result; `meta` carries the summary.
91
+ * @returns the fetch result view, or `undefined` (generic card) on failure or
92
+ * malformed meta.
93
+ */
94
+ export declare function presentFetchResult(args: {
95
+ url: string;
96
+ }, result: ToolResult): WebFetchResultView | undefined;
97
+ /**
98
+ * Register the `web_fetch` tool and its system-prompt guidance.
99
+ *
100
+ * @param ctx - context whose `tools` and `systemPrompt` registries receive the
101
+ * registrations; both are effect-scoped and unregister on plugin dispose.
102
+ * @param timeoutMs - the cooperative tool-call budget (ms) attached as the tool's
103
+ * `ToolDefinition.timeoutMs` for `@deepseek-ai/dsh-timeout-policy` to enforce.
104
+ * @param maxOutputChars - cap on the complete rendered tool output (see
105
+ * {@link formatFetchOutput}) and on source characters converted synchronously.
106
+ */
107
+ export declare function applyWebFetchTool(ctx: Context, timeoutMs: number, maxOutputChars: number): void;
108
+ //# sourceMappingURL=fetch.d.ts.map
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Model-facing `web_search` and `web_fetch` tools over `ctx.web`. This package owns schemas,
3
+ * validation, prompt guidance, limits, and presentation, never concrete providers. Enablement
4
+ * controls tool registration; an enabled tool remains visible when its provider is unavailable
5
+ * and fails with a structured error at execution time.
6
+ * @module @deepseek-ai/dsh-tool-web
7
+ */
8
+ import type { Context } from '@deepseek-ai/cordis';
9
+ import z from '@deepseek-ai/schemastery';
10
+ export { WEB_SEARCH_MAX_RESULTS, applyWebSearchTool, formatSearchOutput, parseSearchArgs, presentSearchCall, presentSearchResult, searchMetaFromValue, searchMetaFromResult } from './search.ts';
11
+ export type { WebSearchMeta } from './search.ts';
12
+ export { applyWebFetchTool, formatFetchOutput, parseFetchArgs, presentFetchCall, presentFetchResult, fetchMetaFromValue, fetchMetaFromResult } from './fetch.ts';
13
+ export type { WebFetchMeta } from './fetch.ts';
14
+ /** Cordis plugin name used by loader diagnostics. */
15
+ export declare const name = "tool-web";
16
+ /** Services required by the web tool suite. */
17
+ export declare const inject: string[];
18
+ /** Default cooperative tool-call timeout budget (ms) for the web tools. */
19
+ export declare const DEFAULT_WEB_TOOL_TIMEOUT_MS = 30000;
20
+ /**
21
+ * Default cap on one `web_fetch` output and on source characters converted
22
+ * synchronously. This leaves headroom above the local provider's default
23
+ * 100,000-character body cap while bounding custom providers and rendered output.
24
+ */
25
+ export declare const DEFAULT_FETCH_MAX_OUTPUT_CHARS = 200000;
26
+ /** Plugin config: which web tools to register, the source cap, per-tool budgets, and the fetch output cap. */
27
+ export interface Config {
28
+ /** Register `web_search`. Defaults to true. */
29
+ search?: boolean;
30
+ /** Register `web_fetch`. Defaults to true. */
31
+ fetch?: boolean;
32
+ /** Upper bound on sources returned by one `web_search` call. */
33
+ searchMaxResults?: number;
34
+ /** Cooperative timeout budget (ms) for `web_fetch`. Defaults to 30000. */
35
+ fetchTimeoutMs?: number;
36
+ /** Cooperative timeout budget (ms) for `web_search`. Defaults to 30000. */
37
+ searchTimeoutMs?: number;
38
+ /** Cap on source characters converted and complete `web_fetch` output characters. Defaults to 200000. */
39
+ fetchMaxOutputChars?: number;
40
+ }
41
+ export declare const Config: z<Config>;
42
+ /**
43
+ * Register the enabled web tools. `search`/`fetch` default to true; a product
44
+ * that wants only one disables the other in config. Each tool's cooperative
45
+ * timeout budget (`fetchTimeoutMs`/`searchTimeoutMs`, default 30000) is resolved
46
+ * here and attached to the tool as `ToolDefinition.timeoutMs` for
47
+ * `@deepseek-ai/dsh-timeout-policy` to enforce. The tools' disposers are
48
+ * fiber-scoped (the effect-based registries clean up on dispose), so no manual
49
+ * teardown is needed.
50
+ */
51
+ export declare function apply(ctx: Context, config: Config): void;
52
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Package-owned invariant companion for `@deepseek-ai/dsh-tool-web`.
3
+ * @module @deepseek-ai/dsh-tool-web/invariant
4
+ */
5
+ import type { Context } from '@deepseek-ai/cordis';
6
+ /** Cordis companion plugin name. */
7
+ export declare const name = "tool-web-invariant";
8
+ /** Service required before the companion can reserve package ownership. */
9
+ export declare const inject: string[];
10
+ /**
11
+ * Register this package's invariant companion.
12
+ * @param ctx - Cordis context carrying the invariant service.
13
+ * @returns the installed registration's disposer after setup succeeds.
14
+ */
15
+ export declare const apply: (ctx: Context) => Promise<() => void>;
16
+ //# sourceMappingURL=invariant.d.ts.map
@@ -0,0 +1,108 @@
1
+ /**
2
+ * The model-facing `web_search` tool: discover current information on the web.
3
+ * Execution goes through `ctx.web` — this module owns only the model-facing
4
+ * schema, argument validation, the result-count bound, and result formatting,
5
+ * never provider selection or network access.
6
+ */
7
+ import type { Context } from '@deepseek-ai/cordis';
8
+ import type { GenericCallView, JsonValue, ToolResult, WebSearchResultView, WebSource } from '@deepseek-ai/dsh-tools';
9
+ import type { WebSearchResult } from '@deepseek-ai/dsh-web';
10
+ /**
11
+ * Default upper bound on returned sources (the `searchMaxResults` config).
12
+ * Owned by the consumer (not the provider or model), mirroring `dsh-tool-fs`'s
13
+ * `READ_LIMIT`. The model just asks a question; the product controls how much
14
+ * context returns. The default `8` aligns with OpenCode's Exa default.
15
+ */
16
+ export declare const WEB_SEARCH_MAX_RESULTS = 8;
17
+ /**
18
+ * Validate value constraints the schema DSL can't express: a non-blank
19
+ * `query`. Throws a plain `Error` otherwise.
20
+ *
21
+ * @param args - the schema-validated `web_search` arguments.
22
+ * @returns the accepted arguments, passed through unchanged.
23
+ */
24
+ export declare function parseSearchArgs(args: {
25
+ query: string;
26
+ }): {
27
+ query: string;
28
+ };
29
+ /**
30
+ * Format a search result as one model-facing text block.
31
+ *
32
+ * @param result - the seam's search outcome.
33
+ * @returns the provider answer (when any), a markdown source list with snippet
34
+ * and date metadata (or `No results found.`), a refine-the-query note when
35
+ * truncated, and a standing cite-your-sources instruction.
36
+ */
37
+ export declare function formatSearchOutput(result: WebSearchResult): string;
38
+ /**
39
+ * Pending-call presentation: a search card titled by the query.
40
+ *
41
+ * @param args - the raw tool arguments; only `query` feeds the view.
42
+ * @returns the generic card view (`kind: 'search'`) shown while the call runs.
43
+ */
44
+ export declare function presentSearchCall(args: {
45
+ query: string;
46
+ }): GenericCallView;
47
+ /**
48
+ * The `web_search` tool's private `tool/result` `meta` payload: the structured
49
+ * sources, the optional provider answer, and the truncation flag. Attached
50
+ * opaquely (as `JsonValue`) on the tool result and persisted with the session
51
+ * log, so `presentResult` reproduces the search card on replay. This projection
52
+ * is the only faithful route to the per-source fields, which the lossy render
53
+ * text cannot carry (the owning rationale is the web-result-card Agent Note).
54
+ */
55
+ export interface WebSearchMeta {
56
+ /** The faithful structured sources, in result order. */
57
+ sources: WebSource[];
58
+ /** True when the seam cut the source list to honor the result cap. */
59
+ truncated: boolean;
60
+ /** The provider-generated answer text, when any. */
61
+ answer?: string;
62
+ }
63
+ /**
64
+ * Project a validated `web_search` output value into its replayable
65
+ * presentation meta ({@link WebSearchMeta} as opaque JSON).
66
+ *
67
+ * @param value - the canonical `web_search` output value (the seam's result shape).
68
+ * @returns the structured sources, the truncation flag, and the answer when present.
69
+ */
70
+ export declare function searchMetaFromValue(value: WebSearchResult): JsonValue;
71
+ /**
72
+ * Narrow opaque live or replayed result metadata to a {@link WebSearchMeta}.
73
+ * Malformed metadata returns `undefined` so presentation can fall back to the
74
+ * generic card instead of throwing during replay.
75
+ *
76
+ * @param meta - result metadata.
77
+ * @returns the validated search meta, or `undefined` for absent or malformed data.
78
+ */
79
+ export declare function searchMetaFromResult(meta: unknown): WebSearchMeta | undefined;
80
+ /**
81
+ * Completed-call presentation: a `web` search card carrying the faithful
82
+ * structured sources from `meta`. It sets no `content` copy — a UI without the
83
+ * `web` capability falls back to the raw `tool/result` content, which is the
84
+ * same text (see the web-result-card Agent Note).
85
+ *
86
+ * @param args - the raw tool arguments; `query` becomes the result-state title so
87
+ * a window-truncated replay that dropped the call head still has one.
88
+ * @param result - the final model-facing tool result; `meta` carries the sources.
89
+ * @returns the search result view, or `undefined` (generic card) on failure or
90
+ * malformed meta.
91
+ */
92
+ export declare function presentSearchResult(args: {
93
+ query: string;
94
+ }, result: ToolResult): WebSearchResultView | undefined;
95
+ /**
96
+ * Register the `web_search` tool and its system-prompt guidance.
97
+ *
98
+ * @param ctx - context whose `tools` and `systemPrompt` registries receive the
99
+ * registrations; both are effect-scoped and unregister on plugin dispose.
100
+ * @param maxResults - the deployment's source cap, sent as every seam
101
+ * request's `maxResults`.
102
+ * @param timeoutMs - the cooperative tool-call budget (ms) attached as the tool's
103
+ * `ToolDefinition.timeoutMs` for `@deepseek-ai/dsh-timeout-policy` to enforce.
104
+ * @param fetchEnabled - whether the same composition exposes `web_fetch`, which
105
+ * controls whether search guidance may recommend that follow-up tool.
106
+ */
107
+ export declare function applyWebSearchTool(ctx: Context, maxResults: number, timeoutMs: number, fetchEnabled: boolean): void;
108
+ //# sourceMappingURL=search.d.ts.map
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@deepseek-ai/dsh-tool-web",
3
+ "description": "Model-facing web tools (web_search, web_fetch) over the DeepSeek Harness web capability seam (ctx.web)",
4
+ "version": "0.0.1-rc.1",
5
+ "publishConfig": {
6
+ "access": "restricted"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
11
+ "directory": "packages/web/tool-web"
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
+ "./invariant": {
22
+ "types": "./lib/types/invariant.d.ts",
23
+ "default": "./lib/invariant.js"
24
+ },
25
+ "./src/*": "./src/*",
26
+ "./package.json": "./package.json"
27
+ },
28
+ "files": [
29
+ "lib/index.js",
30
+ "lib/invariant.js",
31
+ "lib/types/**/*.d.ts"
32
+ ],
33
+ "license": "BSD-3-Clause",
34
+ "peerDependencies": {
35
+ "@deepseek-ai/dsh-invariants": "^0.0.1-rc.1",
36
+ "@deepseek-ai/dsh-llm": "^0.0.1-rc.1",
37
+ "@deepseek-ai/dsh-tools": "^0.0.1-rc.1",
38
+ "@deepseek-ai/dsh-system-prompt": "^0.0.1-rc.1",
39
+ "@deepseek-ai/dsh-web": "^0.0.1-rc.1",
40
+ "@deepseek-ai/cordis": "^4.0.1-rc.1"
41
+ },
42
+ "dependencies": {
43
+ "@joplin/turndown-plugin-gfm": "^1.0.67",
44
+ "turndown": "^7.2.4",
45
+ "@deepseek-ai/schemastery": "^3.18.1-rc.1"
46
+ },
47
+ "devDependencies": {
48
+ "@types/turndown": "^5.0.6",
49
+ "@deepseek-ai/dsh-agent": "^0.0.1-rc.1",
50
+ "@deepseek-ai/dsh-invariants": "^0.0.1-rc.1",
51
+ "@deepseek-ai/dsh-llm": "^0.0.1-rc.1",
52
+ "@deepseek-ai/dsh-session": "^0.0.1-rc.1",
53
+ "@deepseek-ai/dsh-spill-local": "^0.0.1-rc.1",
54
+ "@deepseek-ai/dsh-spill-policy": "^0.0.1-rc.1",
55
+ "@deepseek-ai/dsh-system-prompt": "^0.0.1-rc.1",
56
+ "@deepseek-ai/dsh-timeout-policy": "^0.0.1-rc.1",
57
+ "@deepseek-ai/dsh-tools": "^0.0.1-rc.1",
58
+ "@deepseek-ai/dsh-web-fetch-local": "^0.0.1-rc.1",
59
+ "@deepseek-ai/dsh-web-search-exa": "^0.0.1-rc.1",
60
+ "@deepseek-ai/cordis": "^4.0.1-rc.1",
61
+ "@deepseek-ai/dsh-web": "^0.0.1-rc.1"
62
+ }
63
+ }