@capybara-hq/testing 0.1.0-rc.16 → 0.1.0-rc.18
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.
- package/dist/containers.d.ts +7 -2
- package/dist/containers.js +7 -3
- package/dist/fake-git-server.d.ts +32 -4
- package/dist/fake-git-server.js +84 -18
- package/dist/fixtures.d.ts +4 -2
- package/dist/fixtures.js +5 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/fixtures/extensions/fake-context/.capybara-plugin/plugin.json +7 -0
- package/fixtures/extensions/fake-context/package.json +12 -0
- package/fixtures/extensions/fake-context/src/index.ts +81 -0
- package/fixtures/extensions/fake-lifecycle/.capybara-plugin/plugin.json +7 -0
- package/fixtures/extensions/fake-lifecycle/migrations/0001_init.sql +16 -0
- package/fixtures/extensions/fake-lifecycle/package.json +12 -0
- package/fixtures/extensions/fake-lifecycle/src/index.ts +72 -0
- package/fixtures/extensions/fake-tools-ui/src/index.ts +21 -1
- package/package.json +5 -5
package/dist/containers.d.ts
CHANGED
|
@@ -38,12 +38,17 @@ export declare const DEFAULT_CONTAINER_STARTS = 4;
|
|
|
38
38
|
* `key` is the slot set (tests use their own).
|
|
39
39
|
*/
|
|
40
40
|
export declare function withStartSlot<T>(start: () => Promise<T>, key?: string): Promise<T>;
|
|
41
|
+
/** The PostgreSQL image tests run on: PostgreSQL 17 with pgvector, as in the compose files. */
|
|
42
|
+
export declare const TEST_PG_IMAGE = "pgvector/pgvector:pg17";
|
|
41
43
|
/**
|
|
42
|
-
* Start a throwaway PostgreSQL 17 container
|
|
43
|
-
*
|
|
44
|
+
* Start a throwaway PostgreSQL 17 container (`TEST_PG_IMAGE` unless `image` names another, e.g.
|
|
45
|
+
* plain `postgres:17` to test a server without pgvector). `tuned` is for the run-wide shared
|
|
46
|
+
* instance: many files connect at once (raise `max_connections`), and durability is irrelevant for
|
|
47
|
+
* tests (no fsync).
|
|
44
48
|
*/
|
|
45
49
|
export declare function startPostgresContainer(opts?: {
|
|
46
50
|
tuned?: boolean;
|
|
51
|
+
image?: string;
|
|
47
52
|
}): Promise<TestContainer>;
|
|
48
53
|
/** Start a throwaway Valkey 8 container, returning `redis://host:port`. */
|
|
49
54
|
export declare function startRedisContainer(opts?: {
|
package/dist/containers.js
CHANGED
|
@@ -90,12 +90,16 @@ export async function withStartSlot(start, key = START_SLOTS_KEY) {
|
|
|
90
90
|
r.disconnect();
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
+
/** The PostgreSQL image tests run on: PostgreSQL 17 with pgvector, as in the compose files. */
|
|
94
|
+
export const TEST_PG_IMAGE = "pgvector/pgvector:pg17";
|
|
93
95
|
/**
|
|
94
|
-
* Start a throwaway PostgreSQL 17 container
|
|
95
|
-
*
|
|
96
|
+
* Start a throwaway PostgreSQL 17 container (`TEST_PG_IMAGE` unless `image` names another, e.g.
|
|
97
|
+
* plain `postgres:17` to test a server without pgvector). `tuned` is for the run-wide shared
|
|
98
|
+
* instance: many files connect at once (raise `max_connections`), and durability is irrelevant for
|
|
99
|
+
* tests (no fsync).
|
|
96
100
|
*/
|
|
97
101
|
export async function startPostgresContainer(opts = {}) {
|
|
98
|
-
const image = new PostgreSqlContainer(
|
|
102
|
+
const image = new PostgreSqlContainer(opts.image ?? TEST_PG_IMAGE);
|
|
99
103
|
if (opts.tuned) {
|
|
100
104
|
image.withCommand([
|
|
101
105
|
"postgres",
|
|
@@ -3,8 +3,30 @@ export interface FakeGitRequest {
|
|
|
3
3
|
method: string;
|
|
4
4
|
/** Path and query, e.g. `/x.git/info/refs?service=git-upload-pack`. */
|
|
5
5
|
path: string;
|
|
6
|
-
/**
|
|
6
|
+
/** `git-upload-pack` or `git-receive-pack` for smart-HTTP requests. */
|
|
7
|
+
service?: string;
|
|
8
|
+
/** False when `requireBasic` is set and the request did not carry the matching Basic auth. */
|
|
9
|
+
authorized: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* The `Authorization` header value; set unless `recordAuthorization: false` (the catalog tests
|
|
12
|
+
* assert on it; tests that handle real credentials pass false).
|
|
13
|
+
*/
|
|
7
14
|
authorization?: string;
|
|
15
|
+
/** Lower-case names of the request headers; values are never recorded (no credential in here). */
|
|
16
|
+
headerNames: string[];
|
|
17
|
+
}
|
|
18
|
+
export interface FakeGitServerOptions {
|
|
19
|
+
/** Repos (`owner/repo` or `repo`) created as bare repos at start. */
|
|
20
|
+
repos?: string[];
|
|
21
|
+
/** Seed each of `repos` with one commit on `main` so clones are not empty (default true). */
|
|
22
|
+
seed?: boolean;
|
|
23
|
+
/** Answers 401 (`WWW-Authenticate: Basic realm="fake"`) unless the request carries this Basic auth. */
|
|
24
|
+
/** Record each request's `Authorization` value in `requests` (default true, for tests of what a client sends; pass false to record names only). */
|
|
25
|
+
recordAuthorization?: boolean;
|
|
26
|
+
requireBasic?: {
|
|
27
|
+
username: string;
|
|
28
|
+
password: string;
|
|
29
|
+
};
|
|
8
30
|
}
|
|
9
31
|
/** Entries that are not regular files, for tests of refused trees. */
|
|
10
32
|
export interface FakeGitCommitOptions {
|
|
@@ -40,13 +62,19 @@ export interface FakeGitServer {
|
|
|
40
62
|
commit(repo: string, files: Record<string, string>, opts?: FakeGitCommitOptions): Promise<string>;
|
|
41
63
|
/** Makes every request answer 302 to `location` (`null` restores it). */
|
|
42
64
|
setRedirect(location: string | null): void;
|
|
65
|
+
/** The next request (only) answers `status` with `body`. */
|
|
66
|
+
failNext(status: number, body?: string): void;
|
|
67
|
+
/** The next request (only) answers 302 to `location`. */
|
|
68
|
+
redirectNext(location: string): void;
|
|
69
|
+
/** The sha `ref` (e.g. `refs/heads/main`) points at in the bare repo, or undefined. */
|
|
70
|
+
refOf(repo: string, ref: string): Promise<string | undefined>;
|
|
43
71
|
/** The requests received, in order. */
|
|
44
72
|
requests: FakeGitRequest[];
|
|
45
73
|
stop(): Promise<void>;
|
|
46
74
|
}
|
|
47
75
|
/**
|
|
48
|
-
* A fake git host: bare repos in a temp dir, served
|
|
49
|
-
* (smart HTTP, as CGI) over a loopback http server. Repos allow fetching any reachable commit by sha
|
|
76
|
+
* A fake git host: bare repos in a temp dir, served by the system `git http-backend`
|
|
77
|
+
* (smart HTTP, as CGI, pushes included) over a loopback http server. Repos allow fetching any reachable commit by sha
|
|
50
78
|
* (`uploadpack.allowReachableSHA1InWant`, as GitHub does). Needs `git` on PATH.
|
|
51
79
|
*
|
|
52
80
|
* Spawning git is what these tests spend their time on, and it slows down most under load, so the
|
|
@@ -54,4 +82,4 @@ export interface FakeGitServer {
|
|
|
54
82
|
* `git fast-import`, and a ref advertisement (`GET …/info/refs`) is answered by http-backend once per
|
|
55
83
|
* repo state, then repeated until the next commit to that repo.
|
|
56
84
|
*/
|
|
57
|
-
export declare function startFakeGitServer(): Promise<FakeGitServer>;
|
|
85
|
+
export declare function startFakeGitServer(options?: FakeGitServerOptions): Promise<FakeGitServer>;
|
package/dist/fake-git-server.js
CHANGED
|
@@ -4,7 +4,7 @@ import { appendFile, mkdtemp, readFile, rm } from "node:fs/promises";
|
|
|
4
4
|
import { createServer } from "node:http";
|
|
5
5
|
import { tmpdir } from "node:os";
|
|
6
6
|
import { join, posix } from "node:path";
|
|
7
|
-
const REPO_RE = /^[A-Za-z0-9][A-Za-z0-9._-]
|
|
7
|
+
const REPO_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*(\/[A-Za-z0-9][A-Za-z0-9._-]*)?$/;
|
|
8
8
|
/** Git runs with no user or system config, so a developer's settings never change the repos. */
|
|
9
9
|
function gitEnv(extra = {}) {
|
|
10
10
|
return {
|
|
@@ -56,7 +56,7 @@ function git(args, o = {}) {
|
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
/** Starts `git http-backend` as a CGI script for one request (smart HTTP,
|
|
59
|
+
/** Starts `git http-backend` as a CGI script for one request (smart HTTP, push enabled). */
|
|
60
60
|
function spawnCgi(root, req) {
|
|
61
61
|
const url = new URL(req.url ?? "/", "http://127.0.0.1");
|
|
62
62
|
const env = {
|
|
@@ -77,7 +77,9 @@ function spawnCgi(root, req) {
|
|
|
77
77
|
const enc = req.headers["content-encoding"];
|
|
78
78
|
if (typeof enc === "string")
|
|
79
79
|
env.HTTP_CONTENT_ENCODING = enc;
|
|
80
|
-
const p = spawn("git", ["http-backend"], {
|
|
80
|
+
const p = spawn("git", ["-c", "http.receivepack=true", "http-backend"], {
|
|
81
|
+
env: gitEnv(env),
|
|
82
|
+
});
|
|
81
83
|
// http-backend may exit without reading the whole body (a GET, or a request it refuses): the
|
|
82
84
|
// write then fails with EPIPE. Its exit status and output decide the response, not the pipe.
|
|
83
85
|
p.stdin.on("error", () => { });
|
|
@@ -169,8 +171,8 @@ const fastImportPath = (path) => /^"|[\n"\\]/.test(path)
|
|
|
169
171
|
? `"${path.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n")}"`
|
|
170
172
|
: path;
|
|
171
173
|
/**
|
|
172
|
-
* A fake git host: bare repos in a temp dir, served
|
|
173
|
-
* (smart HTTP, as CGI) over a loopback http server. Repos allow fetching any reachable commit by sha
|
|
174
|
+
* A fake git host: bare repos in a temp dir, served by the system `git http-backend`
|
|
175
|
+
* (smart HTTP, as CGI, pushes included) over a loopback http server. Repos allow fetching any reachable commit by sha
|
|
174
176
|
* (`uploadpack.allowReachableSHA1InWant`, as GitHub does). Needs `git` on PATH.
|
|
175
177
|
*
|
|
176
178
|
* Spawning git is what these tests spend their time on, and it slows down most under load, so the
|
|
@@ -178,26 +180,66 @@ const fastImportPath = (path) => /^"|[\n"\\]/.test(path)
|
|
|
178
180
|
* `git fast-import`, and a ref advertisement (`GET …/info/refs`) is answered by http-backend once per
|
|
179
181
|
* repo state, then repeated until the next commit to that repo.
|
|
180
182
|
*/
|
|
181
|
-
export async function startFakeGitServer() {
|
|
183
|
+
export async function startFakeGitServer(options = {}) {
|
|
182
184
|
const root = await mkdtemp(join(tmpdir(), "capybara-fake-git-"));
|
|
183
185
|
const requests = [];
|
|
184
186
|
let redirect = null;
|
|
187
|
+
let nextFail;
|
|
188
|
+
let nextRedirect;
|
|
189
|
+
const expectedBasic = options.requireBasic === undefined
|
|
190
|
+
? undefined
|
|
191
|
+
: `Basic ${Buffer.from(`${options.requireBasic.username}:${options.requireBasic.password}`).toString("base64")}`;
|
|
185
192
|
/** Ref advertisements by repo, then by request (path, query and `Git-Protocol`). */
|
|
186
193
|
const advertised = new Map();
|
|
187
194
|
/** Bumped by every commit to a repo: an answer read before the commit is not kept. */
|
|
188
195
|
const generation = new Map();
|
|
189
|
-
const repoOf = (pathname) => /^\/(
|
|
196
|
+
const repoOf = (pathname) => /^\/(.+)\.git\/info\/refs$/.exec(pathname)?.[1];
|
|
197
|
+
const pushedRepo = (pathname) => /^\/(.+)\.git\/git-receive-pack$/.exec(pathname)?.[1];
|
|
190
198
|
const server = createServer((req, res) => {
|
|
191
|
-
const
|
|
192
|
-
|
|
199
|
+
const url = new URL(req.url ?? "/", "http://127.0.0.1");
|
|
200
|
+
const authorized = expectedBasic === undefined || req.headers.authorization === expectedBasic;
|
|
201
|
+
const r = {
|
|
202
|
+
method: req.method ?? "GET",
|
|
203
|
+
path: req.url ?? "/",
|
|
204
|
+
authorized,
|
|
205
|
+
headerNames: Object.keys(req.headers),
|
|
206
|
+
};
|
|
207
|
+
if (options.recordAuthorization !== false && typeof req.headers.authorization === "string") {
|
|
193
208
|
r.authorization = req.headers.authorization;
|
|
209
|
+
}
|
|
210
|
+
const service = url.searchParams.get("service") ?? /\/(git-(?:upload|receive)-pack)$/.exec(url.pathname)?.[1];
|
|
211
|
+
if (service !== undefined && service !== null)
|
|
212
|
+
r.service = service;
|
|
194
213
|
requests.push(r);
|
|
214
|
+
if (nextFail !== undefined) {
|
|
215
|
+
const f = nextFail;
|
|
216
|
+
nextFail = undefined;
|
|
217
|
+
res.writeHead(f.status, { "content-type": "text/plain" }).end(f.body);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
if (nextRedirect !== undefined) {
|
|
221
|
+
const l = nextRedirect;
|
|
222
|
+
nextRedirect = undefined;
|
|
223
|
+
res.writeHead(302, { location: l }).end();
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
if (!authorized) {
|
|
227
|
+
res.writeHead(401, { "www-authenticate": 'Basic realm="fake"' }).end();
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
195
230
|
if (redirect !== null) {
|
|
196
231
|
res.writeHead(302, { location: redirect }).end();
|
|
197
232
|
return;
|
|
198
233
|
}
|
|
199
|
-
const url = new URL(req.url ?? "/", "http://127.0.0.1");
|
|
200
234
|
const repo = req.method === "GET" ? repoOf(url.pathname) : undefined;
|
|
235
|
+
const pushed = pushedRepo(url.pathname);
|
|
236
|
+
if (pushed !== undefined) {
|
|
237
|
+
// a push moves refs: advertisements read before it are stale
|
|
238
|
+
res.on("close", () => {
|
|
239
|
+
generation.set(pushed, (generation.get(pushed) ?? 0) + 1);
|
|
240
|
+
advertised.delete(pushed);
|
|
241
|
+
});
|
|
242
|
+
}
|
|
201
243
|
if (repo === undefined) {
|
|
202
244
|
serveCgi(root, req, res);
|
|
203
245
|
return;
|
|
@@ -225,6 +267,13 @@ export async function startFakeGitServer() {
|
|
|
225
267
|
});
|
|
226
268
|
await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
|
|
227
269
|
const port = server.address().port;
|
|
270
|
+
const stopServer = async () => {
|
|
271
|
+
await new Promise((resolve) => {
|
|
272
|
+
server.closeAllConnections();
|
|
273
|
+
server.close(() => resolve());
|
|
274
|
+
});
|
|
275
|
+
await rm(root, { recursive: true, force: true });
|
|
276
|
+
};
|
|
228
277
|
const repoDir = async (repo) => {
|
|
229
278
|
if (!REPO_RE.test(repo))
|
|
230
279
|
throw new Error(`invalid fake repo name: ${repo}`);
|
|
@@ -307,19 +356,36 @@ export async function startFakeGitServer() {
|
|
|
307
356
|
advertised.delete(repo);
|
|
308
357
|
return sha;
|
|
309
358
|
};
|
|
310
|
-
|
|
359
|
+
const fake = {
|
|
311
360
|
url: (repo) => `http://127.0.0.1:${port}/${repo}.git`,
|
|
312
361
|
commit,
|
|
313
362
|
setRedirect: (l) => {
|
|
314
363
|
redirect = l;
|
|
315
364
|
},
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
});
|
|
322
|
-
await rm(root, { recursive: true, force: true });
|
|
365
|
+
failNext: (status, body = "") => {
|
|
366
|
+
nextFail = { status, body };
|
|
367
|
+
},
|
|
368
|
+
redirectNext: (l) => {
|
|
369
|
+
nextRedirect = l;
|
|
323
370
|
},
|
|
371
|
+
refOf: async (repo, ref) => {
|
|
372
|
+
const gitDir = await repoDir(repo);
|
|
373
|
+
return git(["rev-parse", "--verify", "--quiet", ref], { env: { GIT_DIR: gitDir } }).then((sha) => sha || undefined, () => undefined);
|
|
374
|
+
},
|
|
375
|
+
requests,
|
|
376
|
+
stop: stopServer,
|
|
324
377
|
};
|
|
378
|
+
try {
|
|
379
|
+
for (const repo of options.repos ?? []) {
|
|
380
|
+
if (options.seed === false)
|
|
381
|
+
await repoDir(repo);
|
|
382
|
+
else
|
|
383
|
+
await commit(repo, { "README.md": "seed\n" });
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
catch (e) {
|
|
387
|
+
await stopServer();
|
|
388
|
+
throw e;
|
|
389
|
+
}
|
|
390
|
+
return fake;
|
|
325
391
|
}
|
package/dist/fixtures.d.ts
CHANGED
|
@@ -10,19 +10,21 @@
|
|
|
10
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
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) |
|
|
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` |
|
|
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
20
|
* | `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
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; org config secret `token`, `configured()` iff it is set (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) |
|
|
21
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` |
|
|
22
24
|
* | `fake-client-broken` | client code that throws: component `boom` (render), a `run.started` events listener, and a `conversation.empty` replacement (render) |
|
|
23
25
|
* | `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 |
|
|
24
26
|
*/
|
|
25
|
-
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", "fake-client", "fake-client-broken"];
|
|
27
|
+
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-client", "fake-client-broken"];
|
|
26
28
|
/**
|
|
27
29
|
* Fake plugins without an extension (declarative: they live in `fixtures/plugins/<name>`, same
|
|
28
30
|
* pack layout).
|
package/dist/fixtures.js
CHANGED
|
@@ -13,14 +13,16 @@ import { fileURLToPath } from "node:url";
|
|
|
13
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
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) |
|
|
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` |
|
|
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
23
|
* | `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
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; org config secret `token`, `configured()` iff it is set (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) |
|
|
24
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` |
|
|
25
27
|
* | `fake-client-broken` | client code that throws: component `boom` (render), a `run.started` events listener, and a `conversation.empty` replacement (render) |
|
|
26
28
|
* | `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 |
|
|
@@ -31,6 +33,7 @@ export const FAKE_EXTENSIONS = [
|
|
|
31
33
|
"fake-object-store",
|
|
32
34
|
"fake-tools-ui",
|
|
33
35
|
"fake-storage-user",
|
|
36
|
+
"fake-lifecycle",
|
|
34
37
|
"fake-embed",
|
|
35
38
|
"fake-bootstrap-a",
|
|
36
39
|
"fake-bootstrap-b",
|
|
@@ -39,6 +42,7 @@ export const FAKE_EXTENSIONS = [
|
|
|
39
42
|
"fake-im",
|
|
40
43
|
"fake-web",
|
|
41
44
|
"fake-web-2",
|
|
45
|
+
"fake-context",
|
|
42
46
|
"fake-config-form",
|
|
43
47
|
"fake-client",
|
|
44
48
|
"fake-client-broken",
|
package/dist/index.d.ts
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
* keys the kernel owns (assert on them instead of copying their values).
|
|
5
5
|
*/
|
|
6
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, startTestPostgres, startTestRedis, startTestS3, TEST_S3_IMAGE, type TestContainer, type TestS3, } from "./containers.js";
|
|
7
|
+
export { createFreshDatabase, startPostgresContainer, startTestPostgres, startTestRedis, startTestS3, TEST_PG_IMAGE, TEST_S3_IMAGE, type TestContainer, type TestS3, } from "./containers.js";
|
|
8
8
|
export { createDualReplicaHarness, type DualReplicaOptions, type ExtraReplicaHandle, type Harness, REPLICA_HEADER, type ReplicaHandle, type ReplicaResponse, replicaOf, } from "./dual-replica.js";
|
|
9
9
|
export { assertExtensionSecretsReachable, extensionDeploymentSecretValues, } from "./extension-config.js";
|
|
10
10
|
export { FAKE_CHANNEL_BAD_SECRET, FAKE_WEBHOOK_SIGNATURE_HEADER, type FakeChannelCheckCall, 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
11
|
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";
|
|
12
|
+
export { type FakeGitCommitOptions, type FakeGitRequest, type FakeGitServer, type FakeGitServerOptions, startFakeGitServer, } from "./fake-git-server.js";
|
|
13
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
14
|
export { type FakeMarketplace, type FakeMarketplaceRequest, startFakeMarketplace, } from "./fake-marketplace.js";
|
|
15
15
|
export { type FakeMcpCallInfo, type FakeMcpHandlerContext, type FakeMcpPrompt, type FakeMcpRequest, type FakeMcpResource, FakeMcpRpcError, type FakeMcpServer, type FakeMcpServerOptions, type FakeMcpTool, startFakeMcpServer, } from "./fake-mcp-server.js";
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* keys the kernel owns (assert on them instead of copying their values).
|
|
5
5
|
*/
|
|
6
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, startTestPostgres, startTestRedis, startTestS3, TEST_S3_IMAGE, } from "./containers.js";
|
|
7
|
+
export { createFreshDatabase, startPostgresContainer, startTestPostgres, startTestRedis, startTestS3, TEST_PG_IMAGE, TEST_S3_IMAGE, } from "./containers.js";
|
|
8
8
|
export { createDualReplicaHarness, REPLICA_HEADER, replicaOf, } from "./dual-replica.js";
|
|
9
9
|
export { assertExtensionSecretsReachable, extensionDeploymentSecretValues, } from "./extension-config.js";
|
|
10
10
|
export { FAKE_CHANNEL_BAD_SECRET, FAKE_WEBHOOK_SIGNATURE_HEADER, fakeCardAction, fakeDirectoryMember, fakeDm, fakeGroupMessage, fakeWebhookChallenge, fakeWebhookEvents, signFakeWebhook, startFakeChannelServer, } from "./fake-channel.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@capybara-hq/test-plugin-fake-context",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "Test fake: a scripted context provider (context@1) and one tool limited to one-to-one conversations",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@capybara-hq/plugin-sdk": "^0.1.0-rc.0",
|
|
10
|
+
"zod": "^4.6.7"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ContextProvider,
|
|
3
|
+
type ContextRequest,
|
|
4
|
+
defineExtension,
|
|
5
|
+
type ToolSpec,
|
|
6
|
+
} from "@capybara-hq/plugin-sdk";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Test fake of a `context@1` provider (memory plugin spec §6.1). Its behavior follows its
|
|
11
|
+
* deployment config, which the kernel passes back as the request's effective `config`:
|
|
12
|
+
* - `mode: "ok"` (default): returns `{ text }` (`text` default "fake context");
|
|
13
|
+
* - `mode: "null"`: returns null (nothing to add);
|
|
14
|
+
* - `mode: "throw"`: throws;
|
|
15
|
+
* - `mode: "hang"`: waits until the request's signal aborts, then rejects with its reason.
|
|
16
|
+
* Every call is recorded (the request without its signal) on `globalThis.__fakeContext`
|
|
17
|
+
* ({@link fakeContextProbe}; in-process kernels only). It also registers the tool `note` (default
|
|
18
|
+
* policy allow, `sources: ["web", "channel_dm"]`), so `tools` in a request lists
|
|
19
|
+
* `plugin__fake-context__note` only in one-to-one conversations. Its org config (`label`, default
|
|
20
|
+
* "") exists only so a test can store an org copy that no longer validates.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const DeploymentConfig = z.object({
|
|
24
|
+
text: z.string().default("fake context"),
|
|
25
|
+
mode: z.enum(["ok", "null", "throw", "hang"]).default("ok"),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/** An org-only config (all defaults), so a test can make the org's stored copy invalid. */
|
|
29
|
+
const OrgConfig = z.object({ label: z.string().default("") });
|
|
30
|
+
|
|
31
|
+
/** One `provide` call: the request the kernel sent, without its signal. */
|
|
32
|
+
export type FakeContextCall = Omit<ContextRequest, "signal">;
|
|
33
|
+
|
|
34
|
+
/** The probe tests read: every `provide` call of this process. */
|
|
35
|
+
export function fakeContextProbe(): { calls: FakeContextCall[] } {
|
|
36
|
+
const g = globalThis as { __fakeContext?: { calls: FakeContextCall[] } };
|
|
37
|
+
g.__fakeContext ??= { calls: [] };
|
|
38
|
+
return g.__fakeContext;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Rejects with the signal's reason once it aborts. */
|
|
42
|
+
function hang(signal: AbortSignal): Promise<never> {
|
|
43
|
+
return new Promise((_, reject) => {
|
|
44
|
+
if (signal.aborted) reject(signal.reason);
|
|
45
|
+
else signal.addEventListener("abort", () => reject(signal.reason), { once: true });
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const NOTE: ToolSpec = {
|
|
50
|
+
name: "note",
|
|
51
|
+
description:
|
|
52
|
+
"Acknowledge a note. Offered only in web and direct-message conversations. Test fixture only.",
|
|
53
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
54
|
+
defaultPolicy: "allow",
|
|
55
|
+
sources: ["web", "channel_dm"],
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const provider: ContextProvider = {
|
|
59
|
+
async provide(req) {
|
|
60
|
+
const { signal, ...call } = req;
|
|
61
|
+
fakeContextProbe().calls.push(call);
|
|
62
|
+
const cfg = DeploymentConfig.parse(req.config ?? {});
|
|
63
|
+
if (cfg.mode === "throw") throw new Error("fake-context: scripted failure");
|
|
64
|
+
if (cfg.mode === "hang") await hang(signal);
|
|
65
|
+
if (cfg.mode === "null") return null;
|
|
66
|
+
return { text: cfg.text };
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export default defineExtension({
|
|
71
|
+
name: "fake-context",
|
|
72
|
+
version: "0.1.0",
|
|
73
|
+
sdk: "^0.1.0-rc.0",
|
|
74
|
+
provides: ["context@1"],
|
|
75
|
+
config: { deployment: DeploymentConfig, org: OrgConfig },
|
|
76
|
+
permissions: { tools: ["note"] },
|
|
77
|
+
setup(ctx) {
|
|
78
|
+
ctx.provide("context@1", provider);
|
|
79
|
+
ctx.tools.register(NOTE, async () => ({ content: [{ type: "text", text: "Noted." }] }));
|
|
80
|
+
},
|
|
81
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
-- Runs with search_path "plugin_fake_lifecycle, public": table names carry no schema prefix.
|
|
2
|
+
-- Every call of a lifecycle hook (one row per call, failed ones too).
|
|
3
|
+
CREATE TABLE IF NOT EXISTS calls (
|
|
4
|
+
id bigserial PRIMARY KEY,
|
|
5
|
+
mount text NOT NULL,
|
|
6
|
+
payload jsonb NOT NULL,
|
|
7
|
+
at timestamptz NOT NULL DEFAULT now()
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
-- Every successful delivery (one row per call that did not throw).
|
|
11
|
+
CREATE TABLE IF NOT EXISTS deliveries (
|
|
12
|
+
id bigserial PRIMARY KEY,
|
|
13
|
+
mount text NOT NULL,
|
|
14
|
+
payload jsonb NOT NULL,
|
|
15
|
+
at timestamptz NOT NULL DEFAULT now()
|
|
16
|
+
);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@capybara-hq/test-plugin-fake-lifecycle",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "Test fake: observes the lifecycle hooks and records each delivery in its own table",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@capybara-hq/plugin-sdk": "^0.1.0-rc.0",
|
|
10
|
+
"zod": "^4.6.7"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineExtension,
|
|
3
|
+
type ExtensionContext,
|
|
4
|
+
type HookCall,
|
|
5
|
+
orgAccess,
|
|
6
|
+
} from "@capybara-hq/plugin-sdk";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Test fake of an extension that cleans up after removals: it observes the three lifecycle hooks
|
|
11
|
+
* (`org.member_removed`, `agent.deleted`, `org.deleted`) and records every call in its own schema
|
|
12
|
+
* (`plugin_fake_lifecycle`): table `calls` gets one row per call, `deliveries` one row per call
|
|
13
|
+
* that succeeded, each with the mount and the payload. Deployment config `failTimes` (default 0):
|
|
14
|
+
* the first `failTimes` calls of each (mount, payload) throw, so tests can drive the kernel's
|
|
15
|
+
* retries; the count lives in PG, so it holds across replicas. Deployment config `label` (optional,
|
|
16
|
+
* at most 10 characters) is overridable per org, so a test can store an org copy that does not
|
|
17
|
+
* validate (an org whose effective config is invalid).
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const DeploymentConfig = z.object({
|
|
21
|
+
/** How many calls of each (mount, payload) throw before one succeeds. */
|
|
22
|
+
failTimes: z.number().int().min(0).default(0),
|
|
23
|
+
/** Overridable per org; an org copy with a longer label makes that org's config invalid. */
|
|
24
|
+
label: orgAccess(z.string().max(10).optional(), "override"),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
type Db = ExtensionContext["db"];
|
|
28
|
+
|
|
29
|
+
/** Records the call, throws while it is one of the first `failTimes`, else records the delivery. */
|
|
30
|
+
async function handle(
|
|
31
|
+
db: Db,
|
|
32
|
+
mount: string,
|
|
33
|
+
payload: object,
|
|
34
|
+
call: HookCall | undefined,
|
|
35
|
+
): Promise<void> {
|
|
36
|
+
const json = JSON.stringify(payload);
|
|
37
|
+
await db.insertInto("calls").values({ mount, payload: json }).execute();
|
|
38
|
+
const { failTimes } = DeploymentConfig.parse(call?.config ?? {});
|
|
39
|
+
if (failTimes > 0) {
|
|
40
|
+
const row = await db
|
|
41
|
+
.selectFrom("calls")
|
|
42
|
+
.select((eb) => eb.fn.countAll<string>().as("n"))
|
|
43
|
+
.where("mount", "=", mount)
|
|
44
|
+
.where("payload", "=", json)
|
|
45
|
+
.executeTakeFirstOrThrow();
|
|
46
|
+
if (Number(row.n) <= failTimes) throw new Error(`fake-lifecycle: call ${row.n} fails`);
|
|
47
|
+
}
|
|
48
|
+
await db.insertInto("deliveries").values({ mount, payload: json }).execute();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default defineExtension({
|
|
52
|
+
name: "fake-lifecycle",
|
|
53
|
+
version: "0.1.0",
|
|
54
|
+
sdk: "^0.1.0-rc.0",
|
|
55
|
+
provides: [],
|
|
56
|
+
migrations: "../migrations",
|
|
57
|
+
config: { deployment: DeploymentConfig },
|
|
58
|
+
permissions: { hooks: ["org.member_removed", "agent.deleted", "org.deleted"] },
|
|
59
|
+
setup(ctx) {
|
|
60
|
+
ctx.hooks.on(
|
|
61
|
+
"org.member_removed",
|
|
62
|
+
(p, _signal, call) => handle(ctx.db, "org.member_removed", p, call),
|
|
63
|
+
{ mode: "observe" },
|
|
64
|
+
);
|
|
65
|
+
ctx.hooks.on("agent.deleted", (p, _signal, call) => handle(ctx.db, "agent.deleted", p, call), {
|
|
66
|
+
mode: "observe",
|
|
67
|
+
});
|
|
68
|
+
ctx.hooks.on("org.deleted", (p, _signal, call) => handle(ctx.db, "org.deleted", p, call), {
|
|
69
|
+
mode: "observe",
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
});
|
|
@@ -13,6 +13,8 @@ import { z } from "zod";
|
|
|
13
13
|
* it needs no object store (storage is `fake-storage-user`'s).
|
|
14
14
|
* - tool `write` (model-visible `plugin__fake-tools-ui__write`, default policy allow): replaces the
|
|
15
15
|
* conversation's item list in the extension's own table, then invalidates the view `tasks`;
|
|
16
|
+
* - tool `web-only` (default policy allow, `sources: ["web", "channel_dm"]`): returns, as JSON
|
|
17
|
+
* text, the call's `source`, `ownerAccountId`, `accountId` and `role`;
|
|
16
18
|
* - view `tasks` (conversation tab): badge `<done>/<total>` and a checklist;
|
|
17
19
|
* - the plugin also ships the skill `fake-notes` and the connector template `fake-notes`
|
|
18
20
|
* (for the `fake-connector` extension).
|
|
@@ -62,6 +64,16 @@ const WRITE: ToolSpec = {
|
|
|
62
64
|
defaultPolicy: "allow",
|
|
63
65
|
};
|
|
64
66
|
|
|
67
|
+
const WEB_ONLY: ToolSpec = {
|
|
68
|
+
name: "web-only",
|
|
69
|
+
description:
|
|
70
|
+
"Report who and where this call runs: the conversation source, its owner, the caller and the " +
|
|
71
|
+
"caller's role. Offered only in web and direct-message conversations. Test fixture only.",
|
|
72
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
73
|
+
defaultPolicy: "allow",
|
|
74
|
+
sources: ["web", "channel_dm"],
|
|
75
|
+
};
|
|
76
|
+
|
|
65
77
|
const render = (items: FakeItem[]): string =>
|
|
66
78
|
items.length === 0
|
|
67
79
|
? "The list is now empty."
|
|
@@ -126,7 +138,7 @@ export default defineExtension({
|
|
|
126
138
|
},
|
|
127
139
|
],
|
|
128
140
|
permissions: {
|
|
129
|
-
tools: ["write"],
|
|
141
|
+
tools: ["write", "web-only"],
|
|
130
142
|
ui: { views: ["tasks", "agent-notes", "org-admin", "platform-home"] },
|
|
131
143
|
},
|
|
132
144
|
setup(ctx) {
|
|
@@ -156,6 +168,14 @@ export default defineExtension({
|
|
|
156
168
|
},
|
|
157
169
|
};
|
|
158
170
|
});
|
|
171
|
+
ctx.tools.register(WEB_ONLY, async (_input, tctx) => {
|
|
172
|
+
const { source, ownerAccountId, accountId, role } = tctx;
|
|
173
|
+
return {
|
|
174
|
+
content: [
|
|
175
|
+
{ type: "text", text: JSON.stringify({ source, ownerAccountId, accountId, role }) },
|
|
176
|
+
],
|
|
177
|
+
};
|
|
178
|
+
});
|
|
159
179
|
ctx.ui.view("tasks", async ({ conversationId }) =>
|
|
160
180
|
tasksView(conversationId === undefined ? [] : await readItems(ctx.db, conversationId)),
|
|
161
181
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capybara-hq/testing",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.18",
|
|
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,17 +47,17 @@
|
|
|
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.
|
|
50
|
+
"@capybara-hq/kernel": "^0.1.0-rc.28"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/pg": "^8.23.1",
|
|
54
54
|
"@types/ws": "^8.18.2",
|
|
55
|
-
"@capybara-hq/plugin-
|
|
56
|
-
"@capybara-hq/plugin-
|
|
55
|
+
"@capybara-hq/plugin-sdk": "^0.1.0-rc.21",
|
|
56
|
+
"@capybara-hq/plugin-client": "^0.1.0-rc.5"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"vitest": "^5.0.5",
|
|
60
|
-
"@capybara-hq/plugin-sdk": "^0.1.0-rc.
|
|
60
|
+
"@capybara-hq/plugin-sdk": "^0.1.0-rc.21",
|
|
61
61
|
"@capybara-hq/plugin-tools": "^0.1.0-rc.13"
|
|
62
62
|
},
|
|
63
63
|
"peerDependenciesMeta": {
|