@capybara-hq/testing 0.1.0-rc.38 → 0.1.0-rc.39

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.
@@ -52,6 +52,12 @@ export interface DualReplicaOptions {
52
52
  * with the `api` role; use `requestTo(index, …)` to reach a specific replica.
53
53
  */
54
54
  roles?: [string[], string[]];
55
+ /**
56
+ * Runs against the harness's fresh database before the replicas start (it is not migrated yet:
57
+ * run the kernel migrations first when seeding tables), for state the replicas must find at
58
+ * their start.
59
+ */
60
+ beforeStart?: (dbUrl: string) => Promise<void>;
55
61
  }
56
62
  /** 一个副本(独立子进程)的句柄。 */
57
63
  export interface ReplicaHandle {
@@ -208,6 +208,7 @@ export async function createDualReplicaHarness(opts) {
208
208
  }
209
209
  const db = await createFreshDatabase(pgUrl);
210
210
  dropDb = db.drop;
211
+ await opts.beforeStart?.(db.url);
211
212
  const config = {
212
213
  dbUrl: db.url,
213
214
  redisUrl,
@@ -7,7 +7,7 @@
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`; 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) |
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
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
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 |
package/dist/fixtures.js CHANGED
@@ -10,7 +10,7 @@ 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`; 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) |
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
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
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 |
@@ -46,6 +46,7 @@ import { z } from "zod";
46
46
  * `_meta["fake/route"]` (the name of the remote tool that serves it) or else its name; `callTool`
47
47
  * calls the route of `ctx.spec.connectorData` when the kernel passes it, so a route change
48
48
  * without a rename is a definition drift and calls keep the reviewed route until approval;
49
+ * - the endpoint's optional `apiUrl` is a second URL the connector ignores;
49
50
  * - the endpoint's optional `notesText` is free-form text the connector ignores (a `*Text` field
50
51
  * the kernel summarizes in connector views instead of echoing it);
51
52
  * - the URL-mode elicitation error `-32042` goes through `onElicit` (each step accepted -> one
@@ -113,6 +114,11 @@ export function fakeEndpointSchema() {
113
114
  }),
114
115
  /** Free-form text the connector ignores (large-endpoint tests). */
115
116
  notesText: z.string().optional(),
117
+ /**
118
+ * A second URL the connector ignores: a destination field other than `url` (as an OpenAPI
119
+ * base URL), for tests of endpoint edits that move where requests go.
120
+ */
121
+ apiUrl: z.url().refine(urlAllowed, { message: "URL must use http or https" }).optional(),
116
122
  headers: z
117
123
  .record(z.string(), z.string())
118
124
  .default({})
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capybara-hq/testing",
3
- "version": "0.1.0-rc.38",
3
+ "version": "0.1.0-rc.39",
4
4
  "description": "Test helpers for Capybara: test containers, dual-replica harness and fake third-party servers",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -47,18 +47,18 @@
47
47
  "tsx": "^4.23.15",
48
48
  "ws": "^8.22.0",
49
49
  "zod": "^4.6.7",
50
- "@capybara-hq/kernel": "^0.1.0-rc.78"
50
+ "@capybara-hq/kernel": "^0.1.0-rc.85"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/pg": "^8.23.1",
54
54
  "@types/ws": "^8.18.2",
55
- "@capybara-hq/plugin-client": "^0.1.0-rc.8",
56
- "@capybara-hq/plugin-sdk": "^0.1.0-rc.64"
55
+ "@capybara-hq/plugin-sdk": "^0.1.0-rc.69",
56
+ "@capybara-hq/plugin-client": "^0.1.0-rc.9"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "vitest": "^5.0.5",
60
- "@capybara-hq/plugin-sdk": "^0.1.0-rc.64",
61
- "@capybara-hq/plugin-tools": "^0.1.0-rc.23"
60
+ "@capybara-hq/plugin-tools": "^0.1.0-rc.23",
61
+ "@capybara-hq/plugin-sdk": "^0.1.0-rc.69"
62
62
  },
63
63
  "peerDependenciesMeta": {
64
64
  "@capybara-hq/plugin-tools": {