@capybara-hq/testing 0.1.0-rc.4 → 0.1.0-rc.40

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 (99) hide show
  1. package/dist/containers.d.ts +7 -2
  2. package/dist/containers.js +7 -3
  3. package/dist/device-service-conformance.d.ts +38 -0
  4. package/dist/device-service-conformance.js +141 -0
  5. package/dist/dual-replica.d.ts +23 -1
  6. package/dist/dual-replica.js +53 -0
  7. package/dist/fake-channel.d.ts +44 -5
  8. package/dist/fake-channel.js +63 -2
  9. package/dist/fake-dial-in-machine.d.ts +150 -0
  10. package/dist/fake-dial-in-machine.js +367 -0
  11. package/dist/fake-e2b.d.ts +34 -0
  12. package/dist/fake-e2b.js +95 -1
  13. package/dist/fake-git-server.d.ts +32 -4
  14. package/dist/fake-git-server.js +87 -19
  15. package/dist/fake-lark.d.ts +12 -1
  16. package/dist/fake-lark.js +63 -10
  17. package/dist/fake-oauth-server.d.ts +62 -2
  18. package/dist/fake-oauth-server.js +86 -5
  19. package/dist/fake-slack.d.ts +17 -1
  20. package/dist/fake-slack.js +98 -0
  21. package/dist/fake-telegram.d.ts +173 -0
  22. package/dist/fake-telegram.js +632 -0
  23. package/dist/fixtures.d.ts +24 -8
  24. package/dist/fixtures.js +31 -8
  25. package/dist/index.d.ts +15 -9
  26. package/dist/index.js +10 -4
  27. package/dist/kernel-helpers.d.ts +16 -4
  28. package/dist/kernel-helpers.js +39 -4
  29. package/dist/media-samples.d.ts +2 -0
  30. package/dist/media-samples.js +2 -0
  31. package/dist/model-conformance.d.ts +15 -10
  32. package/dist/model-conformance.js +87 -14
  33. package/dist/push-conformance.d.ts +31 -0
  34. package/dist/push-conformance.js +160 -0
  35. package/dist/replica-runner.js +2 -0
  36. package/dist/sandbox-native-conformance.d.ts +31 -0
  37. package/dist/sandbox-native-conformance.js +153 -0
  38. package/dist/sandbox-permission-conformance.d.ts +310 -0
  39. package/dist/sandbox-permission-conformance.js +1491 -0
  40. package/fixtures/extensions/fake-bootstrap-a/src/index.ts +8 -4
  41. package/fixtures/extensions/fake-bootstrap-b/src/index.ts +8 -4
  42. package/fixtures/extensions/fake-client/.capybara-plugin/plugin.json +11 -0
  43. package/fixtures/extensions/fake-client/client/styles/fake.css +11 -0
  44. package/fixtures/extensions/fake-client/package.json +12 -0
  45. package/fixtures/extensions/fake-client/src/client.tsx +51 -0
  46. package/fixtures/extensions/fake-client/src/index.ts +43 -0
  47. package/fixtures/extensions/fake-client/themes/fake.json +11 -0
  48. package/fixtures/extensions/fake-client-broken/.capybara-plugin/plugin.json +7 -0
  49. package/fixtures/extensions/fake-client-broken/package.json +12 -0
  50. package/fixtures/extensions/fake-client-broken/src/client.tsx +22 -0
  51. package/fixtures/extensions/fake-client-broken/src/index.ts +27 -0
  52. package/fixtures/extensions/fake-config-form/src/index.ts +52 -46
  53. package/fixtures/extensions/fake-connector/src/index.ts +64 -34
  54. package/fixtures/extensions/fake-context/.capybara-plugin/plugin.json +7 -0
  55. package/fixtures/extensions/fake-context/package.json +12 -0
  56. package/fixtures/extensions/fake-context/src/index.ts +78 -0
  57. package/fixtures/extensions/fake-dep-provider/src/index.ts +1 -1
  58. package/fixtures/extensions/fake-dep-requirer/src/index.ts +1 -1
  59. package/fixtures/extensions/fake-embed/src/index.ts +26 -26
  60. package/fixtures/extensions/fake-im/.capybara-plugin/plugin.json +7 -1
  61. package/fixtures/extensions/fake-im/guides/fake-im-app.md +32 -0
  62. package/fixtures/extensions/fake-im/guides/fake-im-app.zh.md +32 -0
  63. package/fixtures/extensions/fake-im/src/channel.ts +22 -1
  64. package/fixtures/extensions/fake-im/src/checks.ts +94 -0
  65. package/fixtures/extensions/fake-im/src/directory.ts +44 -20
  66. package/fixtures/extensions/fake-im/src/index.ts +59 -11
  67. package/fixtures/extensions/fake-lifecycle/.capybara-plugin/plugin.json +7 -0
  68. package/fixtures/extensions/fake-lifecycle/migrations/0001_init.sql +16 -0
  69. package/fixtures/extensions/fake-lifecycle/package.json +12 -0
  70. package/fixtures/extensions/fake-lifecycle/src/index.ts +72 -0
  71. package/fixtures/extensions/fake-object-store/src/index.ts +12 -8
  72. package/fixtures/extensions/fake-openapi/src/index.ts +46 -34
  73. package/fixtures/extensions/fake-push/.capybara-plugin/plugin.json +13 -0
  74. package/fixtures/extensions/fake-push/guides/fake-push-key.md +6 -0
  75. package/fixtures/extensions/fake-push/guides/fake-push-key.zh.md +6 -0
  76. package/fixtures/extensions/fake-push/migrations/0001_sends.sql +9 -0
  77. package/fixtures/extensions/fake-push/package.json +12 -0
  78. package/fixtures/extensions/fake-push/src/check.ts +40 -0
  79. package/fixtures/extensions/fake-push/src/index.ts +56 -0
  80. package/fixtures/extensions/fake-push/src/push.ts +103 -0
  81. package/fixtures/extensions/fake-tools-ui/src/index.ts +61 -2
  82. package/fixtures/extensions/fake-web/src/index.ts +5 -4
  83. package/fixtures/extensions/fake-web/src/web.ts +11 -7
  84. package/fixtures/extensions/fake-web-2/src/index.ts +2 -2
  85. package/fixtures/extensions/fake-web-2/src/web.ts +11 -7
  86. package/fixtures/plugins/fake-theme/.capybara-plugin/plugin.json +7 -0
  87. package/fixtures/plugins/fake-theme/brand/app-512.png +0 -0
  88. package/fixtures/plugins/fake-theme/brand/app-mask-512.png +0 -0
  89. package/fixtures/plugins/fake-theme/brand/avatars/bot.svg +1 -0
  90. package/fixtures/plugins/fake-theme/brand/avatars/cat.png +0 -0
  91. package/fixtures/plugins/fake-theme/brand/illustration.svg +1 -0
  92. package/fixtures/plugins/fake-theme/brand/unnamed.svg +1 -0
  93. package/fixtures/plugins/fake-theme/fonts/FakeSans.woff2 +1 -0
  94. package/fixtures/plugins/fake-theme/logo.svg +1 -0
  95. package/fixtures/plugins/fake-theme/package.json +8 -0
  96. package/fixtures/plugins/fake-theme/themes/brand-kit.json +24 -0
  97. package/fixtures/plugins/fake-theme/themes/neon-grid.json +13 -0
  98. package/fixtures/plugins/fake-theme/themes/paper.json +12 -0
  99. package/package.json +6 -5
@@ -7,24 +7,40 @@
7
7
  *
8
8
  * | name | provides / covers |
9
9
  * |---|---|
