@anureo/conformance 0.2.0 → 0.3.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 +8 -4
- package/examples/standalone.d.ts +1 -0
- package/examples/standalone.js +16 -0
- package/package.json +20 -21
- package/src/fake-claude.d.ts +78 -0
- package/src/fake-claude.js +68 -0
- package/src/fake.d.ts +122 -0
- package/src/fake.js +284 -0
- package/src/fixtures.d.ts +38 -0
- package/src/index.d.ts +6 -0
- package/src/index.js +6 -0
- package/src/native.d.ts +44 -0
- package/src/native.js +96 -0
- package/src/suite.d.ts +60 -0
- package/src/suite.js +289 -0
- package/dist/fake-claude.d.ts +0 -40
- package/dist/fake.d.ts +0 -44
- package/dist/fake.js +0 -199
- package/dist/fixtures.d.ts +0 -21
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -409
- package/dist/suite.d.ts +0 -28
- package/examples/standalone.mjs +0 -53
- /package/{dist → src}/fixtures.js +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# @anureo/conformance
|
|
2
2
|
|
|
3
|
-
The
|
|
3
|
+
The Anureo SDK conformance suites drive the revised AHP v1 client through the public runtime API.
|
|
4
|
+
The shared suite, `runConformance`, drives any `HarnessAdapter` to verify the shared behavioral contract that AHP implies.
|
|
5
|
+
Passing the shared suite establishes conformance only within that shared acceptance scope.
|
|
6
|
+
Full adapter conformance also requires the native suite, `runNativeConformance`, which covers overlap,
|
|
7
|
+
active close and independent observations, with native evidence supplied by adapter fixtures.
|
|
8
|
+
Passing a subset does not establish full adapter conformance. See the [acceptance plan](../../docs/native-harness-lifecycle.md#9-实施顺序与验收).
|
|
4
9
|
|
|
5
10
|
> Part of the [Anureo SDK workspace](../../README.md). Install with `npm install @anureo/conformance`.
|
|
6
11
|
|
|
@@ -28,7 +33,7 @@ if (!report.passed) {
|
|
|
28
33
|
|
|
29
34
|
Each case returns `passed`, `failed`, or `not-applicable`:
|
|
30
35
|
|
|
31
|
-
- A scenario is **not-applicable** when its capability was not declared at initialization (e.g. `steer` for a backend without `
|
|
36
|
+
- A scenario is **not-applicable** when its capability was not declared at initialization (e.g. `steer` for a backend without `input.steer.atomicMatch`).
|
|
32
37
|
- A **declared** capability must actually pass its scenario — a missing fixture is a failure, not a skip. Declaring fork without a working fork is exactly the bug this suite exists to catch.
|
|
33
38
|
|
|
34
39
|
## Scenarios
|
|
@@ -49,7 +54,7 @@ Also included: `ScriptedClaudeQuery` / `createFakeClaudeQuery` — a minimal inj
|
|
|
49
54
|
|
|
50
55
|
## Scripted backends under scripts/
|
|
51
56
|
|
|
52
|
-
`scripts/` contains standalone fake backend processes (`fake-acp.ts`, `fake-ahp.ts`, `fake-codex.ts`, `fake-wire.ts`) that speak their real native wire protocols over stdio.
|
|
57
|
+
`scripts/` contains standalone fake backend processes (`fake-acp.ts`, `fake-ahp.ts`, `fake-codex.ts`, `fake-wire.ts`) that speak their real native wire protocols over stdio. Conformance tests use these processes to exercise real wire conversations over stdio.
|
|
53
58
|
|
|
54
59
|
## Development
|
|
55
60
|
|
|
@@ -57,7 +62,6 @@ Also included: `ScriptedClaudeQuery` / `createFakeClaudeQuery` — a minimal inj
|
|
|
57
62
|
cd packages/conformance
|
|
58
63
|
bun run typecheck
|
|
59
64
|
bun test src
|
|
60
|
-
bun examples/standalone.ts # scripted round-trip without any backend
|
|
61
65
|
```
|
|
62
66
|
|
|
63
67
|
## Documentation
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createClient } from '@anureo/sdk';
|
|
2
|
+
import { createScriptedAdapter } from '@anureo/conformance/fake';
|
|
3
|
+
// Runs a scripted backend without an account or model service.
|
|
4
|
+
const client = await createClient({
|
|
5
|
+
adapter: createScriptedAdapter(),
|
|
6
|
+
identity: { adapterId: 'scripted', runtimeConfigId: 'local' },
|
|
7
|
+
});
|
|
8
|
+
try {
|
|
9
|
+
const session = await client.sessions.create({ cwd: process.cwd() });
|
|
10
|
+
const turn = await session.submit({ input: 'Hello from Anureo SDK' });
|
|
11
|
+
console.log((await turn.result()).text);
|
|
12
|
+
await session.close();
|
|
13
|
+
}
|
|
14
|
+
finally {
|
|
15
|
+
await client.dispose();
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anureo/conformance",
|
|
3
|
-
"version": "0.2.0",
|
|
4
3
|
"description": "Shared conformance suite and scripted fixtures for Anureo SDK adapters and AHP implementations",
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"anureo",
|
|
@@ -26,34 +26,33 @@
|
|
|
26
26
|
"type": "module",
|
|
27
27
|
"exports": {
|
|
28
28
|
".": {
|
|
29
|
-
"types": "./
|
|
30
|
-
"import": "./
|
|
31
|
-
"default": "./
|
|
29
|
+
"types": "./src/index.d.ts",
|
|
30
|
+
"import": "./src/index.js",
|
|
31
|
+
"default": "./src/index.js"
|
|
32
32
|
},
|
|
33
33
|
"./fake": {
|
|
34
|
-
"types": "./
|
|
35
|
-
"import": "./
|
|
36
|
-
"default": "./
|
|
34
|
+
"types": "./src/fake.d.ts",
|
|
35
|
+
"import": "./src/fake.js",
|
|
36
|
+
"default": "./src/fake.js"
|
|
37
37
|
},
|
|
38
38
|
"./fixtures": {
|
|
39
|
-
"types": "./
|
|
40
|
-
"import": "./
|
|
41
|
-
"default": "./
|
|
39
|
+
"types": "./src/fixtures.d.ts",
|
|
40
|
+
"import": "./src/fixtures.js",
|
|
41
|
+
"default": "./src/fixtures.js"
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
|
-
"files": [
|
|
45
|
-
"dist",
|
|
46
|
-
"schema",
|
|
47
|
-
"protocol",
|
|
48
|
-
"examples",
|
|
49
|
-
"README.md",
|
|
50
|
-
"LICENSE"
|
|
51
|
-
],
|
|
52
44
|
"dependencies": {
|
|
53
|
-
"@anureo/protocol": "0.
|
|
54
|
-
"@anureo/sdk": "0.
|
|
45
|
+
"@anureo/protocol": "0.3.0",
|
|
46
|
+
"@anureo/sdk": "0.3.0"
|
|
55
47
|
},
|
|
56
48
|
"engines": {
|
|
57
49
|
"node": ">=22"
|
|
58
|
-
}
|
|
50
|
+
},
|
|
51
|
+
"files": [
|
|
52
|
+
"src",
|
|
53
|
+
"bin",
|
|
54
|
+
"schema",
|
|
55
|
+
"protocol",
|
|
56
|
+
"examples"
|
|
57
|
+
]
|
|
59
58
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { JsonObject, JsonValue } from "@anureo/protocol";
|
|
2
|
+
/** Configure the initial output, input behavior and simulated capabilities of a Claude query fixture. */
|
|
3
|
+
export interface ClaudeQueryScript {
|
|
4
|
+
/** Initial messages cloned and buffered in order within the default BoundedEventQueue limits. */
|
|
5
|
+
messages: JsonObject[];
|
|
6
|
+
/**
|
|
7
|
+
* Supply a response script that streamInput awaits after recording each input.
|
|
8
|
+
* Await emit to buffer a message or deliver it to a waiting reader. It can wait for
|
|
9
|
+
* queue capacity and reject on closure or admission failure. Keep emitted objects stable
|
|
10
|
+
* while buffered. Callback failures reject streamInput and leave admitted output available.
|
|
11
|
+
*/
|
|
12
|
+
onInput?: (input: JsonValue, emit: (message: JsonObject) => Promise<void>) => Promise<void>;
|
|
13
|
+
/** Returned by reference when supplied, including an empty list; omission selects the fake model. */
|
|
14
|
+
models?: Array<{
|
|
15
|
+
value: string;
|
|
16
|
+
displayName: string;
|
|
17
|
+
description: string;
|
|
18
|
+
}>;
|
|
19
|
+
/** Set true to allow simulated rewind. Omission or false returns a "No checkpoint" denial. */
|
|
20
|
+
canRewind?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Script a Claude query for a test without launching a peer. Controls record observations
|
|
24
|
+
* for assertions. To use one with a Claude adapter's queryFactory, bridge the factory's
|
|
25
|
+
* prompt into streamInput, project the output as native SDK messages and supply additional
|
|
26
|
+
* Query methods the adapter requires, such as applyFlagSettings.
|
|
27
|
+
* Direct callers end output with finish or close and drain or return the output iterator.
|
|
28
|
+
*/
|
|
29
|
+
export declare class ScriptedClaudeQuery implements AsyncIterable<JsonObject> {
|
|
30
|
+
private readonly script;
|
|
31
|
+
/** Ordered input/control observations; input values are retained by reference. */
|
|
32
|
+
readonly calls: Array<{
|
|
33
|
+
method: string;
|
|
34
|
+
value?: JsonValue;
|
|
35
|
+
}>;
|
|
36
|
+
/** Clone and buffer initial messages; cloning or queue admission failures throw synchronously. */
|
|
37
|
+
constructor(script: ClaudeQueryScript);
|
|
38
|
+
/**
|
|
39
|
+
* Claim exclusive output reads. A second acquisition throws EVENT_STREAM_ALREADY_OWNED
|
|
40
|
+
* until the first iterator releases ownership. Overlapping pending reads reject with
|
|
41
|
+
* CONCURRENT_EVENT_READ. Call return when stopping early. If finish or close settled
|
|
42
|
+
* an already pending read, call return or next again to release ownership.
|
|
43
|
+
*/
|
|
44
|
+
[Symbol.asyncIterator](): AsyncIterator<JsonObject>;
|
|
45
|
+
/**
|
|
46
|
+
* Consume one input stream in order, resolving at EOF after its onInput calls complete.
|
|
47
|
+
* Input, callback and awaited emit failures reject without closing output. The caller
|
|
48
|
+
* owns input cancellation and output closure; consume output concurrently if emits fill the queue.
|
|
49
|
+
*/
|
|
50
|
+
streamInput(stream: AsyncIterable<JsonValue>): Promise<void>;
|
|
51
|
+
/** Record an interrupt without cancelling input or ending output. */
|
|
52
|
+
interrupt(): Promise<void>;
|
|
53
|
+
/** Record a model selection; omitted or empty model strings produce a call without a value. */
|
|
54
|
+
setModel(model?: string): Promise<void>;
|
|
55
|
+
/** Record a permission mode without validating or applying it. */
|
|
56
|
+
setPermissionMode(mode: string): Promise<void>;
|
|
57
|
+
/** Record a thinking-token budget, including null, without validating or applying it. */
|
|
58
|
+
setMaxThinkingTokens(tokens: number | null): Promise<void>;
|
|
59
|
+
/** Record the checkpoint ID and return configured availability; denial is a result, and no files change. */
|
|
60
|
+
rewindFiles(id: string): Promise<{
|
|
61
|
+
canRewind: boolean;
|
|
62
|
+
error?: string;
|
|
63
|
+
}>;
|
|
64
|
+
/** Resolve with the supplied list by reference or a fresh single-model list. This adds no call record. */
|
|
65
|
+
supportedModels(): Promise<{
|
|
66
|
+
value: string;
|
|
67
|
+
displayName: string;
|
|
68
|
+
description: string;
|
|
69
|
+
}[]>;
|
|
70
|
+
/** End output admission once and wake blocked emits to reject. Buffered messages still drain and input stays open. */
|
|
71
|
+
finish(): void;
|
|
72
|
+
/** Record close once and end output admission; buffered messages still drain and input is not cancelled. */
|
|
73
|
+
close(): void;
|
|
74
|
+
private readonly queue;
|
|
75
|
+
private closeCalled;
|
|
76
|
+
}
|
|
77
|
+
/** Create a query with its own call log and output queue. Initial cloning or admission failures throw synchronously. */
|
|
78
|
+
export declare function createFakeClaudeQuery(script: ClaudeQueryScript): ScriptedClaudeQuery;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { BoundedEventQueue } from "@anureo/sdk";
|
|
2
|
+
/**
|
|
3
|
+
* Script a Claude query for a test without launching a peer. Controls record observations
|
|
4
|
+
* for assertions. To use one with a Claude adapter's queryFactory, bridge the factory's
|
|
5
|
+
* prompt into streamInput, project the output as native SDK messages and supply additional
|
|
6
|
+
* Query methods the adapter requires, such as applyFlagSettings.
|
|
7
|
+
* Direct callers end output with finish or close and drain or return the output iterator.
|
|
8
|
+
*/
|
|
9
|
+
export class ScriptedClaudeQuery {
|
|
10
|
+
script;
|
|
11
|
+
/** Ordered input/control observations; input values are retained by reference. */
|
|
12
|
+
calls = [];
|
|
13
|
+
/** Clone and buffer initial messages; cloning or queue admission failures throw synchronously. */
|
|
14
|
+
constructor(script) {
|
|
15
|
+
this.script = script;
|
|
16
|
+
for (const message of script.messages)
|
|
17
|
+
this.queue.push(structuredClone(message));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Claim exclusive output reads. A second acquisition throws EVENT_STREAM_ALREADY_OWNED
|
|
21
|
+
* until the first iterator releases ownership. Overlapping pending reads reject with
|
|
22
|
+
* CONCURRENT_EVENT_READ. Call return when stopping early. If finish or close settled
|
|
23
|
+
* an already pending read, call return or next again to release ownership.
|
|
24
|
+
*/
|
|
25
|
+
[Symbol.asyncIterator]() { return this.queue[Symbol.asyncIterator](); }
|
|
26
|
+
/**
|
|
27
|
+
* Consume one input stream in order, resolving at EOF after its onInput calls complete.
|
|
28
|
+
* Input, callback and awaited emit failures reject without closing output. The caller
|
|
29
|
+
* owns input cancellation and output closure; consume output concurrently if emits fill the queue.
|
|
30
|
+
*/
|
|
31
|
+
async streamInput(stream) {
|
|
32
|
+
for await (const input of stream) {
|
|
33
|
+
this.calls.push({ method: "input", value: input });
|
|
34
|
+
await this.script.onInput?.(input, (message) => this.queue.write(message));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** Record an interrupt without cancelling input or ending output. */
|
|
38
|
+
async interrupt() { this.calls.push({ method: "interrupt" }); }
|
|
39
|
+
/** Record a model selection; omitted or empty model strings produce a call without a value. */
|
|
40
|
+
async setModel(model) { this.calls.push({ method: "setModel", ...(model ? { value: model } : {}) }); }
|
|
41
|
+
/** Record a permission mode without validating or applying it. */
|
|
42
|
+
async setPermissionMode(mode) { this.calls.push({ method: "setPermissionMode", value: mode }); }
|
|
43
|
+
/** Record a thinking-token budget, including null, without validating or applying it. */
|
|
44
|
+
async setMaxThinkingTokens(tokens) { this.calls.push({ method: "setMaxThinkingTokens", value: tokens }); }
|
|
45
|
+
/** Record the checkpoint ID and return configured availability; denial is a result, and no files change. */
|
|
46
|
+
async rewindFiles(id) {
|
|
47
|
+
this.calls.push({ method: "rewindFiles", value: id });
|
|
48
|
+
return this.script.canRewind ? { canRewind: true } : { canRewind: false, error: "No checkpoint" };
|
|
49
|
+
}
|
|
50
|
+
/** Resolve with the supplied list by reference or a fresh single-model list. This adds no call record. */
|
|
51
|
+
async supportedModels() { return this.script.models ?? [{ value: "fake-model", displayName: "Fake", description: "Fixture" }]; }
|
|
52
|
+
/** End output admission once and wake blocked emits to reject. Buffered messages still drain and input stays open. */
|
|
53
|
+
finish() { this.queue.end(); }
|
|
54
|
+
/** Record close once and end output admission; buffered messages still drain and input is not cancelled. */
|
|
55
|
+
close() {
|
|
56
|
+
if (this.closeCalled)
|
|
57
|
+
return;
|
|
58
|
+
this.closeCalled = true;
|
|
59
|
+
this.calls.push({ method: "close" });
|
|
60
|
+
this.queue.end();
|
|
61
|
+
}
|
|
62
|
+
queue = new BoundedEventQueue();
|
|
63
|
+
closeCalled = false;
|
|
64
|
+
}
|
|
65
|
+
/** Create a query with its own call log and output queue. Initial cloning or admission failures throw synchronously. */
|
|
66
|
+
export function createFakeClaudeQuery(script) {
|
|
67
|
+
return new ScriptedClaudeQuery(script);
|
|
68
|
+
}
|
package/src/fake.d.ts
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { type BackendSession, type HarnessAdapter, type SessionEventSink, type SessionMethod } from "@anureo/sdk";
|
|
2
|
+
import { type Capabilities, type AhpRequestMap, type AhpResultMap, type HistoryItem, type InitializeParams, type InitializeResult, type SessionBinding, type SessionOpenParams, type SessionState, type AhpEventPayload } from "@anureo/protocol";
|
|
3
|
+
import type { ConformanceFactory } from "./suite.js";
|
|
4
|
+
/** One backend dispatch, recorded before any custom hook runs. */
|
|
5
|
+
export interface FakeCall {
|
|
6
|
+
method: SessionMethod;
|
|
7
|
+
/** The dispatched object also used by the default handler if the hook returns undefined. */
|
|
8
|
+
params: AhpRequestMap[SessionMethod];
|
|
9
|
+
}
|
|
10
|
+
/** Configure an injectable in-memory backend for SDK, workflow and application fixtures. */
|
|
11
|
+
export interface FakeAdapterOptions {
|
|
12
|
+
/** Replaces the complete default capability set. Adapter capability reads clone it. */
|
|
13
|
+
capabilities?: Capabilities;
|
|
14
|
+
/**
|
|
15
|
+
* ScriptedBackendSession.execute awaits this hook after recording a call. Return undefined to
|
|
16
|
+
* continue with default dispatch, or return a method-matching result to supply the entire
|
|
17
|
+
* response. In the latter case the hook owns the call's events and state changes. A throw or
|
|
18
|
+
* rejection rejects backend dispatch.
|
|
19
|
+
*/
|
|
20
|
+
execute?: (call: FakeCall, sink: SessionEventSink) => Promise<AhpResultMap[SessionMethod] | undefined>;
|
|
21
|
+
/**
|
|
22
|
+
* Publish setup events or hold session acquisition. ScriptedHarnessAdapter.openSession awaits
|
|
23
|
+
* this hook after recording the backend and copying any fork history. A throw or rejection
|
|
24
|
+
* rejects acquisition and leaves the recorded fixture state available.
|
|
25
|
+
*/
|
|
26
|
+
onOpen?: (params: SessionOpenParams, sink: SessionEventSink) => Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
/** Default advertised capabilities. Adapter reads clone the current contents of this mutable template. */
|
|
29
|
+
export declare const FAKE_CAPABILITIES: Capabilities;
|
|
30
|
+
/** Create a fresh adapter to pass to createClient. Await disposal of the client when the fixture is done. */
|
|
31
|
+
export declare function createScriptedAdapter(options?: FakeAdapterOptions): ScriptedHarnessAdapter;
|
|
32
|
+
/**
|
|
33
|
+
* Supply runConformance with a fresh in-memory adapter per case, including held turns and
|
|
34
|
+
* observation faults. A supplied capability set replaces the defaults for applicability checks.
|
|
35
|
+
* The runner owns each client and its adapter.
|
|
36
|
+
*/
|
|
37
|
+
export declare function createScriptedConformanceFactory(capabilities?: Capabilities): ConformanceFactory;
|
|
38
|
+
/**
|
|
39
|
+
* Exercise the SDK with an in-memory adapter that records opens and backend dispatches. By default
|
|
40
|
+
* a submission echoes text and publishes completion before acknowledging it. Hooks can supply
|
|
41
|
+
* other behavior. Await Client.dispose to release SDK ownership while retaining fixture records
|
|
42
|
+
* for assertions.
|
|
43
|
+
*/
|
|
44
|
+
export declare class ScriptedHarnessAdapter implements HarnessAdapter {
|
|
45
|
+
readonly options: FakeAdapterOptions;
|
|
46
|
+
/** Retain fixture options by reference for subsequent capability reads, opens and dispatches. */
|
|
47
|
+
constructor(options?: FakeAdapterOptions);
|
|
48
|
+
/** Backend dispatches in arrival order, including calls intercepted by execute. */
|
|
49
|
+
readonly calls: FakeCall[];
|
|
50
|
+
/** Detached open attempts, including attempts whose hook or fork validation fails. */
|
|
51
|
+
readonly opened: SessionOpenParams[];
|
|
52
|
+
/** Latest supplied event sink per session ID, retained for fixture-controlled publication/failure. */
|
|
53
|
+
readonly sinks: Map<string, SessionEventSink>;
|
|
54
|
+
/** Latest created backend per session ID, recorded before fork validation and onOpen. */
|
|
55
|
+
readonly backends: Map<string, ScriptedBackendSession>;
|
|
56
|
+
/** Number of disposal calls received, including any repeated direct calls. */
|
|
57
|
+
disposeCount: number;
|
|
58
|
+
/** Return detached declared capabilities, using FAKE_CAPABILITIES when omitted. */
|
|
59
|
+
get capabilities(): Capabilities;
|
|
60
|
+
/**
|
|
61
|
+
* Return scripted runtime metadata and cloned capabilities after negotiating AHP v1. The SDK
|
|
62
|
+
* adapter wrapper forwards the result to Client.initialize for validation and storage. Malformed
|
|
63
|
+
* requests and unsupported versions reject.
|
|
64
|
+
*/
|
|
65
|
+
initialize(params: InitializeParams): Promise<InitializeResult>;
|
|
66
|
+
/**
|
|
67
|
+
* Supply OutputSession.open with a backend for SDK attachment. Record the backend and sink
|
|
68
|
+
* before copying fork history so a failed setup is observable. Missing source or boundary
|
|
69
|
+
* rejects with SESSION_NOT_FOUND or TURN_NOT_FOUND, respectively. Await onOpen before returning
|
|
70
|
+
* the backend. Hook failures reject and leave the recorded fixture state available.
|
|
71
|
+
*/
|
|
72
|
+
openSession(params: SessionOpenParams, sink: SessionEventSink): Promise<BackendSession>;
|
|
73
|
+
/** Count adapter release. The SDK wrapper calls this after session cleanup attempts. */
|
|
74
|
+
dispose(): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Give openSession a detached prefix of the source history before setup hooks run. A missing
|
|
77
|
+
* source or boundary throws so open rejects with the fork's fixture records still available.
|
|
78
|
+
*/
|
|
79
|
+
private copyForkHistory;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Inspect or customize the in-memory session recorded by ScriptedHarnessAdapter.openSession.
|
|
83
|
+
* OutputSession dispatches validated SDK requests to this backend. Direct fixture calls to execute
|
|
84
|
+
* bypass those SDK guards.
|
|
85
|
+
*/
|
|
86
|
+
export declare class ScriptedBackendSession implements BackendSession {
|
|
87
|
+
private readonly adapter;
|
|
88
|
+
/** Callbacks supplied at open for event publication, interactions and source faults. */
|
|
89
|
+
readonly sink: SessionEventSink;
|
|
90
|
+
/** Requested identity with a deterministic scripted nativeRef, adopted by the SDK at attachment. */
|
|
91
|
+
readonly binding: SessionBinding;
|
|
92
|
+
/** Capabilities cloned from the adapter at construction and shared with the fixture state. */
|
|
93
|
+
readonly capabilities: Capabilities;
|
|
94
|
+
/** Mutable native history. Default backend history/read returns this array by reference. */
|
|
95
|
+
readonly history: HistoryItem[];
|
|
96
|
+
/** Number of disposal calls received, including any repeated direct calls. */
|
|
97
|
+
disposeCount: number;
|
|
98
|
+
/** Initial attachment snapshot. Default configuration dispatch replaces it without publishing a state event. */
|
|
99
|
+
state: SessionState;
|
|
100
|
+
/** Build a ready attachment snapshot and retain the adapter and event sink for dispatch. */
|
|
101
|
+
constructor(adapter: ScriptedHarnessAdapter, params: SessionOpenParams,
|
|
102
|
+
/** Callbacks supplied at open for event publication, interactions and source faults. */
|
|
103
|
+
sink: SessionEventSink);
|
|
104
|
+
/** Await ordered sink publication. Supply the owning turn ID for item events. Sink failures reject. */
|
|
105
|
+
emit(payload: AhpEventPayload, turnId?: string): Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
* Resolve a scripted result for OutputSession.execute, which uses receipts to bind submissions
|
|
108
|
+
* before returning to Session for request-result validation. Record the call and await the
|
|
109
|
+
* custom hook before using defaults. Defaults that publish events await them before returning
|
|
110
|
+
* a receipt. Sink and hook failures reject dispatch. Default interaction dispatch rejects
|
|
111
|
+
* because Session handles it in its registry.
|
|
112
|
+
*/
|
|
113
|
+
execute<M extends SessionMethod>(method: M, params: AhpRequestMap[M]): Promise<AhpResultMap[M]>;
|
|
114
|
+
/** Count backend release calls from the SDK or direct fixture callers and retain state for assertions. */
|
|
115
|
+
dispose(): Promise<void>;
|
|
116
|
+
/**
|
|
117
|
+
* Produce the default submission receipt after publishing start, preview, final item and terminal.
|
|
118
|
+
* Reuse an item ID across turns to exercise SDK scoping. Store the completed item before terminal
|
|
119
|
+
* publication, where a sink failure can still reject the dispatch.
|
|
120
|
+
*/
|
|
121
|
+
private submitInput;
|
|
122
|
+
}
|