@huaqiu/dsh-tool-part-search 0.3.10 → 0.3.12
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/lib/index.mjs +15 -3
- package/package.json +2 -1
- package/src/index.ts +15 -4
package/lib/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createLogger } from "@hqedge/logging";
|
|
1
2
|
import { createPartSearchService } from "@huaqiu/part-search";
|
|
2
3
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
3
4
|
//#region src/service.ts
|
|
@@ -255,8 +256,19 @@ function toPartIdentifier(args) {
|
|
|
255
256
|
const name = "@huaqiu/dsh-tool-part-search";
|
|
256
257
|
/** Cordis services this half depends on: the DSH node tool registry. */
|
|
257
258
|
const inject = ["tools"];
|
|
258
|
-
/**
|
|
259
|
-
const
|
|
259
|
+
/**
|
|
260
|
+
* Lazy: a module-level `const log = createLogger(...)` would create the file
|
|
261
|
+
* stream at import time (before DSH home is mockable in tests).
|
|
262
|
+
* import time, which on bootstrap touches `dshHomePath('logs')` (transitively
|
|
263
|
+
* via the unified-sink directory resolution). Tests that
|
|
264
|
+
* `vi.mock('@deepseek-ai/dsh-home-paths', …)` get their TMP constant in scope
|
|
265
|
+
* only after the mock factory, so defer the call until `apply()` runs.
|
|
266
|
+
*/
|
|
267
|
+
let _log = null;
|
|
268
|
+
function log() {
|
|
269
|
+
if (_log === null) _log = createLogger({ component: "dsh-part-search" });
|
|
270
|
+
return _log;
|
|
271
|
+
}
|
|
260
272
|
/**
|
|
261
273
|
* Host plugin body — register the four agent-visible part-search tools.
|
|
262
274
|
*
|
|
@@ -270,7 +282,7 @@ const LOG_TAG = "[dsh-part-search]";
|
|
|
270
282
|
function apply(ctx) {
|
|
271
283
|
if (!ctx.tools || typeof ctx.tools.register !== "function") throw new Error("@huaqiu/dsh-tool-part-search requires the DSH `tools` service (ctx.tools.register).");
|
|
272
284
|
const disposers = createPartSearchTools(createPartSearch()).map((tool) => ctx.tools.register(tool));
|
|
273
|
-
|
|
285
|
+
log().info({ tools: disposers.length }, "registered agent tools");
|
|
274
286
|
return function dispose() {
|
|
275
287
|
for (const disposeTool of disposers) try {
|
|
276
288
|
disposeTool();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huaqiu/dsh-tool-part-search",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./lib/index.mjs",
|
|
6
6
|
"types": "./lib/index.d.mts",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"@deepseek-ai/dsh-tools": "^0.1.0-rc.0"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
+
"@hqedge/logging": "^0.2.7",
|
|
25
26
|
"@huaqiu/part-search": "^0.2.0"
|
|
26
27
|
},
|
|
27
28
|
"files": [
|
package/src/index.ts
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
import type { Context } from '@deepseek-ai/cordis'
|
|
27
|
+
import { createLogger, type Logger } from '@hqedge/logging'
|
|
27
28
|
import { createPartSearch } from './service.js'
|
|
28
29
|
import { createPartSearchTools } from './tools.js'
|
|
29
30
|
|
|
@@ -33,8 +34,19 @@ export const name = '@huaqiu/dsh-tool-part-search'
|
|
|
33
34
|
/** Cordis services this half depends on: the DSH node tool registry. */
|
|
34
35
|
export const inject = ['tools'] as const
|
|
35
36
|
|
|
36
|
-
/**
|
|
37
|
-
const
|
|
37
|
+
/**
|
|
38
|
+
* Lazy: a module-level `const log = createLogger(...)` would create the file
|
|
39
|
+
* stream at import time (before DSH home is mockable in tests).
|
|
40
|
+
* import time, which on bootstrap touches `dshHomePath('logs')` (transitively
|
|
41
|
+
* via the unified-sink directory resolution). Tests that
|
|
42
|
+
* `vi.mock('@deepseek-ai/dsh-home-paths', …)` get their TMP constant in scope
|
|
43
|
+
* only after the mock factory, so defer the call until `apply()` runs.
|
|
44
|
+
*/
|
|
45
|
+
let _log: Logger | null = null
|
|
46
|
+
function log(): Logger {
|
|
47
|
+
if (_log === null) _log = createLogger({ component: 'dsh-part-search' })
|
|
48
|
+
return _log
|
|
49
|
+
}
|
|
38
50
|
|
|
39
51
|
/**
|
|
40
52
|
* Host plugin body — register the four agent-visible part-search tools.
|
|
@@ -54,8 +66,7 @@ export function apply(ctx: Context): () => void {
|
|
|
54
66
|
const service = createPartSearch()
|
|
55
67
|
const disposers = createPartSearchTools(service).map((tool) => ctx.tools.register(tool))
|
|
56
68
|
|
|
57
|
-
|
|
58
|
-
console.log(LOG_TAG, 'registered agent tools', { tools: disposers.length })
|
|
69
|
+
log().info({ tools: disposers.length }, 'registered agent tools')
|
|
59
70
|
|
|
60
71
|
return function dispose() {
|
|
61
72
|
for (const disposeTool of disposers) {
|