@deepseek-ai/dsh-repeat-tool-reminder 0.1.2-alpha.5 → 0.1.3-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 CHANGED
@@ -2,5 +2,5 @@
2
2
  # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
3
  # after editing either side, bring the other along and re-record with:
4
4
  # pnpm run verify-translation-pairing --write packages/guard/repeat-tool-reminder/README.md
5
- README.md: 9b3f176e3c84278b454a138f661e3803d31457e1
6
- README.zh.md: f2678fe8c3a7a6412681405bb026c21e24c088bd
5
+ README.md: 81a65629fe0e418e9a34c8b78046437575875e3c
6
+ README.zh.md: d856032c65c788ad701148ab8e678c13cec42e4a
package/README.md CHANGED
@@ -181,6 +181,6 @@ These limits define when the guard is a poor fit. They are current package const
181
181
 
182
182
  This Dev Note is working context for maintainers: open questions and directions that are not decided. It is explicitly non-authoritative — shipped behavior, limits, and accepted rationale live in the sections above, the package code, and the linked Agent Notes.
183
183
 
184
- The [repeat-tool-guard feature note](../../../.agents/notes/archived/feature/2026-07-08-repeat-tool-guard.md) records the original design and alternatives under the former package name; the [naming ledger](../../../.agents/notes/implemented/architecture/2026-08-11-repository-naming-contract-and-rename-ledger.md) records the rename to `repeat-tool-reminder` and its reason.
184
+ The [repeat-tool-guard feature note](../../../.agents/notes/archived/feature/2026-07-08-repeat-tool-guard.md) records the original design and alternatives under the former package name; the [naming ledger](../../../.agents/notes/archived/architecture/2026-08-11-repository-naming-contract-and-rename-ledger.md) records the rename to `repeat-tool-reminder` and its reason.
185
185
 
186
186
  </details>
package/README.zh.md CHANGED
@@ -181,6 +181,6 @@ The repeated calls are not making progress. Do not call this tool with these exa
181
181
 
182
182
  本开发备注是维护者的工作上下文:开放问题与尚未决定的探索方向。它明确不具权威性——已交付的行为、限制与既定理由以上文、包代码和相关 Agent Note 为准。
183
183
 
184
- [repeat-tool-guard Agent Note](../../../.agents/notes/archived/feature/2026-07-08-repeat-tool-guard.md) 以旧包名记录了原始设计与备选方案;[改名台账](../../../.agents/notes/implemented/architecture/2026-08-11-repository-naming-contract-and-rename-ledger.zh.md) 记录了改名为 `repeat-tool-reminder` 及其原因。
184
+ [repeat-tool-guard Agent Note](../../../.agents/notes/archived/feature/2026-07-08-repeat-tool-guard.md) 以旧包名记录了原始设计与备选方案;[改名台账](../../../.agents/notes/archived/architecture/2026-08-11-repository-naming-contract-and-rename-ledger.md) 记录了改名为 `repeat-tool-reminder` 及其原因。
185
185
 
186
186
  </details>
package/lib/index.js CHANGED
@@ -495,6 +495,9 @@ function harnessErrorCode(error) {
495
495
  }
496
496
  //#endregion
497
497
  //#region ../../llm/llm/src/content.ts
