@deepseek-ai/dsh-plugin-package-inventory-deepseek 0.2.0-rc.2 → 0.2.1-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/README.i18n.yaml +8 -8
- package/README.md +4 -6
- package/README.zh.md +4 -6
- package/lib/index.js +38 -29
- package/lib/types/index.js +45 -38
- package/lib/types/types.d.ts +2 -2
- package/package.json +19 -19
package/README.i18n.yaml
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
en: b0996e1a88373a84
|
|
10
10
|
zh: 3116d7e2bfe79073
|
|
11
11
|
/deepseek-ai-dsh-plugin-package-inventory-deepseek/summary:
|
|
12
|
-
en:
|
|
13
|
-
zh:
|
|
12
|
+
en: 3221d18e8a799635
|
|
13
|
+
zh: 78635db501959932
|
|
14
14
|
/deepseek-ai-dsh-plugin-package-inventory-deepseek/table-of-contents:
|
|
15
15
|
en: 13227fb47b30946f
|
|
16
16
|
zh: 97fe1dca5445d22a
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
en: dea20f16d15856af
|
|
19
19
|
zh: 6548dc9da63375e5
|
|
20
20
|
/deepseek-ai-dsh-plugin-package-inventory-deepseek/collection:
|
|
21
|
-
en:
|
|
22
|
-
zh:
|
|
21
|
+
en: fd0ce77b11c992ad
|
|
22
|
+
zh: 455fe92e68f7456a
|
|
23
23
|
/deepseek-ai-dsh-plugin-package-inventory-deepseek/model-experience:
|
|
24
24
|
en: 215e7ba838619b7b
|
|
25
25
|
zh: a311da3843709f90
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
en: 6dc3e97d0281180a
|
|
37
37
|
zh: 7abe4d4b128ef32d
|
|
38
38
|
/deepseek-ai-dsh-plugin-package-inventory-deepseek/known-limitations-and-deferred-work:
|
|
39
|
-
en:
|
|
40
|
-
zh:
|
|
39
|
+
en: cf2f28daf83bb4a8
|
|
40
|
+
zh: 3e18c67cea5e0ece
|
|
41
41
|
/deepseek-ai-dsh-plugin-package-inventory-deepseek/known-limitations-and-deferred-work/dev-note:
|
|
42
|
-
en:
|
|
43
|
-
zh:
|
|
42
|
+
en: e67f633dc6fe7773
|
|
43
|
+
zh: e88aeb617ffb74ea
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ English | [中文](README.zh.md)
|
|
|
9
9
|
|
|
10
10
|
## Summary
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Best-effort active Loader-backed plugin package inventory for official DeepSeek LLM API requests. This function plugin injects the Loader, live Agent registry, and `ctx.deepseekLlmApiExtensions`, then owns the `dsh_plugin_packages` field. Enable it when the official API needs the active package list for request diagnostics.
|
|
13
13
|
|
|
14
14
|
## Table of Contents
|
|
15
15
|
|
|
@@ -37,9 +37,9 @@ Every request re-reads active non-group entries from the host Loader tree. When
|
|
|
37
37
|
|
|
38
38
|
At activation, the plugin samples the optional `ctx.pluginPackages` service. Shipped app boot mounts that service before profile Loader entries, so bare package and package-subpath identities use the same authoritative runtime resolution as their imports, including its misses, without requiring a `./package.json` export. If the service is absent, the plugin retains native Node package-search lookup for its lifetime and does not switch an existing inventory when a resolver mounts later. A low-level embedder that wants runtime resolution identities must therefore mount `PluginPackages` before both the Loader entries and this plugin.
|
|
39
39
|
|
|
40
|
-
Each ordinary entry uses its owning Loader tree base. A standing preset's root entries use the harness base, matching the preset Loader's deliberate bare-package override; nested includes retain their own bases. Relative and absolute modules walk to their nearest manifest; a
|
|
40
|
+
Each ordinary entry uses its owning Loader tree base. A standing preset's root entries use the harness base, matching the preset Loader's deliberate bare-package override; nested includes retain their own bases. Relative and absolute modules walk to their nearest manifest; manifests without a non-blank string `name` are omitted. A missing or invalid `version` produces a name-only entry, regardless of `private`. A nested directory with its own manifest does not inherit its parent's identity. Package resolution, manifest reading, and JSON parsing failures omit only that entry and log one warning per module; inventory metadata does not block model requests. Entries are deduplicated by name and optional version and sorted with a locale-independent comparison; name-only entries sort before same-name versioned entries, and different versions remain separate.
|
|
41
41
|
|
|
42
|
-
The version-1 `dsh_plugin_packages` field contains
|
|
42
|
+
The version-1 `dsh_plugin_packages` field contains `{ name, version }` or `{ name }` entries; `version` is included only when it is a non-blank string. Disabled, pending, failed, disposed, unloading, structural `cordis:` rows, ordinary dependencies, loose files without an owning package identity, programmatically mounted child fibers, and in-memory dynamic plugins are excluded.
|
|
43
43
|
|
|
44
44
|
<a id="model-experience"></a>
|
|
45
45
|
## Model Experience
|
|
@@ -63,7 +63,7 @@ None; package lifecycle changes do not alter the model-visible prefix.
|
|
|
63
63
|
<a id="known-limitations-and-deferred-work"></a>
|
|
64
64
|
|
|
65
65
|
- **Loader package identity only** — programmatic child fibers and in-memory dynamic plugins do not have authoritative npm names and versions and remain outside this inventory.
|
|
66
|
-
- **
|
|
66
|
+
- **Unavailable identities are omitted** — the inventory can be partial when package metadata is unavailable.
|
|
67
67
|
- **In-place package replacement requires restart** — manifest identities are cached for the process lifetime. Loader enable, disable, mount, unmount, and ordinary source HMR still refresh the active entry set, but replacing a mounted package's manifest with another version in the same process is not a supported upgrade path.
|
|
68
68
|
|
|
69
69
|
|
|
@@ -76,5 +76,3 @@ None; package lifecycle changes do not alter the model-visible prefix.
|
|
|
76
76
|
None.
|
|
77
77
|
|
|
78
78
|
</details>
|
|
79
|
-
|
|
80
|
-
**Runtime invariant:** No companion is published. Each request reads authoritative Loader fiber state and package manifests directly; the plugin retains no independently mutable inventory.
|
package/README.zh.md
CHANGED
|
@@ -9,7 +9,7 @@ kind: "package-reference"
|
|
|
9
9
|
|
|
10
10
|
## 概述
|
|
11
11
|
|
|
12
|
-
用于 DeepSeek 官方 LLM API
|
|
12
|
+
用于 DeepSeek 官方 LLM API 请求的尽力收集型活跃 Loader 插件包清单。该函数插件注入 Loader、存活 Agent 注册表与 `ctx.deepseekLlmApiExtensions`,并拥有 `dsh_plugin_packages` 字段。当官方 API 需要活动包清单进行请求诊断时,请启用它。
|
|
13
13
|
|
|
14
14
|
## 目录
|
|
15
15
|
|
|
@@ -37,9 +37,9 @@ kind: "package-reference"
|
|
|
37
37
|
|
|
38
38
|
插件在激活时读取一次可选的 `ctx.pluginPackages` 服务。随附 app boot 会在 profile Loader 配置项之前挂载该服务,因此裸包和包子路径的身份使用与其 import 相同的权威 runtime resolution,包括它未命中的情况,并且无需包导出 `./package.json`。若该服务不存在,插件会在整个生命周期中保留 Node 原生包搜索,之后再挂载 resolver 也不会切换既有清单。因此,希望使用 runtime resolution 身份的底层嵌入方必须先挂载 `PluginPackages`,再挂载 Loader 配置项和本插件。
|
|
39
39
|
|
|
40
|
-
每个普通配置项使用其所属 Loader 树的基址。standing preset 的根配置项使用宿主基址,与 preset Loader 对裸包的显式覆写保持一致;嵌套 include 仍使用自身基址。相对与绝对模块会向上查找最近的 manifest
|
|
40
|
+
每个普通配置项使用其所属 Loader 树的基址。standing preset 的根配置项使用宿主基址,与 preset Loader 对裸包的显式覆写保持一致;嵌套 include 仍使用自身基址。相对与绝对模块会向上查找最近的 manifest(元数据清单);`name` 不是非空白字符串的 manifest 会被省略。`version` 缺失或无效时,只上报名称,不受 `private` 影响。拥有自身 manifest 的嵌套目录不会继承父包的身份。包解析、manifest 读取或 JSON 解析失败时,系统只省略对应配置项,并对每个模块只记录一次警告;清单元数据不会阻塞模型请求。系统按名称和可选版本去重,并使用与 locale 无关的比较排序;只有名称的配置项排在同名且有版本的配置项之前,不同版本仍分开保留。
|
|
41
41
|
|
|
42
|
-
版本 1 的 `dsh_plugin_packages`
|
|
42
|
+
版本 1 的 `dsh_plugin_packages` 字段包含 `{ name, version }` 或 `{ name }` 配置项;仅当 `version` 为非空白字符串时才包含该字段。系统会排除禁用、pending、failed、disposed、unloading 状态,结构性 `cordis:` 配置项,普通依赖,没有所属包身份的松散文件,以编程方式挂载的子 fiber,以及内存动态插件。
|
|
43
43
|
|
|
44
44
|
<a id="model-experience"></a>
|
|
45
45
|
## 模型体验
|
|
@@ -63,7 +63,7 @@ kind: "package-reference"
|
|
|
63
63
|
<a id="known-limitations-and-deferred-work"></a>
|
|
64
64
|
|
|
65
65
|
- **仅含 Loader 包来源**——以编程方式创建的子 fiber 与内存动态插件没有权威 NPM 名称/版本来源,因此不在该清单内。
|
|
66
|
-
-
|
|
66
|
+
- **省略不可用身份**——包元数据不可用时,清单可能不完整。
|
|
67
67
|
- **原地替换包需要重启**——manifest 身份会在进程存活期内缓存。Loader 的启用、禁用、挂载、卸载与普通源码 HMR 仍会刷新存活配置项集合,但在同一进程中把已挂载包的 manifest 替换为另一版本并不是受支持的升级路径。
|
|
68
68
|
|
|
69
69
|
|
|
@@ -76,5 +76,3 @@ kind: "package-reference"
|
|
|
76
76
|
无。
|
|
77
77
|
|
|
78
78
|
</details>
|
|
79
|
-
|
|
80
|
-
**运行时不变式:** 不发布伴生入口。每次请求直接读取权威 Loader fiber 状态与 package manifest,插件不保留独立可变 inventory。
|
package/lib/index.js
CHANGED
|
@@ -27,15 +27,14 @@ function barePackageName(specifier) {
|
|
|
27
27
|
const [first = "", second = ""] = specifier.split("/");
|
|
28
28
|
return first.startsWith("@") ? `${first}/${second}` : first;
|
|
29
29
|
}
|
|
30
|
-
/** Read
|
|
31
|
-
function identityFromManifest(path
|
|
30
|
+
/** Read a named identity, including its version only when it is a non-blank string. */
|
|
31
|
+
function identityFromManifest(path) {
|
|
32
32
|
const manifest = JSON.parse(readFileSync(path, "utf8"));
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
return {
|
|
33
|
+
if (typeof manifest.name !== "string" || manifest.name.trim().length === 0) return void 0;
|
|
34
|
+
return typeof manifest.version === "string" && manifest.version.trim().length > 0 ? {
|
|
36
35
|
name: manifest.name,
|
|
37
36
|
version: manifest.version
|
|
38
|
-
};
|
|
37
|
+
} : { name: manifest.name };
|
|
39
38
|
}
|
|
40
39
|
/** Resolve a bare package without requiring it to export `./package.json`. */
|
|
41
40
|
function barePackageManifest(packageName, anchors, packages) {
|
|
@@ -70,60 +69,69 @@ var PackageIdentityResolver = class {
|
|
|
70
69
|
this.packages = packages;
|
|
71
70
|
}
|
|
72
71
|
/** Resolve one Loader entry's owning package, or absence for a non-package loose module. */
|
|
73
|
-
resolve({
|
|
72
|
+
resolve({ moduleName, baseUrl, bareBaseUrl }) {
|
|
74
73
|
/* v8 ignore next -- Loader entry trees inherit a base URL; the fallback supports direct embedders. */
|
|
75
|
-
const treeBase =
|
|
74
|
+
const treeBase = baseUrl ?? this.hostBaseUrl;
|
|
76
75
|
const anchors = [...new Set([
|
|
77
76
|
bareBaseUrl ?? treeBase,
|
|
78
77
|
treeBase,
|
|
79
78
|
this.hostBaseUrl,
|
|
80
79
|
import.meta.url
|
|
81
80
|
])];
|
|
82
|
-
const key = `${anchors.join("\0")}\u0000${
|
|
81
|
+
const key = `${anchors.join("\0")}\u0000${moduleName}`;
|
|
83
82
|
if (this.cache.has(key)) return this.cache.get(key);
|
|
84
|
-
const packageName = barePackageName(
|
|
83
|
+
const packageName = barePackageName(moduleName);
|
|
85
84
|
let manifest;
|
|
86
85
|
if (packageName !== void 0) {
|
|
87
86
|
manifest = barePackageManifest(packageName, anchors, this.packages);
|
|
88
87
|
if (manifest === void 0) throw new Error(`plugin-package-inventory-deepseek: cannot resolve active package ${JSON.stringify(packageName)}`);
|
|
89
|
-
} else if (!
|
|
90
|
-
const moduleUrl = isAbsolute(
|
|
88
|
+
} else if (!moduleName.startsWith("cordis:")) {
|
|
89
|
+
const moduleUrl = isAbsolute(moduleName) ? pathToFileURL(moduleName) : new URL(moduleName, treeBase);
|
|
91
90
|
if (moduleUrl.protocol === "file:") manifest = nearestManifest(fileURLToPath(moduleUrl));
|
|
92
91
|
}
|
|
93
|
-
const identity = manifest === void 0 ? void 0 : identityFromManifest(manifest
|
|
92
|
+
const identity = manifest === void 0 ? void 0 : identityFromManifest(manifest);
|
|
94
93
|
this.cache.set(key, identity);
|
|
95
94
|
return identity;
|
|
96
95
|
}
|
|
97
96
|
};
|
|
98
97
|
/** Yield active, non-structural entries from one Loader tree. */
|
|
99
|
-
function activeEntries(tree
|
|
98
|
+
function activeEntries(tree) {
|
|
100
99
|
return [...tree.entries()].filter((entry) => !entry.options.group && !entry.disabled && entry.fiber?.state === 2).map((entry) => ({
|
|
101
|
-
entry,
|
|
102
|
-
...entry.parent.tree ===
|
|
100
|
+
moduleName: entry.options.name,
|
|
101
|
+
...entry.parent.tree.ctx.baseUrl === void 0 ? {} : { baseUrl: entry.parent.tree.ctx.baseUrl }
|
|
103
102
|
}));
|
|
104
103
|
}
|
|
105
104
|
/** Deterministic text order independent of the host's ICU data and locale. */
|
|
106
105
|
function compareWireText(left, right) {
|
|
107
106
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
108
107
|
}
|
|
109
|
-
/** Collect
|
|
110
|
-
|
|
108
|
+
/** Collect available identities from active packages for one request. */
|
|
109
|
+
function collectActivePluginPackages(ctx, resolver, hostBaseUrl, unreadable, sessionId) {
|
|
111
110
|
const entries = activeEntries(ctx.loader);
|
|
112
|
-
|
|
111
|
+
const presets = ctx.get("agentPresets");
|
|
112
|
+
if (sessionId !== void 0 && presets !== void 0) {
|
|
113
113
|
const agent = ctx.agents.get(brandString(sessionId));
|
|
114
|
-
if (agent !== void 0) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
114
|
+
if (agent !== void 0) for (const composition of presets.inspectCompositions(agent.ctx)) entries.push(...composition.modules.map(({ useHostBase, ...entry }) => ({
|
|
115
|
+
...entry,
|
|
116
|
+
...useHostBase ? { bareBaseUrl: hostBaseUrl } : {}
|
|
117
|
+
})));
|
|
119
118
|
}
|
|
120
119
|
const unique = /* @__PURE__ */ new Map();
|
|
121
120
|
for (const activeEntry of entries) {
|
|
122
|
-
|
|
121
|
+
let identity;
|
|
122
|
+
try {
|
|
123
|
+
identity = resolver.resolve(activeEntry);
|
|
124
|
+
} catch (error) {
|
|
125
|
+
if (!unreadable.has(activeEntry.moduleName)) {
|
|
126
|
+
unreadable.add(activeEntry.moduleName);
|
|
127
|
+
ctx.logger.warn("plugin-package-inventory-deepseek: omitting unreadable package identity for %s: %o", activeEntry.moduleName, error);
|
|
128
|
+
}
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
123
131
|
if (identity === void 0) continue;
|
|
124
|
-
unique.set(`${identity.name}\u0000${identity.version}`, identity);
|
|
132
|
+
unique.set(`${identity.name}\u0000${identity.version ?? ""}`, identity);
|
|
125
133
|
}
|
|
126
|
-
return [...unique.values()].sort((left, right) => compareWireText(left.name, right.name) || compareWireText(left.version, right.version));
|
|
134
|
+
return [...unique.values()].sort((left, right) => compareWireText(left.name, right.name) || compareWireText(left.version ?? "", right.version ?? ""));
|
|
127
135
|
}
|
|
128
136
|
/**
|
|
129
137
|
* Register the complete `dsh_plugin_packages` request contribution when enabled.
|
|
@@ -134,10 +142,11 @@ function apply(ctx, config) {
|
|
|
134
142
|
if (config.enabled === false) return;
|
|
135
143
|
const hostBaseUrl = ctx.baseUrl ?? import.meta.url;
|
|
136
144
|
const resolver = new PackageIdentityResolver(hostBaseUrl, ctx.get("pluginPackages"));
|
|
137
|
-
|
|
145
|
+
const unreadable = /* @__PURE__ */ new Set();
|
|
146
|
+
ctx.deepseekLlmApiExtensions.register("dsh_plugin_packages", { prepare: (request) => {
|
|
138
147
|
return { value: {
|
|
139
148
|
version: 1,
|
|
140
|
-
packages:
|
|
149
|
+
packages: collectActivePluginPackages(ctx, resolver, hostBaseUrl, unreadable, request.sessionId)
|
|
141
150
|
} };
|
|
142
151
|
} });
|
|
143
152
|
}
|
package/lib/types/index.js
CHANGED
|
@@ -26,16 +26,14 @@ function barePackageName(specifier) {
|
|
|
26
26
|
// An active Loader entry already passed module resolution, so a scoped bare name has its package segment.
|
|
27
27
|
return first.startsWith('@') ? `${first}/${second}` : first;
|
|
28
28
|
}
|
|
29
|
-
/** Read
|
|
30
|
-
function identityFromManifest(path
|
|
29
|
+
/** Read a named identity, including its version only when it is a non-blank string. */
|
|
30
|
+
function identityFromManifest(path) {
|
|
31
31
|
const manifest = JSON.parse(readFileSync(path, 'utf8'));
|
|
32
|
-
if (
|
|
32
|
+
if (typeof manifest.name !== 'string' || manifest.name.trim().length === 0)
|
|
33
33
|
return undefined;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
return { name: manifest.name, version: manifest.version };
|
|
34
|
+
return typeof manifest.version === 'string' && manifest.version.trim().length > 0
|
|
35
|
+
? { name: manifest.name, version: manifest.version }
|
|
36
|
+
: { name: manifest.name };
|
|
39
37
|
}
|
|
40
38
|
/** Resolve a bare package without requiring it to export `./package.json`. */
|
|
41
39
|
function barePackageManifest(packageName, anchors, packages) {
|
|
@@ -77,14 +75,14 @@ class PackageIdentityResolver {
|
|
|
77
75
|
this.packages = packages;
|
|
78
76
|
}
|
|
79
77
|
/** Resolve one Loader entry's owning package, or absence for a non-package loose module. */
|
|
80
|
-
resolve({
|
|
78
|
+
resolve({ moduleName, baseUrl, bareBaseUrl }) {
|
|
81
79
|
/* v8 ignore next -- Loader entry trees inherit a base URL; the fallback supports direct embedders. */
|
|
82
|
-
const treeBase =
|
|
80
|
+
const treeBase = baseUrl ?? this.hostBaseUrl;
|
|
83
81
|
const anchors = [...new Set([bareBaseUrl ?? treeBase, treeBase, this.hostBaseUrl, import.meta.url])];
|
|
84
|
-
const key = `${anchors.join('\u0000')}\u0000${
|
|
82
|
+
const key = `${anchors.join('\u0000')}\u0000${moduleName}`;
|
|
85
83
|
if (this.cache.has(key))
|
|
86
84
|
return this.cache.get(key);
|
|
87
|
-
const packageName = barePackageName(
|
|
85
|
+
const packageName = barePackageName(moduleName);
|
|
88
86
|
let manifest;
|
|
89
87
|
if (packageName !== undefined) {
|
|
90
88
|
manifest = barePackageManifest(packageName, anchors, this.packages);
|
|
@@ -92,59 +90,66 @@ class PackageIdentityResolver {
|
|
|
92
90
|
throw new Error(`plugin-package-inventory-deepseek: cannot resolve active package ${JSON.stringify(packageName)}`);
|
|
93
91
|
}
|
|
94
92
|
}
|
|
95
|
-
else if (!
|
|
96
|
-
const moduleUrl = isAbsolute(
|
|
97
|
-
? pathToFileURL(
|
|
98
|
-
: new URL(
|
|
93
|
+
else if (!moduleName.startsWith('cordis:')) {
|
|
94
|
+
const moduleUrl = isAbsolute(moduleName)
|
|
95
|
+
? pathToFileURL(moduleName)
|
|
96
|
+
: new URL(moduleName, treeBase);
|
|
99
97
|
if (moduleUrl.protocol === 'file:')
|
|
100
98
|
manifest = nearestManifest(fileURLToPath(moduleUrl));
|
|
101
99
|
}
|
|
102
|
-
const identity = manifest === undefined ? undefined : identityFromManifest(manifest
|
|
100
|
+
const identity = manifest === undefined ? undefined : identityFromManifest(manifest);
|
|
103
101
|
this.cache.set(key, identity);
|
|
104
102
|
return identity;
|
|
105
103
|
}
|
|
106
104
|
}
|
|
107
105
|
/** Yield active, non-structural entries from one Loader tree. */
|
|
108
|
-
function activeEntries(tree
|
|
106
|
+
function activeEntries(tree) {
|
|
109
107
|
return [...tree.entries()]
|
|
110
108
|
.filter(entry => !entry.options.group
|
|
111
109
|
&& !entry.disabled
|
|
112
110
|
&& entry.fiber?.state === 2 /* FiberState.ACTIVE */)
|
|
113
111
|
.map(entry => ({
|
|
114
|
-
entry,
|
|
115
|
-
...entry.parent.tree ===
|
|
116
|
-
? { bareBaseUrl: rootBareBaseUrl }
|
|
117
|
-
: {},
|
|
112
|
+
moduleName: entry.options.name,
|
|
113
|
+
...entry.parent.tree.ctx.baseUrl === undefined ? {} : { baseUrl: entry.parent.tree.ctx.baseUrl },
|
|
118
114
|
}));
|
|
119
115
|
}
|
|
120
116
|
/** Deterministic text order independent of the host's ICU data and locale. */
|
|
121
117
|
function compareWireText(left, right) {
|
|
122
118
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
123
119
|
}
|
|
124
|
-
/** Collect
|
|
125
|
-
|
|
120
|
+
/** Collect available identities from active packages for one request. */
|
|
121
|
+
function collectActivePluginPackages(ctx, resolver, hostBaseUrl, unreadable, sessionId) {
|
|
126
122
|
const entries = activeEntries(ctx.loader);
|
|
127
|
-
|
|
123
|
+
const presets = ctx.get('agentPresets');
|
|
124
|
+
if (sessionId !== undefined && presets !== undefined) {
|
|
128
125
|
const agent = ctx.agents.get(brandString(sessionId));
|
|
129
126
|
if (agent !== undefined) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (presetTree !== undefined)
|
|
137
|
-
entries.push(...activeEntries(presetTree, hostBaseUrl));
|
|
127
|
+
for (const composition of presets.inspectCompositions(agent.ctx)) {
|
|
128
|
+
entries.push(...composition.modules.map(({ useHostBase, ...entry }) => ({
|
|
129
|
+
...entry,
|
|
130
|
+
...useHostBase ? { bareBaseUrl: hostBaseUrl } : {},
|
|
131
|
+
})));
|
|
132
|
+
}
|
|
138
133
|
}
|
|
139
134
|
}
|
|
140
135
|
const unique = new Map();
|
|
141
136
|
for (const activeEntry of entries) {
|
|
142
|
-
|
|
137
|
+
let identity;
|
|
138
|
+
try {
|
|
139
|
+
identity = resolver.resolve(activeEntry);
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
if (!unreadable.has(activeEntry.moduleName)) {
|
|
143
|
+
unreadable.add(activeEntry.moduleName);
|
|
144
|
+
ctx.logger.warn('plugin-package-inventory-deepseek: omitting unreadable package identity for %s: %o', activeEntry.moduleName, error);
|
|
145
|
+
}
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
143
148
|
if (identity === undefined)
|
|
144
149
|
continue;
|
|
145
|
-
unique.set(`${identity.name}\u0000${identity.version}`, identity);
|
|
150
|
+
unique.set(`${identity.name}\u0000${identity.version ?? ''}`, identity);
|
|
146
151
|
}
|
|
147
|
-
return [...unique.values()].sort((left, right) => (compareWireText(left.name, right.name) || compareWireText(left.version, right.version)));
|
|
152
|
+
return [...unique.values()].sort((left, right) => (compareWireText(left.name, right.name) || compareWireText(left.version ?? '', right.version ?? '')));
|
|
148
153
|
}
|
|
149
154
|
/**
|
|
150
155
|
* Register the complete `dsh_plugin_packages` request contribution when enabled.
|
|
@@ -156,11 +161,13 @@ export function apply(ctx, config) {
|
|
|
156
161
|
return;
|
|
157
162
|
const hostBaseUrl = ctx.baseUrl ?? import.meta.url;
|
|
158
163
|
const resolver = new PackageIdentityResolver(hostBaseUrl, ctx.get('pluginPackages'));
|
|
164
|
+
// Unreadable identities are re-resolved on every request; log each module once.
|
|
165
|
+
const unreadable = new Set();
|
|
159
166
|
ctx.deepseekLlmApiExtensions.register('dsh_plugin_packages', {
|
|
160
|
-
prepare:
|
|
167
|
+
prepare: (request) => {
|
|
161
168
|
const value = {
|
|
162
169
|
version: 1,
|
|
163
|
-
packages:
|
|
170
|
+
packages: collectActivePluginPackages(ctx, resolver, hostBaseUrl, unreadable, request.sessionId),
|
|
164
171
|
};
|
|
165
172
|
return { value };
|
|
166
173
|
},
|
package/lib/types/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/** Wire types for the active DeepSeek plugin package inventory. */
|
|
2
|
-
/** One
|
|
2
|
+
/** One active plugin package, with its version when available. */
|
|
3
3
|
export interface DeepSeekPluginPackageIdentity {
|
|
4
4
|
readonly name: string;
|
|
5
|
-
readonly version
|
|
5
|
+
readonly version?: string;
|
|
6
6
|
}
|
|
7
7
|
/** Versioned full package inventory carried by each official DeepSeek request. */
|
|
8
8
|
export interface DeepSeekPluginPackageInventoryExtension {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-plugin-package-inventory-deepseek",
|
|
3
3
|
"description": "Active Loader-backed plugin package inventory for official DeepSeek LLM API requests",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.1-alpha.2",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -32,16 +32,16 @@
|
|
|
32
32
|
],
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@deepseek-ai/dsh-brand": "0.2.
|
|
36
|
-
"@deepseek-ai/schemastery": "~3.18.
|
|
35
|
+
"@deepseek-ai/dsh-brand": "0.2.1-alpha.2",
|
|
36
|
+
"@deepseek-ai/schemastery": "~3.18.5-alpha.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@deepseek-ai/cordis": "~4.0.
|
|
40
|
-
"@deepseek-ai/
|
|
41
|
-
"@deepseek-ai/dsh-agent
|
|
42
|
-
"@deepseek-ai/dsh-
|
|
43
|
-
"@deepseek-ai/dsh-
|
|
44
|
-
"@deepseek-ai/
|
|
39
|
+
"@deepseek-ai/cordis": "~4.0.5-alpha.1",
|
|
40
|
+
"@deepseek-ai/cordis-plugin-loader": "~1.0.6-alpha.1",
|
|
41
|
+
"@deepseek-ai/dsh-agent": "0.2.1-alpha.2",
|
|
42
|
+
"@deepseek-ai/dsh-agent-preset-registry": "0.2.1-alpha.2",
|
|
43
|
+
"@deepseek-ai/dsh-deepseek-llm-api-extensions": "0.2.1-alpha.2",
|
|
44
|
+
"@deepseek-ai/dsh-session": "0.2.1-alpha.2"
|
|
45
45
|
},
|
|
46
46
|
"peerDependenciesMeta": {
|
|
47
47
|
"@deepseek-ai/dsh-agent-preset-registry": {
|
|
@@ -49,15 +49,15 @@
|
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@deepseek-ai/dsh-app-boot": "0.2.
|
|
53
|
-
"@deepseek-ai/cordis": "~4.0.
|
|
54
|
-
"@deepseek-ai/cordis-plugin-include": "~1.0.
|
|
55
|
-
"@deepseek-ai/cordis-plugin-loader": "~1.0.
|
|
56
|
-
"@deepseek-ai/dsh-agent": "0.2.
|
|
57
|
-
"@deepseek-ai/dsh-
|
|
58
|
-
"@deepseek-ai/dsh-
|
|
59
|
-
"@deepseek-ai/dsh-
|
|
60
|
-
"@deepseek-ai/dsh-session
|
|
61
|
-
"@deepseek-ai/dsh-
|
|
52
|
+
"@deepseek-ai/dsh-app-boot": "0.2.1-alpha.2",
|
|
53
|
+
"@deepseek-ai/cordis": "~4.0.5-alpha.1",
|
|
54
|
+
"@deepseek-ai/cordis-plugin-include": "~1.0.10-alpha.1",
|
|
55
|
+
"@deepseek-ai/cordis-plugin-loader": "~1.0.6-alpha.1",
|
|
56
|
+
"@deepseek-ai/dsh-agent": "0.2.1-alpha.2",
|
|
57
|
+
"@deepseek-ai/dsh-agent-preset-registry": "0.2.1-alpha.2",
|
|
58
|
+
"@deepseek-ai/dsh-deepseek-llm-api-extensions": "0.2.1-alpha.2",
|
|
59
|
+
"@deepseek-ai/dsh-scope": "0.2.1-alpha.2",
|
|
60
|
+
"@deepseek-ai/dsh-session": "0.2.1-alpha.2",
|
|
61
|
+
"@deepseek-ai/dsh-session-projection": "0.2.1-alpha.2"
|
|
62
62
|
}
|
|
63
63
|
}
|