@intentic/extension-api 1.431.0 → 1.432.0
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/README.md +124 -4
- package/dist/api.d.ts +1 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/backend-reach.d.ts +23 -0
- package/dist/backend-reach.d.ts.map +1 -0
- package/dist/backend-reach.js +241 -0
- package/dist/backend-reach.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.ts +12 -2
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +110 -132
- package/dist/runtime.js.map +1 -1
- package/dist/server-reach.d.ts +58 -0
- package/dist/server-reach.d.ts.map +1 -0
- package/dist/server-reach.js +2 -0
- package/dist/server-reach.js.map +1 -0
- package/dist/server.d.ts +186 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/sleep-fake.d.ts +15 -0
- package/dist/sleep-fake.d.ts.map +1 -0
- package/dist/sleep-fake.js +99 -0
- package/dist/sleep-fake.js.map +1 -0
- package/dist/sleep-reach.d.ts +7 -0
- package/dist/sleep-reach.d.ts.map +1 -0
- package/dist/sleep-reach.js +104 -0
- package/dist/sleep-reach.js.map +1 -0
- package/dist/testing.d.ts +64 -9
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +322 -13
- package/dist/testing.js.map +1 -1
- package/dist/turn-reach.d.ts +7 -0
- package/dist/turn-reach.d.ts.map +1 -0
- package/dist/turn-reach.js +140 -0
- package/dist/turn-reach.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +4 -4
- package/src/api.ts +3 -0
- package/src/backend-reach.integration.test.ts +154 -0
- package/src/backend-reach.ts +335 -0
- package/src/caller.integration.test.ts +108 -0
- package/src/index.ts +1 -0
- package/src/runtime.ts +184 -157
- package/src/server-reach.ts +104 -0
- package/src/server.ts +364 -3
- package/src/sleep-fake.ts +140 -0
- package/src/sleep-reach.integration.test.ts +119 -0
- package/src/sleep-reach.ts +147 -0
- package/src/surface.json +12741 -0
- package/src/testing.ts +506 -23
- package/src/turn-reach.integration.test.ts +166 -0
- package/src/turn-reach.ts +198 -0
- package/src/version.ts +110 -1
package/src/testing.ts
CHANGED
|
@@ -1,21 +1,62 @@
|
|
|
1
1
|
import { mkdtemp, rm } from "node:fs/promises";
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
import { type ExtensionReach, extensionRouteReach } from "@intentic/extension-manifest/permissions";
|
|
5
|
-
import { type
|
|
4
|
+
import { type DeclaredPermissions, declaredReachOf, type ExtensionReach, extensionRouteReach } from "@intentic/extension-manifest/permissions";
|
|
5
|
+
import { type PublicRouteContribution, publicRouteAutomationOf, publicRouteFor } from "@intentic/extension-manifest";
|
|
6
|
+
import {
|
|
7
|
+
type ExtensionActivity,
|
|
8
|
+
extensionActivityUrl,
|
|
9
|
+
ExtensionActivitySchema,
|
|
10
|
+
EXTENSION_BROWSER_TOOLS,
|
|
11
|
+
EXTENSION_CALLER_HEADER,
|
|
12
|
+
EXTENSION_CALLER_TTL_MS,
|
|
13
|
+
extensionBrowserUrl,
|
|
14
|
+
ExtensionBrowserCallSchema,
|
|
15
|
+
type ExtensionCallerClaim,
|
|
16
|
+
type ExtensionCallerIdentity,
|
|
17
|
+
EXTENSION_EVENTS_KINDS_PARAM,
|
|
18
|
+
type ExtensionEvent,
|
|
19
|
+
extensionEventsUrl,
|
|
20
|
+
type ExtensionExec,
|
|
21
|
+
type ExtensionExecResult,
|
|
22
|
+
ExtensionExecSchema,
|
|
23
|
+
extensionExecUrl,
|
|
24
|
+
ExtensionJobReportSchema,
|
|
25
|
+
extensionJobsUrl,
|
|
26
|
+
ExtensionJobStartSchema,
|
|
27
|
+
ExtensionNavigateArgumentsSchema,
|
|
28
|
+
ExtensionOwnerBrowserCallSchema,
|
|
29
|
+
extensionOwnerBrowserUrl,
|
|
30
|
+
extensionSettingsUrl,
|
|
31
|
+
extensionWorkHoldUrl,
|
|
32
|
+
ExtensionWorkHoldSchema,
|
|
33
|
+
NO_TOOL_GRANTS,
|
|
34
|
+
readCallerClaim,
|
|
35
|
+
} from "@intentic/sandbox-contract/extension-protocol";
|
|
6
36
|
import { EXTENSION_TOKEN_HEADER } from "@intentic/sandbox-contract/headers";
|
|
7
37
|
import { activateServerModule, createServerApi, deactivateWithin, healthWithin } from "./runtime.js";
|
|
38
|
+
import { type FakeSleep, fakeSleep } from "./sleep-fake.js";
|
|
8
39
|
import type {
|
|
9
40
|
ApprovedAction,
|
|
10
41
|
ApprovedActionOutcome,
|
|
42
|
+
ApprovedPost,
|
|
43
|
+
AutomationFire,
|
|
44
|
+
ExtensionCallerWho,
|
|
11
45
|
ExtensionHealth,
|
|
12
46
|
ExtensionServerApi,
|
|
13
47
|
ExtensionServerModule,
|
|
14
48
|
ExtensionSettingValues,
|
|
49
|
+
PublicRouteVerification,
|
|
50
|
+
JobEnd,
|
|
15
51
|
ServerActivation,
|
|
52
|
+
ToolArguments,
|
|
16
53
|
ToolCard,
|
|
17
54
|
ToolCallContext,
|
|
55
|
+
ToolCallGrants,
|
|
18
56
|
ToolDefinition,
|
|
57
|
+
ToolResult,
|
|
58
|
+
WatchCheck,
|
|
59
|
+
WatchCheckAnswer,
|
|
19
60
|
} from "./server.js";
|
|
20
61
|
|
|
21
62
|
// A backend under test, on the real backend api (runtime.ts) with only the daemon stood in for: every call the extension
|
|
@@ -28,12 +69,27 @@ import type {
|
|
|
28
69
|
const DAEMON = "http://daemon.fake";
|
|
29
70
|
const TOKEN = "fake-extension-token";
|
|
30
71
|
|
|
31
|
-
// The part of a manifest the fake reads: who the extension is
|
|
72
|
+
// The part of a manifest the fake reads: who the extension is, how far it reaches, and what else it declares it may
|
|
73
|
+
// hear, hold, run and be woken by (`events`, `work`, `exec`, `fires`), each judged as the daemon judges it.
|
|
32
74
|
export interface FakeManifest {
|
|
33
75
|
readonly publisher: string;
|
|
34
76
|
readonly name: string;
|
|
35
|
-
readonly permissions?: { readonly daemon?: readonly string[] };
|
|
36
|
-
readonly contributes?:
|
|
77
|
+
readonly permissions?: ({ readonly daemon?: readonly string[] | undefined } & DeclaredPermissions) | undefined;
|
|
78
|
+
readonly contributes?:
|
|
79
|
+
| {
|
|
80
|
+
readonly listener?: { readonly provider: string } | undefined;
|
|
81
|
+
readonly watchKinds?: readonly { readonly id: string }[] | undefined;
|
|
82
|
+
readonly publicRoutes?: readonly Pick<PublicRouteContribution, "path" | "methods" | "automation" | "wakes">[] | undefined;
|
|
83
|
+
}
|
|
84
|
+
| undefined;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Who a request into `/x` comes from, as the daemon's proxy would assert it (a person's `folders` being what their areas
|
|
88
|
+
// come to), and how long ago it was minted (ms): an assertion older than its two-minute window reads as no caller, and
|
|
89
|
+
// the daemon refuses it.
|
|
90
|
+
export interface FakeRouteOptions {
|
|
91
|
+
readonly caller?: ExtensionCallerWho & { readonly folders?: readonly string[] | undefined };
|
|
92
|
+
readonly mintedAgoMs?: number;
|
|
37
93
|
}
|
|
38
94
|
|
|
39
95
|
export interface FakeExtensionOptions {
|
|
@@ -42,6 +98,18 @@ export interface FakeExtensionOptions {
|
|
|
42
98
|
// not there.
|
|
43
99
|
readonly daemon?: (request: Request) => Response | undefined | Promise<Response | undefined>;
|
|
44
100
|
readonly settings?: ExtensionSettingValues;
|
|
101
|
+
// Answers a command run through `api.exec` whose class the manifest declares; absent, every command exits 0 having
|
|
102
|
+
// printed nothing.
|
|
103
|
+
readonly exec?: (command: ExtensionExec) => ExtensionExecResult | Promise<ExtensionExecResult>;
|
|
104
|
+
// (2026-11-26) What the turn calling a tool holds, unless `callTool`'s context names its own: nothing when absent.
|
|
105
|
+
readonly grants?: ToolCallGrants;
|
|
106
|
+
// (2026-11-26) Answers a call through `api.browser.call` the manifest declares and the call's grants admit, as the
|
|
107
|
+
// turn's browser router would; absent, an empty result. A tool outside the page tools the daemon admits, and a
|
|
108
|
+
// navigation off the account's sites, are refused before it is asked, as the daemon refuses them.
|
|
109
|
+
readonly browser?: (call: FakeBrowserCall) => ToolResult | Promise<ToolResult>;
|
|
110
|
+
// (2026-11-26) Answers a call through `api.ownerBrowser.call` the manifest declares and the grants admit; absent, an
|
|
111
|
+
// empty result.
|
|
112
|
+
readonly ownerBrowser?: (call: FakeOwnerBrowserCall) => ToolResult | Promise<ToolResult>;
|
|
45
113
|
// Each a fresh temp directory when absent, removed again by `dispose`.
|
|
46
114
|
readonly workspaceRoot?: string;
|
|
47
115
|
readonly extensionDir?: string;
|
|
@@ -49,33 +117,96 @@ export interface FakeExtensionOptions {
|
|
|
49
117
|
readonly cacheDir?: string;
|
|
50
118
|
}
|
|
51
119
|
|
|
52
|
-
//
|
|
53
|
-
|
|
120
|
+
// (2026-11-26) A call that reached the turn's browser (`api.browser.call`), as the daemon was asked and admitted it.
|
|
121
|
+
export interface FakeBrowserCall {
|
|
122
|
+
readonly account: string;
|
|
123
|
+
readonly tool: string;
|
|
124
|
+
readonly args: ToolArguments;
|
|
125
|
+
readonly conversationId?: string | undefined;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// (2026-11-26) A call that reached the owner's browser (`api.ownerBrowser.call`).
|
|
129
|
+
export interface FakeOwnerBrowserCall {
|
|
130
|
+
readonly browser: string;
|
|
131
|
+
readonly tool: string;
|
|
132
|
+
readonly args: ToolArguments;
|
|
133
|
+
readonly conversationId?: string | undefined;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// (2026-11-26) A job a tool started (`api.jobs.start`), as the daemon filed it: what it showed while it ran, its end once
|
|
137
|
+
// its work told it, and whether it was stopped.
|
|
138
|
+
export interface FakeJob {
|
|
139
|
+
readonly id: string;
|
|
140
|
+
readonly conversationId: string;
|
|
141
|
+
readonly command: string;
|
|
142
|
+
readonly description: string;
|
|
143
|
+
readonly lane?: { readonly name: string; readonly key?: string | undefined; readonly most?: number | undefined } | undefined;
|
|
144
|
+
readonly lines: readonly string[];
|
|
145
|
+
readonly end?: JobEnd | undefined;
|
|
146
|
+
readonly stopped: boolean;
|
|
147
|
+
}
|
|
54
148
|
|
|
55
|
-
// One request the extension sent the daemon,
|
|
149
|
+
// One request the extension sent the daemon, whether its reach admitted it, and the caller it carried an assertion of
|
|
150
|
+
// (`api.daemon.asCaller`), as the daemon would believe it.
|
|
56
151
|
export interface FakeDaemonCall {
|
|
57
152
|
readonly line: string;
|
|
58
153
|
readonly admitted: boolean;
|
|
154
|
+
readonly caller?: ExtensionCallerWho | undefined;
|
|
59
155
|
}
|
|
60
156
|
|
|
61
157
|
export interface FakeExtension {
|
|
62
158
|
readonly api: ExtensionServerApi;
|
|
63
159
|
readonly calls: readonly FakeDaemonCall[];
|
|
64
160
|
readonly logs: readonly string[];
|
|
161
|
+
// The labels of the work it holds now (`api.work.hold`), as the daemon counts them.
|
|
162
|
+
readonly holds: readonly string[];
|
|
163
|
+
// Every command it ran through `api.exec`, as the daemon was asked.
|
|
164
|
+
readonly execs: readonly ExtensionExec[];
|
|
165
|
+
// (2026-11-26) Every row it wrote in the activity feed (`api.activity.append`), as the daemon took it.
|
|
166
|
+
readonly activities: readonly ExtensionActivity[];
|
|
167
|
+
// (2026-11-26) Every call that reached the turn's browser and the owner's, and every job its tools started.
|
|
168
|
+
readonly browserCalls: readonly FakeBrowserCall[];
|
|
169
|
+
readonly ownerBrowserCalls: readonly FakeOwnerBrowserCall[];
|
|
170
|
+
readonly jobs: readonly FakeJob[];
|
|
171
|
+
// (2026-11-27) Hosted sleep (`api.sleep`): `now()` tells every before-sleep watch and resolves with how many answered
|
|
172
|
+
// ready, `boot` is what `api.sleep.boot()` answers, and `wakeUrls` every URL handed out (sleep-fake.ts).
|
|
173
|
+
readonly sleep: Omit<FakeSleep, "door">;
|
|
174
|
+
// (2026-11-26) The job's end once its work told it, as `wait` hands it to the agent.
|
|
175
|
+
jobEnd(id: string): Promise<JobEnd>;
|
|
176
|
+
// (2026-11-26) The agent or a person stopping the job: its work's signal aborts.
|
|
177
|
+
stopJob(id: string): void;
|
|
65
178
|
// Activates a server module as the backend host does, keeping what it hands back for `deactivate` and `health`.
|
|
66
179
|
activate(module: Partial<ExtensionServerModule> & { default?: ExtensionServerModule }): Promise<void>;
|
|
67
|
-
// A request into the extension's own /x namespace, `path` relative to it, as the daemon's proxy delivers it
|
|
68
|
-
|
|
180
|
+
// A request into the extension's own /x namespace, `path` relative to it, as the daemon's proxy delivers it: with an
|
|
181
|
+
// assertion of `options.caller` (a person signed in when absent, the owner), which `api.caller` reads.
|
|
182
|
+
route(path: string, init?: RequestInit, options?: FakeRouteOptions): Promise<Response>;
|
|
183
|
+
// A call through one of its public routes (`contributes.publicRoutes`), `path` relative to /door/<id>, as the daemon's
|
|
184
|
+
// door delivers it once its protections passed: rejects for a method and path no declared route answers, which the
|
|
185
|
+
// daemon answers 404 without the backend hearing of it. `verified` fills in or overrides what the door checked.
|
|
186
|
+
publicRoute(path: string, init?: RequestInit, verified?: Partial<PublicRouteVerification>): Promise<Response>;
|
|
69
187
|
// The tools it serves a card (undefined: the extension-level server), and one call to one of them.
|
|
70
188
|
tools(card?: ToolCard): Promise<readonly ToolDefinition[]>;
|
|
71
189
|
// Answers whatever the tool's own `call` answers, as ToolDefinition declares it; the host turns that into what the
|
|
72
|
-
// model reads.
|
|
190
|
+
// model reads. (2026-11-26) The call is handed `grants` (the context's, else the options', else none) and a ticket
|
|
191
|
+
// good while it runs, as the daemon's door hands them.
|
|
73
192
|
callTool(name: string, args?: ToolArguments, card?: ToolCard, context?: Partial<ToolCallContext>): ReturnType<ToolDefinition["call"]>;
|
|
74
193
|
// An approved action handed over as the daemon's approvals executor hands it, through the host's door.
|
|
75
194
|
perform(action: ApprovedAction, signal?: AbortSignal): Promise<ApprovedActionOutcome>;
|
|
195
|
+
// (2026-11-26) An approved post handed over as the daemon's approvals executor hands it, through the host's door:
|
|
196
|
+
// rejects when the backend publishes no posts (`api.approvals.publish`). The rest of the post is filled in.
|
|
197
|
+
publish(post: Pick<ApprovedPost, "platform" | "content" | "target"> & Partial<ApprovedPost>, signal?: AbortSignal): Promise<ApprovedActionOutcome>;
|
|
198
|
+
// An automation's fire handed to the handler it names, as the daemon's automations engine hands it through the host's
|
|
199
|
+
// door; the rest of the fire is filled in. Rejects when no handler of that name is registered, which the daemon reads
|
|
200
|
+
// as "not yet" and tries again later.
|
|
201
|
+
fire(handler: string, fire?: Partial<Omit<AutomationFire, "handler">>): Promise<void>;
|
|
202
|
+
// A watch's check handed to the handler served for its kind, as the daemon's automations engine hands it through the
|
|
203
|
+
// host's door; the rest of the check is filled in. Rejects when nothing serves the kind, which the daemon says on the
|
|
204
|
+
// automation's run as a check that could not run.
|
|
205
|
+
check(kind: string, check?: Partial<Omit<WatchCheck, "kind">>, signal?: AbortSignal): Promise<WatchCheckAnswer>;
|
|
76
206
|
// The owner changing its settings: stored, and told to the extension over its event stream as the daemon would.
|
|
77
207
|
setSettings(values: ExtensionSettingValues): void;
|
|
78
|
-
// A frame on its event stream, as the daemon sends it (`files`, `refs`, `repos`, `settings`
|
|
208
|
+
// A frame on its event stream, as the daemon sends it (`files`, `refs`, `repos`, `settings`, and `run`, `activity` and
|
|
209
|
+
// (2026-11-26) `ci`, which reach a stream only when the manifest declares them).
|
|
79
210
|
emit(event: ExtensionEvent): void;
|
|
80
211
|
// Its own account of itself, as the host reads it under the host's deadline and vocabulary.
|
|
81
212
|
health(): Promise<ExtensionHealth>;
|
|
@@ -91,6 +222,219 @@ const json = <T>(body: T, status = 200): Response => Response.json(body, { statu
|
|
|
91
222
|
const changedKeys = (before: ExtensionSettingValues, after: ExtensionSettingValues): string[] =>
|
|
92
223
|
[...new Set([...Object.keys(before), ...Object.keys(after)])].filter((key) => before[key] !== after[key]).toSorted();
|
|
93
224
|
|
|
225
|
+
// The owner, signed in: who a fake request into /x comes from unless the test says otherwise.
|
|
226
|
+
const OWNER: ExtensionCallerIdentity = { kind: "person", email: "owner@example.com", tier: "owner" };
|
|
227
|
+
|
|
228
|
+
// A caller's assertion as the daemon's proxy mints it, signed with the fake's own word in place of the daemon's key: the
|
|
229
|
+
// fake daemon believes only those it minted.
|
|
230
|
+
const fakeAssertion = (claim: ExtensionCallerClaim): string => `${Buffer.from(JSON.stringify(claim), "utf8").toString("base64url")}.fake-daemon-signature`;
|
|
231
|
+
|
|
232
|
+
// A caller as the assertion's claim spells it: a person's lists copied, every other kind as it is.
|
|
233
|
+
const claimOf = (caller: NonNullable<FakeRouteOptions["caller"]>): ExtensionCallerIdentity => {
|
|
234
|
+
if (caller.kind !== "person") {
|
|
235
|
+
return { ...caller };
|
|
236
|
+
}
|
|
237
|
+
const { areas, folders, manages, ...person } = caller;
|
|
238
|
+
const claim: ExtensionCallerIdentity = { ...person };
|
|
239
|
+
if (areas !== undefined) {
|
|
240
|
+
claim.areas = [...areas];
|
|
241
|
+
}
|
|
242
|
+
if (folders !== undefined) {
|
|
243
|
+
claim.folders = [...folders];
|
|
244
|
+
}
|
|
245
|
+
if (manages !== undefined) {
|
|
246
|
+
claim.manages = [...manages];
|
|
247
|
+
}
|
|
248
|
+
return claim;
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
// Who an assertion the fake daemon believed says is calling, without the folders only the backend reads.
|
|
252
|
+
const callerWho = (claim: ExtensionCallerClaim | undefined): ExtensionCallerWho | undefined => {
|
|
253
|
+
if (claim === undefined) {
|
|
254
|
+
return undefined;
|
|
255
|
+
}
|
|
256
|
+
const { folders: _folders, ...who } = claim.caller.kind === "person" ? claim.caller : { ...claim.caller, folders: undefined };
|
|
257
|
+
return who;
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
// ---- the turn a tool's call stands on (2026-11-26) ------------------------------------------------------------------
|
|
261
|
+
|
|
262
|
+
// What a ticket stands for: the grants of the call it was minted for, its conversation, and the job it is, if one.
|
|
263
|
+
interface FakeStanding {
|
|
264
|
+
readonly grants: ToolCallGrants;
|
|
265
|
+
readonly conversationId?: string | undefined;
|
|
266
|
+
readonly job?: string | undefined;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// A host as an account's site is matched: lowercased, `www.` dropped; a site's subdomain is on it.
|
|
270
|
+
const onSites = (url: string, sites: readonly string[]): boolean => {
|
|
271
|
+
const host = URL.parse(url)?.hostname.toLowerCase().replace(/^www\./u, "");
|
|
272
|
+
return host !== undefined && host !== "" && sites.some((site) => host === site || host.endsWith(`.${site}`));
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
const EMPTY_RESULT: ToolResult = { content: [] };
|
|
276
|
+
const BROWSER_TOOLS: ReadonlySet<string> = new Set(EXTENSION_BROWSER_TOOLS);
|
|
277
|
+
|
|
278
|
+
// A job as the fake daemon runs it: its record, its stream's controller, and who waits on its end.
|
|
279
|
+
interface RunningFakeJob {
|
|
280
|
+
record: FakeJob;
|
|
281
|
+
readonly stream: ReadableStreamDefaultController<Uint8Array>;
|
|
282
|
+
readonly ended: PromiseWithResolvers<JobEnd>;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// The url a navigation names, when it names one.
|
|
286
|
+
const navigationUrl = (args: ToolArguments | undefined): string | undefined => ExtensionNavigateArgumentsSchema.safeParse(args).data?.url;
|
|
287
|
+
|
|
288
|
+
// The daemon's turn doors, judged as it judges them (extensions/turn/tool-turn-doors.ts): the declared power, a live
|
|
289
|
+
// ticket, the grants it stands for, and for an account's browser the page tools and the account's sites; a job filed in
|
|
290
|
+
// the call's conversation, begun at once (no lane waits here), its lines and end kept.
|
|
291
|
+
const fakeTurn = (options: FakeExtensionOptions, declared: readonly string[]) => {
|
|
292
|
+
const tickets = new Map<string, FakeStanding>();
|
|
293
|
+
const browserCalls: FakeBrowserCall[] = [];
|
|
294
|
+
const ownerBrowserCalls: FakeOwnerBrowserCall[] = [];
|
|
295
|
+
const jobs = new Map<string, RunningFakeJob>();
|
|
296
|
+
const encoder = new TextEncoder();
|
|
297
|
+
let minted = 0;
|
|
298
|
+
const mint = (standing: FakeStanding) => {
|
|
299
|
+
minted += 1;
|
|
300
|
+
const ticket = `fake-ticket-${minted}`;
|
|
301
|
+
tickets.set(ticket, standing);
|
|
302
|
+
return { ticket, release: () => void tickets.delete(ticket) };
|
|
303
|
+
};
|
|
304
|
+
// The standing behind a request, or the refusal the daemon answers with.
|
|
305
|
+
const standingOf = (power: string, ticket: string): FakeStanding | Response => {
|
|
306
|
+
if (!declared.includes(power)) {
|
|
307
|
+
return json({ error: `"${power}" is not declared in permissions.turn` }, 403);
|
|
308
|
+
}
|
|
309
|
+
return tickets.get(ticket) ?? json({ error: "no call of this extension's tools, nor a job one started, is running under that ticket" }, 403);
|
|
310
|
+
};
|
|
311
|
+
const browserCall = async (request: Request): Promise<Response> => {
|
|
312
|
+
const asked = ExtensionBrowserCallSchema.parse(await request.json());
|
|
313
|
+
const standing = standingOf("browser", asked.turn);
|
|
314
|
+
if (standing instanceof Response) {
|
|
315
|
+
return standing;
|
|
316
|
+
}
|
|
317
|
+
const account = standing.grants.accounts.find((held) => held.id === asked.account);
|
|
318
|
+
if (account === undefined) {
|
|
319
|
+
return json({ error: `the turn that made this call holds no account "${asked.account}"` }, 403);
|
|
320
|
+
}
|
|
321
|
+
if (!BROWSER_TOOLS.has(asked.tool)) {
|
|
322
|
+
return json({ error: `${asked.tool} is not a browser tool an extension may call` }, 403);
|
|
323
|
+
}
|
|
324
|
+
const url = navigationUrl(asked.arguments);
|
|
325
|
+
if (asked.tool === "browser_navigate" && (url === undefined || !onSites(url, account.sites))) {
|
|
326
|
+
return json({ error: `account "${account.id}" signs in on ${account.sites.join(" or ")}; that url is not on them` }, 403);
|
|
327
|
+
}
|
|
328
|
+
const call: FakeBrowserCall = { account: account.id, tool: asked.tool, args: asked.arguments ?? {}, conversationId: standing.conversationId };
|
|
329
|
+
browserCalls.push(call);
|
|
330
|
+
return json({ result: (await options.browser?.(call)) ?? EMPTY_RESULT });
|
|
331
|
+
};
|
|
332
|
+
const ownerBrowserCall = async (request: Request): Promise<Response> => {
|
|
333
|
+
const asked = ExtensionOwnerBrowserCallSchema.parse(await request.json());
|
|
334
|
+
const standing = standingOf("owner-browser", asked.turn);
|
|
335
|
+
if (standing instanceof Response) {
|
|
336
|
+
return standing;
|
|
337
|
+
}
|
|
338
|
+
if (!standing.grants.browsers.includes(asked.browser)) {
|
|
339
|
+
return json({ error: `the turn that made this call holds no browser of the owner's called "${asked.browser}"` }, 403);
|
|
340
|
+
}
|
|
341
|
+
const call: FakeOwnerBrowserCall = { browser: asked.browser, tool: asked.tool, args: asked.arguments ?? {}, conversationId: standing.conversationId };
|
|
342
|
+
ownerBrowserCalls.push(call);
|
|
343
|
+
return json({ result: (await options.ownerBrowser?.(call)) ?? EMPTY_RESULT });
|
|
344
|
+
};
|
|
345
|
+
const frame = (job: RunningFakeJob, body: Readonly<Record<string, string | number>>): void => {
|
|
346
|
+
try {
|
|
347
|
+
job.stream.enqueue(encoder.encode(`${JSON.stringify(body)}\n`));
|
|
348
|
+
} catch {
|
|
349
|
+
// allow(silent-catch): a stream the extension already let go of takes no more frames
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
const close = (job: RunningFakeJob): void => {
|
|
353
|
+
try {
|
|
354
|
+
job.stream.close();
|
|
355
|
+
} catch {
|
|
356
|
+
// allow(silent-catch): already closed by the extension's side, which is the state being reached
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
const startJob = async (request: Request): Promise<Response> => {
|
|
360
|
+
const asked = ExtensionJobStartSchema.parse(await request.json());
|
|
361
|
+
const standing = standingOf("jobs", asked.turn);
|
|
362
|
+
if (standing instanceof Response) {
|
|
363
|
+
return standing;
|
|
364
|
+
}
|
|
365
|
+
if (standing.conversationId === undefined) {
|
|
366
|
+
return json({ error: "the turn that made this call has no conversation to file a job in" }, 409);
|
|
367
|
+
}
|
|
368
|
+
const id = `job-${jobs.size + 1}`;
|
|
369
|
+
const ticket = mint({ ...standing, job: id });
|
|
370
|
+
const record: FakeJob = { id, conversationId: standing.conversationId, command: asked.command, description: asked.description, lane: asked.lane, lines: [], stopped: false };
|
|
371
|
+
const body = new ReadableStream<Uint8Array>({
|
|
372
|
+
start: (stream) => {
|
|
373
|
+
const job: RunningFakeJob = { record, stream, ended: Promise.withResolvers<JobEnd>() };
|
|
374
|
+
jobs.set(id, job);
|
|
375
|
+
void job.ended.promise.then(() => ticket.release());
|
|
376
|
+
frame(job, { kind: "filed", id, job: ticket.ticket, ahead: 0 });
|
|
377
|
+
frame(job, { kind: "begin" });
|
|
378
|
+
},
|
|
379
|
+
});
|
|
380
|
+
return new Response(body, { headers: { "content-type": "application/x-ndjson" } });
|
|
381
|
+
};
|
|
382
|
+
const reportJob = async (request: Request, id: string): Promise<Response> => {
|
|
383
|
+
const asked = ExtensionJobReportSchema.parse(await request.json());
|
|
384
|
+
const standing = standingOf("jobs", asked.job);
|
|
385
|
+
const job = jobs.get(id);
|
|
386
|
+
if (standing instanceof Response || standing.job !== id || job === undefined) {
|
|
387
|
+
return json({ error: `no job "${id}" of this extension is running under that ticket` }, 404);
|
|
388
|
+
}
|
|
389
|
+
if (asked.say !== undefined) {
|
|
390
|
+
job.record = { ...job.record, lines: [...job.record.lines, asked.say] };
|
|
391
|
+
}
|
|
392
|
+
if (asked.end !== undefined && job.record.end === undefined) {
|
|
393
|
+
job.record = { ...job.record, end: asked.end };
|
|
394
|
+
job.ended.resolve(asked.end);
|
|
395
|
+
close(job);
|
|
396
|
+
}
|
|
397
|
+
return json({ ok: true });
|
|
398
|
+
};
|
|
399
|
+
const jobsPath = extensionJobsUrl();
|
|
400
|
+
return {
|
|
401
|
+
mint,
|
|
402
|
+
browserCalls,
|
|
403
|
+
ownerBrowserCalls,
|
|
404
|
+
jobs: (): FakeJob[] => [...jobs.values()].map((job) => job.record),
|
|
405
|
+
door: async (request: Request, url: URL): Promise<Response | undefined> => {
|
|
406
|
+
if (url.pathname === extensionBrowserUrl()) {
|
|
407
|
+
return await browserCall(request);
|
|
408
|
+
}
|
|
409
|
+
if (url.pathname === extensionOwnerBrowserUrl()) {
|
|
410
|
+
return await ownerBrowserCall(request);
|
|
411
|
+
}
|
|
412
|
+
if (url.pathname === jobsPath) {
|
|
413
|
+
return await startJob(request);
|
|
414
|
+
}
|
|
415
|
+
return url.pathname.startsWith(`${jobsPath}/`) ? await reportJob(request, decodeURIComponent(url.pathname.slice(jobsPath.length + 1))) : undefined;
|
|
416
|
+
},
|
|
417
|
+
jobEnd: async (id: string): Promise<JobEnd> => {
|
|
418
|
+
const job = jobs.get(id);
|
|
419
|
+
if (job === undefined) {
|
|
420
|
+
throw new Error(`no job "${id}" was started`);
|
|
421
|
+
}
|
|
422
|
+
return await job.ended.promise;
|
|
423
|
+
},
|
|
424
|
+
stopJob: (id: string): void => {
|
|
425
|
+
const job = jobs.get(id);
|
|
426
|
+
if (job === undefined || job.record.end !== undefined) {
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
const end: JobEnd = { ok: false, output: "stopped" };
|
|
430
|
+
job.record = { ...job.record, stopped: true, end };
|
|
431
|
+
frame(job, { kind: "stopped" });
|
|
432
|
+
job.ended.resolve(end);
|
|
433
|
+
close(job);
|
|
434
|
+
},
|
|
435
|
+
};
|
|
436
|
+
};
|
|
437
|
+
|
|
94
438
|
export const fakeExtensionApi = async (options: FakeExtensionOptions): Promise<FakeExtension> => {
|
|
95
439
|
const made: string[] = [];
|
|
96
440
|
const dirOf = async (given: string | undefined, label: string): Promise<string> => {
|
|
@@ -104,8 +448,14 @@ export const fakeExtensionApi = async (options: FakeExtensionOptions): Promise<F
|
|
|
104
448
|
const workspaceRoot = await dirOf(options.workspaceRoot, "workspace");
|
|
105
449
|
const id = `${options.manifest.publisher}.${options.manifest.name}`;
|
|
106
450
|
const reach: ExtensionReach = { permissions: options.manifest.permissions?.daemon ?? [], listener: options.manifest.contributes?.listener?.provider };
|
|
451
|
+
const declared = declaredReachOf(options.manifest.permissions);
|
|
107
452
|
const calls: FakeDaemonCall[] = [];
|
|
108
453
|
const logs: string[] = [];
|
|
454
|
+
const holds = new Map<symbol, string>();
|
|
455
|
+
const execs: ExtensionExec[] = [];
|
|
456
|
+
const activities: ExtensionActivity[] = [];
|
|
457
|
+
const turn = fakeTurn(options, declared.turn);
|
|
458
|
+
const sleeping = fakeSleep(id, options.manifest.contributes?.publicRoutes ?? []);
|
|
109
459
|
let settings: ExtensionSettingValues = { ...options.settings };
|
|
110
460
|
// Every event stream the extension holds open, each written to by `emit`. A frame sent while none is open waits for
|
|
111
461
|
// the next one: the runtime opens its stream a moment after the first listener registers, and a test that listens
|
|
@@ -131,6 +481,56 @@ export const fakeExtensionApi = async (options: FakeExtensionOptions): Promise<F
|
|
|
131
481
|
}
|
|
132
482
|
};
|
|
133
483
|
|
|
484
|
+
// A hold stands while its answer is open, as the daemon's does: a heartbeat at once, then nothing until let go.
|
|
485
|
+
const holdStream = (label: string, signal: AbortSignal | null): Response => {
|
|
486
|
+
const key = Symbol(label);
|
|
487
|
+
holds.set(key, label);
|
|
488
|
+
const release = (): void => void holds.delete(key);
|
|
489
|
+
signal?.addEventListener("abort", release);
|
|
490
|
+
const body = new ReadableStream<Uint8Array>({
|
|
491
|
+
start: (controller) => controller.enqueue(encoder.encode(`${JSON.stringify({ kind: "heartbeat" })}\n`)),
|
|
492
|
+
cancel: release,
|
|
493
|
+
});
|
|
494
|
+
return new Response(body, { headers: { "content-type": "application/x-ndjson" } });
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
// The extension's own doors, judged by what its manifest declares as the daemon judges them (own.routes.ts,
|
|
498
|
+
// own-doors.ts); undefined for a request that is for none of them.
|
|
499
|
+
const ownDoor = async (request: Request, url: URL, signal: AbortSignal | null): Promise<Response | undefined> => {
|
|
500
|
+
if (request.method === "GET" && url.pathname === extensionSettingsUrl()) {
|
|
501
|
+
return json({ settings });
|
|
502
|
+
}
|
|
503
|
+
if (request.method === "GET" && url.pathname === extensionEventsUrl()) {
|
|
504
|
+
const asked = (url.searchParams.get(EXTENSION_EVENTS_KINDS_PARAM) ?? "").split(",").filter((kind) => kind !== "");
|
|
505
|
+
const refused = asked.find((kind) => !declared.events.some((each) => each === kind));
|
|
506
|
+
return refused === undefined ? eventStream(signal) : json({ error: `the event kind "${refused}" is not declared in permissions.events` }, 403);
|
|
507
|
+
}
|
|
508
|
+
if (request.method === "POST" && url.pathname === extensionWorkHoldUrl()) {
|
|
509
|
+
const hold = ExtensionWorkHoldSchema.safeParse(await request.json());
|
|
510
|
+
if (!declared.work || !hold.success) {
|
|
511
|
+
return json({ error: declared.work ? "a hold carries { label }" : "permissions.work is not declared" }, declared.work ? 400 : 403);
|
|
512
|
+
}
|
|
513
|
+
return holdStream(hold.data.label, signal);
|
|
514
|
+
}
|
|
515
|
+
if (request.method === "POST" && url.pathname === extensionExecUrl()) {
|
|
516
|
+
const command = ExtensionExecSchema.parse(await request.json());
|
|
517
|
+
if (!declared.exec.includes(command.class)) {
|
|
518
|
+
return json({ error: `the workload class "${command.class}" is not declared in permissions.exec` }, 403);
|
|
519
|
+
}
|
|
520
|
+
execs.push(command);
|
|
521
|
+
return json((await options.exec?.(command)) ?? { waitedMs: 0, exitCode: 0, stdout: "", stderr: "", truncated: false });
|
|
522
|
+
}
|
|
523
|
+
if (request.method === "POST" && url.pathname === extensionActivityUrl()) {
|
|
524
|
+
const row = ExtensionActivitySchema.safeParse(await request.json());
|
|
525
|
+
if (!row.success) {
|
|
526
|
+
return json({ error: `not an activity row: ${row.error.issues[0]?.message ?? "the body does not parse"}` }, 400);
|
|
527
|
+
}
|
|
528
|
+
activities.push(row.data);
|
|
529
|
+
return json({ ok: true });
|
|
530
|
+
}
|
|
531
|
+
return (await sleeping.door(request, url, signal)) ?? (request.method === "POST" ? await turn.door(request, url) : undefined);
|
|
532
|
+
};
|
|
533
|
+
|
|
134
534
|
const eventStream = (signal: AbortSignal | null): Response => {
|
|
135
535
|
let held: ReadableStreamDefaultController<Uint8Array> | undefined;
|
|
136
536
|
const body = new ReadableStream<Uint8Array>({
|
|
@@ -157,6 +557,17 @@ export const fakeExtensionApi = async (options: FakeExtensionOptions): Promise<F
|
|
|
157
557
|
};
|
|
158
558
|
|
|
159
559
|
// The daemon's side of the wire: the token checked, the reach judged, then the extension's own routes or the test's.
|
|
560
|
+
// The assertions minted for this extension's requests, which alone the fake daemon believes, as the daemon believes
|
|
561
|
+
// only its own key's.
|
|
562
|
+
const minted = new Set<string>();
|
|
563
|
+
const believed = (assertion: string | null): ExtensionCallerClaim | "refused" | undefined => {
|
|
564
|
+
if (assertion === null || assertion === "") {
|
|
565
|
+
return undefined;
|
|
566
|
+
}
|
|
567
|
+
const claim = readCallerClaim(assertion);
|
|
568
|
+
return claim === undefined || !minted.has(assertion) || claim.extension !== id || Date.now() >= claim.expiresAt ? "refused" : claim;
|
|
569
|
+
};
|
|
570
|
+
|
|
160
571
|
const daemon = async (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {
|
|
161
572
|
const request = new Request(input, init);
|
|
162
573
|
const url = new URL(request.url);
|
|
@@ -166,17 +577,16 @@ export const fakeExtensionApi = async (options: FakeExtensionOptions): Promise<F
|
|
|
166
577
|
return json({ error: "unauthorized" }, 401);
|
|
167
578
|
}
|
|
168
579
|
const admitted = extensionRouteReach(reach, request.method, url.pathname);
|
|
169
|
-
|
|
580
|
+
const claim = believed(request.headers.get(EXTENSION_CALLER_HEADER));
|
|
581
|
+
if (claim === "refused") {
|
|
582
|
+
calls.push({ line, admitted: false });
|
|
583
|
+
return json({ error: "the caller assertion was not minted for this extension by this daemon, or is past its window" }, 401);
|
|
584
|
+
}
|
|
585
|
+
calls.push({ line, admitted, caller: callerWho(claim) });
|
|
170
586
|
if (!admitted) {
|
|
171
587
|
return json({ error: "extension token not valid for this route" }, 403);
|
|
172
588
|
}
|
|
173
|
-
|
|
174
|
-
return json({ settings });
|
|
175
|
-
}
|
|
176
|
-
if (request.method === "GET" && url.pathname === extensionEventsUrl()) {
|
|
177
|
-
return eventStream(init?.signal ?? null);
|
|
178
|
-
}
|
|
179
|
-
return (await options.daemon?.(request)) ?? json({ error: "not found" }, 404);
|
|
589
|
+
return (await ownDoor(request, url, init?.signal ?? null)) ?? (await options.daemon?.(request)) ?? json({ error: "not found" }, 404);
|
|
180
590
|
};
|
|
181
591
|
|
|
182
592
|
const slots = createServerApi({
|
|
@@ -190,6 +600,8 @@ export const fakeExtensionApi = async (options: FakeExtensionOptions): Promise<F
|
|
|
190
600
|
cacheDir: await dirOf(options.cacheDir, "cache"),
|
|
191
601
|
log: (message) => logs.push(message),
|
|
192
602
|
fetch: daemon,
|
|
603
|
+
declared,
|
|
604
|
+
watchKinds: (options.manifest.contributes?.watchKinds ?? []).map((kind) => kind.id),
|
|
193
605
|
});
|
|
194
606
|
let activation: ServerActivation = {};
|
|
195
607
|
|
|
@@ -197,15 +609,56 @@ export const fakeExtensionApi = async (options: FakeExtensionOptions): Promise<F
|
|
|
197
609
|
api: slots.api,
|
|
198
610
|
calls,
|
|
199
611
|
logs,
|
|
612
|
+
get holds() {
|
|
613
|
+
return [...holds.values()];
|
|
614
|
+
},
|
|
615
|
+
execs,
|
|
616
|
+
activities,
|
|
617
|
+
browserCalls: turn.browserCalls,
|
|
618
|
+
ownerBrowserCalls: turn.ownerBrowserCalls,
|
|
619
|
+
get jobs() {
|
|
620
|
+
return turn.jobs();
|
|
621
|
+
},
|
|
622
|
+
sleep: sleeping,
|
|
623
|
+
jobEnd: turn.jobEnd,
|
|
624
|
+
stopJob: turn.stopJob,
|
|
200
625
|
activate: async (module) => {
|
|
201
626
|
activation = await activateServerModule(module, slots.api, { extensionId: id });
|
|
202
627
|
},
|
|
203
|
-
route: async (path, init) => {
|
|
628
|
+
route: async (path, init, routeOptions = {}) => {
|
|
204
629
|
const handler = slots.handler();
|
|
205
630
|
if (handler === undefined) {
|
|
206
631
|
return json({ error: `the "${id}" backend serves no routes` }, 404);
|
|
207
632
|
}
|
|
208
|
-
|
|
633
|
+
const issuedAt = Date.now() - (routeOptions.mintedAgoMs ?? 0);
|
|
634
|
+
const assertion = fakeAssertion({
|
|
635
|
+
v: 1,
|
|
636
|
+
sandbox: "fake",
|
|
637
|
+
extension: id,
|
|
638
|
+
issuedAt,
|
|
639
|
+
expiresAt: issuedAt + EXTENSION_CALLER_TTL_MS,
|
|
640
|
+
nonce: `${minted.size}`,
|
|
641
|
+
caller: claimOf(routeOptions.caller ?? OWNER),
|
|
642
|
+
});
|
|
643
|
+
minted.add(assertion);
|
|
644
|
+
const headers = new Headers(init?.headers);
|
|
645
|
+
headers.set(EXTENSION_CALLER_HEADER, assertion);
|
|
646
|
+
return (await handler(new Request(new URL(path, "http://extension.internal"), { ...init, headers }))) ?? json({ error: "not found" }, 404);
|
|
647
|
+
},
|
|
648
|
+
publicRoute: async (path, init, verified = {}) => {
|
|
649
|
+
const handler = slots.publicHandler();
|
|
650
|
+
if (handler === undefined) {
|
|
651
|
+
throw new Error(`"${id}" serves no public routes`);
|
|
652
|
+
}
|
|
653
|
+
const url = new URL(path, "http://extension.internal");
|
|
654
|
+
const segments = url.pathname.split("/").filter((segment) => segment !== "");
|
|
655
|
+
const method = init?.method ?? "GET";
|
|
656
|
+
const landed = publicRouteFor(options.manifest.contributes?.publicRoutes ?? [], method, segments);
|
|
657
|
+
if (landed === undefined) {
|
|
658
|
+
throw new Error(`"${id}" declares no public route answering ${method} ${url.pathname}: the daemon answers 404 before the backend hears of it`);
|
|
659
|
+
}
|
|
660
|
+
const verification: PublicRouteVerification = { route: landed.path, at: Date.now(), automationId: publicRouteAutomationOf(landed, segments), ...verified };
|
|
661
|
+
return (await handler(new Request(url, init), verification)) ?? json({ error: "not found" }, 404);
|
|
209
662
|
},
|
|
210
663
|
tools: async (card) => (await slots.tools()?.(card)) ?? [],
|
|
211
664
|
callTool: async (name, args = {}, card, context = {}) => {
|
|
@@ -213,7 +666,13 @@ export const fakeExtensionApi = async (options: FakeExtensionOptions): Promise<F
|
|
|
213
666
|
if (tool === undefined) {
|
|
214
667
|
throw new Error(`"${id}" serves no tool named ${name}${card === undefined ? "" : ` for card ${card.id}`}`);
|
|
215
668
|
}
|
|
216
|
-
|
|
669
|
+
const grants = context.grants ?? options.grants ?? NO_TOOL_GRANTS;
|
|
670
|
+
const standing = turn.mint({ grants, conversationId: context.conversationId });
|
|
671
|
+
try {
|
|
672
|
+
return await tool.call(args, { signal: context.signal ?? new AbortController().signal, conversationId: context.conversationId, grants, ticket: standing.ticket });
|
|
673
|
+
} finally {
|
|
674
|
+
standing.release();
|
|
675
|
+
}
|
|
217
676
|
},
|
|
218
677
|
perform: async (action, signal = new AbortController().signal) => {
|
|
219
678
|
const performer = slots.performer();
|
|
@@ -222,6 +681,30 @@ export const fakeExtensionApi = async (options: FakeExtensionOptions): Promise<F
|
|
|
222
681
|
}
|
|
223
682
|
return performer(action, { signal });
|
|
224
683
|
},
|
|
684
|
+
publish: async (post, signal = new AbortController().signal) => {
|
|
685
|
+
const publisher = slots.publisher();
|
|
686
|
+
if (publisher === undefined) {
|
|
687
|
+
throw new Error(`"${id}" publishes no approved posts`);
|
|
688
|
+
}
|
|
689
|
+
return publisher({ id: `post-${Date.now()}`, approvedAt: Date.now(), actionRules: {}, ...post }, { signal });
|
|
690
|
+
},
|
|
691
|
+
fire: async (handler, fire = {}) => {
|
|
692
|
+
const listener = slots.fireHandler(handler);
|
|
693
|
+
if (listener === undefined) {
|
|
694
|
+
throw new Error(`"${id}" has registered no "${handler}" fire handler`);
|
|
695
|
+
}
|
|
696
|
+
await listener(
|
|
697
|
+
{ id: fire.id ?? `fire-${Date.now()}`, automationId: fire.automationId ?? "test-automation", firedAt: fire.firedAt ?? Date.now(), coalesced: fire.coalesced ?? 0, prompt: fire.prompt ?? "", payload: fire.payload, observed: fire.observed, handler },
|
|
698
|
+
{ signal: new AbortController().signal },
|
|
699
|
+
);
|
|
700
|
+
},
|
|
701
|
+
check: async (kind, check = {}, signal = new AbortController().signal) => {
|
|
702
|
+
const handler = slots.checkHandler(kind);
|
|
703
|
+
if (handler === undefined) {
|
|
704
|
+
throw new Error(`"${id}" serves no "${kind}" watch kind`);
|
|
705
|
+
}
|
|
706
|
+
return handler({ kind, params: check.params ?? {}, last: check.last, reach: check.reach ?? {}, automationId: check.automationId }, { signal });
|
|
707
|
+
},
|
|
225
708
|
setSettings: (values) => {
|
|
226
709
|
const keys = changedKeys(settings, values);
|
|
227
710
|
settings = { ...values };
|