10
- * | `fake-connector` | `connector@1` kind `fake`: an MCP client for `startFakeMcpServer` (auth, one 401 retry, connectorData routes from `_meta["fake/route"]`, onToolsChanged, onElicit incl. `-32042`, resources, prompts, inspect); endpoint `{ url, headers?, notesText? }`; template `fake-demo`; deployment config `allowInsecureLoopback` (default true), `inspectAuth` (`bearer` / `api_key`), `kind` (default `fake`; `mcp` lets clients that know only the official kinds drive it) |
11
- * | `fake-openapi` | `connector@1` kind `openapi` (the web wizard's OpenAPI flow): reads a small JSON document (`securitySchemes` as auth hints, `operations` as tools) from the endpoint's `specUrl`, calls operations over HTTP with the injected auth; endpoint `{ specUrl, baseUrl?, operations? }`; deployment config `allowInsecureLoopback` (default true) |
10
+ * | `fake-connector` | `connector@1` kind `fake`: an MCP client for `startFakeMcpServer` (auth, one 401 retry, connectorData routes from `_meta["fake/route"]`, onToolsChanged, onElicit incl. `-32042`, resources, prompts, inspect); endpoint `{ url, headers?, notesText?, apiUrl? }`; template `fake-demo`; requests go through `ctx.net.fetch` (test kernels set `net.allowInsecureLoopback`; `testKernelConfig` and `runConfig` do); deployment config `inspectAuth` (`bearer` / `api_key`), `kind` (default `fake`; `mcp` lets clients that know only the official kinds drive it) |
11
+ * | `fake-openapi` | `connector@1` kind `openapi` (the web wizard's OpenAPI flow): reads a small JSON document (`securitySchemes` as auth hints, `operations` as tools) from the endpoint's `specUrl`, calls operations over HTTP with the injected auth; endpoint `{ specUrl, baseUrl?, operations? }`; requests go through `ctx.net.fetch`, no deployment config |
12
12
  * | `fake-object-store` | `object-store@1` on the `startTestS3()` container (deployment config as `TestS3` gives it; POST-policy presign) |
13
- * | `fake-tools-ui` | tool `write`, view `tasks`, a migration, skill `fake-notes`, template `fake-notes` (for fake-connector); no storage |
13
+ * | `fake-tools-ui` | tools `write` and `web-only` (`sources` web and channel_dm; returns its call context), view `tasks`, a migration, skill `fake-notes`, template `fake-notes` (for fake-connector); no storage |
14
14
  * | `fake-storage-user` | tools `note` / `read_note` through `ctx.storage` (`permissions.storage`) |
15
+ * | `fake-lifecycle` | observes `org.member_removed`, `agent.deleted` and `org.deleted`; a migration with tables `calls` (every call) and `deliveries` (every call that succeeded), each row the mount and the payload; deployment config `failTimes` (default 0): the first `failTimes` calls of each (mount, payload) throw, and `label` (optional, at most 10 characters, overridable per org: an invalid org copy) |
15
16
  * | `fake-embed` | embeds `panel` (page) and `panel-conv` (conversation), static `/ui/panel.js`, token-checked routes, SSE over `ctx.bus` |
16
17
  * | `fake-bootstrap-a` | `model-provider@2` with a required secret `apiKey` (pending configuration until set) |
17
18
  * | `fake-bootstrap-b` | `object-store@1` kept in its own PG table; `bucket` + secret `secretKey` |
18
19
  * | `fake-dep-provider` / `fake-dep-requirer` | a dependency pair on `counter@1` (the requirer's plugin.json depends on the provider) |
19
- * | `fake-im` | a whole IM platform for `startFakeChannelServer`: `channel@1` (cards, edits, threads, webhook inbound), `identity-source@1`, `directory@1` (org config `url` of a directory book) and tool `post_announcement` (default policy ask, posts to the platform); deployment config `platformUrl`, `tenant`, `clientId`, secret `clientSecret`. Its `src/index.ts` also exports `makeFakeImChannel`, `fakeImIdentitySource`, `fakeImDirectory` for test extensions that need one part |
20
- * | `fake-web` / `fake-web-2` | `web-search@1` and `web-fetch@1`, scripted by a prefix of the query or of the fetched URL's path (`error:<kind>`, `throw:`, `hang:`, `redirect:<url>`, `junk:`, `empty:`, `big:<n>`; see `makeFakeWeb`); results name the provider; org config secret `token`, `configured()` iff it is set (throws for `throw:configured`); calls recorded on `globalThis.__fakeWeb` (`fakeWebProbe`) |
20
+ * | `fake-im` | a whole IM platform for `startFakeChannelServer`: `channel@1` (cards, edits, threads, files via `sendFile`, webhook inbound), `identity-source@1`, `directory@1` (the org-overridable deployment field `directoryUrl` of a directory book, fetched through `configUrlFetch`; unset = not configured) and tool `post_announcement` (default policy ask, posts to the platform); platform-only deployment config `platformUrl`, `tenant`, `clientId`, secret `clientSecret`. Its `src/index.ts` also exports `makeFakeImChannel`, `fakeImIdentitySource`, `makeFakeImDirectory` for test extensions that need one part |
21
+ * | `fake-web` / `fake-web-2` | `web-search@1` and `web-fetch@1`, scripted by a prefix of the query or of the fetched URL's path (`error:<kind>`, `throw:`, `hang:`, `redirect:<url>`, `junk:`, `empty:`, `big:<n>`; see `makeFakeWeb`); results name the provider; deployment config: a required, org-overridable secret `token` the platform may leave empty, `configured()` iff it is set and not `unconfigured` (throws for `throw:configured`); calls recorded on `globalThis.__fakeWeb` (`fakeWebProbe`) |
22
+ * | `fake-context` | `context@1` scripted by its deployment config (`text`, default "fake context"; `mode` `ok` / `null` / `throw` / `hang`); calls recorded on `globalThis.__fakeContext` (`fakeContextProbe`); tool `note` (`sources` web and channel_dm) |
23
+ * | `fake-client` | client extension (`permissions.client`, no extension point): components `hud` (`conversation.properties.section`, server view with `data`), `brand` (`shell.brand`, renders `builtin` in `data-testid="fake-client-brand"`), `empty` (`conversation.empty`), `frame` (`conversation.composer.frame`) and `fx` (`shell.overlay`); `client/styles/fake.css` (outline-color on `button.primary` and the composer's buttons, `--cx-fake-client-run` while `run=running`); an `events` listener storing the last event type; theme `fake`; `suggestedAppearance` = theme `fake` + `shell.brand` -> `brand` |
24
+ * | `fake-client-broken` | client code that throws: component `boom` (render), a `run.started` events listener, and a `conversation.empty` replacement (render) |
25
+ * | `fake-push` | `push-provider@1` scripted by the token prefix (`dead:`, `auth:`, `rate:`, `flaky:<n>:`, `throw:`, `net:`, `hang:`; else delivered); deployment config `apps` (default `["com.example.app"]`), optional secret `key`; every send is a row of `plugin_fake_push.sends` and an entry of `fakePushProbe().sends`; `makeFakePush()` is the same provider without a kernel |
21
26
  * | `fake-config-form` | display name 表单样例 / Form sample; no extension point: an openai-compatible-shaped deployment config (endpoints with a preset menu, an API key per endpoint in the secret record `apiKeys`, model rows, advanced fields, localized custom issues) carrying the config form hints of the extension config forms spec §6, for the web form e2e |
22
27
  */
23
- export declare const FAKE_EXTENSIONS: readonly ["fake-connector", "fake-openapi", "fake-object-store", "fake-tools-ui", "fake-storage-user", "fake-embed", "fake-bootstrap-a", "fake-bootstrap-b", "fake-dep-provider", "fake-dep-requirer", "fake-im", "fake-web", "fake-web-2", "fake-config-form"];
28
+ export declare const FAKE_EXTENSIONS: readonly ["fake-connector", "fake-openapi", "fake-object-store", "fake-tools-ui", "fake-storage-user", "fake-lifecycle", "fake-embed", "fake-bootstrap-a", "fake-bootstrap-b", "fake-dep-provider", "fake-dep-requirer", "fake-im", "fake-web", "fake-web-2", "fake-context", "fake-config-form", "fake-push", "fake-client", "fake-client-broken"];
29
+ /**
30
+ * Fake plugins without an extension (declarative: they live in `fixtures/plugins/<name>`, same
31
+ * pack layout).
32
+ *
33
+ * | name | provides / covers |
34
+ * |---|---|
35
+ * | `fake-theme` | themes `neon-grid` (dark only, wordmark, font `FakeSans`, logo) and `paper` (light and dark), and `brand-kit` (dark and light, every brand asset: logo, illustration, app icons, avatars `bot` and `cat`; `brand/unnamed.svg` is in the directory but named by no theme); passes `capybara-plugin check` |
36
+ */
37
+ export declare const FAKE_PLUGINS: readonly ["fake-theme"];
38
+ /** The name of a fake plugin. */
39
+ export type FakePluginName = (typeof FAKE_PLUGINS)[number];
24
40
  /** The name of a fake extension (also its plugin and extension name). */
25
41
  export type FakeExtensionName = (typeof FAKE_EXTENSIONS)[number];
26
42
  /** The plugin directory of a fake (pack layout), for `packFixture` or a packer of your own. */
27
- export declare function fakeExtensionDir(name: FakeExtensionName): string;
43
+ export declare function fakeExtensionDir(name: FakeExtensionName | FakePluginName): string;
28
44
  /**
29
45
  * The extension entry `src/index.ts` of a fake, for kernel configs that load extensions by path
30
46
  * (`extensions: [fakeExtensionEntry("fake-connector")]`). `createDualReplicaHarness` loads it in
@@ -48,4 +64,4 @@ export interface PackedFixture {
48
64
  * skills and templates), writes it to `outDir` and returns its path, bytes and sha256. Packing
49
65
  * leaves no files in the fixture directory.
50
66
  */
51
- export declare function packFixture(name: FakeExtensionName, outDir: string): Promise<PackedFixture>;
67
+ export declare function packFixture(name: FakeExtensionName | FakePluginName, outDir: string): Promise<PackedFixture>;
package/dist/fixtures.js CHANGED
@@ -10,17 +10,22 @@ import { fileURLToPath } from "node:url";
10
10
  *
11
11
  * | name | provides / covers |
12
12
  * |---|---|
13
- * | `fake-connector` | `connector@1` kind `fake`: an MCP client for `startFakeMcpServer` (auth, one 401 retry, connectorData routes from `_meta["fake/route"]`, onToolsChanged, onElicit incl. `-32042`, resources, prompts, inspect); endpoint `{ url, headers?, notesText? }`; template `fake-demo`; deployment config `allowInsecureLoopback` (default true), `inspectAuth` (`bearer` / `api_key`), `kind` (default `fake`; `mcp` lets clients that know only the official kinds drive it) |
14
- * | `fake-openapi` | `connector@1` kind `openapi` (the web wizard's OpenAPI flow): reads a small JSON document (`securitySchemes` as auth hints, `operations` as tools) from the endpoint's `specUrl`, calls operations over HTTP with the injected auth; endpoint `{ specUrl, baseUrl?, operations? }`; deployment config `allowInsecureLoopback` (default true) |
13
+ * | `fake-connector` | `connector@1` kind `fake`: an MCP client for `startFakeMcpServer` (auth, one 401 retry, connectorData routes from `_meta["fake/route"]`, onToolsChanged, onElicit incl. `-32042`, resources, prompts, inspect); endpoint `{ url, headers?, notesText?, apiUrl? }`; template `fake-demo`; requests go through `ctx.net.fetch` (test kernels set `net.allowInsecureLoopback`; `testKernelConfig` and `runConfig` do); deployment config `inspectAuth` (`bearer` / `api_key`), `kind` (default `fake`; `mcp` lets clients that know only the official kinds drive it) |
14
+ * | `fake-openapi` | `connector@1` kind `openapi` (the web wizard's OpenAPI flow): reads a small JSON document (`securitySchemes` as auth hints, `operations` as tools) from the endpoint's `specUrl`, calls operations over HTTP with the injected auth; endpoint `{ specUrl, baseUrl?, operations? }`; requests go through `ctx.net.fetch`, no deployment config |
15
15
  * | `fake-object-store` | `object-store@1` on the `startTestS3()` container (deployment config as `TestS3` gives it; POST-policy presign) |
16
- * | `fake-tools-ui` | tool `write`, view `tasks`, a migration, skill `fake-notes`, template `fake-notes` (for fake-connector); no storage |
16
+ * | `fake-tools-ui` | tools `write` and `web-only` (`sources` web and channel_dm; returns its call context), view `tasks`, a migration, skill `fake-notes`, template `fake-notes` (for fake-connector); no storage |
17
17
  * | `fake-storage-user` | tools `note` / `read_note` through `ctx.storage` (`permissions.storage`) |
18
+ * | `fake-lifecycle` | observes `org.member_removed`, `agent.deleted` and `org.deleted`; a migration with tables `calls` (every call) and `deliveries` (every call that succeeded), each row the mount and the payload; deployment config `failTimes` (default 0): the first `failTimes` calls of each (mount, payload) throw, and `label` (optional, at most 10 characters, overridable per org: an invalid org copy) |
18
19
  * | `fake-embed` | embeds `panel` (page) and `panel-conv` (conversation), static `/ui/panel.js`, token-checked routes, SSE over `ctx.bus` |
19
20
  * | `fake-bootstrap-a` | `model-provider@2` with a required secret `apiKey` (pending configuration until set) |
20
21
  * | `fake-bootstrap-b` | `object-store@1` kept in its own PG table; `bucket` + secret `secretKey` |
21
22
  * | `fake-dep-provider` / `fake-dep-requirer` | a dependency pair on `counter@1` (the requirer's plugin.json depends on the provider) |
22
- * | `fake-im` | a whole IM platform for `startFakeChannelServer`: `channel@1` (cards, edits, threads, webhook inbound), `identity-source@1`, `directory@1` (org config `url` of a directory book) and tool `post_announcement` (default policy ask, posts to the platform); deployment config `platformUrl`, `tenant`, `clientId`, secret `clientSecret`. Its `src/index.ts` also exports `makeFakeImChannel`, `fakeImIdentitySource`, `fakeImDirectory` for test extensions that need one part |
23
- * | `fake-web` / `fake-web-2` | `web-search@1` and `web-fetch@1`, scripted by a prefix of the query or of the fetched URL's path (`error:<kind>`, `throw:`, `hang:`, `redirect:<url>`, `junk:`, `empty:`, `big:<n>`; see `makeFakeWeb`); results name the provider; org config secret `token`, `configured()` iff it is set (throws for `throw:configured`); calls recorded on `globalThis.__fakeWeb` (`fakeWebProbe`) |
23
+ * | `fake-im` | a whole IM platform for `startFakeChannelServer`: `channel@1` (cards, edits, threads, files via `sendFile`, webhook inbound), `identity-source@1`, `directory@1` (the org-overridable deployment field `directoryUrl` of a directory book, fetched through `configUrlFetch`; unset = not configured) and tool `post_announcement` (default policy ask, posts to the platform); platform-only deployment config `platformUrl`, `tenant`, `clientId`, secret `clientSecret`. Its `src/index.ts` also exports `makeFakeImChannel`, `fakeImIdentitySource`, `makeFakeImDirectory` for test extensions that need one part |
24
+ * | `fake-web` / `fake-web-2` | `web-search@1` and `web-fetch@1`, scripted by a prefix of the query or of the fetched URL's path (`error:<kind>`, `throw:`, `hang:`, `redirect:<url>`, `junk:`, `empty:`, `big:<n>`; see `makeFakeWeb`); results name the provider; deployment config: a required, org-overridable secret `token` the platform may leave empty, `configured()` iff it is set and not `unconfigured` (throws for `throw:configured`); calls recorded on `globalThis.__fakeWeb` (`fakeWebProbe`) |
25
+ * | `fake-context` | `context@1` scripted by its deployment config (`text`, default "fake context"; `mode` `ok` / `null` / `throw` / `hang`); calls recorded on `globalThis.__fakeContext` (`fakeContextProbe`); tool `note` (`sources` web and channel_dm) |
26
+ * | `fake-client` | client extension (`permissions.client`, no extension point): components `hud` (`conversation.properties.section`, server view with `data`), `brand` (`shell.brand`, renders `builtin` in `data-testid="fake-client-brand"`), `empty` (`conversation.empty`), `frame` (`conversation.composer.frame`) and `fx` (`shell.overlay`); `client/styles/fake.css` (outline-color on `button.primary` and the composer's buttons, `--cx-fake-client-run` while `run=running`); an `events` listener storing the last event type; theme `fake`; `suggestedAppearance` = theme `fake` + `shell.brand` -> `brand` |
27
+ * | `fake-client-broken` | client code that throws: component `boom` (render), a `run.started` events listener, and a `conversation.empty` replacement (render) |
28
+ * | `fake-push` | `push-provider@1` scripted by the token prefix (`dead:`, `auth:`, `rate:`, `flaky:<n>:`, `throw:`, `net:`, `hang:`; else delivered); deployment config `apps` (default `["com.example.app"]`), optional secret `key`; every send is a row of `plugin_fake_push.sends` and an entry of `fakePushProbe().sends`; `makeFakePush()` is the same provider without a kernel |
24
29
  * | `fake-config-form` | display name 表单样例 / Form sample; no extension point: an openai-compatible-shaped deployment config (endpoints with a preset menu, an API key per endpoint in the secret record `apiKeys`, model rows, advanced fields, localized custom issues) carrying the config form hints of the extension config forms spec §6, for the web form e2e |
25
30
  */
26
31
  export const FAKE_EXTENSIONS = [
@@ -29,6 +34,7 @@ export const FAKE_EXTENSIONS = [
29
34
  "fake-object-store",
30
35
  "fake-tools-ui",
31
36
  "fake-storage-user",
37
+ "fake-lifecycle",
32
38
  "fake-embed",
33
39
  "fake-bootstrap-a",
34
40
  "fake-bootstrap-b",
@@ -37,13 +43,28 @@ export const FAKE_EXTENSIONS = [
37
43
  "fake-im",
38
44
  "fake-web",
39
45
  "fake-web-2",
46
+ "fake-context",
40
47
  "fake-config-form",
48
+ "fake-push",
49
+ "fake-client",
50
+ "fake-client-broken",
41
51
  ];
52
+ /**
53
+ * Fake plugins without an extension (declarative: they live in `fixtures/plugins/<name>`, same
54
+ * pack layout).
55
+ *
56
+ * | name | provides / covers |
57
+ * |---|---|
58
+ * | `fake-theme` | themes `neon-grid` (dark only, wordmark, font `FakeSans`, logo) and `paper` (light and dark), and `brand-kit` (dark and light, every brand asset: logo, illustration, app icons, avatars `bot` and `cat`; `brand/unnamed.svg` is in the directory but named by no theme); passes `capybara-plugin check` |
59
+ */
60
+ export const FAKE_PLUGINS = ["fake-theme"];
42
61
  /** `fixtures/extensions/` of this package (same path from `src/` and from `dist/`). */
43
62
  const FIXTURES_DIR = fileURLToPath(new URL("../fixtures/extensions/", import.meta.url));
63
+ /** `fixtures/plugins/` of this package. */
64
+ const PLUGINS_DIR = fileURLToPath(new URL("../fixtures/plugins/", import.meta.url));
44
65
  /** The plugin directory of a fake (pack layout), for `packFixture` or a packer of your own. */
45
66
  export function fakeExtensionDir(name) {
46
- return join(FIXTURES_DIR, name);
67
+ return join(FAKE_PLUGINS.includes(name) ? PLUGINS_DIR : FIXTURES_DIR, name);
47
68
  }
48
69
  /**
49
70
  * The extension entry `src/index.ts` of a fake, for kernel configs that load extensions by path
@@ -89,8 +110,10 @@ async function packer() {
89
110
  * leaves no files in the fixture directory.
90
111
  */
91
112
  export async function packFixture(name, outDir) {
92
- if (!FAKE_EXTENSIONS.includes(name))
93
- throw new Error(`unknown fake extension ${String(name)}`);
113
+ const known = FAKE_EXTENSIONS.includes(name) ||
114
+ FAKE_PLUGINS.includes(name);
115
+ if (!known)
116
+ throw new Error(`unknown fake extension or plugin ${String(name)}`);
94
117
  const pack = await packer();
95
118
  const r = await pack(fakeExtensionDir(name), outDir);
96
119
  return { file: r.file, bytes: new Uint8Array(await readFile(r.file)), sha256: r.sha256 };
package/dist/index.d.ts CHANGED
@@ -3,23 +3,29 @@
3
3
  * package and the SDK: the database helpers and types, and model-visible texts, queue names and
4
4
  * keys the kernel owns (assert on them instead of copying their values).
5
5
  */
6
- export { type ConversationEvent, createDb, gatewayReplicasKey, type KernelConfig, type KernelSchemaDb, kernelDb, MAINTENANCE_QUEUE_NAME, runJobId, SANDBOX_LOCK_TTL_MS, SANDBOX_RECREATED_NOTICE, SANDBOX_STARTED_NOTICE, SANDBOX_SUSPEND_JOB, UNKNOWN_RESULT_TEXT, } from "@capybara-hq/kernel";
7
- export { createFreshDatabase, startTestPostgres, startTestRedis, startTestS3, TEST_S3_IMAGE, type TestContainer, type TestS3, } from "./containers.js";
6
+ export { type ConversationEvent, createDb, gatewayReplicasKey, type KernelConfig, type KernelSchemaDb, kernelDb, MAINTENANCE_QUEUE_NAME, runJobId, SANDBOX_LOCK_TTL_MS, SANDBOX_RESTARTED_NOTICE, SANDBOX_STARTED_NOTICE, SANDBOX_SUSPEND_JOB, UNKNOWN_RESULT_TEXT, } from "@capybara-hq/kernel";
7
+ export { createFreshDatabase, startPostgresContainer, startTestPostgres, startTestRedis, startTestS3, TEST_PG_IMAGE, TEST_S3_IMAGE, type TestContainer, type TestS3, } from "./containers.js";
8
+ export { DEVICE_SERVICE_ARGV_PROBE, DEVICE_SERVICE_ECHO_SCRIPT, type DeviceServiceFixture, runDeviceServiceConformance, } from "./device-service-conformance.js";
8
9
  export { createDualReplicaHarness, type DualReplicaOptions, type ExtraReplicaHandle, type Harness, REPLICA_HEADER, type ReplicaHandle, type ReplicaResponse, replicaOf, } from "./dual-replica.js";
9
10
  export { assertExtensionSecretsReachable, extensionDeploymentSecretValues, } from "./extension-config.js";
10
- export { FAKE_CHANNEL_BAD_SECRET, FAKE_WEBHOOK_SIGNATURE_HEADER, type FakeChannelFailMatch, type FakeChannelPost, type FakeChannelSent, type FakeChannelServer, type FakeChannelServerOptions, type FakeChannelStream, type FakeChannelUser, type FakeDirectoryBook, type FakeSenderProfile, fakeCardAction, fakeDirectoryMember, fakeDm, fakeGroupMessage, fakeWebhookChallenge, fakeWebhookEvents, signFakeWebhook, startFakeChannelServer, } from "./fake-channel.js";
11
+ export { FAKE_CHANNEL_BAD_SECRET, FAKE_WEBHOOK_SIGNATURE_HEADER, type FakeChannelCheckCall, type FakeChannelFailMatch, type FakeChannelPost, type FakeChannelSent, type FakeChannelSentFile, type FakeChannelServer, type FakeChannelServerOptions, type FakeChannelStream, type FakeChannelUser, type FakeDirectoryBook, type FakeSenderProfile, fakeCardAction, fakeDirectoryMember, fakeDm, fakeGroupMessage, fakeWebhookChallenge, fakeWebhookEvents, signFakeWebhook, startFakeChannelServer, } from "./fake-channel.js";
12
+ export { FAKE_DIAL_IN_PROTOCOL, FakeDialInMachine, type FakeDialInMachineOptions, FakeMachineStream, signInFakeMachine, } from "./fake-dial-in-machine.js";
11
13
  export { type FakeE2BCall, type FakeE2BMatch, type FakeE2BOptions, type FakeE2BSandbox, type FakeE2BServer, startFakeE2B, } from "./fake-e2b.js";
12
- export { type FakeGitCommitOptions, type FakeGitRequest, type FakeGitServer, startFakeGitServer, } from "./fake-git-server.js";
13
- export { encryptLarkWebhook, type FakeLarkAck, type FakeLarkApi, type FakeLarkButton, type FakeLarkCall, type FakeLarkDepartment, type FakeLarkFailure, type FakeLarkMessage, type FakeLarkOptions, type FakeLarkServer, type FakeLarkUser, findLarkButton, larkCardAction, larkMessageEvent, signLarkWebhook, startFakeLark, } from "./fake-lark.js";
14
+ export { type FakeGitCommitOptions, type FakeGitRequest, type FakeGitServer, type FakeGitServerOptions, startFakeGitServer, } from "./fake-git-server.js";
15
+ export { encryptLarkWebhook, type FakeLarkAck, type FakeLarkApi, type FakeLarkButton, type FakeLarkCall, type FakeLarkDepartment, type FakeLarkFailure, type FakeLarkMessage, type FakeLarkOptions, type FakeLarkServer, type FakeLarkUpload, type FakeLarkUser, findLarkButton, larkCardAction, larkMessageEvent, signLarkWebhook, startFakeLark, } from "./fake-lark.js";
14
16
  export { type FakeMarketplace, type FakeMarketplaceRequest, startFakeMarketplace, } from "./fake-marketplace.js";
15
17
  export { type FakeMcpCallInfo, type FakeMcpHandlerContext, type FakeMcpPrompt, type FakeMcpRequest, type FakeMcpResource, FakeMcpRpcError, type FakeMcpServer, type FakeMcpServerOptions, type FakeMcpTool, startFakeMcpServer, } from "./fake-mcp-server.js";
16
18
  export { type FakeModelServer, type FakeRequest, type FakeResponse, startFakeModelServer, } from "./fake-model-server.js";
17
19
  export { type FakeNpmPackage, type FakeNpmRegistry, npmProvenanceAttestations, startFakeNpmRegistry, } from "./fake-npm-registry.js";
18
- export { type FakeOAuthClient, type FakeOAuthServer, type FakeOAuthServerOptions, type FakeTokenRequest, startFakeOAuthServer, } from "./fake-oauth-server.js";
20
+ export { type FakeOAuthClient, type FakeOAuthServer, type FakeOAuthServerOptions, type FakeOidcClaims, type FakeTokenRequest, startFakeOAuthServer, } from "./fake-oauth-server.js";
19
21
  export { defaultFakeOpenApiSpec, type FakeOpenApiRequest, type FakeOpenApiServer, type FakeOpenApiServerOptions, type FakePet, startFakeOpenApiServer, } from "./fake-openapi-server.js";
20
- export { type FakeSlackAck, type FakeSlackCall, type FakeSlackFailure, type FakeSlackMessage, type FakeSlackOptions, type FakeSlackServer, type FakeSlackUser, findSlackButton, signSlackWebhook, slackBlockAction, slackDmEvent, slackEventCallback, slackInteractiveForm, slackMentionEvent, startFakeSlack, } from "./fake-slack.js";
22
+ export { type FakeSlackAck, type FakeSlackCall, type FakeSlackFailure, type FakeSlackFile, type FakeSlackMessage, type FakeSlackOptions, type FakeSlackServer, type FakeSlackUser, findSlackButton, signSlackWebhook, slackBlockAction, slackDmEvent, slackEventCallback, slackInteractiveForm, slackMentionEvent, startFakeSlack, } from "./fake-slack.js";
23
+ export { type FakeTelegramBot, type FakeTelegramCall, type FakeTelegramFailure, type FakeTelegramMessage, type FakeTelegramOptions, type FakeTelegramServer, findTelegramButton, startFakeTelegram, type TgChat, type TgUser, telegramCallback, telegramGroupMessage, telegramPrivateMessage, telegramWebhookHeaders, } from "./fake-telegram.js";
21
24
  export { FAKE_EXTENSIONS, type FakeExtensionName, fakeExtensionDir, fakeExtensionEntry, type PackedFixture, packFixture, } from "./fixtures.js";
22
- export { cardRecorded, cookieRequest, createAgent, createConversation, createLocalAccount, createOrg, eventsOf, joinOrg, type KernelApp, type KernelRequest, type KernelRequestOptions, type KernelResponse, login, pidOwningLocalPort, postMessage, sleep, startTestKernel, TEST_PASSWORD, type TestKernel, testKernelConfig, truncateTables, waitFor, waitForEvent, waitForTerminal, } from "./kernel-helpers.js";
23
- export { isPngBase64, pdfBase64, pdfSampleWord, redPngBase64, solidPngBase64, } from "./media-samples.js";
25
+ export { cardRecorded, cookieRequest, createAgent, createConversation, createLocalAccount, createOrg, enableModelProviders, eventsOf, joinOrg, type KernelApp, type KernelRequest, type KernelRequestOptions, type KernelResponse, login, pidOwningLocalPort, postMessage, sleep, startTestKernel, TEST_PASSWORD, type TestKernel, testKernelConfig, truncateTables, waitFor, waitForEvent, waitForTerminal, } from "./kernel-helpers.js";
26
+ export { FAKE_PNG_BASE64, isPngBase64, pdfBase64, pdfSampleWord, redPngBase64, solidPngBase64, } from "./media-samples.js";
24
27
  export { type ConformanceTarget, checkDeclaredParameters, describeModelProviderConformance, MEDIA_SAMPLES, thinkingReplayParams, } from "./model-conformance.js";
28
+ export { describePushProviderConformance, type PushConformanceTarget, type PushOutcome, type PushVendorRequest, } from "./push-conformance.js";
29
+ export { type NativeFixtureEntry, runSandboxNativeConformance, type SandboxNativeFixture, } from "./sandbox-native-conformance.js";
30
+ export { runSandboxPermissionConformance, type SandboxPermissionConformancePart, type SandboxPermissionEndpoint, type SandboxPermissionFixture, type SandboxPermissionGrant, type SandboxPermissionOpenNetwork, type SandboxPermissionTarget, } from "./sandbox-permission-conformance.js";
25
31
  export { openSse, type SseClient, type SseMessage } from "./sse.js";
package/dist/index.js CHANGED
@@ -3,11 +3,13 @@
3
3
  * package and the SDK: the database helpers and types, and model-visible texts, queue names and
4
4
  * keys the kernel owns (assert on them instead of copying their values).
5
5
  */
6
- export { createDb, gatewayReplicasKey, kernelDb, MAINTENANCE_QUEUE_NAME, runJobId, SANDBOX_LOCK_TTL_MS, SANDBOX_RECREATED_NOTICE, SANDBOX_STARTED_NOTICE, SANDBOX_SUSPEND_JOB, UNKNOWN_RESULT_TEXT, } from "@capybara-hq/kernel";
7
- export { createFreshDatabase, startTestPostgres, startTestRedis, startTestS3, TEST_S3_IMAGE, } from "./containers.js";
6
+ export { createDb, gatewayReplicasKey, kernelDb, MAINTENANCE_QUEUE_NAME, runJobId, SANDBOX_LOCK_TTL_MS, SANDBOX_RESTARTED_NOTICE, SANDBOX_STARTED_NOTICE, SANDBOX_SUSPEND_JOB, UNKNOWN_RESULT_TEXT, } from "@capybara-hq/kernel";
7
+ export { createFreshDatabase, startPostgresContainer, startTestPostgres, startTestRedis, startTestS3, TEST_PG_IMAGE, TEST_S3_IMAGE, } from "./containers.js";
8
+ export { DEVICE_SERVICE_ARGV_PROBE, DEVICE_SERVICE_ECHO_SCRIPT, runDeviceServiceConformance, } from "./device-service-conformance.js";
8
9
  export { createDualReplicaHarness, REPLICA_HEADER, replicaOf, } from "./dual-replica.js";
9
10
  export { assertExtensionSecretsReachable, extensionDeploymentSecretValues, } from "./extension-config.js";
10
11
  export { FAKE_CHANNEL_BAD_SECRET, FAKE_WEBHOOK_SIGNATURE_HEADER, fakeCardAction, fakeDirectoryMember, fakeDm, fakeGroupMessage, fakeWebhookChallenge, fakeWebhookEvents, signFakeWebhook, startFakeChannelServer, } from "./fake-channel.js";
12
+ export { FAKE_DIAL_IN_PROTOCOL, FakeDialInMachine, FakeMachineStream, signInFakeMachine, } from "./fake-dial-in-machine.js";
11
13
  export { startFakeE2B, } from "./fake-e2b.js";
12
14
  export { startFakeGitServer, } from "./fake-git-server.js";
13
15
  export { encryptLarkWebhook, findLarkButton, larkCardAction, larkMessageEvent, signLarkWebhook, startFakeLark, } from "./fake-lark.js";
@@ -18,8 +20,12 @@ export { npmProvenanceAttestations, startFakeNpmRegistry, } from "./fake-npm-reg
18
20
  export { startFakeOAuthServer, } from "./fake-oauth-server.js";
19
21
  export { defaultFakeOpenApiSpec, startFakeOpenApiServer, } from "./fake-openapi-server.js";
20
22
  export { findSlackButton, signSlackWebhook, slackBlockAction, slackDmEvent, slackEventCallback, slackInteractiveForm, slackMentionEvent, startFakeSlack, } from "./fake-slack.js";
23
+ export { findTelegramButton, startFakeTelegram, telegramCallback, telegramGroupMessage, telegramPrivateMessage, telegramWebhookHeaders, } from "./fake-telegram.js";
21
24
  export { FAKE_EXTENSIONS, fakeExtensionDir, fakeExtensionEntry, packFixture, } from "./fixtures.js";
22
- export { cardRecorded, cookieRequest, createAgent, createConversation, createLocalAccount, createOrg, eventsOf, joinOrg, login, pidOwningLocalPort, postMessage, sleep, startTestKernel, TEST_PASSWORD, testKernelConfig, truncateTables, waitFor, waitForEvent, waitForTerminal, } from "./kernel-helpers.js";
23
- export { isPngBase64, pdfBase64, pdfSampleWord, redPngBase64, solidPngBase64, } from "./media-samples.js";
25
+ export { cardRecorded, cookieRequest, createAgent, createConversation, createLocalAccount, createOrg, enableModelProviders, eventsOf, joinOrg, login, pidOwningLocalPort, postMessage, sleep, startTestKernel, TEST_PASSWORD, testKernelConfig, truncateTables, waitFor, waitForEvent, waitForTerminal, } from "./kernel-helpers.js";
26
+ export { FAKE_PNG_BASE64, isPngBase64, pdfBase64, pdfSampleWord, redPngBase64, solidPngBase64, } from "./media-samples.js";
24
27
  export { checkDeclaredParameters, describeModelProviderConformance, MEDIA_SAMPLES, thinkingReplayParams, } from "./model-conformance.js";
28
+ export { describePushProviderConformance, } from "./push-conformance.js";
29
+ export { runSandboxNativeConformance, } from "./sandbox-native-conformance.js";
30
+ export { runSandboxPermissionConformance, } from "./sandbox-permission-conformance.js";
25
31
  export { openSse } from "./sse.js";
@@ -12,7 +12,8 @@ export declare const sleep: (ms: number) => Promise<void>;
12
12
  export declare function waitFor<T>(fn: () => Promise<T | null | undefined | false>, timeoutMs?: number, label?: string, stepMs?: number): Promise<T>;
13
13
  /**
14
14
  * A kernel config for tests: the given PG / Redis, a fixed master key, an ephemeral HTTP port,
15
- * auto-approved extension permissions, short run-lock timings and the official marketplace off
15
+ * auto-approved extension permissions, `net.allowInsecureLoopback` (fake servers on loopback),
16
+ * short run-lock timings and the official marketplace off
16
17
  * (it is on by default and its address is on the internet). `overrides` are top-level config keys
17
18
  * and win; `runtime` is merged into the defaults, and `marketplaces` too, so other marketplace
18
19
  * settings keep the official one off unless `marketplaces.official` turns it on.
@@ -87,6 +88,14 @@ export declare function createLocalAccount(db: KernelSchemaDb, login: string, di
87
88
  export declare function login(k: Pick<TestKernel, "http">, name: string, password?: string): Promise<KernelRequest>;
88
89
  /** Creates an org as `req`'s user (who becomes its owner); returns its id. */
89
90
  export declare function createOrg(req: KernelRequest, name?: string): Promise<string>;
91
+ /**
92
+ * Switches on in `orgId`, through the org's extension switch (`PUT
93
+ * /api/v1/orgs/:orgId/extensions/:name`; `req` is an org admin), every model provider the kernel
94
+ * loaded that is not on there yet, and returns their names. A model provider is on only in the
95
+ * orgs that enabled it (like every other extension), so a test that saves or runs an agent in a
96
+ * new org calls this first; `only` limits it to those providers.
97
+ */
98
+ export declare function enableModelProviders(req: KernelRequest, orgId: string, only?: readonly string[]): Promise<string[]>;
90
99
  /**
91
100
  * A new account joins the org through an invitation (created by `owner`, accepted with `login`
92
101
  * and {@link TEST_PASSWORD}); returns the account id and its signed-in request function.
@@ -96,15 +105,18 @@ export declare function joinOrg(k: Pick<TestKernel, "http">, owner: KernelReques
96
105
  req: KernelRequest;
97
106
  }>;
98
107
  /**
99
- * Creates an org-visible agent; returns its id. Without `tools` the agent has none (model-fake then
100
- * answers ordinary messages instead of calling the first tool).
108
+ * Creates an org-visible agent; returns its id. An agent has every tool the org offers unless
109
+ * `disabledTools` turns it off (tools default-on spec), and every skill on in the org unless
110
+ * `disabledSkills` turns it off (skills default-on spec); with several tools model-fake answers
111
+ * ordinary messages instead of calling one.
101
112
  */
102
113
  export declare function createAgent(req: KernelRequest, orgId: string, opts?: {
103
114
  model?: {
104
115
  provider: string;
105
116
  model: string;
106
117
  };
107
- tools?: unknown[];
118
+ disabledTools?: unknown[];
119
+ disabledSkills?: unknown[];
108
120
  }): Promise<string>;
109
121
  /** Creates a conversation with the agent; returns its id. */
110
122
  export declare function createConversation(req: KernelRequest, orgId: string, agentId: string): Promise<string>;
@@ -26,7 +26,8 @@ export async function waitFor(fn, timeoutMs = 10_000, label = "condition", stepM
26
26
  }
27
27
  /**
28
28
  * A kernel config for tests: the given PG / Redis, a fixed master key, an ephemeral HTTP port,
29
- * auto-approved extension permissions, short run-lock timings and the official marketplace off
29
+ * auto-approved extension permissions, `net.allowInsecureLoopback` (fake servers on loopback),
30
+ * short run-lock timings and the official marketplace off
30
31
  * (it is on by default and its address is on the internet). `overrides` are top-level config keys
31
32
  * and win; `runtime` is merged into the defaults, and `marketplaces` too, so other marketplace
32
33
  * settings keep the official one off unless `marketplaces.official` turns it on.
@@ -44,6 +45,8 @@ export function testKernelConfig(urls, overrides) {
44
45
  ...marketplaces,
45
46
  official: { enabled: false, ...marketplaces?.official },
46
47
  },
48
+ // Fake servers run on loopback: ctx.net may reach them (a test overrides `net` to assert refusals)
49
+ net: { allowInsecureLoopback: true },
47
50
  ...rest,
48
51
  });
49
52
  }
@@ -157,6 +160,35 @@ export async function createOrg(req, name = "Acme") {
157
160
  expectStatus(res, 201, "create org");
158
161
  return res.json().org.id;
159
162
  }
163
+ /**
164
+ * Switches on in `orgId`, through the org's extension switch (`PUT
165
+ * /api/v1/orgs/:orgId/extensions/:name`; `req` is an org admin), every model provider the kernel
166
+ * loaded that is not on there yet, and returns their names. A model provider is on only in the
167
+ * orgs that enabled it (like every other extension), so a test that saves or runs an agent in a
168
+ * new org calls this first; `only` limits it to those providers.
169
+ */
170
+ export async function enableModelProviders(req, orgId, only) {
171
+ const list = await req({ method: "GET", url: `/api/v1/orgs/${orgId}/extensions` });
172
+ expectStatus(list, 200, "list the org's extensions");
173
+ const { extensions } = list.json();
174
+ const enabled = [];
175
+ for (const e of extensions) {
176
+ if (e.enabled || !e.available)
177
+ continue;
178
+ if (!e.provides.some((p) => p.startsWith("model-provider@")))
179
+ continue;
180
+ if (only !== undefined && !only.includes(e.plugin))
181
+ continue;
182
+ const on = await req({
183
+ method: "PUT",
184
+ url: `/api/v1/orgs/${orgId}/extensions/${encodeURIComponent(e.plugin)}`,
185
+ payload: { enabled: true },
186
+ });
187
+ expectStatus(on, 200, `enable ${e.plugin}`);
188
+ enabled.push(e.plugin);
189
+ }
190
+ return enabled;
191
+ }
160
192
  /**
161
193
  * A new account joins the org through an invitation (created by `owner`, accepted with `login`
162
194
  * and {@link TEST_PASSWORD}); returns the account id and its signed-in request function.
@@ -178,8 +210,10 @@ export async function joinOrg(k, owner, orgId, name, role = "member") {
178
210
  return { accountId: accepted.json().account.id, req };
179
211
  }
180
212
  /**
181
- * Creates an org-visible agent; returns its id. Without `tools` the agent has none (model-fake then
182
- * answers ordinary messages instead of calling the first tool).
213
+ * Creates an org-visible agent; returns its id. An agent has every tool the org offers unless
214
+ * `disabledTools` turns it off (tools default-on spec), and every skill on in the org unless
215
+ * `disabledSkills` turns it off (skills default-on spec); with several tools model-fake answers
216
+ * ordinary messages instead of calling one.
183
217
  */
184
218
  export async function createAgent(req, orgId, opts = {}) {
185
219
  const res = await req({
@@ -190,7 +224,8 @@ export async function createAgent(req, orgId, opts = {}) {
190
224
  name: "Helper",
191
225
  instructions: "Be helpful.",
192
226
  model: opts.model ?? { provider: "model-fake", model: "fake-1" },
193
- tools: opts.tools ?? [],
227
+ disabledTools: opts.disabledTools ?? [],
228
+ ...(opts.disabledSkills !== undefined && { disabledSkills: opts.disabledSkills }),
194
229
  },
195
230
  visibility: "org",
196
231
  },
@@ -8,3 +8,5 @@ export declare function pdfBase64(word: string): string;
8
8
  export declare function isPngBase64(data: unknown): boolean;
9
9
  /** 夹具用:从 {@link pdfBase64} 生成的 PDF 里读出印的词;不是这样的 PDF 时返回 null。 */
10
10
  export declare function pdfSampleWord(data: unknown): string | null;
11
+ /** A valid 1x1 PNG, base64; model-fake keeps an identical copy (a test checks they are equal). */
12
+ export declare const FAKE_PNG_BASE64 = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC";
@@ -74,3 +74,5 @@ export function pdfSampleWord(data) {
74
74
  return null;
75
75
  return /\(([A-Z0-9]+)\) Tj/.exec(pdf)?.[1] ?? null;
76
76
  }
77
+ /** A valid 1x1 PNG, base64; model-fake keeps an identical copy (a test checks they are equal). */
78
+ export const FAKE_PNG_BASE64 = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC";
@@ -1,26 +1,31 @@
1
- import { type ModelInfo, type ModelParameter, type ModelProvider, type ModelProviderV1, type ParamValue } from "@capybara-hq/plugin-sdk";
1
+ import { type ModelInfo, type ModelParameter, type ModelProvider, type ParamValue } from "@capybara-hq/plugin-sdk";
2
2
  interface TargetCommon {
3
3
  model: string;
4
4
  expect: {
5
5
  thinking: boolean;
6
6
  caching: boolean;
7
+ /** Set when the provider lists an embedding model: runs the embedding cases. */
8
+ embedding?: {
9
+ model: string;
10
+ dimensions: number;
11
+ };
12
+ /** Set when the provider lists an image generation model: runs the image cases. */
13
+ imageGeneration?: {
14
+ model: string;
15
+ };
7
16
  };
8
17
  /** caching 用例的稳定前缀大小(约 token 数),默认 5000。 */
9
18
  cachePrefixTokens?: number;
10
19
  teardown(): Promise<void>;
11
20
  }
12
21
  /**
13
- * 被测供应商:`contract` 缺省为 1(`model-provider@1`);`@2` 插件须给 `contract: 2` 与插件名
14
- * (用于校验厂商专有参数的键名前缀)。
22
+ * The provider under test (`model-provider@2`) and its plugin name (checks the key prefix of
23
+ * vendor-specific parameters).
15
24
  */
16
- export type ConformanceTarget = TargetCommon & ({
17
- contract?: 1;
18
- provider: ModelProviderV1;
19
- } | {
20
- contract: 2;
25
+ export type ConformanceTarget = TargetCommon & {
21
26
  plugin: string;
22
27
  provider: ModelProvider;
23
- });
28
+ };
24
29
  /**
25
30
  * `@2` 参数声明检查:每个模型的 `parameters` 须通过 `assertValidDeclarations`,
26
31
  * 每个声明的默认值须通过 `validateParams`。返回问题列表(形如 `<模型 id>: <原因>`),无问题为空。
@@ -56,6 +61,6 @@ export declare const MEDIA_SAMPLES: {
56
61
  readonly word: "MANGO";
57
62
  };
58
63
  };
59
- /** model-provider 一致性套件(`@1` 与 `@2`):每个供应商插件都应通过。 */
64
+ /** The model-provider conformance suite (`@2`): every provider plugin should pass it. */
60
65
  export declare function describeModelProviderConformance(name: string, setup: () => Promise<ConformanceTarget>): void;
61
66
  export {};
@@ -1,11 +1,9 @@
1
- import { assertValidDeclarations, EFFORT_VALUES, isModelError, sanitizeParams, validateParams, } from "@capybara-hq/plugin-sdk";
1
+ import { assertValidDeclarations, EFFORT_VALUES, isModelError, isValidImageGenerationInfo, sanitizeParams, validateEmbedResult, validateImageGenerateResult, validateParams, } from "@capybara-hq/plugin-sdk";
2
2
  import { afterAll, beforeAll, describe, expect, it } from "vitest";
3
3
  import { pdfBase64, redPngBase64 } from "./media-samples.js";
4
4
  function streamOf(t, req, signal) {
5
5
  const { params, ...rest } = req;
6
- if (t.contract === 2)
7
- return t.provider.stream({ ...rest, params: params ?? {} }, { signal });
8
- return t.provider.stream(rest, { signal });
6
+ return t.provider.stream({ ...rest, params: params ?? {} }, { signal });
9
7
  }
10
8
  /**
11
9
  * `@2` 参数声明检查:每个模型的 `parameters` 须通过 `assertValidDeclarations`,
@@ -81,7 +79,7 @@ export const MEDIA_SAMPLES = {
81
79
  },
82
80
  };
83
81
  const textOf = (content) => content.map((b) => (b.type === "text" ? b.text : "")).join("");
84
- /** model-provider 一致性套件(`@1` 与 `@2`):每个供应商插件都应通过。 */
82
+ /** The model-provider conformance suite (`@2`): every provider plugin should pass it. */
85
83
  export function describeModelProviderConformance(name, setup) {
86
84
  describe(`model-provider conformance: ${name}`, () => {
87
85
  let t;
@@ -145,16 +143,12 @@ export function describeModelProviderConformance(name, setup) {
145
143
  }));
146
144
  expect(second.done.content.some((b) => b.type === "text")).toBe(true);
147
145
  });
148
- /** 思考用例的参数:`@1` 发 `effort: "high"`;`@2` 见 {@link thinkingReplayParams}。 */
146
+ /** The thinking case's parameters, see {@link thinkingReplayParams}. */
149
147
  const thinkingOver = async () => {
150
- if (t.contract !== 2)
151
- return { effort: "high" };
152
148
  const info = (await t.provider.listModels()).find((m) => m.id === t.model);
153
149
  return { params: thinkingReplayParams(info?.parameters ?? []) };
154
150
  };
155
- it("declares valid parameters", async (ctx) => {
156
- if (t.contract !== 2)
157
- return ctx.skip();
151
+ it("declares valid parameters", async () => {
158
152
  expect(checkDeclaredParameters(t.plugin, await t.provider.listModels())).toEqual([]);
159
153
  });
160
154
  it("thinking replay", async (ctx) => {
@@ -211,10 +205,8 @@ export function describeModelProviderConformance(name, setup) {
211
205
  }));
212
206
  expect(done.content.length).toBeGreaterThan(0);
213
207
  });
214
- /** `@2` 模型的能力声明;`@1` 返回 null(媒体用例只对 `@2` 跑)。 */
208
+ /** The model's declared capabilities (null when it is not listed). */
215
209
  const caps = async () => {
216
- if (t.contract !== 2)
217
- return null;
218
210
  const info = (await t.provider.listModels()).find((m) => m.id === t.model);
219
211
  return info?.capabilities ?? null;
220
212
  };
@@ -260,6 +252,87 @@ export function describeModelProviderConformance(name, setup) {
260
252
  expect(done.stopReason).toBe("end_turn");
261
253
  expect(textOf(done.content).toUpperCase()).toContain(s.word);
262
254
  });
255
+ describe("embedding", () => {
256
+ const inputs = ["alpha", "bravo", "charlie"];
257
+ const run = async () => {
258
+ const emb = t.expect.embedding;
259
+ const provider = t.provider;
260
+ if (!emb || !provider.embed)
261
+ throw new Error("the target declares embedding but has no embed");
262
+ const req = { model: emb.model, input: inputs, dimensions: emb.dimensions };
263
+ const res = await provider.embed(req, { signal: new AbortController().signal });
264
+ const models = await provider.listModels();
265
+ const info = models.find((m) => m.id === emb.model)?.embedding;
266
+ return { req, res, info };
267
+ };
268
+ it("embeds a batch in order", async (ctx) => {
269
+ if (!t.expect.embedding)
270
+ return ctx.skip();
271
+ const { res } = await run();
272
+ expect(res.vectors).toHaveLength(inputs.length);
273
+ for (const v of res.vectors)
274
+ expect(v).toHaveLength(t.expect.embedding.dimensions);
275
+ expect(res.usage.inputTokens).toBeGreaterThanOrEqual(0);
276
+ });
277
+ it("embed result passes validateEmbedResult", async (ctx) => {
278
+ if (!t.expect.embedding)
279
+ return ctx.skip();
280
+ const { req, res, info } = await run();
281
+ expect(info).toBeDefined();
282
+ if (!info)
283
+ return;
284
+ expect(validateEmbedResult(req, info, res)).toBeNull();
285
+ });
286
+ });
287
+ describe("image generation", () => {
288
+ const run = async (n) => {
289
+ const img = t.expect.imageGeneration;
290
+ const provider = t.provider;
291
+ if (!img || !provider.generateImage) {
292
+ throw new Error("the target declares imageGeneration but has no generateImage");
293
+ }
294
+ const models = await provider.listModels();
295
+ const info = models.find((m) => m.id === img.model)?.imageGeneration;
296
+ if (!info)
297
+ throw new Error(`model ${img.model} lists no imageGeneration`);
298
+ const req = {
299
+ model: img.model,
300
+ prompt: "a small red square",
301
+ size: info.defaultSize,
302
+ n,
303
+ params: {},
304
+ };
305
+ const res = await provider.generateImage(req, { signal: new AbortController().signal });
306
+ return { req, res, info };
307
+ };
308
+ it("lists valid imageGeneration info", async (ctx) => {
309
+ const img = t.expect.imageGeneration;
310
+ if (!img)
311
+ return ctx.skip();
312
+ const models = await t.provider.listModels();
313
+ const info = models.find((m) => m.id === img.model)?.imageGeneration;
314
+ expect(isValidImageGenerationInfo(info)).toBe(true);
315
+ });
316
+ it("generates one image that passes validateImageGenerateResult", async (ctx) => {
317
+ if (!t.expect.imageGeneration)
318
+ return ctx.skip();
319
+ const { req, res, info } = await run(1);
320
+ expect(validateImageGenerateResult(req, info, res)).toBeNull();
321
+ });
322
+ // A model that returns one image per call declares maxImages 1; the kernel never asks it
323
+ // for more, so the suite does not either.
324
+ it("generates two images when the model allows it", async (ctx) => {
325
+ const img = t.expect.imageGeneration;
326
+ if (!img)
327
+ return ctx.skip();
328
+ const listed = (await t.provider.listModels()).find((m) => m.id === img.model);
329
+ if ((listed?.imageGeneration?.maxImages ?? 0) < 2)
330
+ return ctx.skip();
331
+ const { req, res, info } = await run(2);
332
+ expect(res.images).toHaveLength(2);
333
+ expect(validateImageGenerateResult(req, info, res)).toBeNull();
334
+ });
335
+ });
263
336
  it("abort", async () => {
264
337
  const ac = new AbortController();
265
338
  const it = streamOf(t, base(), ac.signal)[Symbol.asyncIterator]();
@@ -0,0 +1,31 @@
1
+ import { type PushProvider } from "@capybara-hq/plugin-sdk";
2
+ /** What the vendor does for one token. */
3
+ export type PushOutcome = "delivered" | "unregistered" | "auth" | "rate_limited" | "transient" | "network_error" | "hang";
4
+ /** A vendor request as the suite checks it (what reached the vendor, not what the provider was given). */
5
+ export interface PushVendorRequest {
6
+ token: string;
7
+ title: string;
8
+ body: string;
9
+ path: string;
10
+ origin: string;
11
+ threadId: string;
12
+ collapseId: string;
13
+ }
14
+ /** The provider under test and its (fake) vendor. */
15
+ export interface PushConformanceTarget {
16
+ /** The plugin name. */
17
+ plugin: string;
18
+ make(): Promise<{
19
+ provider: PushProvider;
20
+ /** Makes the vendor answer `outcome` for `token`. */
21
+ arrange(token: string, outcome: PushOutcome): void;
22
+ /** Every request that reached the vendor. */
23
+ requests(): PushVendorRequest[];
24
+ close(): Promise<void>;
25
+ }>;
26
+ }
27
+ /**
28
+ * Runs the `push-provider@1` conformance suite against one provider and its fake vendor. The suite
29
+ * never sleeps: `hang` settles on the signal's abort event.
30
+ */
31
+ export declare function describePushProviderConformance(t: PushConformanceTarget): void;