@agent-surface/cli 0.8.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.
@@ -0,0 +1,202 @@
1
+ import {
2
+ renderSurfacePlain
3
+ } from "./chunk-KZUR4CAU.js";
4
+ import {
5
+ createSurfaceRunner,
6
+ isPlain,
7
+ loadInk,
8
+ paint,
9
+ transient,
10
+ write
11
+ } from "./chunk-S2LM3N6D.js";
12
+ import "./chunk-ODUIFFPM.js";
13
+
14
+ // src/render/model.ts
15
+ function leafOf(capabilityId) {
16
+ const withoutPlane = capabilityId.replace(/^(view|domain):/, "");
17
+ const dot = withoutPlane.lastIndexOf(".");
18
+ return dot === -1 ? withoutPlane : withoutPlane.slice(dot + 1);
19
+ }
20
+ function observationTags() {
21
+ return ["observation"];
22
+ }
23
+ function actionTags(action) {
24
+ const tags = [action.effect];
25
+ if (action.idempotent) tags.push("idempotent");
26
+ if (action.reversible) tags.push("reversible");
27
+ if (action.confirmation !== "never") tags.push(`confirmation:${action.confirmation}`);
28
+ return tags;
29
+ }
30
+ function procedureTags(procedure) {
31
+ const tags = [procedure.effect];
32
+ if (procedure.confirmation !== "never") tags.push(`confirmation:${procedure.confirmation}`);
33
+ for (const field of procedure.boundFields) {
34
+ tags.push(`${field.path} bound${field.locked ? "+locked" : ""}`);
35
+ }
36
+ return tags;
37
+ }
38
+ function explanationIndex(explanation) {
39
+ const index = /* @__PURE__ */ new Map();
40
+ for (const capability of explanation.capabilities) {
41
+ index.set(`${capability.capabilityId}\0${capability.registrationId}`, capability);
42
+ }
43
+ return index;
44
+ }
45
+ function buildView(result, options = {}) {
46
+ const { snapshot, explanation } = result;
47
+ const index = explanationIndex(explanation);
48
+ const groups = [];
49
+ const counts = { callable: 0, disabled: 0, hidden: 0 };
50
+ const enrich = (row, capabilityId, registrationId) => {
51
+ const explained = index.get(`${capabilityId}\0${registrationId}`);
52
+ if (options.explain && explained) {
53
+ row.policies = explained.policies;
54
+ row.availability = explained.availability;
55
+ }
56
+ return row;
57
+ };
58
+ for (const component of snapshot.components) {
59
+ const rows = [];
60
+ for (const observation of component.observations) {
61
+ rows.push(
62
+ enrich(
63
+ rowFor(observation, "observation", observationTags(), options, {
64
+ input: void 0,
65
+ output: observation.outputSchema
66
+ }),
67
+ observation.capabilityId,
68
+ component.registrationId
69
+ )
70
+ );
71
+ }
72
+ for (const action of component.actions) {
73
+ rows.push(
74
+ enrich(
75
+ rowFor(action, "action", actionTags(action), options, {
76
+ input: action.inputSchema,
77
+ output: action.outputSchema
78
+ }),
79
+ action.capabilityId,
80
+ component.registrationId
81
+ )
82
+ );
83
+ }
84
+ groups.push({
85
+ heading: component.instanceId === "default" ? component.type : `${component.type}@${component.instanceId}`,
86
+ rows
87
+ });
88
+ }
89
+ if (snapshot.procedures.length > 0) {
90
+ groups.push({
91
+ heading: "authoritative (domain)",
92
+ rows: snapshot.procedures.map(
93
+ (procedure) => enrich(
94
+ {
95
+ capabilityId: procedure.procedureId,
96
+ name: procedure.procedureId.replace(/^domain:/, ""),
97
+ kind: "procedure",
98
+ plane: "domain",
99
+ outcome: procedure.available ? "expose" : "disable",
100
+ description: procedure.description,
101
+ ...procedure.unavailableReason ? { reason: procedure.unavailableReason } : {},
102
+ tags: procedureTags(procedure),
103
+ ...options.schemas ? { schemas: { input: procedure.inputSchema, output: procedure.outputSchema } } : {}
104
+ },
105
+ procedure.procedureId,
106
+ procedure.registrationId
107
+ )
108
+ )
109
+ });
110
+ }
111
+ if (options.explain) {
112
+ const hidden = explanation.capabilities.filter((c) => c.outcome === "hide");
113
+ if (hidden.length > 0) {
114
+ groups.push({
115
+ heading: "hidden by policy (absent from the snapshot)",
116
+ rows: hidden.map((capability) => ({
117
+ capabilityId: capability.capabilityId,
118
+ name: leafOf(capability.capabilityId),
119
+ kind: capability.kind,
120
+ plane: capability.plane,
121
+ outcome: "hide",
122
+ description: capability.description,
123
+ tags: [`${capability.component.type}@${capability.component.instanceId}`],
124
+ policies: capability.policies,
125
+ availability: capability.availability
126
+ }))
127
+ });
128
+ }
129
+ }
130
+ for (const capability of explanation.capabilities) {
131
+ if (capability.outcome === "expose") counts.callable += 1;
132
+ else if (capability.outcome === "disable") counts.disabled += 1;
133
+ else counts.hidden += 1;
134
+ }
135
+ return {
136
+ scenario: result.scenario,
137
+ ...snapshot.route?.path ? { route: snapshot.route.path } : {},
138
+ groups,
139
+ counts,
140
+ explained: options.explain === true
141
+ };
142
+ }
143
+ function rowFor(descriptor, kind, tags, options, schemas) {
144
+ return {
145
+ capabilityId: descriptor.capabilityId,
146
+ name: descriptor.name,
147
+ kind,
148
+ plane: "view",
149
+ outcome: descriptor.available ? "expose" : "disable",
150
+ description: descriptor.description,
151
+ ...descriptor.unavailableReason ? { reason: descriptor.unavailableReason } : {},
152
+ tags,
153
+ ...options.schemas ? { schemas } : {}
154
+ };
155
+ }
156
+
157
+ // src/commands/inspect.tsx
158
+ import { jsx } from "react/jsx-runtime";
159
+ async function runInspect(options) {
160
+ const runner = await createSurfaceRunner(options.configPath);
161
+ const ink = isPlain(options) ? null : await loadInk();
162
+ try {
163
+ const scenario = options.scenario ?? runner.scenarioNames[0];
164
+ const stop = ink ? await transient(/* @__PURE__ */ jsx(ink.Loading, { label: `mounting ${scenario}\u2026` })) : void 0;
165
+ let result;
166
+ try {
167
+ result = await runner.collect({
168
+ scenario,
169
+ ...options.scope ? { scope: options.scope } : {}
170
+ });
171
+ } finally {
172
+ stop?.();
173
+ }
174
+ if (options.json) {
175
+ write(
176
+ JSON.stringify(
177
+ {
178
+ scenario: result.scenario,
179
+ snapshot: result.snapshot,
180
+ ...options.explain ? { explanation: result.explanation } : {}
181
+ },
182
+ null,
183
+ 2
184
+ )
185
+ );
186
+ return 0;
187
+ }
188
+ const view = buildView(result, {
189
+ ...options.explain ? { explain: true } : {},
190
+ ...options.schemas ? { schemas: true } : {}
191
+ });
192
+ if (ink) await paint(/* @__PURE__ */ jsx(ink.Surface, { view }));
193
+ else write(renderSurfacePlain(view));
194
+ return 0;
195
+ } finally {
196
+ await runner.close();
197
+ }
198
+ }
199
+ export {
200
+ runInspect
201
+ };
202
+ //# sourceMappingURL=inspect-3AXX3VVK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/render/model.ts","../src/commands/inspect.tsx"],"sourcesContent":["import type {\n AgentActionDescriptor,\n AgentObservationDescriptor,\n AgentProcedureDescriptor,\n AgentSurfaceSnapshot,\n} from \"@agent-surface/core\";\nimport type { CapabilityExplanation, SurfaceExplanation } from \"@agent-surface/core/explain\";\nimport type { CollectResult } from \"../collect.js\";\n\n/**\n * One view model, two renderers. The Ink UI and the plain-text fallback both\n * consume this, so `--plain` can never drift into showing something different\n * from what a TTY shows.\n */\nexport interface CapabilityRow {\n capabilityId: string;\n /** Leaf name — the group heading already carries the rest of the id. */\n name: string;\n kind: \"observation\" | \"action\" | \"procedure\";\n plane: \"view\" | \"domain\";\n outcome: \"expose\" | \"disable\" | \"hide\";\n description: string;\n reason?: string;\n tags: string[];\n policies?: CapabilityExplanation[\"policies\"];\n availability?: CapabilityExplanation[\"availability\"];\n schemas?: { input?: unknown; output?: unknown };\n}\n\nexport interface CapabilityGroup {\n heading: string;\n rows: CapabilityRow[];\n}\n\nexport interface SurfaceView {\n scenario: string;\n route?: string;\n groups: CapabilityGroup[];\n counts: { callable: number; disabled: number; hidden: number };\n explained: boolean;\n}\n\nexport interface ViewOptions {\n explain?: boolean;\n schemas?: boolean;\n}\n\nfunction leafOf(capabilityId: string): string {\n const withoutPlane = capabilityId.replace(/^(view|domain):/, \"\");\n const dot = withoutPlane.lastIndexOf(\".\");\n return dot === -1 ? withoutPlane : withoutPlane.slice(dot + 1);\n}\n\nfunction observationTags(): string[] {\n return [\"observation\"];\n}\n\nfunction actionTags(action: AgentActionDescriptor): string[] {\n const tags: string[] = [action.effect];\n if (action.idempotent) tags.push(\"idempotent\");\n if (action.reversible) tags.push(\"reversible\");\n if (action.confirmation !== \"never\") tags.push(`confirmation:${action.confirmation}`);\n return tags;\n}\n\nfunction procedureTags(procedure: AgentProcedureDescriptor): string[] {\n const tags: string[] = [procedure.effect];\n if (procedure.confirmation !== \"never\") tags.push(`confirmation:${procedure.confirmation}`);\n for (const field of procedure.boundFields) {\n tags.push(`${field.path} bound${field.locked ? \"+locked\" : \"\"}`);\n }\n return tags;\n}\n\nfunction explanationIndex(explanation: SurfaceExplanation): Map<string, CapabilityExplanation> {\n const index = new Map<string, CapabilityExplanation>();\n for (const capability of explanation.capabilities) {\n // Keyed by id + registration so two instances of one component stay apart.\n index.set(`${capability.capabilityId}\u0000${capability.registrationId}`, capability);\n }\n return index;\n}\n\nexport function buildView(result: CollectResult, options: ViewOptions = {}): SurfaceView {\n const { snapshot, explanation } = result;\n const index = explanationIndex(explanation);\n const groups: CapabilityGroup[] = [];\n const counts = { callable: 0, disabled: 0, hidden: 0 };\n\n const enrich = (\n row: CapabilityRow,\n capabilityId: string,\n registrationId: string,\n ): CapabilityRow => {\n const explained = index.get(`${capabilityId}\u0000${registrationId}`);\n if (options.explain && explained) {\n row.policies = explained.policies;\n row.availability = explained.availability;\n }\n return row;\n };\n\n for (const component of snapshot.components) {\n const rows: CapabilityRow[] = [];\n\n for (const observation of component.observations) {\n rows.push(\n enrich(\n rowFor(observation, \"observation\", observationTags(), options, {\n input: undefined,\n output: observation.outputSchema,\n }),\n observation.capabilityId,\n component.registrationId,\n ),\n );\n }\n for (const action of component.actions) {\n rows.push(\n enrich(\n rowFor(action, \"action\", actionTags(action), options, {\n input: action.inputSchema,\n output: action.outputSchema,\n }),\n action.capabilityId,\n component.registrationId,\n ),\n );\n }\n\n groups.push({\n heading:\n component.instanceId === \"default\"\n ? component.type\n : `${component.type}@${component.instanceId}`,\n rows,\n });\n }\n\n if (snapshot.procedures.length > 0) {\n groups.push({\n heading: \"authoritative (domain)\",\n rows: snapshot.procedures.map((procedure) =>\n enrich(\n {\n capabilityId: procedure.procedureId,\n name: procedure.procedureId.replace(/^domain:/, \"\"),\n kind: \"procedure\",\n plane: \"domain\",\n outcome: procedure.available ? \"expose\" : \"disable\",\n description: procedure.description,\n ...(procedure.unavailableReason ? { reason: procedure.unavailableReason } : {}),\n tags: procedureTags(procedure),\n ...(options.schemas\n ? { schemas: { input: procedure.inputSchema, output: procedure.outputSchema } }\n : {}),\n },\n procedure.procedureId,\n procedure.registrationId,\n ),\n ),\n });\n }\n\n // Hidden capabilities exist only in the explanation — that is the whole point\n // of it. They get their own group so nobody mistakes them for callable.\n if (options.explain) {\n const hidden = explanation.capabilities.filter((c) => c.outcome === \"hide\");\n if (hidden.length > 0) {\n groups.push({\n heading: \"hidden by policy (absent from the snapshot)\",\n rows: hidden.map((capability) => ({\n capabilityId: capability.capabilityId,\n name: leafOf(capability.capabilityId),\n kind: capability.kind,\n plane: capability.plane,\n outcome: \"hide\" as const,\n description: capability.description,\n tags: [`${capability.component.type}@${capability.component.instanceId}`],\n policies: capability.policies,\n availability: capability.availability,\n })),\n });\n }\n }\n\n for (const capability of explanation.capabilities) {\n if (capability.outcome === \"expose\") counts.callable += 1;\n else if (capability.outcome === \"disable\") counts.disabled += 1;\n else counts.hidden += 1;\n }\n\n return {\n scenario: result.scenario,\n ...(snapshot.route?.path ? { route: snapshot.route.path } : {}),\n groups,\n counts,\n explained: options.explain === true,\n };\n}\n\nfunction rowFor(\n descriptor: AgentObservationDescriptor | AgentActionDescriptor,\n kind: \"observation\" | \"action\",\n tags: string[],\n options: ViewOptions,\n schemas: { input?: unknown; output?: unknown },\n): CapabilityRow {\n return {\n capabilityId: descriptor.capabilityId,\n name: descriptor.name,\n kind,\n plane: \"view\",\n outcome: descriptor.available ? \"expose\" : \"disable\",\n description: descriptor.description,\n ...(descriptor.unavailableReason ? { reason: descriptor.unavailableReason } : {}),\n tags,\n ...(options.schemas ? { schemas } : {}),\n };\n}\n","import { createSurfaceRunner } from \"../load.js\";\nimport { buildView } from \"../render/model.js\";\nimport { renderSurfacePlain } from \"../render/plain.js\";\nimport { isPlain, loadInk, paint, transient, write } from \"../output.js\";\n\nexport interface InspectOptions {\n configPath: string;\n scenario?: string;\n scope?: string[];\n explain?: boolean;\n schemas?: boolean;\n json?: boolean;\n plain?: boolean;\n}\n\nexport async function runInspect(options: InspectOptions): Promise<number> {\n const runner = await createSurfaceRunner(options.configPath);\n // `null` when Ink cannot run here (React 18 host), which is a fallback to\n // plain text rather than a failed command — see loadInk().\n const ink = isPlain(options) ? null : await loadInk();\n try {\n const scenario = options.scenario ?? runner.scenarioNames[0]!;\n const stop = ink ? await transient(<ink.Loading label={`mounting ${scenario}…`} />) : undefined;\n\n let result;\n try {\n result = await runner.collect({\n scenario,\n ...(options.scope ? { scope: options.scope } : {}),\n });\n } finally {\n stop?.();\n }\n\n if (options.json) {\n write(\n JSON.stringify(\n {\n scenario: result.scenario,\n snapshot: result.snapshot,\n ...(options.explain ? { explanation: result.explanation } : {}),\n },\n null,\n 2,\n ),\n );\n return 0;\n }\n\n const view = buildView(result, {\n ...(options.explain ? { explain: true } : {}),\n ...(options.schemas ? { schemas: true } : {}),\n });\n\n if (ink) await paint(<ink.Surface view={view} />);\n else write(renderSurfacePlain(view));\n return 0;\n } finally {\n await runner.close();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA+CA,SAAS,OAAO,cAA8B;AAC5C,QAAM,eAAe,aAAa,QAAQ,mBAAmB,EAAE;AAC/D,QAAM,MAAM,aAAa,YAAY,GAAG;AACxC,SAAO,QAAQ,KAAK,eAAe,aAAa,MAAM,MAAM,CAAC;AAC/D;AAEA,SAAS,kBAA4B;AACnC,SAAO,CAAC,aAAa;AACvB;AAEA,SAAS,WAAW,QAAyC;AAC3D,QAAM,OAAiB,CAAC,OAAO,MAAM;AACrC,MAAI,OAAO,WAAY,MAAK,KAAK,YAAY;AAC7C,MAAI,OAAO,WAAY,MAAK,KAAK,YAAY;AAC7C,MAAI,OAAO,iBAAiB,QAAS,MAAK,KAAK,gBAAgB,OAAO,YAAY,EAAE;AACpF,SAAO;AACT;AAEA,SAAS,cAAc,WAA+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Q;AAAA,QAC5B;AAAA,QACA,GAAI,QAAQ,QAAQ,EAAE,OAAO,QAAQ,MAAM,IAAI,CAAC;AAAA,MAClD,CAAC;AAAA,IACH,UAAE;AACA,aAAO;AAAA,IACT;AAEA,QAAI,QAAQ,MAAM;AAChB;AAAA,QACE,KAAK;AAAA,UACH;AAAA,YACE,UAAU,OAAO;AAAA,YACjB,UAAU,OAAO;AAAA,YACjB,GAAI,QAAQ,UAAU,EAAE,aAAa,OAAO,YAAY,IAAI,CAAC;AAAA,UAC/D;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAEA,UAAM,OAAO,UAAU,QAAQ;AAAA,MAC7B,GAAI,QAAQ,UAAU,EAAE,SAAS,KAAK,IAAI,CAAC;AAAA,MAC3C,GAAI,QAAQ,UAAU,EAAE,SAAS,KAAK,IAAI,CAAC;AAAA,IAC7C,CAAC;AAED,QAAI,IAAK,OAAM,MAAM,oBAAC,IAAI,SAAJ,EAAY,MAAY,CAAE;AAAA,QAC3C,OAAM,mBAAmB,IAAI,CAAC;AACnC,WAAO;AAAA,EACT,UAAE;AACA,UAAM,OAAO,MAAM;AAAA,EACrB;AACF;","names":[]}
@@ -0,0 +1,36 @@
1
+ import {
2
+ createSurfaceRunner,
3
+ write
4
+ } from "./chunk-S2LM3N6D.js";
5
+ import {
6
+ baselineDirFor,
7
+ baselinePath,
8
+ normalize,
9
+ writeBaseline
10
+ } from "./chunk-ODUIFFPM.js";
11
+
12
+ // src/commands/snapshot.ts
13
+ import { relative } from "path";
14
+ async function runSnapshot(options) {
15
+ const runner = await createSurfaceRunner(options.configPath);
16
+ try {
17
+ const scenarios = options.scenario ? [options.scenario] : runner.scenarioNames;
18
+ const dir = baselineDirFor(options.configPath, options.baselineDir ?? runner.config.baselineDir);
19
+ for (const scenario of scenarios) {
20
+ const result = await runner.collect({
21
+ scenario,
22
+ ...options.scope ? { scope: options.scope } : {}
23
+ });
24
+ const path = baselinePath(dir, scenario);
25
+ writeBaseline(path, normalize(result.snapshot));
26
+ write(`wrote ${relative(process.cwd(), path)}`);
27
+ }
28
+ return 0;
29
+ } finally {
30
+ await runner.close();
31
+ }
32
+ }
33
+ export {
34
+ runSnapshot
35
+ };
36
+ //# sourceMappingURL=snapshot-3D55FL63.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/snapshot.ts"],"sourcesContent":["import { relative } from \"node:path\";\nimport { createSurfaceRunner } from \"../load.js\";\nimport { baselineDirFor, baselinePath, normalize, writeBaseline } from \"../baseline.js\";\nimport { write } from \"../output.js\";\n\nexport interface SnapshotOptions {\n configPath: string;\n scenario?: string;\n scope?: string[];\n baselineDir?: string;\n}\n\n/** Writes (or refreshes) the committed baseline `check` compares against. */\nexport async function runSnapshot(options: SnapshotOptions): Promise<number> {\n const runner = await createSurfaceRunner(options.configPath);\n try {\n const scenarios = options.scenario ? [options.scenario] : runner.scenarioNames;\n const dir = baselineDirFor(options.configPath, options.baselineDir ?? runner.config.baselineDir);\n\n for (const scenario of scenarios) {\n const result = await runner.collect({\n scenario,\n ...(options.scope ? { scope: options.scope } : {}),\n });\n const path = baselinePath(dir, scenario);\n writeBaseline(path, normalize(result.snapshot));\n write(`wrote ${relative(process.cwd(), path)}`);\n }\n return 0;\n } finally {\n await runner.close();\n }\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,gBAAgB;AAazB,eAAsB,YAAY,SAA2C;AAC3E,QAAM,SAAS,MAAM,oBAAoB,QAAQ,UAAU;AAC3D,MAAI;AACF,UAAM,YAAY,QAAQ,WAAW,CAAC,QAAQ,QAAQ,IAAI,OAAO;AACjE,UAAM,MAAM,eAAe,QAAQ,YAAY,QAAQ,eAAe,OAAO,OAAO,WAAW;AAE/F,eAAW,YAAY,WAAW;AAChC,YAAM,SAAS,MAAM,OAAO,QAAQ;AAAA,QAClC;AAAA,QACA,GAAI,QAAQ,QAAQ,EAAE,OAAO,QAAQ,MAAM,IAAI,CAAC;AAAA,MAClD,CAAC;AACD,YAAM,OAAO,aAAa,KAAK,QAAQ;AACvC,oBAAc,MAAM,UAAU,OAAO,QAAQ,CAAC;AAC9C,YAAM,SAAS,SAAS,QAAQ,IAAI,GAAG,IAAI,CAAC,EAAE;AAAA,IAChD;AACA,WAAO;AAAA,EACT,UAAE;AACA,UAAM,OAAO,MAAM;AAAA,EACrB;AACF;","names":[]}
@@ -0,0 +1,30 @@
1
+ import { RenderedAgentSurface } from '@agent-surface/testing/react';
2
+ import { AgentConsumer } from '@agent-surface/core';
3
+ import { M as MountResult, S as ScenarioProps, a as SurfaceConfig } from './config-DqK8YqyQ.js';
4
+ import 'react';
5
+
6
+ declare const DEFAULT_CLI_CONSUMER: AgentConsumer;
7
+ interface MountScenarioOptions {
8
+ consumer?: AgentConsumer;
9
+ }
10
+ interface MountedScenario<TApp> {
11
+ scenario: string;
12
+ surface: RenderedAgentSurface;
13
+ mounted: MountResult<TApp>;
14
+ /**
15
+ * Whatever `mount()` returned as `app`. Typed as `TApp` rather than
16
+ * `TApp | undefined` because a config that never sets it infers `TApp` as
17
+ * `unknown`, and forcing a `!` on every test that *does* set it is worse
18
+ * than trusting the config's own return type.
19
+ */
20
+ app: TApp;
21
+ consumer: AgentConsumer;
22
+ }
23
+ /**
24
+ * The one mounting path. `agent-surface inspect` and the Vitest helper both
25
+ * come through here, so a scenario cannot behave one way in CI and another in
26
+ * the terminal — which is the entire reason scenarios live in one file.
27
+ */
28
+ declare function mountScenario<TScenario extends ScenarioProps, TApp>(config: SurfaceConfig<TScenario, TApp>, scenario: string, options?: MountScenarioOptions): Promise<MountedScenario<TApp>>;
29
+
30
+ export { DEFAULT_CLI_CONSUMER, MountResult, type MountScenarioOptions, type MountedScenario, ScenarioProps, SurfaceConfig, mountScenario };
package/dist/vitest.js ADDED
@@ -0,0 +1,9 @@
1
+ import {
2
+ DEFAULT_CLI_CONSUMER,
3
+ mountScenario
4
+ } from "./chunk-A2G4QLX5.js";
5
+ export {
6
+ DEFAULT_CLI_CONSUMER,
7
+ mountScenario
8
+ };
9
+ //# sourceMappingURL=vitest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "@agent-surface/cli",
3
+ "version": "0.8.0",
4
+ "description": "Inspect and check the agent surface your app exposes — in the terminal and in CI",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "bin": {
8
+ "agent-surface": "./dist/bin.js"
9
+ },
10
+ "main": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js"
16
+ },
17
+ "./vitest": {
18
+ "types": "./dist/vitest.d.ts",
19
+ "import": "./dist/vitest.js"
20
+ }
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "LICENSE"
25
+ ],
26
+ "dependencies": {
27
+ "ink": "^6.3.1",
28
+ "ink-spinner": "^5.0.0",
29
+ "jsdom": "^26.1.0",
30
+ "react": "^19.1.1",
31
+ "vite": "^7.1.3",
32
+ "vite-node": "^3.2.4",
33
+ "@agent-surface/core": "^0.8.0",
34
+ "@agent-surface/react": "^0.8.0",
35
+ "@agent-surface/testing": "^0.8.0"
36
+ },
37
+ "peerDependencies": {
38
+ "@testing-library/react": ">=14",
39
+ "react-dom": ">=18.2"
40
+ },
41
+ "devDependencies": {
42
+ "@testing-library/react": "^16.3.0",
43
+ "@types/jsdom": "^21.1.7",
44
+ "@types/node": "^20.19.0",
45
+ "@types/react": "^19.1.9",
46
+ "react-dom": "^19.1.1"
47
+ },
48
+ "author": "Paolo Barbato",
49
+ "engines": {
50
+ "node": ">=20.19.0"
51
+ },
52
+ "repository": {
53
+ "type": "git",
54
+ "url": "git+https://github.com/Wiseair-srl/agent-surface.git",
55
+ "directory": "packages/cli"
56
+ },
57
+ "homepage": "https://agent-surface-docs.vercel.app",
58
+ "bugs": {
59
+ "url": "https://github.com/Wiseair-srl/agent-surface/issues"
60
+ },
61
+ "publishConfig": {
62
+ "access": "public"
63
+ },
64
+ "keywords": [
65
+ "agent-surface",
66
+ "cli",
67
+ "agent",
68
+ "ai",
69
+ "llm",
70
+ "frontend",
71
+ "capabilities",
72
+ "inspect",
73
+ "policies"
74
+ ],
75
+ "scripts": {
76
+ "build": "tsup",
77
+ "typecheck": "tsc --noEmit"
78
+ }
79
+ }