@adea-ai/runtime-gateway-protocol 1.16.0 → 1.16.1

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/emulator.js DELETED
@@ -1,137 +0,0 @@
1
- import { GatewayCommandEnvelopeSchema, GatewayEnvelopeSchema, GatewayProtocolManifest, negotiateGatewayProtocolVersion, } from './protocol.js';
2
- import { inventoryFixtures } from './fixtures.js';
3
- export class GatewayProtocolError extends Error {
4
- code;
5
- constructor(code) {
6
- super(code);
7
- this.code = code;
8
- this.name = 'GatewayProtocolError';
9
- }
10
- }
11
- export class ReferenceRuntimeNode {
12
- #effects = new Map();
13
- #ledger = new Map();
14
- #maxLedgerEntries;
15
- #now;
16
- #lastObservedSequence = 0;
17
- constructor(options = {}) {
18
- const maxLedgerEntries = options.maxLedgerEntries ?? 10_000;
19
- if (!Number.isSafeInteger(maxLedgerEntries) || maxLedgerEntries <= 0) {
20
- throw new GatewayProtocolError('INVALID_LEDGER_CAPACITY');
21
- }
22
- this.#maxLedgerEntries = maxLedgerEntries;
23
- this.#now = options.now ?? (() => new Date());
24
- }
25
- observe(envelopeValue) {
26
- const envelope = GatewayEnvelopeSchema.parse(envelopeValue);
27
- this.#lastObservedSequence = Math.max(this.#lastObservedSequence, envelope.sequence);
28
- return envelope.type;
29
- }
30
- lastObservedSequence() {
31
- return this.#lastObservedSequence;
32
- }
33
- receive(commandValue) {
34
- const command = GatewayCommandEnvelopeSchema.parse(commandValue);
35
- const recorded = this.#ledger.get(command.commandId);
36
- if (recorded !== undefined) {
37
- if (recorded.payloadHash !== command.payloadHash) {
38
- throw new GatewayProtocolError('COMMAND_PAYLOAD_MISMATCH');
39
- }
40
- return { ack: this.#ack(command, 'replayed'), result: structuredClone(recorded.result) };
41
- }
42
- if (Date.parse(command.expiresAt) <= this.#now().getTime()) {
43
- return { ack: this.#ack(command, 'expired') };
44
- }
45
- if (this.#ledger.size >= this.#maxLedgerEntries) {
46
- throw new GatewayProtocolError('COMMAND_LEDGER_CAPACITY_EXCEEDED');
47
- }
48
- const result = this.#result(command);
49
- this.#effects.set(command.commandId, 1);
50
- this.#ledger.set(command.commandId, { payloadHash: command.payloadHash, result });
51
- return { ack: this.#ack(command, 'accepted'), result: structuredClone(result) };
52
- }
53
- effectCount(commandId) {
54
- return this.#effects.get(commandId) ?? 0;
55
- }
56
- #ack(command, disposition) {
57
- return {
58
- type: 'ack',
59
- schemaVersion: 1,
60
- protocolVersion: command.protocolVersion,
61
- sequence: command.sequence,
62
- nodeId: command.nodeId,
63
- workspaceId: command.workspaceId,
64
- traceId: command.traceId,
65
- sentAt: this.#now().toISOString(),
66
- channelGeneration: command.channelGeneration,
67
- commandId: command.commandId,
68
- payloadHash: command.payloadHash,
69
- disposition,
70
- };
71
- }
72
- #result(command) {
73
- return {
74
- type: 'result',
75
- schemaVersion: 1,
76
- protocolVersion: command.protocolVersion,
77
- sequence: command.sequence + 1,
78
- nodeId: command.nodeId,
79
- workspaceId: command.workspaceId,
80
- traceId: command.traceId,
81
- sentAt: this.#now().toISOString(),
82
- channelGeneration: command.channelGeneration,
83
- commandId: command.commandId,
84
- payloadHash: command.payloadHash,
85
- status: 'succeeded',
86
- completedAt: this.#now().toISOString(),
87
- result: { data: { outcome: 'reference-complete' } },
88
- };
89
- }
90
- }
91
- export function runGatewayProtocolConformance() {
92
- const command = conformanceCommand();
93
- const node = new ReferenceRuntimeNode({ now: () => new Date('2026-08-25T12:00:01.000Z') });
94
- const first = node.receive(command);
95
- const replay = node.receive(command);
96
- const checks = [
97
- GatewayEnvelopeSchema.safeParse(command).success,
98
- negotiateGatewayProtocolVersion(GatewayProtocolManifest.supported, [{ major: 1, minor: 0 }])
99
- ?.major === 1,
100
- first.ack.disposition === 'accepted',
101
- replay.ack.disposition === 'replayed',
102
- node.effectCount(command.commandId) === 1,
103
- inventoryFixtures.noProvider.contextProviders.length === 0,
104
- inventoryFixtures.cortanaCompatible.contextProviders.length === 1,
105
- inventoryFixtures.alternateProvider.contextProviders.length === 1,
106
- GatewayEnvelopeSchema.safeParse({ ...command, operation: 'pi.command' }).success === false,
107
- ];
108
- if (checks.some((check) => !check))
109
- throw new GatewayProtocolError('CONFORMANCE_FAILED');
110
- return { scenarios: 9, passed: 9 };
111
- }
112
- function conformanceCommand() {
113
- return {
114
- type: 'command',
115
- schemaVersion: 1,
116
- protocolVersion: { major: 1, minor: 0 },
117
- sequence: 1,
118
- nodeId: 'rnr_01JABCDEF0123456789ABCDEFG',
119
- workspaceId: 'wsp_01JABCDEF0123456789ABCDEFG',
120
- traceId: 'trc_01JABCDEF0123456789ABCDEFG',
121
- sentAt: '2026-08-25T12:00:00.000Z',
122
- channelGeneration: 1,
123
- commandId: 'cmd_01JABCDEF0123456789ABCDEFG',
124
- idempotencyKey: 'conformance:01JABCDEF0123456789ABCDEFG',
125
- payloadHash: `sha256:${'a'.repeat(64)}`,
126
- issuedAt: '2026-08-25T12:00:00.000Z',
127
- expiresAt: '2026-08-25T12:01:00.000Z',
128
- family: 'runtime',
129
- operation: 'runtime.execute',
130
- driver: { family: 'reference-runtime', version: '1.0.0' },
131
- runtimeConnectionId: 'rtc_01JABCDEF0123456789ABCDEFG',
132
- executionId: 'exe_01JABCDEF0123456789ABCDEFG',
133
- attemptId: 'att_01JABCDEF0123456789ABCDEFG',
134
- requiredCapabilities: ['runtime.execute'],
135
- payload: { version: 1, parameters: { fixture: true } },
136
- };
137
- }
@@ -1,149 +0,0 @@
1
- export declare const inventoryFixtures: Readonly<{
2
- noProvider: {
3
- schemaVersion: 1;
4
- protocolVersion: {
5
- major: number;
6
- minor: number;
7
- };
8
- sequence: number;
9
- nodeId: string;
10
- workspaceId: string;
11
- traceId: string;
12
- sentAt: string;
13
- channelGeneration: number;
14
- type: "inventory";
15
- mode?: "delta" | "snapshot" | undefined;
16
- snapshotVersion: number;
17
- baseSnapshotVersion?: number | undefined;
18
- observedAt: string;
19
- runtimeDrivers: {
20
- opaqueRef: string;
21
- driverFamily: string;
22
- adapterVersion?: string | undefined;
23
- driverVersion: string;
24
- harnessVersion?: string | undefined;
25
- capabilityTtlMs?: number | undefined;
26
- protocolVersion: {
27
- major: number;
28
- minor: number;
29
- };
30
- health: "degraded" | "healthy" | "unavailable";
31
- capabilities: string[];
32
- limitations: string[];
33
- }[];
34
- contextProviders: {
35
- opaqueRef: string;
36
- driverFamily: string;
37
- adapterVersion?: string | undefined;
38
- driverVersion: string;
39
- harnessVersion?: string | undefined;
40
- capabilityTtlMs?: number | undefined;
41
- protocolVersion: {
42
- major: number;
43
- minor: number;
44
- };
45
- health: "degraded" | "healthy" | "unavailable";
46
- capabilities: string[];
47
- limitations: string[];
48
- }[];
49
- removedRuntimeRefs?: string[] | undefined;
50
- };
51
- cortanaCompatible: {
52
- schemaVersion: 1;
53
- protocolVersion: {
54
- major: number;
55
- minor: number;
56
- };
57
- sequence: number;
58
- nodeId: string;
59
- workspaceId: string;
60
- traceId: string;
61
- sentAt: string;
62
- channelGeneration: number;
63
- type: "inventory";
64
- mode?: "delta" | "snapshot" | undefined;
65
- snapshotVersion: number;
66
- baseSnapshotVersion?: number | undefined;
67
- observedAt: string;
68
- runtimeDrivers: {
69
- opaqueRef: string;
70
- driverFamily: string;
71
- adapterVersion?: string | undefined;
72
- driverVersion: string;
73
- harnessVersion?: string | undefined;
74
- capabilityTtlMs?: number | undefined;
75
- protocolVersion: {
76
- major: number;
77
- minor: number;
78
- };
79
- health: "degraded" | "healthy" | "unavailable";
80
- capabilities: string[];
81
- limitations: string[];
82
- }[];
83
- contextProviders: {
84
- opaqueRef: string;
85
- driverFamily: string;
86
- adapterVersion?: string | undefined;
87
- driverVersion: string;
88
- harnessVersion?: string | undefined;
89
- capabilityTtlMs?: number | undefined;
90
- protocolVersion: {
91
- major: number;
92
- minor: number;
93
- };
94
- health: "degraded" | "healthy" | "unavailable";
95
- capabilities: string[];
96
- limitations: string[];
97
- }[];
98
- removedRuntimeRefs?: string[] | undefined;
99
- };
100
- alternateProvider: {
101
- schemaVersion: 1;
102
- protocolVersion: {
103
- major: number;
104
- minor: number;
105
- };
106
- sequence: number;
107
- nodeId: string;
108
- workspaceId: string;
109
- traceId: string;
110
- sentAt: string;
111
- channelGeneration: number;
112
- type: "inventory";
113
- mode?: "delta" | "snapshot" | undefined;
114
- snapshotVersion: number;
115
- baseSnapshotVersion?: number | undefined;
116
- observedAt: string;
117
- runtimeDrivers: {
118
- opaqueRef: string;
119
- driverFamily: string;
120
- adapterVersion?: string | undefined;
121
- driverVersion: string;
122
- harnessVersion?: string | undefined;
123
- capabilityTtlMs?: number | undefined;
124
- protocolVersion: {
125
- major: number;
126
- minor: number;
127
- };
128
- health: "degraded" | "healthy" | "unavailable";
129
- capabilities: string[];
130
- limitations: string[];
131
- }[];
132
- contextProviders: {
133
- opaqueRef: string;
134
- driverFamily: string;
135
- adapterVersion?: string | undefined;
136
- driverVersion: string;
137
- harnessVersion?: string | undefined;
138
- capabilityTtlMs?: number | undefined;
139
- protocolVersion: {
140
- major: number;
141
- minor: number;
142
- };
143
- health: "degraded" | "healthy" | "unavailable";
144
- capabilities: string[];
145
- limitations: string[];
146
- }[];
147
- removedRuntimeRefs?: string[] | undefined;
148
- };
149
- }>;
package/dist/fixtures.js DELETED
@@ -1,48 +0,0 @@
1
- import { GatewayInventoryEnvelopeSchema } from './protocol.js';
2
- const common = {
3
- type: 'inventory',
4
- schemaVersion: 1,
5
- protocolVersion: { major: 1, minor: 0 },
6
- sequence: 2,
7
- nodeId: 'rnr_01JABCDEF0123456789ABCDEFG',
8
- workspaceId: 'wsp_01JABCDEF0123456789ABCDEFG',
9
- traceId: 'trc_01JABCDEF0123456789ABCDEFG',
10
- sentAt: '2026-08-25T12:00:00.000Z',
11
- channelGeneration: 1,
12
- snapshotVersion: 1,
13
- observedAt: '2026-08-25T12:00:00.000Z',
14
- runtimeDrivers: [
15
- {
16
- opaqueRef: 'nref_01JABCDEF0123456789ABCDEFG',
17
- driverFamily: 'reference-runtime',
18
- driverVersion: '1.0.0',
19
- harnessVersion: '1.0.0',
20
- protocolVersion: { major: 1, minor: 0 },
21
- health: 'healthy',
22
- capabilities: ['runtime.execute'],
23
- limitations: [],
24
- },
25
- ],
26
- };
27
- const contextProvider = (driverFamily, opaqueRef) => ({
28
- opaqueRef,
29
- driverFamily,
30
- driverVersion: '1.0.0',
31
- protocolVersion: { major: 1, minor: 0 },
32
- health: 'healthy',
33
- capabilities: ['context.status', 'context.read'],
34
- limitations: [],
35
- });
36
- export const inventoryFixtures = Object.freeze({
37
- noProvider: GatewayInventoryEnvelopeSchema.parse({ ...common, contextProviders: [] }),
38
- cortanaCompatible: GatewayInventoryEnvelopeSchema.parse({
39
- ...common,
40
- snapshotVersion: 2,
41
- contextProviders: [contextProvider('local-context', 'pvr_01JABCDEF0123456789ABCDEFG')],
42
- }),
43
- alternateProvider: GatewayInventoryEnvelopeSchema.parse({
44
- ...common,
45
- snapshotVersion: 3,
46
- contextProviders: [contextProvider('alternate-context', 'pvr_01JBBCDEF0123456789ABCDEFG')],
47
- }),
48
- });