@omniaura/scenario-sim 0.1.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 +118 -0
- package/dist/browser.d.ts +81 -0
- package/dist/browser.js +303 -0
- package/dist/browser.js.map +1 -0
- package/dist/chunk-44ZHRYG6.js +959 -0
- package/dist/chunk-44ZHRYG6.js.map +1 -0
- package/dist/chunk-7FWVWBX6.js +380 -0
- package/dist/chunk-7FWVWBX6.js.map +1 -0
- package/dist/chunk-7HBAY3QY.js +133 -0
- package/dist/chunk-7HBAY3QY.js.map +1 -0
- package/dist/chunk-KU4W4SKO.js +1236 -0
- package/dist/chunk-KU4W4SKO.js.map +1 -0
- package/dist/cli.js +131 -0
- package/dist/cli.js.map +1 -0
- package/dist/engine-2w32ngB2.d.ts +897 -0
- package/dist/engine-HE7MEQHD.js +15 -0
- package/dist/engine-HE7MEQHD.js.map +1 -0
- package/dist/examples.d.ts +38 -0
- package/dist/examples.js +233 -0
- package/dist/examples.js.map +1 -0
- package/dist/index.d.ts +322 -0
- package/dist/index.js +61 -0
- package/dist/index.js.map +1 -0
- package/dist/pulse.d.ts +40 -0
- package/dist/pulse.js +80 -0
- package/dist/pulse.js.map +1 -0
- package/dist/scenario--CvzkzX_.d.ts +637 -0
- package/dist/server.d.ts +29 -0
- package/dist/server.js +14 -0
- package/dist/server.js.map +1 -0
- package/dist/vite.d.ts +27 -0
- package/dist/vite.js +48 -0
- package/dist/vite.js.map +1 -0
- package/package.json +91 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Simulator,
|
|
3
|
+
UPGRADED_HEADER,
|
|
4
|
+
isUpgraded,
|
|
5
|
+
matchPath,
|
|
6
|
+
upgradedResponse
|
|
7
|
+
} from "./chunk-7FWVWBX6.js";
|
|
8
|
+
import {
|
|
9
|
+
FaultLayer,
|
|
10
|
+
Rng,
|
|
11
|
+
Run,
|
|
12
|
+
Store,
|
|
13
|
+
StreamHub,
|
|
14
|
+
TopicLog,
|
|
15
|
+
VIRTUAL_EPOCH,
|
|
16
|
+
VirtualClock,
|
|
17
|
+
compileRoute,
|
|
18
|
+
crud,
|
|
19
|
+
defineScenario,
|
|
20
|
+
delayed,
|
|
21
|
+
empty,
|
|
22
|
+
json,
|
|
23
|
+
malformed,
|
|
24
|
+
problem,
|
|
25
|
+
route,
|
|
26
|
+
sequence,
|
|
27
|
+
sse,
|
|
28
|
+
statusText,
|
|
29
|
+
text,
|
|
30
|
+
ws
|
|
31
|
+
} from "./chunk-44ZHRYG6.js";
|
|
32
|
+
export {
|
|
33
|
+
FaultLayer,
|
|
34
|
+
Rng,
|
|
35
|
+
Run,
|
|
36
|
+
Simulator,
|
|
37
|
+
Store,
|
|
38
|
+
StreamHub,
|
|
39
|
+
TopicLog,
|
|
40
|
+
UPGRADED_HEADER,
|
|
41
|
+
VIRTUAL_EPOCH,
|
|
42
|
+
VirtualClock,
|
|
43
|
+
compileRoute,
|
|
44
|
+
crud,
|
|
45
|
+
defineScenario,
|
|
46
|
+
delayed,
|
|
47
|
+
empty,
|
|
48
|
+
isUpgraded,
|
|
49
|
+
json,
|
|
50
|
+
malformed,
|
|
51
|
+
matchPath,
|
|
52
|
+
problem,
|
|
53
|
+
route,
|
|
54
|
+
sequence,
|
|
55
|
+
sse,
|
|
56
|
+
statusText,
|
|
57
|
+
text,
|
|
58
|
+
upgradedResponse,
|
|
59
|
+
ws
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/pulse.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Simulator } from './index.js';
|
|
2
|
+
import './scenario--CvzkzX_.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @omniaura/scenario-sim/pulse — expose the simulator's control plane as
|
|
6
|
+
* `scenario.*` commands on a solid-pulse controller, so the panel's Scenarios
|
|
7
|
+
* tab and the `solid-pulse` CLI drive exactly the same operations. Works with
|
|
8
|
+
* an in-process Simulator (browser adapter) or a remote control URL (server /
|
|
9
|
+
* Vite adapter).
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
interface ControllerLike {
|
|
13
|
+
register(spec: {
|
|
14
|
+
name: string;
|
|
15
|
+
summary: string;
|
|
16
|
+
args?: Record<string, string>;
|
|
17
|
+
ui?: string;
|
|
18
|
+
}, handler: (args: Record<string, unknown>) => unknown | Promise<unknown>): void;
|
|
19
|
+
unregister(name: string): void;
|
|
20
|
+
has(name: string): boolean;
|
|
21
|
+
}
|
|
22
|
+
interface PulseLike {
|
|
23
|
+
controller: ControllerLike;
|
|
24
|
+
bus: {
|
|
25
|
+
emit(kind: string, data: Record<string, unknown>): unknown;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
type ScenarioClient = {
|
|
29
|
+
kind: "local";
|
|
30
|
+
sim: Simulator;
|
|
31
|
+
run?: string;
|
|
32
|
+
} | {
|
|
33
|
+
kind: "remote";
|
|
34
|
+
controlUrl: string;
|
|
35
|
+
run?: string;
|
|
36
|
+
fetch?: typeof fetch;
|
|
37
|
+
};
|
|
38
|
+
declare function attachScenarioCommands(pulse: PulseLike, client: ScenarioClient): () => void;
|
|
39
|
+
|
|
40
|
+
export { type ScenarioClient, attachScenarioCommands };
|
package/dist/pulse.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// src/pulse.ts
|
|
2
|
+
var UI = "Scenarios tab";
|
|
3
|
+
function attachScenarioCommands(pulse, client) {
|
|
4
|
+
const runOf = (a) => a.run === void 0 ? client.run : String(a.run);
|
|
5
|
+
const remote = async (method, route, body, query) => {
|
|
6
|
+
if (client.kind !== "remote") throw new Error("remote call on a local client");
|
|
7
|
+
const f = client.fetch ?? fetch;
|
|
8
|
+
const url = new URL(`${client.controlUrl}${route}`);
|
|
9
|
+
for (const [k, v] of Object.entries(query ?? {})) if (v !== void 0 && v !== null) url.searchParams.set(k, String(v));
|
|
10
|
+
const res = await f(url, { method, headers: { "content-type": "application/json" }, body: body ? JSON.stringify(body) : void 0 });
|
|
11
|
+
const text = await res.text();
|
|
12
|
+
const parsed = text ? JSON.parse(text) : {};
|
|
13
|
+
if (!res.ok) throw new Error(String(parsed.detail ?? parsed.error ?? `${res.status}`));
|
|
14
|
+
return parsed;
|
|
15
|
+
};
|
|
16
|
+
const local = () => client.kind === "local" ? client.sim.api : null;
|
|
17
|
+
const num = (v, d) => v === void 0 || v === null || v === "" ? d : Number(v);
|
|
18
|
+
const parseJson = (v) => typeof v === "string" && /^[[{]/.test(v.trim()) ? JSON.parse(v) : v;
|
|
19
|
+
const commands = [
|
|
20
|
+
[{ name: "scenario.list", summary: "Scenarios the simulator knows.", ui: UI }, async () => local()?.scenarios() ?? (await remote("GET", "/scenarios")).scenarios],
|
|
21
|
+
[{ name: "scenario.status", summary: "Run status: scenario, seed, clock, state counts, streams, faults, routes.", args: { run: "run id" }, ui: UI }, async (a) => local()?.status(runOf(a)) ?? remote("GET", "/status", void 0, { run: runOf(a) })],
|
|
22
|
+
[{ name: "scenario.select", summary: "Bind the run to a scenario with fresh state.", args: { name: "scenario name", seed: "optional seed", run: "run id" }, ui: UI }, async (a) => {
|
|
23
|
+
const name = String(a.name ?? "");
|
|
24
|
+
const seed = a.seed === void 0 ? void 0 : String(a.seed);
|
|
25
|
+
const l = local();
|
|
26
|
+
const result = l ? await l.select(runOf(a) ?? "default", name, seed) : await remote("POST", "/select", { scenario: name, seed, run: runOf(a) });
|
|
27
|
+
pulse.bus.emit("pulse.note", { note: `scenario \u2192 ${name}${seed ? ` (seed ${seed})` : ""}` });
|
|
28
|
+
return result;
|
|
29
|
+
}],
|
|
30
|
+
[{ name: "scenario.reset", summary: "Rebuild the run's scenario (same seed unless given).", args: { seed: "optional seed", run: "run id" }, ui: UI }, async (a) => {
|
|
31
|
+
const seed = a.seed === void 0 || a.seed === "" ? void 0 : String(a.seed);
|
|
32
|
+
const l = local();
|
|
33
|
+
const result = l ? await l.reset(runOf(a) ?? "default", seed) : await remote("POST", "/reset", { seed, run: runOf(a) });
|
|
34
|
+
pulse.bus.emit("pulse.note", { note: `scenario reset${seed ? ` (seed ${seed})` : ""}` });
|
|
35
|
+
return result;
|
|
36
|
+
}],
|
|
37
|
+
[{ name: "scenario.step", summary: "Advance the run's virtual clock (switches it to manual mode).", args: { ms: "milliseconds (default 1000)", run: "run id" }, ui: UI }, async (a) => local()?.step(runOf(a) ?? "default", num(a.ms, 1e3)) ?? remote("POST", "/step", { ms: num(a.ms, 1e3), run: runOf(a) })],
|
|
38
|
+
[{ name: "scenario.clock", summary: "Set clock mode/speed.", args: { mode: "manual|realtime", speed: "multiplier", run: "run id" }, ui: UI }, async (a) => {
|
|
39
|
+
const patch = { mode: a.mode, speed: a.speed === void 0 ? void 0 : Number(a.speed) };
|
|
40
|
+
return local()?.clock(runOf(a) ?? "default", patch) ?? remote("POST", "/clock", { ...patch, run: runOf(a) });
|
|
41
|
+
}],
|
|
42
|
+
[{ name: "scenario.state", summary: "Inspect the run's state store (all collections or one).", args: { collection: "collection name", run: "run id" }, ui: UI }, async (a) => local()?.state(runOf(a) ?? "default", a.collection === void 0 ? void 0 : String(a.collection)) ?? remote("GET", "/state", void 0, { run: runOf(a), collection: a.collection })],
|
|
43
|
+
[{ name: "scenario.events", summary: "Store mutation log (insert/update/remove/custom).", args: { since: "seq", limit: "max", collection: "filter", run: "run id" }, ui: UI }, async (a) => local()?.events(runOf(a) ?? "default", { since: num(a.since, 0), limit: num(a.limit, 100), collection: a.collection === void 0 ? void 0 : String(a.collection) }) ?? remote("GET", "/events", void 0, { run: runOf(a), since: a.since, limit: a.limit, collection: a.collection })],
|
|
44
|
+
[{ name: "scenario.log", summary: "Run log: requests, streams, actions.", args: { since: "seq", limit: "max", run: "run id" }, ui: UI }, async (a) => local()?.log(runOf(a) ?? "default", { since: num(a.since, 0), limit: num(a.limit, 100) }) ?? remote("GET", "/log", void 0, { run: runOf(a), since: a.since, limit: a.limit })],
|
|
45
|
+
[{ name: "scenario.streams", summary: "Open SSE/WebSocket connections and topics.", args: { run: "run id" }, ui: UI }, async (a) => local()?.streams(runOf(a) ?? "default") ?? remote("GET", "/streams", void 0, { run: runOf(a) })],
|
|
46
|
+
[{ name: "scenario.disconnect", summary: "Close or hard-drop stream connections (by id, topic, path, or all).", args: { id: "connection id", topic: "topic", path: "route path", all: "true", drop: "true = no close frame", code: "close code", reason: "text", run: "run id" }, ui: UI }, async (a) => {
|
|
47
|
+
const target = { id: a.id, topic: a.topic, path: a.path, all: a.all === true || a.all === "true" };
|
|
48
|
+
const opts = { code: a.code === void 0 ? void 0 : Number(a.code), reason: a.reason, drop: a.drop === true || a.drop === "true" };
|
|
49
|
+
return local()?.disconnect(runOf(a) ?? "default", target, opts) ?? remote("POST", "/streams/disconnect", { ...target, ...opts, run: runOf(a) });
|
|
50
|
+
}],
|
|
51
|
+
[{ name: "scenario.publish", summary: "Publish an event to a topic by hand.", args: { topic: "topic", data: "JSON object", run: "run id" }, ui: UI }, async (a) => {
|
|
52
|
+
const data = parseJson(a.data) ?? {};
|
|
53
|
+
return local()?.publish(runOf(a) ?? "default", String(a.topic), data) ?? remote("POST", "/publish", { topic: a.topic, data, run: runOf(a) });
|
|
54
|
+
}],
|
|
55
|
+
[{ name: "scenario.overrides", summary: "List endpoint overrides.", args: { run: "run id" }, ui: UI }, async (a) => local()?.overrides(runOf(a) ?? "default") ?? remote("GET", "/overrides", void 0, { run: runOf(a) })],
|
|
56
|
+
[{ name: "scenario.override", summary: "Force an endpoint's answer (status/body/malformed, once or sticky).", args: { matcher: "path substring", method: "GET|POST|\u2026", status: "number", body: "JSON", times: "auto-expire after N", delayMs: "ms", malformed: "invalid-json|wrong-content-type|truncated|empty-200|html-500|schema-drift", run: "run id" }, ui: UI }, async (a) => {
|
|
57
|
+
const input = { matcher: String(a.matcher), method: a.method, status: a.status === void 0 ? void 0 : Number(a.status), body: parseJson(a.body), times: a.times === void 0 ? void 0 : Number(a.times), delayMs: a.delayMs === void 0 ? void 0 : Number(a.delayMs), malformed: a.malformed };
|
|
58
|
+
return local()?.setOverride(runOf(a) ?? "default", input) ?? remote("POST", "/overrides", { ...input, run: runOf(a) });
|
|
59
|
+
}],
|
|
60
|
+
[{ name: "scenario.override.clear", summary: "Clear one override (by id/matcher) or all.", args: { matcher: "id or matcher", method: "method", run: "run id" }, ui: UI }, async (a) => local()?.clearOverrides(runOf(a) ?? "default", a.matcher, a.method) ?? remote("DELETE", "/overrides", void 0, { run: runOf(a), matcher: a.matcher, method: a.method })],
|
|
61
|
+
[{ name: "scenario.faults", summary: "Set latency/jitter/fail mode/stream latency.", args: { latencyMs: "ms", jitterMs: "ms", failMode: "off|data|all", streamLatencyMs: "ms", run: "run id" }, ui: UI }, async (a) => {
|
|
62
|
+
const patch = { latencyMs: a.latencyMs === void 0 ? void 0 : Number(a.latencyMs), jitterMs: a.jitterMs === void 0 ? void 0 : Number(a.jitterMs), failMode: a.failMode, streamLatencyMs: a.streamLatencyMs === void 0 ? void 0 : Number(a.streamLatencyMs) };
|
|
63
|
+
return local()?.faults(runOf(a) ?? "default", patch) ?? remote("POST", "/faults", { ...patch, run: runOf(a) });
|
|
64
|
+
}],
|
|
65
|
+
[{ name: "scenario.action", summary: "Run a scenario-defined action (see scenario.status \u2192 actions).", args: { name: "action name", args: "JSON object", run: "run id" }, ui: UI }, async (a) => {
|
|
66
|
+
const args = parseJson(a.args) ?? {};
|
|
67
|
+
const l = local();
|
|
68
|
+
return l ? { result: await l.action(runOf(a) ?? "default", String(a.name), args) } : remote("POST", "/action", { name: a.name, args, run: runOf(a) });
|
|
69
|
+
}],
|
|
70
|
+
[{ name: "scenario.runs", summary: "List isolated runs.", ui: UI }, async () => local()?.runs() ?? remote("GET", "/runs")]
|
|
71
|
+
];
|
|
72
|
+
for (const [spec, handler] of commands) pulse.controller.register(spec, handler);
|
|
73
|
+
return () => {
|
|
74
|
+
for (const [spec] of commands) pulse.controller.unregister(spec.name);
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
attachScenarioCommands
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=pulse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/pulse.ts"],"sourcesContent":["/**\n * @omniaura/scenario-sim/pulse — expose the simulator's control plane as\n * `scenario.*` commands on a solid-pulse controller, so the panel's Scenarios\n * tab and the `solid-pulse` CLI drive exactly the same operations. Works with\n * an in-process Simulator (browser adapter) or a remote control URL (server /\n * Vite adapter).\n */\n\nimport type { Simulator } from \"./core/engine.js\";\n\ninterface ControllerLike {\n register(spec: { name: string; summary: string; args?: Record<string, string>; ui?: string }, handler: (args: Record<string, unknown>) => unknown | Promise<unknown>): void;\n unregister(name: string): void;\n has(name: string): boolean;\n}\n\ninterface PulseLike {\n controller: ControllerLike;\n bus: { emit(kind: string, data: Record<string, unknown>): unknown };\n}\n\nexport type ScenarioClient = { kind: \"local\"; sim: Simulator; run?: string } | { kind: \"remote\"; controlUrl: string; run?: string; fetch?: typeof fetch };\n\nconst UI = \"Scenarios tab\";\n\nexport function attachScenarioCommands(pulse: PulseLike, client: ScenarioClient): () => void {\n const runOf = (a: Record<string, unknown>) => (a.run === undefined ? client.run : String(a.run));\n const remote = async (method: string, route: string, body?: Record<string, unknown>, query?: Record<string, unknown>) => {\n if (client.kind !== \"remote\") throw new Error(\"remote call on a local client\");\n const f = client.fetch ?? fetch;\n const url = new URL(`${client.controlUrl}${route}`);\n for (const [k, v] of Object.entries(query ?? {})) if (v !== undefined && v !== null) url.searchParams.set(k, String(v));\n const res = await f(url, { method, headers: { \"content-type\": \"application/json\" }, body: body ? JSON.stringify(body) : undefined });\n const text = await res.text();\n const parsed = text ? (JSON.parse(text) as Record<string, unknown>) : {};\n if (!res.ok) throw new Error(String(parsed.detail ?? parsed.error ?? `${res.status}`));\n return parsed;\n };\n const local = () => (client.kind === \"local\" ? client.sim.api : null);\n const num = (v: unknown, d: number) => (v === undefined || v === null || v === \"\" ? d : Number(v));\n const parseJson = (v: unknown) => (typeof v === \"string\" && /^[[{]/.test(v.trim()) ? (JSON.parse(v) as unknown) : v);\n\n const commands: Array<[{ name: string; summary: string; args?: Record<string, string>; ui?: string }, (a: Record<string, unknown>) => unknown | Promise<unknown>]> = [\n [{ name: \"scenario.list\", summary: \"Scenarios the simulator knows.\", ui: UI }, async () => local()?.scenarios() ?? ((await remote(\"GET\", \"/scenarios\")) as { scenarios: unknown }).scenarios],\n [{ name: \"scenario.status\", summary: \"Run status: scenario, seed, clock, state counts, streams, faults, routes.\", args: { run: \"run id\" }, ui: UI }, async (a) => local()?.status(runOf(a)) ?? remote(\"GET\", \"/status\", undefined, { run: runOf(a) })],\n [{ name: \"scenario.select\", summary: \"Bind the run to a scenario with fresh state.\", args: { name: \"scenario name\", seed: \"optional seed\", run: \"run id\" }, ui: UI }, async (a) => {\n const name = String(a.name ?? \"\");\n const seed = a.seed === undefined ? undefined : String(a.seed);\n const l = local();\n const result = l ? await l.select(runOf(a) ?? \"default\", name, seed) : await remote(\"POST\", \"/select\", { scenario: name, seed, run: runOf(a) });\n pulse.bus.emit(\"pulse.note\", { note: `scenario → ${name}${seed ? ` (seed ${seed})` : \"\"}` });\n return result;\n }],\n [{ name: \"scenario.reset\", summary: \"Rebuild the run's scenario (same seed unless given).\", args: { seed: \"optional seed\", run: \"run id\" }, ui: UI }, async (a) => {\n const seed = a.seed === undefined || a.seed === \"\" ? undefined : String(a.seed);\n const l = local();\n const result = l ? await l.reset(runOf(a) ?? \"default\", seed) : await remote(\"POST\", \"/reset\", { seed, run: runOf(a) });\n pulse.bus.emit(\"pulse.note\", { note: `scenario reset${seed ? ` (seed ${seed})` : \"\"}` });\n return result;\n }],\n [{ name: \"scenario.step\", summary: \"Advance the run's virtual clock (switches it to manual mode).\", args: { ms: \"milliseconds (default 1000)\", run: \"run id\" }, ui: UI }, async (a) => local()?.step(runOf(a) ?? \"default\", num(a.ms, 1000)) ?? remote(\"POST\", \"/step\", { ms: num(a.ms, 1000), run: runOf(a) })],\n [{ name: \"scenario.clock\", summary: \"Set clock mode/speed.\", args: { mode: \"manual|realtime\", speed: \"multiplier\", run: \"run id\" }, ui: UI }, async (a) => {\n const patch = { mode: a.mode as \"manual\" | \"realtime\" | undefined, speed: a.speed === undefined ? undefined : Number(a.speed) };\n return local()?.clock(runOf(a) ?? \"default\", patch) ?? remote(\"POST\", \"/clock\", { ...patch, run: runOf(a) });\n }],\n [{ name: \"scenario.state\", summary: \"Inspect the run's state store (all collections or one).\", args: { collection: \"collection name\", run: \"run id\" }, ui: UI }, async (a) => local()?.state(runOf(a) ?? \"default\", a.collection === undefined ? undefined : String(a.collection)) ?? remote(\"GET\", \"/state\", undefined, { run: runOf(a), collection: a.collection })],\n [{ name: \"scenario.events\", summary: \"Store mutation log (insert/update/remove/custom).\", args: { since: \"seq\", limit: \"max\", collection: \"filter\", run: \"run id\" }, ui: UI }, async (a) => local()?.events(runOf(a) ?? \"default\", { since: num(a.since, 0), limit: num(a.limit, 100), collection: a.collection === undefined ? undefined : String(a.collection) }) ?? remote(\"GET\", \"/events\", undefined, { run: runOf(a), since: a.since, limit: a.limit, collection: a.collection })],\n [{ name: \"scenario.log\", summary: \"Run log: requests, streams, actions.\", args: { since: \"seq\", limit: \"max\", run: \"run id\" }, ui: UI }, async (a) => local()?.log(runOf(a) ?? \"default\", { since: num(a.since, 0), limit: num(a.limit, 100) }) ?? remote(\"GET\", \"/log\", undefined, { run: runOf(a), since: a.since, limit: a.limit })],\n [{ name: \"scenario.streams\", summary: \"Open SSE/WebSocket connections and topics.\", args: { run: \"run id\" }, ui: UI }, async (a) => local()?.streams(runOf(a) ?? \"default\") ?? remote(\"GET\", \"/streams\", undefined, { run: runOf(a) })],\n [{ name: \"scenario.disconnect\", summary: \"Close or hard-drop stream connections (by id, topic, path, or all).\", args: { id: \"connection id\", topic: \"topic\", path: \"route path\", all: \"true\", drop: \"true = no close frame\", code: \"close code\", reason: \"text\", run: \"run id\" }, ui: UI }, async (a) => {\n const target = { id: a.id as string | undefined, topic: a.topic as string | undefined, path: a.path as string | undefined, all: a.all === true || a.all === \"true\" };\n const opts = { code: a.code === undefined ? undefined : Number(a.code), reason: a.reason as string | undefined, drop: a.drop === true || a.drop === \"true\" };\n return local()?.disconnect(runOf(a) ?? \"default\", target, opts) ?? remote(\"POST\", \"/streams/disconnect\", { ...target, ...opts, run: runOf(a) });\n }],\n [{ name: \"scenario.publish\", summary: \"Publish an event to a topic by hand.\", args: { topic: \"topic\", data: \"JSON object\", run: \"run id\" }, ui: UI }, async (a) => {\n const data = (parseJson(a.data) as Record<string, unknown>) ?? {};\n return local()?.publish(runOf(a) ?? \"default\", String(a.topic), data) ?? remote(\"POST\", \"/publish\", { topic: a.topic, data, run: runOf(a) });\n }],\n [{ name: \"scenario.overrides\", summary: \"List endpoint overrides.\", args: { run: \"run id\" }, ui: UI }, async (a) => local()?.overrides(runOf(a) ?? \"default\") ?? remote(\"GET\", \"/overrides\", undefined, { run: runOf(a) })],\n [{ name: \"scenario.override\", summary: \"Force an endpoint's answer (status/body/malformed, once or sticky).\", args: { matcher: \"path substring\", method: \"GET|POST|…\", status: \"number\", body: \"JSON\", times: \"auto-expire after N\", delayMs: \"ms\", malformed: \"invalid-json|wrong-content-type|truncated|empty-200|html-500|schema-drift\", run: \"run id\" }, ui: UI }, async (a) => {\n const input = { matcher: String(a.matcher), method: a.method as string | undefined, status: a.status === undefined ? undefined : Number(a.status), body: parseJson(a.body), times: a.times === undefined ? undefined : Number(a.times), delayMs: a.delayMs === undefined ? undefined : Number(a.delayMs), malformed: a.malformed as never };\n return local()?.setOverride(runOf(a) ?? \"default\", input) ?? remote(\"POST\", \"/overrides\", { ...input, run: runOf(a) });\n }],\n [{ name: \"scenario.override.clear\", summary: \"Clear one override (by id/matcher) or all.\", args: { matcher: \"id or matcher\", method: \"method\", run: \"run id\" }, ui: UI }, async (a) => local()?.clearOverrides(runOf(a) ?? \"default\", a.matcher as string | undefined, a.method as string | undefined) ?? remote(\"DELETE\", \"/overrides\", undefined, { run: runOf(a), matcher: a.matcher, method: a.method })],\n [{ name: \"scenario.faults\", summary: \"Set latency/jitter/fail mode/stream latency.\", args: { latencyMs: \"ms\", jitterMs: \"ms\", failMode: \"off|data|all\", streamLatencyMs: \"ms\", run: \"run id\" }, ui: UI }, async (a) => {\n const patch = { latencyMs: a.latencyMs === undefined ? undefined : Number(a.latencyMs), jitterMs: a.jitterMs === undefined ? undefined : Number(a.jitterMs), failMode: a.failMode as \"off\" | \"data\" | \"all\" | undefined, streamLatencyMs: a.streamLatencyMs === undefined ? undefined : Number(a.streamLatencyMs) };\n return local()?.faults(runOf(a) ?? \"default\", patch) ?? remote(\"POST\", \"/faults\", { ...patch, run: runOf(a) });\n }],\n [{ name: \"scenario.action\", summary: \"Run a scenario-defined action (see scenario.status → actions).\", args: { name: \"action name\", args: \"JSON object\", run: \"run id\" }, ui: UI }, async (a) => {\n const args = (parseJson(a.args) as Record<string, unknown>) ?? {};\n const l = local();\n return l ? { result: await l.action(runOf(a) ?? \"default\", String(a.name), args) } : remote(\"POST\", \"/action\", { name: a.name, args, run: runOf(a) });\n }],\n [{ name: \"scenario.runs\", summary: \"List isolated runs.\", ui: UI }, async () => local()?.runs() ?? remote(\"GET\", \"/runs\")],\n ];\n\n for (const [spec, handler] of commands) pulse.controller.register(spec, handler);\n return () => {\n for (const [spec] of commands) pulse.controller.unregister(spec.name);\n };\n}\n"],"mappings":";AAuBA,IAAM,KAAK;AAEJ,SAAS,uBAAuB,OAAkB,QAAoC;AAC3F,QAAM,QAAQ,CAAC,MAAgC,EAAE,QAAQ,SAAY,OAAO,MAAM,OAAO,EAAE,GAAG;AAC9F,QAAM,SAAS,OAAO,QAAgB,OAAe,MAAgC,UAAoC;AACvH,QAAI,OAAO,SAAS,SAAU,OAAM,IAAI,MAAM,+BAA+B;AAC7E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