@agent-surface/testing 0.16.0 → 0.17.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/dist/{chunk-QV7I5CCY.js → chunk-N4OYE4EE.js} +2 -1
- package/dist/chunk-N4OYE4EE.js.map +1 -0
- package/dist/{harness-B_t1q70R.d.ts → harness-dvJE7PNr.d.ts} +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-QV7I5CCY.js.map +0 -1
|
@@ -10,6 +10,7 @@ function createTestSurface(options) {
|
|
|
10
10
|
const ownsRegistry = options?.registry === void 0;
|
|
11
11
|
const registry = options?.registry ?? createAgentSurfaceRegistry({
|
|
12
12
|
environment: "test",
|
|
13
|
+
...options?.authority ? { authority: options.authority } : {},
|
|
13
14
|
context: () => hostRef.current,
|
|
14
15
|
audit: auditSink
|
|
15
16
|
});
|
|
@@ -124,4 +125,4 @@ function createTestSurface(options) {
|
|
|
124
125
|
export {
|
|
125
126
|
createTestSurface
|
|
126
127
|
};
|
|
127
|
-
//# sourceMappingURL=chunk-
|
|
128
|
+
//# sourceMappingURL=chunk-N4OYE4EE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/harness.ts"],"sourcesContent":["import {\n createAgentSurfaceRegistry,\n memoryAuditSink,\n type AgentConsumer,\n type AgentInvocationResult,\n type AgentSurfaceEvent,\n type AgentSurfaceRegistry,\n type AgentSurfaceSnapshot,\n type AuditEvent,\n type CapabilityAuthority,\n type JsonValue,\n type PendingConfirmation,\n type SnapshotContext,\n} from \"@agent-surface/core\";\n\nexport interface TestSurfaceOptions {\n registry?: AgentSurfaceRegistry; // default: fresh registry, environment \"test\"\n authority?: CapabilityAuthority; // required when registry is omitted\n consumer?: AgentConsumer; // default {id:\"test\", kind:\"test\"}\n host?: Record<string, unknown>; // overrides RegistryOptions.context()\n}\n\nexport interface TestSurface {\n registry: AgentSurfaceRegistry;\n snapshot(ctx?: Partial<SnapshotContext>): AgentSurfaceSnapshot;\n\n /** Invoke with test conveniences: auto invocationId, auto registrationId\n resolution from the latest snapshot, typed input. */\n invoke(\n capabilityId: string,\n input?: JsonValue,\n opts?: {\n instanceId?: string;\n registrationId?: string; // pass a captured one to simulate staleness\n surfaceVersion?: string;\n confirmationId?: string;\n consumer?: AgentConsumer;\n },\n ): Promise<AgentInvocationResult>;\n\n /** Sugar: invoke an observation and return its parsed output (throws on error). */\n observe<T = JsonValue>(capabilityId: string, opts?: { instanceId?: string }): Promise<T>;\n\n /** Capture current resolution tokens for later stale-invocation tests. */\n captureRef(\n capabilityId: string,\n instanceId?: string,\n ): { registrationId: string; surfaceVersion: string };\n\n /** Swap host context mid-test (auth changes): as({user: admin}). */\n as(host: Record<string, unknown>): void;\n\n confirmations: {\n pending(): PendingConfirmation[];\n approve(confirmationId?: string): void; // default: the only pending one\n deny(confirmationId?: string, reason?: string): void;\n expire(confirmationId?: string): void; // force-expires that record\n };\n\n /** All registry events recorded since creation, in order. */\n events(): AgentSurfaceEvent[];\n auditLog(): AuditEvent[];\n\n dispose(): void;\n}\n\nexport function createTestSurface(options?: TestSurfaceOptions): TestSurface {\n const hostRef: { current: Record<string, unknown> } = { current: options?.host ?? {} };\n const consumer: AgentConsumer = options?.consumer ?? { id: \"test\", kind: \"test\" };\n const auditSink = memoryAuditSink({ capacity: 5000 });\n const ownsRegistry = options?.registry === undefined;\n\n const registry =\n options?.registry ??\n createAgentSurfaceRegistry({\n environment: \"test\",\n ...(options?.authority ? { authority: options.authority } : {}),\n context: () => hostRef.current,\n audit: auditSink,\n });\n\n const events: AgentSurfaceEvent[] = [];\n const unsubscribe = registry.subscribe((event) => {\n events.push(event);\n });\n\n function resolveRegistrationId(\n capabilityId: string,\n instanceId: string | undefined,\n ): string | undefined {\n const snapshot = registry.snapshot({ consumer });\n const matches: string[] = [];\n for (const component of snapshot.components) {\n if (instanceId !== undefined && component.instanceId !== instanceId) continue;\n const caps = [...component.observations, ...component.actions];\n if (caps.some((c) => c.capabilityId === capabilityId)) {\n matches.push(component.registrationId);\n }\n }\n for (const proc of snapshot.procedures) {\n if (proc.procedureId === capabilityId) matches.push(proc.registrationId);\n }\n // Auto-attach only when unambiguous; otherwise let the registry produce\n // AMBIGUOUS_INSTANCE / CAPABILITY_NOT_FOUND / COMPONENT_UNMOUNTED.\n return matches.length === 1 ? matches[0] : undefined;\n }\n\n function pickPending(confirmationId: string | undefined): string {\n if (confirmationId !== undefined) return confirmationId;\n const pending = registry.confirmations.pending();\n if (pending.length === 1) return pending[0]!.confirmationId;\n throw new Error(\n pending.length === 0\n ? \"no pending confirmation to resolve\"\n : \"multiple pending confirmations — pass an explicit confirmationId\",\n );\n }\n\n const surface: TestSurface = {\n registry,\n\n snapshot(ctx) {\n return registry.snapshot({ consumer, ...ctx });\n },\n\n invoke(capabilityId, input, opts) {\n const registrationId =\n opts?.registrationId !== undefined\n ? opts.registrationId\n : resolveRegistrationId(capabilityId, opts?.instanceId);\n return registry.invoke(\n {\n capabilityId,\n ...(input !== undefined ? { input } : {}),\n ...(opts?.instanceId !== undefined ? { instanceId: opts.instanceId } : {}),\n ...(registrationId !== undefined ? { registrationId } : {}),\n ...(opts?.surfaceVersion !== undefined ? { surfaceVersion: opts.surfaceVersion } : {}),\n ...(opts?.confirmationId !== undefined ? { confirmationId: opts.confirmationId } : {}),\n },\n { consumer: opts?.consumer ?? consumer },\n );\n },\n\n async observe<T = JsonValue>(capabilityId: string, opts?: { instanceId?: string }): Promise<T> {\n const versionBefore = registry.getVersion();\n const result = await surface.invoke(capabilityId, undefined, opts);\n if (result.status === \"error\") {\n throw new Error(\n `observe(${capabilityId}) failed: ${result.error.code} — ${result.error.message}`,\n );\n }\n const versionAfter = registry.getVersion();\n if (versionAfter !== versionBefore) {\n throw new Error(\n `observe(${capabilityId}) mutated the surface (version ${versionBefore} → ${versionAfter}); observations MUST be side-effect free (docs/01)`,\n );\n }\n return result.output as T;\n },\n\n captureRef(capabilityId, instanceId) {\n const registrationId = resolveRegistrationId(capabilityId, instanceId);\n if (registrationId === undefined) {\n throw new Error(`captureRef: no unique live registration exposes ${capabilityId}`);\n }\n return { registrationId, surfaceVersion: registry.getVersion() };\n },\n\n as(host) {\n if (!ownsRegistry) {\n throw new Error(\n \"as() requires a harness-created registry — pass `host` through your own RegistryOptions.context instead\",\n );\n }\n hostRef.current = host;\n },\n\n confirmations: {\n pending() {\n return registry.confirmations.pending();\n },\n approve(confirmationId) {\n registry.confirmations.resolve(pickPending(confirmationId), { approved: true });\n },\n deny(confirmationId, reason) {\n registry.confirmations.resolve(pickPending(confirmationId), {\n approved: false,\n ...(reason !== undefined ? { reason } : {}),\n });\n },\n expire(confirmationId) {\n registry.confirmations.forceExpire(pickPending(confirmationId));\n },\n },\n\n events() {\n return [...events];\n },\n\n auditLog() {\n return auditSink.events();\n },\n\n dispose() {\n unsubscribe();\n if (ownsRegistry) registry.dispose();\n },\n };\n\n return surface;\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAWK;AAqDA,SAAS,kBAAkB,SAA2C;AAC3E,QAAM,UAAgD,EAAE,SAAS,SAAS,QAAQ,CAAC,EAAE;AACrF,QAAM,WAA0B,SAAS,YAAY,EAAE,IAAI,QAAQ,MAAM,OAAO;AAChF,QAAM,YAAY,gBAAgB,EAAE,UAAU,IAAK,CAAC;AACpD,QAAM,eAAe,SAAS,aAAa;AAE3C,QAAM,WACJ,SAAS,YACT,2BAA2B;AAAA,IACzB,aAAa;AAAA,IACb,GAAI,SAAS,YAAY,EAAE,WAAW,QAAQ,UAAU,IAAI,CAAC;AAAA,IAC7D,SAAS,MAAM,QAAQ;AAAA,IACvB,OAAO;AAAA,EACT,CAAC;AAEH,QAAM,SAA8B,CAAC;AACrC,QAAM,cAAc,SAAS,UAAU,CAAC,UAAU;AAChD,WAAO,KAAK,KAAK;AAAA,EACnB,CAAC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AS,cAAc,QAAQ,YAAY,cAAc,GAAG;AAAA,UAC1D,UAAU;AAAA,UACV,GAAI,WAAW,SAAY,EAAE,OAAO,IAAI,CAAC;AAAA,QAC3C,CAAC;AAAA,MACH;AAAA,MACA,OAAO,gBAAgB;AACrB,iBAAS,cAAc,YAAY,YAAY,cAAc,CAAC;AAAA,MAChE;AAAA,IACF;AAAA,IAEA,SAAS;AACP,aAAO,CAAC,GAAG,MAAM;AAAA,IACnB;AAAA,IAEA,WAAW;AACT,aAAO,UAAU,OAAO;AAAA,IAC1B;AAAA,IAEA,UAAU;AACR,kBAAY;AACZ,UAAI,aAAc,UAAS,QAAQ;AAAA,IACrC;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { AgentSurfaceRegistry, SnapshotContext, AgentSurfaceSnapshot, JsonValue, AgentConsumer, AgentInvocationResult, PendingConfirmation, AgentSurfaceEvent, AuditEvent } from '@agent-surface/core';
|
|
1
|
+
import { AgentSurfaceRegistry, SnapshotContext, AgentSurfaceSnapshot, JsonValue, AgentConsumer, AgentInvocationResult, PendingConfirmation, AgentSurfaceEvent, AuditEvent, CapabilityAuthority } from '@agent-surface/core';
|
|
2
2
|
|
|
3
3
|
interface TestSurfaceOptions {
|
|
4
4
|
registry?: AgentSurfaceRegistry;
|
|
5
|
+
authority?: CapabilityAuthority;
|
|
5
6
|
consumer?: AgentConsumer;
|
|
6
7
|
host?: Record<string, unknown>;
|
|
7
8
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { T as TestSurface, a as TestSurfaceOptions, c as createTestSurface } from './harness-
|
|
1
|
+
export { T as TestSurface, a as TestSurfaceOptions, c as createTestSurface } from './harness-dvJE7PNr.js';
|
|
2
2
|
import { AgentSurfaceSnapshot } from '@agent-surface/core';
|
|
3
3
|
export { AgentSurfaceMatchers, matchers, toBeOk, toExpose, toExposeUnavailable, toFailWith, toMatchSurfaceSnapshot } from './matchers.js';
|
|
4
4
|
|
package/dist/index.js
CHANGED
package/dist/react.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentType, ReactNode, ReactElement } from 'react';
|
|
2
2
|
import { RenderResult } from '@testing-library/react';
|
|
3
|
-
import { a as TestSurfaceOptions, T as TestSurface } from './harness-
|
|
3
|
+
import { a as TestSurfaceOptions, T as TestSurface } from './harness-dvJE7PNr.js';
|
|
4
4
|
import '@agent-surface/core';
|
|
5
5
|
|
|
6
6
|
interface RenderAgentSurfaceOptions extends TestSurfaceOptions {
|
package/dist/react.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-surface/testing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Deterministic test harness, matchers and semantic snapshots for agent surfaces — no LLM required",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"LICENSE"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@agent-surface/core": "^0.
|
|
29
|
+
"@agent-surface/core": "^0.17.0"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@agent-surface/react": ">=0.1.0",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@types/react": "^19.1.9",
|
|
52
52
|
"vitest": "^3.2.4",
|
|
53
53
|
"zod": "^4.1.5",
|
|
54
|
-
"@agent-surface/react": "0.
|
|
54
|
+
"@agent-surface/react": "0.17.0"
|
|
55
55
|
},
|
|
56
56
|
"author": "Paolo Barbato",
|
|
57
57
|
"engines": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/harness.ts"],"sourcesContent":["import {\n createAgentSurfaceRegistry,\n memoryAuditSink,\n type AgentConsumer,\n type AgentInvocationResult,\n type AgentSurfaceEvent,\n type AgentSurfaceRegistry,\n type AgentSurfaceSnapshot,\n type AuditEvent,\n type JsonValue,\n type PendingConfirmation,\n type SnapshotContext,\n} from \"@agent-surface/core\";\n\nexport interface TestSurfaceOptions {\n registry?: AgentSurfaceRegistry; // default: fresh registry, environment \"test\"\n consumer?: AgentConsumer; // default {id:\"test\", kind:\"test\"}\n host?: Record<string, unknown>; // overrides RegistryOptions.context()\n}\n\nexport interface TestSurface {\n registry: AgentSurfaceRegistry;\n snapshot(ctx?: Partial<SnapshotContext>): AgentSurfaceSnapshot;\n\n /** Invoke with test conveniences: auto invocationId, auto registrationId\n resolution from the latest snapshot, typed input. */\n invoke(\n capabilityId: string,\n input?: JsonValue,\n opts?: {\n instanceId?: string;\n registrationId?: string; // pass a captured one to simulate staleness\n surfaceVersion?: string;\n confirmationId?: string;\n consumer?: AgentConsumer;\n },\n ): Promise<AgentInvocationResult>;\n\n /** Sugar: invoke an observation and return its parsed output (throws on error). */\n observe<T = JsonValue>(capabilityId: string, opts?: { instanceId?: string }): Promise<T>;\n\n /** Capture current resolution tokens for later stale-invocation tests. */\n captureRef(\n capabilityId: string,\n instanceId?: string,\n ): { registrationId: string; surfaceVersion: string };\n\n /** Swap host context mid-test (auth changes): as({user: admin}). */\n as(host: Record<string, unknown>): void;\n\n confirmations: {\n pending(): PendingConfirmation[];\n approve(confirmationId?: string): void; // default: the only pending one\n deny(confirmationId?: string, reason?: string): void;\n expire(confirmationId?: string): void; // force-expires that record\n };\n\n /** All registry events recorded since creation, in order. */\n events(): AgentSurfaceEvent[];\n auditLog(): AuditEvent[];\n\n dispose(): void;\n}\n\nexport function createTestSurface(options?: TestSurfaceOptions): TestSurface {\n const hostRef: { current: Record<string, unknown> } = { current: options?.host ?? {} };\n const consumer: AgentConsumer = options?.consumer ?? { id: \"test\", kind: \"test\" };\n const auditSink = memoryAuditSink({ capacity: 5000 });\n const ownsRegistry = options?.registry === undefined;\n\n const registry =\n options?.registry ??\n createAgentSurfaceRegistry({\n environment: \"test\",\n context: () => hostRef.current,\n audit: auditSink,\n });\n\n const events: AgentSurfaceEvent[] = [];\n const unsubscribe = registry.subscribe((event) => {\n events.push(event);\n });\n\n function resolveRegistrationId(\n capabilityId: string,\n instanceId: string | undefined,\n ): string | undefined {\n const snapshot = registry.snapshot({ consumer });\n const matches: string[] = [];\n for (const component of snapshot.components) {\n if (instanceId !== undefined && component.instanceId !== instanceId) continue;\n const caps = [...component.observations, ...component.actions];\n if (caps.some((c) => c.capabilityId === capabilityId)) {\n matches.push(component.registrationId);\n }\n }\n for (const proc of snapshot.procedures) {\n if (proc.procedureId === capabilityId) matches.push(proc.registrationId);\n }\n // Auto-attach only when unambiguous; otherwise let the registry produce\n // AMBIGUOUS_INSTANCE / CAPABILITY_NOT_FOUND / COMPONENT_UNMOUNTED.\n return matches.length === 1 ? matches[0] : undefined;\n }\n\n function pickPending(confirmationId: string | undefined): string {\n if (confirmationId !== undefined) return confirmationId;\n const pending = registry.confirmations.pending();\n if (pending.length === 1) return pending[0]!.confirmationId;\n throw new Error(\n pending.length === 0\n ? \"no pending confirmation to resolve\"\n : \"multiple pending confirmations — pass an explicit confirmationId\",\n );\n }\n\n const surface: TestSurface = {\n registry,\n\n snapshot(ctx) {\n return registry.snapshot({ consumer, ...ctx });\n },\n\n invoke(capabilityId, input, opts) {\n const registrationId =\n opts?.registrationId !== undefined\n ? opts.registrationId\n : resolveRegistrationId(capabilityId, opts?.instanceId);\n return registry.invoke(\n {\n capabilityId,\n ...(input !== undefined ? { input } : {}),\n ...(opts?.instanceId !== undefined ? { instanceId: opts.instanceId } : {}),\n ...(registrationId !== undefined ? { registrationId } : {}),\n ...(opts?.surfaceVersion !== undefined ? { surfaceVersion: opts.surfaceVersion } : {}),\n ...(opts?.confirmationId !== undefined ? { confirmationId: opts.confirmationId } : {}),\n },\n { consumer: opts?.consumer ?? consumer },\n );\n },\n\n async observe<T = JsonValue>(capabilityId: string, opts?: { instanceId?: string }): Promise<T> {\n const versionBefore = registry.getVersion();\n const result = await surface.invoke(capabilityId, undefined, opts);\n if (result.status === \"error\") {\n throw new Error(\n `observe(${capabilityId}) failed: ${result.error.code} — ${result.error.message}`,\n );\n }\n const versionAfter = registry.getVersion();\n if (versionAfter !== versionBefore) {\n throw new Error(\n `observe(${capabilityId}) mutated the surface (version ${versionBefore} → ${versionAfter}); observations MUST be side-effect free (docs/01)`,\n );\n }\n return result.output as T;\n },\n\n captureRef(capabilityId, instanceId) {\n const registrationId = resolveRegistrationId(capabilityId, instanceId);\n if (registrationId === undefined) {\n throw new Error(`captureRef: no unique live registration exposes ${capabilityId}`);\n }\n return { registrationId, surfaceVersion: registry.getVersion() };\n },\n\n as(host) {\n if (!ownsRegistry) {\n throw new Error(\n \"as() requires a harness-created registry — pass `host` through your own RegistryOptions.context instead\",\n );\n }\n hostRef.current = host;\n },\n\n confirmations: {\n pending() {\n return registry.confirmations.pending();\n },\n approve(confirmationId) {\n registry.confirmations.resolve(pickPending(confirmationId), { approved: true });\n },\n deny(confirmationId, reason) {\n registry.confirmations.resolve(pickPending(confirmationId), {\n approved: false,\n ...(reason !== undefined ? { reason } : {}),\n });\n },\n expire(confirmationId) {\n registry.confirmations.forceExpire(pickPending(confirmationId));\n },\n },\n\n events() {\n return [...events];\n },\n\n auditLog() {\n return auditSink.events();\n },\n\n dispose() {\n unsubscribe();\n if (ownsRegistry) registry.dispose();\n },\n };\n\n return surface;\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAUK;AAoDA,SAAS,kBAAkB,SAA2C;AAC3E,QAAM,UAAgD,EAAE,SAAS,SAAS,QAAQ,CAAC,EAAE;AACrF,QAAM,WAA0B,SAAS,YAAY,EAAE,IAAI,QAAQ,MAAM,OAAO;AAChF,QAAM,YAAY,gBAAgB,EAAE,UAAU,IAAK,CAAC;AACpD,QAAM,eAAe,SAAS,aAAa;AAE3C,QAAM,WACJ,SAAS,YACT,2BAA2B;AAAA,IACzB,aAAa;AAAA,IACb,SAAS,MAAM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