@minidoll/agentkit-dsh-plugin 0.1.0 → 0.1.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.
package/dist/index.js CHANGED
@@ -174,6 +174,7 @@ import { randomUUID } from "node:crypto";
174
174
  import { existsSync as existsSync4, readFileSync as readFileSync3, readdirSync as readdirSync2 } from "node:fs";
175
175
  import { join as join4 } from "node:path";
176
176
  var MAX_CONTEXT_BYTES = 900;
177
+ var SOURCE_KIND = "agentkit-context";
177
178
  var factoryLoader = null;
178
179
  async function loadFactory() {
179
180
  factoryLoader ??= (async () => {
@@ -192,7 +193,7 @@ function handcraft(text) {
192
193
  role: "user",
193
194
  id: randomUUID(),
194
195
  content: [{ type: "text", text }],
195
- source: { kind: "user" }
196
+ source: { kind: SOURCE_KIND }
196
197
  };
197
198
  }
198
199
  function assertUserMessage(value) {
@@ -201,7 +202,7 @@ function assertUserMessage(value) {
201
202
  if (m.role !== "user") return false;
202
203
  if (typeof m.id !== "string" || m.id === "") return false;
203
204
  const src = m.source;
204
- if (src === void 0 || src.kind !== "user") return false;
205
+ if (src === void 0 || src.kind !== SOURCE_KIND) return false;
205
206
  const content = m.content;
206
207
  if (!Array.isArray(content) || content.length === 0) return false;
207
208
  return content.every((b) => {
@@ -307,7 +308,7 @@ async function buildAdditionalContexts(input) {
307
308
  return { ok: false, reason: "nothing to inject for this path" };
308
309
  }
309
310
  const factory = await loadFactory();
310
- const msg = factory !== null ? factory({ content: [{ type: "text", text }], source: { kind: "user" } }) : handcraft(text);
311
+ const msg = factory !== null ? factory({ content: [{ type: "text", text }], source: { kind: SOURCE_KIND } }) : handcraft(text);
311
312
  if (!assertUserMessage(msg)) {
312
313
  input.trace?.(`inject rejected: shape check failed (${factory !== null ? "factory" : "handcraft"})`);
313
314
  return { ok: false, reason: "shape check failed" };
package/dist/inject.d.ts CHANGED
@@ -12,12 +12,24 @@ interface TextBlock {
12
12
  * 拿不到时**照抄契约**手工构造 —— 形状必须与 `dsh-llm` 的
13
13
  * `MessageBase`/`UserMessage`/`TextBlock` 完全一致。
14
14
  */
15
+ /**
16
+ * 注入消息的自定义 producer kind(2026-10-30 真机问题的修复)。
17
+ *
18
+ * `dsh-llm` 的类型注释写得很清楚:
19
+ * "user messages carry **any producer's kind**, and consumers fall through
20
+ * unknown kinds. There is no shared catch-all `plugin` kind."
21
+ *
22
+ * 此前我用 `{kind:'user'}` —— 于是 UI 把它当成**真用户输入**,
23
+ * 渲染进了 Think/推理区,把正常结论挤到折叠区里。
24
+ * 改成自定义 kind 后,消费者按"未知来源"走默认路径,不会误当用户输入。
25
+ */
26
+ export declare const SOURCE_KIND = "agentkit-context";
15
27
  export interface UserMessageLike {
16
28
  role: 'user';
17
29
  id: string;
18
30
  content: TextBlock[];
19
31
  source: {
20
- kind: 'user';
32
+ kind: string;
21
33
  };
22
34
  }
23
35
  /**
package/dist/inject.js CHANGED
@@ -30,6 +30,25 @@ import { existsSync, readFileSync, readdirSync } from 'node:fs';
30
30
  import { join } from 'node:path';
31
31
  /** 注入内容的硬上限(字节)。超过就截断 —— 注入不是"越多越好"。 */
32
32
  export const MAX_CONTEXT_BYTES = 900;
33
+ /**
34
+ * 构造一条合法的 UserMessage。
35
+ *
36
+ * `createUserMessage` 拿得到就用它(id 由官方生成,最保险);
37
+ * 拿不到时**照抄契约**手工构造 —— 形状必须与 `dsh-llm` 的
38
+ * `MessageBase`/`UserMessage`/`TextBlock` 完全一致。
39
+ */
40
+ /**
41
+ * 注入消息的自定义 producer kind(2026-10-30 真机问题的修复)。
42
+ *
43
+ * `dsh-llm` 的类型注释写得很清楚:
44
+ * "user messages carry **any producer's kind**, and consumers fall through
45
+ * unknown kinds. There is no shared catch-all `plugin` kind."
46
+ *
47
+ * 此前我用 `{kind:'user'}` —— 于是 UI 把它当成**真用户输入**,
48
+ * 渲染进了 Think/推理区,把正常结论挤到折叠区里。
49
+ * 改成自定义 kind 后,消费者按"未知来源"走默认路径,不会误当用户输入。
50
+ */
51
+ export const SOURCE_KIND = 'agentkit-context';
33
52
  /** 尝试加载官方工厂(结果缓存;拿不到就是 null,不重试)。 */
34
53
  let factoryLoader = null;
35
54
  async function loadFactory() {
@@ -54,7 +73,7 @@ function handcraft(text) {
54
73
  role: 'user',
55
74
  id: randomUUID(),
56
75
  content: [{ type: 'text', text }],
57
- source: { kind: 'user' },
76
+ source: { kind: SOURCE_KIND },
58
77
  };
59
78
  }
60
79
  /**
@@ -71,7 +90,7 @@ export function assertUserMessage(value) {
71
90
  if (typeof m.id !== 'string' || m.id === '')
72
91
  return false;
73
92
  const src = m.source;
74
- if (src === undefined || src.kind !== 'user')
93
+ if (src === undefined || src.kind !== SOURCE_KIND)
75
94
  return false;
76
95
  const content = m.content;
77
96
  if (!Array.isArray(content) || content.length === 0)
@@ -229,7 +248,7 @@ export async function buildAdditionalContexts(input) {
229
248
  }
230
249
  const factory = await loadFactory();
231
250
  const msg = factory !== null
232
- ? factory({ content: [{ type: 'text', text }], source: { kind: 'user' } })
251
+ ? factory({ content: [{ type: 'text', text }], source: { kind: SOURCE_KIND } })
233
252
  : handcraft(text);
234
253
  if (!assertUserMessage(msg)) {
235
254
  // 形状不合法 ⇒ **不注入**(而不是把坏形状交给宿主,那正是事故)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minidoll/agentkit-dsh-plugin",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "DeepSeek Harness 插件:项目自包含的 lifecycle hooks(配置随仓库走,per-session 发现)",
5
5
  "license": "MIT",
6
6
  "type": "module",