@qilin-agent/repeat-tool-reminder 3.1.5 → 3.1.7

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.
Files changed (2) hide show
  1. package/lib/index.js +61 -19
  2. package/package.json +13 -13
package/lib/index.js CHANGED
@@ -52,7 +52,7 @@ const REMOTE_METHOD_DESCRIPTOR = "@qilin-agent/typert-protocol/remote-methods";
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
+ };
109
120
  }
110
- function remoteDecorator(invocation, mode, exportName) {
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);
130
+ }
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, {
@@ -1598,7 +1620,12 @@ var LlmError = class extends HarnessError {
1598
1620
  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");
1599
1621
  detached.push({
1600
1622
  ...entry,
1601
- settingsPath: [...entry.settingsPath]
1623
+ settingsPath: [...entry.settingsPath],
1624
+ ...entry.baseURLEnv === void 0 ? {} : { baseURLEnv: [...entry.baseURLEnv] },
1625
+ ...entry.nativeAuth === void 0 ? {} : { nativeAuth: {
1626
+ ...entry.nativeAuth,
1627
+ env: [...entry.nativeAuth.env]
1628
+ } }
1602
1629
  });
1603
1630
  }
1604
1631
  for (const entry of held) this.directory.delete(entry.provider);
@@ -1630,7 +1657,12 @@ var LlmError = class extends HarnessError {
1630
1657
  listConfigurableProviders() {
1631
1658
  return [...this.directory.values()].map((entry) => ({
1632
1659
  ...entry,
1633
- settingsPath: [...entry.settingsPath]
1660
+ settingsPath: [...entry.settingsPath],
1661
+ ...entry.baseURLEnv === void 0 ? {} : { baseURLEnv: [...entry.baseURLEnv] },
1662
+ ...entry.nativeAuth === void 0 ? {} : { nativeAuth: {
1663
+ ...entry.nativeAuth,
1664
+ env: [...entry.nativeAuth.env]
1665
+ } }
1634
1666
  }));
1635
1667
  }
1636
1668
  /**
@@ -1723,6 +1755,16 @@ var LlmError = class extends HarnessError {
1723
1755
  return this.adapters.get(provider)?.adapter.imageRequestPricing(provider, model);
1724
1756
  }
1725
1757
  /**
1758
+ * Resolve the image projection for an exact registered model route.
1759
+ * @param provider - registered provider route.
1760
+ * @param model - exact model id.
1761
+ * @param image - normalized image reference.
1762
+ * @returns dimensions and byte target used by the adapter's request serializer.
1763
+ */
1764
+ imageRequestTarget(provider, model, image) {
1765
+ return this.registration(provider).adapter.imageRequestTarget(provider, model, image);
1766
+ }
1767
+ /**
1726
1768
  * Resolve the exact text one durable file occurrence contributes to every
1727
1769
  * provider request in the current execution environment.
1728
1770
  * @param ref - durable verbatim file reference from model history.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@qilin-agent/repeat-tool-reminder",
3
3
  "description": "Repeat-tool-call guard plugin: advisory reminders when an agent loops on identical tool calls",
4
- "version": "3.1.5",
4
+ "version": "3.1.7",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -30,21 +30,21 @@
30
30
  ],
31
31
  "license": "MIT",
32
32
  "dependencies": {
33
- "@qilin-agent/schemastery": "~3.18.3"
33
+ "@qilin-agent/schemastery": "~3.18.5"
34
34
  },
35
35
  "peerDependencies": {
36
- "@qilin-agent/agent": "3.1.5",
37
- "@qilin-agent/tools": "3.1.5",
38
- "@qilin-agent/kylin": "~4.0.3"
36
+ "@qilin-agent/agent": "3.1.7",
37
+ "@qilin-agent/kylin": "~4.0.5",
38
+ "@qilin-agent/tools": "3.1.7"
39
39
  },
40
40
  "devDependencies": {
41
- "@qilin-agent/agent": "3.1.5",
42
- "@qilin-agent/agent-loop-testkit": "3.1.5",
43
- "@qilin-agent/session": "3.1.5",
44
- "@qilin-agent/agent-loop": "3.1.5",
45
- "@qilin-agent/llm": "3.1.5",
46
- "@qilin-agent/tools": "3.1.5",
47
- "@qilin-agent/kylin": "~4.0.3",
48
- "@qilin-agent/session-projection": "3.1.5"
41
+ "@qilin-agent/agent": "3.1.7",
42
+ "@qilin-agent/llm": "3.1.7",
43
+ "@qilin-agent/agent-loop-testkit": "3.1.7",
44
+ "@qilin-agent/session": "3.1.7",
45
+ "@qilin-agent/agent-loop": "3.1.7",
46
+ "@qilin-agent/tools": "3.1.7",
47
+ "@qilin-agent/kylin": "~4.0.5",
48
+ "@qilin-agent/session-projection": "3.1.7"
49
49
  }
50
50
  }