@capybara-hq/plugin-model-fake 0.1.0-rc.0 → 0.1.0-rc.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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "name": "model-fake",
4
- "version": "0.1.0-rc.0",
4
+ "version": "0.1.0-rc.1",
5
5
  "publisher": "Capybara",
6
6
  "description": "Deterministic scripted model provider (model-provider@2) for runtime tests, e2e tests and keyless demos",
7
7
  "homepage": "https://github.com/capybara-hq/core/tree/main/plugins/model-fake#readme",
@@ -9,7 +9,7 @@
9
9
  "entry": "./dist/index.mjs",
10
10
  "manifest": {
11
11
  "name": "model-fake",
12
- "version": "0.1.0-rc.0",
12
+ "version": "0.1.0-rc.1",
13
13
  "sdk": "^0.1.0-rc.0",
14
14
  "provides": [
15
15
  "model-provider@2"
package/dist/index.mjs CHANGED
@@ -170,6 +170,20 @@ function scripted(req) {
170
170
  error: new ModelError(kind, `Scripted ${kind} failure`)
171
171
  };
172
172
  }
173
+ const multi = /^tools:(\[[\s\S]*\])$/.exec(text);
174
+ if (multi) {
175
+ try {
176
+ const calls = JSON.parse(multi[1]);
177
+ const [first2, ...more] = calls;
178
+ if (first2 === void 0) throw new Error("empty");
179
+ return { kind: "tool", name: first2.name, input: first2.input, more };
180
+ } catch {
181
+ return {
182
+ kind: "fail",
183
+ error: new ModelError("invalid_request", "tools directive carries invalid JSON")
184
+ };
185
+ }
186
+ }
173
187
  const tool = /^tool:([^:]+):([\s\S]*)$/.exec(text);
174
188
  if (tool) {
175
189
  try {
@@ -242,13 +256,22 @@ function createFakeProvider(opts) {
242
256
  cacheWriteTokens: cache.write
243
257
  });
244
258
  if (p.kind === "tool") {
245
- const id = `call_${createHash("sha256").update(`${req.messages.length}:${p.name}:${JSON.stringify(p.input)}`).digest("hex").slice(0, 12)}`;
246
- const content = [{ type: "tool_call", id, name: p.name, input: p.input }];
259
+ const calls = [{ name: p.name, input: p.input }, ...p.more ?? []];
260
+ const content = calls.map((c, i) => ({
261
+ type: "tool_call",
262
+ id: `call_${createHash("sha256").update(
263
+ `${req.messages.length}:${i === 0 ? "" : `${i}:`}${c.name}:${JSON.stringify(c.input)}`
264
+ ).digest("hex").slice(0, 12)}`,
265
+ name: c.name,
266
+ input: c.input
267
+ }));
247
268
  yield {
248
269
  type: "message_complete",
249
270
  content,
250
271
  stopReason: "tool_use",
251
- usage: usage(p.name.length + JSON.stringify(p.input ?? null).length)
272
+ usage: usage(
273
+ calls.reduce((n, c) => n + c.name.length + JSON.stringify(c.input ?? null).length, 0)
274
+ )
252
275
  };
253
276
  return;
254
277
  }
@@ -293,7 +316,7 @@ var DeploymentConfig = z.object({
293
316
  });
294
317
  var index_default = defineExtension({
295
318
  name: "model-fake",
296
- version: "0.1.0-rc.0",
319
+ version: "0.1.0-rc.1",
297
320
  sdk: "^0.1.0-rc.0",
298
321
  provides: [MODEL_PROVIDER_EXTENSION_POINT_V2],
299
322
  config: { deployment: DeploymentConfig },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capybara-hq/plugin-model-fake",
3
- "version": "0.1.0-rc.0",
3
+ "version": "0.1.0-rc.1",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "description": "Deterministic scripted model provider (model-provider@2) for runtime tests, e2e tests and keyless demos",