@deepseek-ai/dsh-tool-testkit 0.0.0-stage → 0.2.2-alpha.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DeepSeek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,37 @@
1
+ # Bilingual-pair consistency record for README.md (docs/i18n/README.md): per heading
2
+ # section, a hash of its English and Chinese blocks outside code blocks and generated regions.
3
+ # After editing either side, bring the other along and re-record with:
4
+ # pnpm run verify-translation-pairing --write packages/test-support/tool-testkit/README.md
5
+ /:
6
+ en: 6c56a58c1397154b
7
+ zh: 7e37b4f4915f0a75
8
+ /deepseek-ai-dsh-tool-testkit:
9
+ en: 6f5f9186228a4b87
10
+ zh: e05d9c94ad8a6c2e
11
+ /deepseek-ai-dsh-tool-testkit/summary:
12
+ en: 36a296389a56ac64
13
+ zh: f1aecbfb8f0ce528
14
+ /deepseek-ai-dsh-tool-testkit/table-of-contents:
15
+ en: d152484eb41ac6b4
16
+ zh: 1db86285abf6c499
17
+ /deepseek-ai-dsh-tool-testkit/use-this-package:
18
+ en: 0489d9c434d64281
19
+ zh: 02e72be3ec225898
20
+ /deepseek-ai-dsh-tool-testkit/understand-the-implementation:
21
+ en: 236c624cc2445cd1
22
+ zh: 60d9dbafe03332b9
23
+ /deepseek-ai-dsh-tool-testkit/further-exploration:
24
+ en: db619f3ee3d024ef
25
+ zh: 02e35fcebaebd40e
26
+ /deepseek-ai-dsh-tool-testkit/model-experience:
27
+ en: 478835c82631e8c3
28
+ zh: cb4f938bcaa046be
29
+ /deepseek-ai-dsh-tool-testkit/model-experience/kv-cache-effect:
30
+ en: be3fa044c8f27bf0
31
+ zh: 35fdb79b58ba91f6
32
+ /deepseek-ai-dsh-tool-testkit/known-limitations-and-deferred-work:
33
+ en: c21236a743177477
34
+ zh: 8cc8678c2133a8be
35
+ /deepseek-ai-dsh-tool-testkit/known-limitations-and-deferred-work/dev-note:
36
+ en: e67f633dc6fe7773
37
+ zh: e88aeb617ffb74ea
package/README.md CHANGED
@@ -1,3 +1,91 @@
1
- # Temporary Holding Version
1
+ ---
2
+ description: "Define test tools and invoke tool pipelines or selected executors in repository tests and benchmarks."
3
+ kind: "package-library"
4
+ ---
2
5
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
6
+ # @deepseek-ai/dsh-tool-testkit
7
+
8
+ English | [中文](README.zh.md)
9
+
10
+ ## Summary
11
+
12
+ Use this package to define content-producing test tools and exercise tool execution without running an Agent turn. Tests and benchmarks import its helpers as a development dependency. Callers own the Cordis context, plugin composition, and teardown.
13
+
14
+ ## Table of Contents
15
+
16
+ - [Use this package](#use-this-package)
17
+ - [Understand the implementation](#understand-the-implementation)
18
+ - [Further Exploration](#further-exploration)
19
+ - [Model Experience](#model-experience)
20
+ - [Known Limitations and Deferred Work](#known-limitations-and-deferred-work)
21
+ - [Dev Note](#dev-note)
22
+
23
+ -----
24
+
25
+ <a id="use-this-package"></a>
26
+ ## Use this package
27
+
28
+ Add `@deepseek-ai/dsh-tool-testkit` to the consuming package's `devDependencies`. Define a fixture when the test needs rendered content without a domain-specific result value:
29
+
30
+ ```ts
31
+ import { defineContentToolFixture } from '@deepseek-ai/dsh-tool-testkit'
32
+
33
+ const tool = defineContentToolFixture({
34
+ name: 'echo',
35
+ description: 'Return a test message.',
36
+ parameters: {},
37
+ execute: async () => [{ type: 'text', text: 'hello' }],
38
+ })
39
+ ```
40
+
41
+ Register the returned definition through the caller's tool registry. Use `executeToolFixture` for an already-parsed invocation, or `executeModelToolFixture` to pass one JSON-encoded call through the selected executor. The latter requires the caller to mount that executor and rejects arguments that cannot be JSON-encoded or an executor response without a result. See [`src/index.ts`](src/index.ts) for invocation fields.
42
+
43
+ -----
44
+
45
+ <a id="understand-the-implementation"></a>
46
+ ## Understand the implementation
47
+
48
+ <details>
49
+ <summary>Implementation internals — click to expand</summary>
50
+
51
+ [`src/index.ts`](src/index.ts) adapts content blocks into a tool's canonical JSON value and delegates execution to the production pipeline or registry. It creates no context and owns no plugin registrations.
52
+
53
+ </details>
54
+
55
+ -----
56
+
57
+ <a id="further-exploration"></a>
58
+ ## Further Exploration
59
+
60
+ - [Tools package](../../core/tools/README.md) — tool definitions, registry, and execution policy.
61
+ - [Testing policy](../../../docs/testing.md) — choosing verification for production behavior.
62
+ - [Test-support group map](../README.md) — sibling test utilities.
63
+
64
+ -----
65
+
66
+ <a id="model-experience"></a>
67
+ ## Model Experience
68
+
69
+ None, as these test helpers do not assemble or send model requests.
70
+
71
+ #### KV Cache effect
72
+
73
+ None; the package itself sends no provider request.
74
+
75
+ ## Known Limitations and Deferred Work
76
+
77
+ <a id="known-limitations-and-deferred-work"></a>
78
+
79
+ - Content-array values are test fixtures; product tools declare domain-owned output schemas.
80
+ - Direct pipeline execution omits model-batch scheduling. Both execution helpers omit root Session logging; use an Agent turn when verifying the recorded conversation.
81
+ - Plugin composition and context disposal remain caller-owned.
82
+
83
+ <a id="dev-note"></a>
84
+ ### Dev Note
85
+
86
+ <details>
87
+ <summary>Working context for maintainers — click to expand</summary>
88
+
89
+ None.
90
+
91
+ </details>
package/README.zh.md ADDED
@@ -0,0 +1,91 @@
1
+ ---
2
+ description: "在仓库测试和基准测试中定义测试工具,并调用工具流水线或选定的执行器。"
3
+ kind: "package-library"
4
+ ---
5
+
6
+ # @deepseek-ai/dsh-tool-testkit
7
+
8
+ [English](README.md) | 中文
9
+
10
+ ## 概述
11
+
12
+ 使用本包定义生成内容的测试工具,并在不运行 Agent 回合的情况下测试工具执行。测试和基准测试将这些辅助函数作为开发依赖导入。调用方负责 Cordis context、插件组合和资源清理。
13
+
14
+ ## 目录
15
+
16
+ - [使用本包](#use-this-package)
17
+ - [理解实现](#understand-the-implementation)
18
+ - [进一步探索](#further-exploration)
19
+ - [模型体验](#model-experience)
20
+ - [已知限制与后续工作](#known-limitations-and-deferred-work)
21
+ - [开发备注](#dev-note)
22
+
23
+ -----
24
+
25
+ <a id="use-this-package"></a>
26
+ ## 使用本包
27
+
28
+ 将 `@deepseek-ai/dsh-tool-testkit` 加入消费包的 `devDependencies`。测试只需要渲染内容而不需要领域结果值时,可以定义以下 fixture:
29
+
30
+ ```ts
31
+ import { defineContentToolFixture } from '@deepseek-ai/dsh-tool-testkit'
32
+
33
+ const tool = defineContentToolFixture({
34
+ name: 'echo',
35
+ description: 'Return a test message.',
36
+ parameters: {},
37
+ execute: async () => [{ type: 'text', text: 'hello' }],
38
+ })
39
+ ```
40
+
41
+ 通过调用方的工具注册表注册返回的定义。使用 `executeToolFixture` 执行已解析的调用,或使用 `executeModelToolFixture` 将一次 JSON 编码的调用交给选定的执行器。后者要求调用方挂载该执行器,并在参数无法编码为 JSON 或执行器响应缺少结果时拒绝。调用字段见 [`src/index.ts`](src/index.ts)。
42
+
43
+ -----
44
+
45
+ <a id="understand-the-implementation"></a>
46
+ ## 理解实现
47
+
48
+ <details>
49
+ <summary>实现细节——点击展开</summary>
50
+
51
+ [`src/index.ts`](src/index.ts) 将内容块适配为工具的规范 JSON 值,并将执行委托给生产流水线或注册表。它不创建 context,也不持有插件注册。
52
+
53
+ </details>
54
+
55
+ -----
56
+
57
+ <a id="further-exploration"></a>
58
+ ## 进一步探索
59
+
60
+ - [工具包](../../core/tools/README.zh.md)——工具定义、注册表和执行策略。
61
+ - [测试策略](../../../docs/testing.zh.md)——为生产行为选择验证方式。
62
+ - [test-support 分组地图](../README.zh.md)——同组测试工具。
63
+
64
+ -----
65
+
66
+ <a id="model-experience"></a>
67
+ ## 模型体验
68
+
69
+ 无,这些测试辅助函数不组装或发送模型请求。
70
+
71
+ #### KV Cache 影响
72
+
73
+ 无;本包自身不发送 provider 请求。
74
+
75
+ ## 已知限制与后续工作
76
+
77
+ <a id="known-limitations-and-deferred-work"></a>
78
+
79
+ - 内容数组值仅用于测试 fixture;产品工具声明领域自己的输出 schema。
80
+ - 直接执行流水线不包含模型批次调度。两种执行辅助函数都不记录根 Session 日志;验证会话记录时应运行 Agent 回合。
81
+ - 插件组合和 context 释放仍由调用方负责。
82
+
83
+ <a id="dev-note"></a>
84
+ ### 开发备注
85
+
86
+ <details>
87
+ <summary>维护者工作上下文——点击展开</summary>
88
+
89
+ 无。
90
+
91
+ </details>
package/lib/index.js ADDED
@@ -0,0 +1,68 @@
1
+ import { ToolExecutionPipeline } from "@deepseek-ai/dsh-tools/pipeline";
2
+ import { defineTool } from "@deepseek-ai/dsh-tools";
3
+ //#region lib/types/index.js
4
+ /** Canonical tool-definition fixtures for repository tests. @module @deepseek-ai/dsh-tool-testkit */
5
+ const CONTENT_VALUE_SCHEMA = {
6
+ type: "array",
7
+ items: { type: "json" }
8
+ };
9
+ /**
10
+ * Define a test fixture that deliberately uses its content blocks as the
11
+ * canonical JSON value. Product tools must declare domain-owned DTOs instead.
12
+ * @param options - ordinary fixture fields plus a content-producing body.
13
+ * @returns a registry-ready tool with an explicit JSON-array output contract.
14
+ * @internal
15
+ */
16
+ function defineContentToolFixture(options) {
17
+ const execute = options.execute;
18
+ return defineTool({
19
+ ...options,
20
+ output: {
21
+ schema: CONTENT_VALUE_SCHEMA,
22
+ render: (_args, value) => value
23
+ },
24
+ async execute(args, exec) {
25
+ return await execute(args, exec);
26
+ }
27
+ });
28
+ }
29
+ /**
30
+ * Exercise invocation stages directly, preserving parsed and nested test inputs.
31
+ * Use executeModelToolFixture for a complete single-call batch.
32
+ * @param ctx - context owning the tool definitions and execution policy.
33
+ * @param input - parsed invocation, including nested identity when testing a composite.
34
+ * @returns the settled capability result.
35
+ * @internal
36
+ */
37
+ async function executeToolFixture(ctx, input) {
38
+ const pipeline = new ToolExecutionPipeline(ctx);
39
+ const prepared = await pipeline.prepare(input);
40
+ const outcome = prepared.kind === "dispatch" ? await pipeline.dispatch(prepared.exec) : prepared;
41
+ return pipeline.complete(prepared.exec, outcome);
42
+ }
43
+ /**
44
+ * Run one raw call through the selected executor without root Session logging.
45
+ * @param ctx - context owning the selected executor.
46
+ * @param input - JSON arguments, optional Agent supplying scoped tools and tool context, and optional step admission.
47
+ * @returns the single settled result.
48
+ * @internal
49
+ */
50
+ async function executeModelToolFixture(ctx, input) {
51
+ const args = JSON.stringify(input.arguments);
52
+ if (args === void 0) throw new TypeError("Model tool fixture arguments must encode as JSON");
53
+ const outcome = (await ctx.tools.execute({
54
+ calls: [{
55
+ type: "tool-call",
56
+ id: input.callId,
57
+ name: input.name,
58
+ arguments: args
59
+ }],
60
+ signal: input.signal,
61
+ ...input.agent === void 0 ? {} : { agent: input.agent },
62
+ ...input.toolSet === void 0 ? {} : { toolSet: input.toolSet }
63
+ })).results[0];
64
+ if (outcome === void 0) throw new Error("Executor omitted the model tool fixture result");
65
+ return outcome.result;
66
+ }
67
+ //#endregion
68
+ export { defineContentToolFixture, executeModelToolFixture, executeToolFixture };
@@ -0,0 +1,42 @@
1
+ /** Canonical tool-definition fixtures for repository tests. @module @deepseek-ai/dsh-tool-testkit */
2
+ import type { Context } from '@deepseek-ai/cordis';
3
+ import type { ContentBlock } from '@deepseek-ai/dsh-llm';
4
+ import type { DefineToolOptions, InferArgs, ParameterSchemaSpec, ToolDefinition, ToolExecutionInput, ToolExecutionResult, ToolRunContext } from '@deepseek-ai/dsh-tools';
5
+ declare const CONTENT_VALUE_SCHEMA: {
6
+ readonly type: "array";
7
+ readonly items: {
8
+ readonly type: "json";
9
+ };
10
+ };
11
+ /** Options for a fixture whose canonical value is its rendered content array. */
12
+ export type ContentToolFixtureOptions<S extends ParameterSchemaSpec> = Omit<DefineToolOptions<S, typeof CONTENT_VALUE_SCHEMA>, 'output' | 'execute'> & {
13
+ /** Produce the fixture's content blocks as its canonical test value. */
14
+ execute(args: InferArgs<S>, exec: ToolRunContext): Promise<ContentBlock[]>;
15
+ };
16
+ /**
17
+ * Define a test fixture that deliberately uses its content blocks as the
18
+ * canonical JSON value. Product tools must declare domain-owned DTOs instead.
19
+ * @param options - ordinary fixture fields plus a content-producing body.
20
+ * @returns a registry-ready tool with an explicit JSON-array output contract.
21
+ * @internal
22
+ */
23
+ export declare function defineContentToolFixture<const S extends ParameterSchemaSpec>(options: ContentToolFixtureOptions<S>): ToolDefinition;
24
+ /**
25
+ * Exercise invocation stages directly, preserving parsed and nested test inputs.
26
+ * Use executeModelToolFixture for a complete single-call batch.
27
+ * @param ctx - context owning the tool definitions and execution policy.
28
+ * @param input - parsed invocation, including nested identity when testing a composite.
29
+ * @returns the settled capability result.
30
+ * @internal
31
+ */
32
+ export declare function executeToolFixture(ctx: Context, input: ToolExecutionInput): Promise<ToolExecutionResult>;
33
+ /**
34
+ * Run one raw call through the selected executor without root Session logging.
35
+ * @param ctx - context owning the selected executor.
36
+ * @param input - JSON arguments, optional Agent supplying scoped tools and tool context, and optional step admission.
37
+ * @returns the single settled result.
38
+ * @internal
39
+ */
40
+ export declare function executeModelToolFixture(ctx: Context, input: Pick<ToolExecutionInput, 'callId' | 'name' | 'arguments' | 'signal' | 'agent' | 'toolSet'>): Promise<ToolExecutionResult>;
41
+ export {};
42
+ //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,40 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-tool-testkit",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "description": "Tool definition and execution fixtures for tests and benchmarks",
4
+ "version": "0.2.2-alpha.2",
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/test-support/tool-testkit"
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
+ "./src/*": "./src/*",
22
+ "./package.json": "./package.json"
23
+ },
24
+ "files": [
25
+ "lib/index.js",
26
+ "lib/types/**/*.d.ts"
27
+ ],
28
+ "license": "MIT",
29
+ "peerDependencies": {
30
+ "@deepseek-ai/cordis": "~4.0.6-alpha.1",
31
+ "@deepseek-ai/dsh-llm": "0.2.2-alpha.2",
32
+ "@deepseek-ai/dsh-tools": "0.2.2-alpha.2"
33
+ },
34
+ "devDependencies": {
35
+ "@deepseek-ai/cordis": "~4.0.6-alpha.1",
36
+ "@deepseek-ai/dsh-llm": "0.2.2-alpha.2",
37
+ "@deepseek-ai/dsh-system-prompt": "0.2.2-alpha.2",
38
+ "@deepseek-ai/dsh-tools": "0.2.2-alpha.2"
39
+ }
6
40
  }