@capybara-hq/plugin-model-fake 0.1.0-rc.12 → 0.1.0-rc.13

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.12",
4
+ "version": "0.1.0-rc.13",
5
5
  "publisher": "Capybara",
6
6
  "description": {
7
7
  "en": "Deterministic scripted model provider (model-provider@2) for runtime tests, e2e tests and keyless demos",
@@ -16,7 +16,7 @@
16
16
  "entry": "./dist/index.mjs",
17
17
  "manifest": {
18
18
  "name": "model-fake",
19
- "version": "0.1.0-rc.12",
19
+ "version": "0.1.0-rc.13",
20
20
  "sdk": "^0.1.0-rc.0",
21
21
  "provides": [
22
22
  "model-provider@2"
package/dist/index.mjs CHANGED
@@ -192,6 +192,22 @@ function scripted(req) {
192
192
  };
193
193
  }
194
194
  }
195
+ const slowTool = /^slowtool:(\d+):([^:]+):([\s\S]*)$/.exec(text);
196
+ if (slowTool) {
197
+ try {
198
+ return {
199
+ kind: "tool",
200
+ name: slowTool[2],
201
+ input: JSON.parse(slowTool[3]),
202
+ delayMs: Number(slowTool[1])
203
+ };
204
+ } catch {
205
+ return {
206
+ kind: "fail",
207
+ error: new ModelError("invalid_request", "slowtool directive carries invalid JSON")
208
+ };
209
+ }
210
+ }
195
211
  const tool = /^tool:([^:]+):([\s\S]*)$/.exec(text);
196
212
  if (tool) {
197
213
  try {
@@ -330,6 +346,7 @@ function createFakeProvider(opts) {
330
346
  cacheWriteTokens: cache.write
331
347
  });
332
348
  if (p.kind === "tool") {
349
+ if (p.delayMs !== void 0 && p.delayMs > 0) await sleep(p.delayMs, signal);
333
350
  const calls = [{ name: p.name, input: p.input }, ...p.more ?? []];
334
351
  const content = calls.map((c, i) => ({
335
352
  type: "tool_call",
@@ -406,7 +423,7 @@ var DeploymentConfig = z.object({
406
423
  });
407
424
  var index_default = defineExtension({
408
425
  name: "model-fake",
409
- version: "0.1.0-rc.12",
426
+ version: "0.1.0-rc.13",
410
427
  sdk: "^0.1.0-rc.0",
411
428
  provides: [MODEL_PROVIDER_EXTENSION_POINT_V2],
412
429
  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.12",
3
+ "version": "0.1.0-rc.13",
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",