498
+ function quoted(value) {
499
+ return JSON.stringify(value);
500
+ }
498
501
  /**
499
502
  * Stable text shown to a model that cannot accept one durable image reference.
500
503
  * @param ref - durable normalized attachment omitted from the request.
@@ -514,6 +517,74 @@ function textOnlyImageText(ref) {
514
517
  function contentHasImage(content) {
515
518
  return content.some((block) => block.type === "image" || block.type === "tool-result" && contentHasImage(block.content));
516
519
  }
520
+ /**
521
+ * True when typed model content contains a file block, walking nested
522
+ * tool-result content on the same recursion every file policy shares.
523
+ * @param content - typed model content blocks.
524
+ * @returns whether any nested block is a file.
525
+ */
526
+ function contentHasFile(content) {
527
+ return content.some((block) => block.type === "file" || block.type === "tool-result" && contentHasFile(block.content));
528
+ }
529
+ /**
530
+ * Stable model-facing handle for one durable file reference: the address of
531
+ * the verbatim stored copy and the instruction to read it on demand. This is
532
+ * the only representation a provider ever receives for a file.
533
+ * @param ref - durable verbatim file reference.
534
+ * @param readonlyPath - execution-world path of the stored copy, when resolvable.
535
+ * @returns deterministic handle text naming the file, its size, and its address.
536
+ */
537
+ function fileHandleText(ref, readonlyPath) {
538
+ const digest = String(ref.attachmentId).slice(7, 15);
539
+ const identity = `File ${quoted(ref.name)} (${ref.bytes} bytes, sha256:${digest})`;
540
+ if (readonlyPath === void 0) return `[${identity} was uploaded, but the current execution environment cannot access a readable path. Report that limitation if its contents are needed; do not claim to have read it.]`;
541
+ return `[${identity}: verbatim read-only copy saved at ${quoted(readonlyPath)}. Read that path with your file tools when its contents are needed; copy it to a writable location before modifying it. When delegating file work, include this saved path in the delegation prompt; only subagents sharing this execution environment can read it.]`;
542
+ }
543
+ /** Replace every file occurrence, including nested tool results, with handle text. */
544
+ function replaceFilesWithHandles(blocks, resolvePath) {
545
+ let next;
546
+ for (const [index, block] of blocks.entries()) {
547
+ if (block.type === "file") {
548
+ next ??= blocks.slice(0, index);
549
+ next.push({
550
+ type: "text",
551
+ text: fileHandleText(block.attachment, resolvePath(block.attachment))
552
+ });
553
+ continue;
554
+ }
555
+ if (block.type === "tool-result") {
556
+ const content = replaceFilesWithHandles(block.content, resolvePath);
557
+ if (content !== block.content) {
558
+ next ??= blocks.slice(0, index);
559
+ next.push({
560
+ ...block,
561
+ content
562
+ });
563
+ continue;
564
+ }
565
+ }
566
+ next?.push(block);
567
+ }
568
+ return next ?? blocks;
569
+ }
570
+ /**
571
+ * Project durable file history into deterministic handle text for every model
572
+ * route. Unlike images, no provider receives file blocks natively, so this
573
+ * projection is unconditional in request assembly.
574
+ * @param messages - complete request history.
575
+ * @param resolvePath - resolve one reference's current execution-world read path.
576
+ * @returns the original list without files, otherwise shallow message copies with handle text.
577
+ */
578
+ function projectFilesToText(messages, resolvePath) {
579
+ if (!messages.some((message) => contentHasFile(message.content))) return messages;
580
+ return messages.map((message) => {
581
+ const content = replaceFilesWithHandles(message.content, resolvePath);
582
+ return content === message.content ? message : {
583
+ ...message,
584
+ content
585
+ };
586
+ });
587
+ }
517
588
  /** Replace every image occurrence, including nested tool results, for a text-only model. */
