@deepseek-ai/dsh-repeat-tool-reminder 0.2.1-alpha.1 → 0.2.1-alpha.3

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.js CHANGED
@@ -52,7 +52,7 @@ const REMOTE_METHOD_DESCRIPTOR = "@deepseek-ai/dsh-typert-protocol/remote-method
52
52
  * a Host composition to read it.
53
53
  * @param service - owning Service instance, normally `this`.
54
54
  * @param serviceKey - exact Cordis service key.
55
- * @param options - optional distinct wire namespace.
55
+ * @param options - optional wire namespace.
56
56
  * @returns a frozen, inspectable binding with no compiler-injected metadata.
57
57
  */
58
58
  function bindTypertRemote(service, serviceKey, options = {}) {
@@ -60,7 +60,7 @@ function bindTypertRemote(service, serviceKey, options = {}) {
60
60
  const namespace = options.namespace ?? serviceKey;
61
61
  validateName("namespace", namespace);
62
62
  const ctx = Reflect.get(service, "ctx");
63
- if (ctx instanceof Context) provideInvocationAccessor(ctx);
63
+ if (Context.is(ctx)) provideInvocationAccessor(ctx);
64
64
  return Object.freeze({
65
65
  service,
66
66
  serviceKey,
@@ -75,7 +75,7 @@ var TypertRemoteService = class extends Service {
75
75
  * Register the Service and bind the same key to Typert Gateway.
76
76
  * @param ctx - owning Cordis Context.
77
77
  * @param serviceKey - exact Cordis service key and default wire namespace.
78
- * @param options - optional distinct wire namespace.
78
+ * @param options - optional wire namespace.
79
79
  */
80
80
  constructor(ctx, serviceKey, options = {}) {
81
81
  super(ctx, serviceKey);
@@ -95,21 +95,42 @@ function provideInvocationAccessor(ctx) {
95
95
  function Remote(methodExportOrOptions, context) {
96
96
  if (typeof methodExportOrOptions === "string") {
97
97
  validateName("Remote export name", methodExportOrOptions);
98
- return remoteDecorator({ kind: "direct" }, void 0, methodExportOrOptions);
99
- }
100
- if (typeof methodExportOrOptions === "object") {
101
- if (remoteOptionMode(methodExportOrOptions) !== "stream" || Reflect.ownKeys(methodExportOrOptions).length !== 1) throw new TypeError("typert-protocol: Remote options must contain exactly mode: \"stream\"");
102
- return remoteDecorator({ kind: "direct" }, "stream");
98
+ return remoteDecorator({ kind: "direct" }, { exportName: methodExportOrOptions });
103
99
  }
100
+ if (typeof methodExportOrOptions === "object") return remoteDecorator({ kind: "direct" }, markerOptions(methodExportOrOptions, REMOTE_OPTION_KEYS, "Remote options require name, mode: \"stream\", or resources"));
104
101
  if (context === void 0) throw new TypeError("typert-protocol: Remote decorator context is missing");
105
102
  addMarkerInitializer(context, { kind: "direct" });
106
103
  }
107
- function remoteOptionMode(options) {
108
- return Reflect.get(options, "mode");
104
+ const REMOTE_OPTION_KEYS = new Set([
105
+ "name",
106
+ "mode",
107
+ "resources"
108
+ ]);
109
+ /** Validate one decorator options object against its accepted keys and select the marker fields. */
110
+ function markerOptions(options, accepted, requirement) {
111
+ const keys = Reflect.ownKeys(options);
112
+ if (keys.length === 0 || keys.some((key) => typeof key !== "string" || !accepted.has(key)) || Object.hasOwn(options, "mode") && options.mode !== "stream") throw new TypeError(`typert-protocol: ${requirement}`);
113
+ const { mode, name, resources } = options;
114
+ if (name !== void 0) validateName("Remote export name", name);
115
+ return {
116
+ ...mode === void 0 ? {} : { mode },
117
+ ...name === void 0 ? {} : { exportName: name },
118
+ ...resources === void 0 ? {} : { resources: resourceReaders(resources) }
119
+ };
120
+ }
121
+ /** Freeze declared readers into the marker record; a misdeclared reader fails at decoration. */
122
+ function resourceReaders(resources) {
123
+ const readers = {};
124
+ for (const [kind, reader] of Object.entries(resources)) {
125
+ if (typeof reader !== "function") throw new TypeError(`typert-protocol: Remote resource reader "${kind}" must be a function`);
126
+ readers[kind] = reader;
127
+ }
128
+ if (Object.keys(readers).length === 0) throw new TypeError("typert-protocol: Remote resources require at least one reader");
129
+ return Object.freeze(readers);
109
130
  }
110
- function remoteDecorator(invocation, mode, exportName) {
131
+ function remoteDecorator(invocation, options = {}) {
111
132
  return function(_method, context) {
112
- addMarkerInitializer(context, invocation, mode, exportName);
133
+ addMarkerInitializer(context, invocation, options);
113
134
  };
114
135
  }
115
136
  function readRemoteMethodDescriptor(prototype) {
@@ -123,26 +144,27 @@ function readRemoteMethodDescriptor(prototype) {
123
144
  if (!Array.isArray(methods)) throw new TypeError("typert-protocol: Remote method descriptor methods must be an array");
124
145
  return descriptor;
125
146
  }
126
- function addMarkerInitializer(context, invocation, mode, exportName) {
147
+ function addMarkerInitializer(context, invocation, options = {}) {
127
148
  if (context.private || context.static || typeof context.name !== "string") throw new TypeError("typert-protocol: Remote decorators require a public instance method with a string name");
128
149
  const method = context.name;
129
150
  context.addInitializer(function() {
130
151
  const prototype = Object.getPrototypeOf(this);
131
152
  if (prototype === null) throw new TypeError(`typert-protocol: cannot mark Remote method "${method}" on an object without a prototype`);
132
- mark(prototype, method, invocation, mode, exportName);
153
+ mark(prototype, method, invocation, options);
133
154
  });
134
155
  }
135
- function mark(prototype, method, invocation, mode, exportName) {
156
+ function mark(prototype, method, invocation, { mode, exportName, resources }) {
136
157
  const descriptor = readRemoteMethodDescriptor(prototype);
137
158
  const marker = Object.freeze({
138
159
  method,
139
160
  ...exportName === void 0 || exportName === method ? {} : { exportName },
140
161
  ...mode === void 0 ? {} : { mode },
141
- invocation: Object.freeze(invocation)
162
+ invocation: Object.freeze(invocation),
163
+ ...resources === void 0 ? {} : { resources }
142
164
  });
143
165
  const current = descriptor?.methods.find((candidate) => candidate.method === method);
144
166
  if (current !== void 0) {
145
- if (current.exportName === marker.exportName && current.mode === marker.mode && sameInvocation(current.invocation, invocation)) return;
167
+ if (current.exportName === marker.exportName && current.mode === marker.mode && current.resources === marker.resources && sameInvocation(current.invocation, invocation)) return;
146
168
  throw new Error(`typert-protocol: Remote method "${method}" has conflicting invocation markers`);
147
169
  }
148
170
  Object.defineProperty(prototype, REMOTE_METHOD_DESCRIPTOR, {
@@ -1590,10 +1612,7 @@ var LlmError = class extends HarnessError {
1590
1612
  if (entry.provider.length === 0 || entry.displayName.length === 0 || entry.settingsNs.length === 0) throw new LlmError("configurable providers need a non-empty provider, displayName, and settingsNs", "INVALID_DIRECTORY");
1591
1613
  if (entry.settingsPath.some((segment) => segment.length === 0)) throw new LlmError(`configurable provider "${entry.provider}" has an empty settingsPath segment`, "INVALID_DIRECTORY");
1592
1614
  if (this.directory.has(entry.provider) && !own.has(entry.provider) || detached.some((seen) => seen.provider === entry.provider)) throw new LlmError(`configurable provider "${entry.provider}" is already declared`, "DUPLICATE_DIRECTORY");
1593
- detached.push({
1594
- ...entry,
1595
- settingsPath: [...entry.settingsPath]
1596
- });
1615
+ detached.push(detachDirectoryEntry(entry));
1597
1616
  }
1598
1617
  for (const entry of held) this.directory.delete(entry.provider);
1599
1618
  for (const entry of detached) this.directory.set(entry.provider, entry);
@@ -1622,10 +1641,7 @@ var LlmError = class extends HarnessError {
1622
1641
  * @returns detached directory entries in declaration order.
1623
1642
  */
1624
1643
  listConfigurableProviders() {
1625
- return [...this.directory.values()].map((entry) => ({
1626
- ...entry,
1627
- settingsPath: [...entry.settingsPath]
1628
- }));
1644
+ return [...this.directory.values()].map(detachDirectoryEntry);
1629
1645
  }
1630
1646
  /**
1631
1647
  * Offer to interrogate provider endpoints on behalf of the settings
@@ -1717,6 +1733,16 @@ var LlmError = class extends HarnessError {
1717
1733
  return this.adapters.get(provider)?.adapter.imageRequestPricing(provider, model);
1718
1734
  }
1719
1735
  /**
1736
+ * Resolve the image projection for an exact registered model route.
1737
+ * @param provider - registered provider route.
1738
+ * @param model - exact model id.
1739
+ * @param image - normalized image reference.
1740
+ * @returns dimensions and byte target used by the adapter's request serializer.
1741
+ */
1742
+ imageRequestTarget(provider, model, image) {
1743
+ return this.registration(provider).adapter.imageRequestTarget(provider, model, image);
1744
+ }
1745
+ /**
1720
1746
  * Resolve the exact text one durable file occurrence contributes to every
1721
1747
  * provider request in the current execution environment.
1722
1748
  * @param ref - durable verbatim file reference from model history.
@@ -1862,20 +1888,33 @@ var LlmError = class extends HarnessError {
1862
1888
  * Resolve one call under its current adapter registration. The returned
1863
1889
  * one-shot handle keeps that registration across header logging and dispatch,
1864
1890
  * so HMR cannot combine one adapter's capability result with another adapter.
1865
- * @param config - provider/model route and optional request controls.
1891
+ * An optional synchronous callback selects concrete controls using captured
1892
+ * model metadata. Defaults and validation apply to its result. Callback
1893
+ * failures and cancellation reject preparation before dispatch.
1894
+ * @param config - provider/model route and optional concrete request controls.
1866
1895
  * @param signal - optional cancellation for adapter-owned capability lookup.
1896
+ * @param configure - pure control selection, called once before defaults and validation.
1867
1897
  * @returns a prepared config and its registration-bound stream entry point.
1868
1898
  */
1869
- async prepareCall(config, signal) {
1870
- const registration = this.registration(config.provider);
1871
- const adapterCall = await registration.adapter.prepareCall(config.provider, config.model, signal);
1872
- const modelInfo = this.normalizeModelInfo(registration, config.model, adapterCall.model);
1873
- const resolved = this.resolveCallWithInfo(config, modelInfo);
1899
+ async prepareCall(config, signal, configure) {
1900
+ signal?.throwIfAborted();
1901
+ const { provider, model, ...controls } = config;
1902
+ const registration = this.registration(provider);
1903
+ const adapterCall = await registration.adapter.prepareCall(provider, model, signal);
1904
+ signal?.throwIfAborted();
1905
+ const modelInfo = this.normalizeModelInfo(registration, model, adapterCall.model);
1906
+ const proposed = configure === void 0 ? config : {
1907
+ ...configure(deepFreeze(structuredClone(controls)), deepFreeze(modelInfo)),
1908
+ provider,
1909
+ model
1910
+ };
1911
+ signal?.throwIfAborted();
1912
+ const resolved = this.resolveCallWithInfo(proposed, modelInfo);
1874
1913
  const resolvedConfig = deepFreeze(structuredClone(resolved.config));
1875
1914
  const context = resolved.context === void 0 ? void 0 : deepFreeze(structuredClone(resolved.context));
1876
1915
  const adapterDefaults = deepFreeze({
1877
- ...config.reasoningEffort === void 0 && resolvedConfig.reasoningEffort !== void 0 ? { reasoningEffort: true } : {},
1878
- ...config.maxTokens === void 0 && resolvedConfig.maxTokens !== void 0 ? { maxTokens: true } : {}
1916
+ ...proposed.reasoningEffort === void 0 && resolvedConfig.reasoningEffort !== void 0 ? { reasoningEffort: true } : {},
1917
+ ...proposed.maxTokens === void 0 && resolvedConfig.maxTokens !== void 0 ? { maxTokens: true } : {}
1879
1918
  });
1880
1919
  let dispatched = false;
1881
1920
  return Object.freeze({
@@ -2052,6 +2091,19 @@ function adapterFailureChunk(error, signal) {
2052
2091
  }
2053
2092
  };
2054
2093
  }
2094
+ /** Copy a directory entry, including its arrays, so neither side can mutate the other's copy. */
2095
+ function detachDirectoryEntry(entry) {
2096
+ const { nativeAuth } = entry;
2097
+ return {
2098
+ ...entry,
2099
+ settingsPath: [...entry.settingsPath],
2100
+ ...entry.baseURLEnv === void 0 ? {} : { baseURLEnv: [...entry.baseURLEnv] },
2101
+ ...nativeAuth === void 0 ? {} : { nativeAuth: {
2102
+ ...nativeAuth,
2103
+ env: [...nativeAuth.env]
2104
+ } }
2105
+ };
2106
+ }
2055
2107
  //#endregion
2056
2108
  //#region lib/types/index.js
2057
2109
  /**
package/locale/en.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "meta": {
3
+ "title": "repeat-tool-reminder"
4
+ }
5
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "重复工具调用提醒",
4
+ "description": "在 AI 重复执行相同工具调用时,提示它调整做法。"
5
+ }
6
+ }
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.2.1-alpha.1",
4
+ "version": "0.2.1-alpha.3",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -19,29 +19,31 @@
19
19
  "default": "./lib/index.js"
20
20
  },
21
21
  "./src/*": "./src/*",
22
- "./package.json": "./package.json"
22
+ "./package.json": "./package.json",
23
+ "./locale/*.json": "./locale/*.json"
23
24
  },
24
25
  "files": [
26
+ "locale/*.json",
25
27
  "lib/index.js",
26
28
  "lib/types/**/*.d.ts"
27
29
  ],
28
30
  "license": "MIT",
29
31
  "dependencies": {
30
- "@deepseek-ai/schemastery": "~3.18.5-alpha.1"
32
+ "@deepseek-ai/schemastery": "~3.18.5-alpha.2"
31
33
  },
32
34
  "peerDependencies": {
33
- "@deepseek-ai/dsh-agent": "0.2.1-alpha.1",
34
- "@deepseek-ai/dsh-tools": "0.2.1-alpha.1",
35
- "@deepseek-ai/cordis": "~4.0.5-alpha.1"
35
+ "@deepseek-ai/dsh-agent": "0.2.1-alpha.3",
36
+ "@deepseek-ai/dsh-tools": "0.2.1-alpha.3",
37
+ "@deepseek-ai/cordis": "~4.0.5-alpha.2"
36
38
  },
37
39
  "devDependencies": {
38
- "@deepseek-ai/dsh-agent": "0.2.1-alpha.1",
39
- "@deepseek-ai/dsh-agent-loop": "0.2.1-alpha.1",
40
- "@deepseek-ai/dsh-agent-loop-testkit": "0.2.1-alpha.1",
41
- "@deepseek-ai/dsh-llm": "0.2.1-alpha.1",
42
- "@deepseek-ai/dsh-session": "0.2.1-alpha.1",
43
- "@deepseek-ai/dsh-tools": "0.2.1-alpha.1",
44
- "@deepseek-ai/cordis": "~4.0.5-alpha.1",
45
- "@deepseek-ai/dsh-session-projection": "0.2.1-alpha.1"
40
+ "@deepseek-ai/dsh-agent": "0.2.1-alpha.3",
41
+ "@deepseek-ai/dsh-agent-loop": "0.2.1-alpha.3",
42
+ "@deepseek-ai/dsh-agent-loop-testkit": "0.2.1-alpha.3",
43
+ "@deepseek-ai/dsh-llm": "0.2.1-alpha.3",
44
+ "@deepseek-ai/dsh-session": "0.2.1-alpha.3",
45
+ "@deepseek-ai/dsh-tools": "0.2.1-alpha.3",
46
+ "@deepseek-ai/cordis": "~4.0.5-alpha.2",
47
+ "@deepseek-ai/dsh-session-projection": "0.2.1-alpha.3"
46
48
  }
47
49
  }