518
589
  function replaceImagesForTextModel(blocks) {
519
590
  let next;
@@ -950,6 +1021,15 @@ var LlmError = class extends HarnessError {
950
1021
  imageRequestPricing(provider, model) {
951
1022
  return this.adapters.get(provider)?.adapter.imageRequestPricing(provider, model);
952
1023
  }
1024
+ /**
1025
+ * Resolve the exact text one durable file occurrence contributes to every
1026
+ * provider request in the current execution environment.
1027
+ * @param ref - durable verbatim file reference from model history.
1028
+ * @returns the same deterministic handle text used at adapter dispatch.
1029
+ */
1030
+ fileRequestText(ref) {
1031
+ return fileHandleText(ref, this.fileReadPath(ref));
1032
+ }
953
1033
  /** Detach typed adapter-owned modality metadata. */
954
1034
  detachedModalities(modalities) {
955
1035
  return modalities === void 0 ? void 0 : [...modalities];
@@ -1143,6 +1223,20 @@ var LlmError = class extends HarnessError {
1143
1223
  return Object.isFrozen(options) ? deepFreeze(filtered) : filtered;
1144
1224
  }
1145
1225
  /**
1226
+ * Resolve the current execution-world read path of one durable file
1227
+ * reference through the mounted attachment and filesystem providers.
1228
+ */
1229
+ fileReadPath(ref) {
1230
+ let hostPath;
1231
+ try {
1232
+ hostPath = this.ctx.get("attachments")?.fileHostPath(ref);
1233
+ } catch {
1234
+ return;
1235
+ }
1236
+ if (hostPath === void 0) return void 0;
1237
+ return this.ctx.get("fs")?.processPathFromHostPath(hostPath);
1238
+ }
1239
+ /**
1146
1240
  * Final adapter boundary. Adapter selection, dispatch, iterator construction,
1147
1241
  * and iteration failures become one terminal failure chunk. Middleware and
1148
1242
  * downstream consumer failures remain thrown plugin or consumer errors.
@@ -1173,13 +1267,16 @@ var LlmError = class extends HarnessError {
1173
1267
  ...options,
1174
1268
  ...resolvedConfig
1175
1269
  };
1176
- const projectedOptions = modelInfo.inputModalities !== void 0 && !modelInfo.inputModalities.includes("image") && resolvedOptions.messages.some((message) => contentHasImage(message.content)) ? Object.isFrozen(resolvedOptions) ? deepFreeze({
1270
+ let projectedMessages = resolvedOptions.messages;
1271
+ if (projectedMessages.some((message) => contentHasFile(message.content))) projectedMessages = projectFilesToText(projectedMessages, (ref) => this.fileReadPath(ref));
1272
+ if (modelInfo.inputModalities !== void 0 && !modelInfo.inputModalities.includes("image") && projectedMessages.some((message) => contentHasImage(message.content))) projectedMessages = projectImagesForTextModel(projectedMessages);
1273
+ const projectedOptions = projectedMessages === resolvedOptions.messages ? resolvedOptions : Object.isFrozen(resolvedOptions) ? deepFreeze({
1177
1274
  ...resolvedOptions,
1178
- messages: projectImagesForTextModel(resolvedOptions.messages)
1275
+ messages: projectedMessages
1179
1276
  }) : {
1180
1277
  ...resolvedOptions,
1181
- messages: projectImagesForTextModel(resolvedOptions.messages)
1182
- } : resolvedOptions;
1278
+ messages: projectedMessages
1279
+ };
1183
1280
  iterator = dispatch(this.forAdapter(projectedOptions, adapter))[Symbol.asyncIterator]();
1184
1281
  } catch (error) {
1185
1282
  yield adapterFailureChunk(error, options.signal);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-repeat-tool-reminder",
3
3
  "description": "Repeat-tool-call guard plugin: advisory reminders when an agent loops on identical tool calls",
4
- "version": "0.1.2-alpha.5",
4
+ "version": "0.1.3-alpha.2",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -30,18 +30,18 @@
30
30
  "@deepseek-ai/schemastery": "^3.18.2"
31
31
  },
32
32
  "peerDependencies": {
33
- "@deepseek-ai/dsh-agent": "^0.1.2-alpha.5",
34
- "@deepseek-ai/dsh-tools": "^0.1.2-alpha.5",
33
+ "@deepseek-ai/dsh-agent": "^0.1.3-alpha.2",
34
+ "@deepseek-ai/dsh-tools": "^0.1.3-alpha.2",
35
35
  "@deepseek-ai/cordis": "^4.0.2"
36
36
  },
37
37
  "devDependencies": {
38
- "@deepseek-ai/dsh-agent": "^0.1.2-alpha.5",
39
- "@deepseek-ai/dsh-agent-loop": "^0.1.2-alpha.5",
40
- "@deepseek-ai/dsh-agent-loop-testkit": "^0.1.2-alpha.5",
41
- "@deepseek-ai/dsh-llm": "^0.1.2-alpha.5",
42
- "@deepseek-ai/dsh-session": "^0.1.2-alpha.5",
43
- "@deepseek-ai/dsh-tools": "^0.1.2-alpha.5",
38
+ "@deepseek-ai/dsh-agent": "^0.1.3-alpha.2",
39
+ "@deepseek-ai/dsh-agent-loop": "^0.1.3-alpha.2",
40
+ "@deepseek-ai/dsh-agent-loop-testkit": "^0.1.3-alpha.2",
41
+ "@deepseek-ai/dsh-llm": "^0.1.3-alpha.2",
42
+ "@deepseek-ai/dsh-session": "^0.1.3-alpha.2",
44
43
  "@deepseek-ai/cordis": "^4.0.2",
45
- "@deepseek-ai/dsh-session-projection": "^0.1.2-alpha.5"
44
+ "@deepseek-ai/dsh-tools": "^0.1.3-alpha.2",
45
+ "@deepseek-ai/dsh-session-projection": "^0.1.3-alpha.2"
46
46
  }
47
47
  }