@oquen/protocol 2.0.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/ACTBase.d.ts +23 -0
- package/ACTBase.js +51 -0
- package/ACTBase.ts +53 -0
- package/OXP.d.ts +2 -0
- package/OXP.js +3 -0
- package/OXP.ts +7 -0
- package/Readme.md +100 -0
- package/go.mod +3 -0
- package/index.d.ts +11 -0
- package/index.js +55 -0
- package/index.ts +61 -0
- package/package.json +22 -0
- package/tsconfig.json +14 -0
package/ACTBase.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base struct (Abstraction) of the ACT state engine.
|
|
3
|
+
* Manages the 64-byte hardware register mapping.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ACTBase {
|
|
6
|
+
typeHash: bigint;
|
|
7
|
+
dataPtr: bigint;
|
|
8
|
+
dataSize: bigint;
|
|
9
|
+
metadata: number;
|
|
10
|
+
private _command;
|
|
11
|
+
stateBitmask: number;
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
z: number;
|
|
15
|
+
tx: number;
|
|
16
|
+
ty: number;
|
|
17
|
+
tz: number;
|
|
18
|
+
currentFrame: bigint;
|
|
19
|
+
internalSetCommand(cmd: number, data?: number): void;
|
|
20
|
+
setCommand(cmd: number, data?: number): void;
|
|
21
|
+
get command(): number;
|
|
22
|
+
pack(): ArrayBuffer;
|
|
23
|
+
}
|
package/ACTBase.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base struct (Abstraction) of the ACT state engine.
|
|
3
|
+
* Manages the 64-byte hardware register mapping.
|
|
4
|
+
*/
|
|
5
|
+
export class ACTBase {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.typeHash = 0n;
|
|
8
|
+
this.dataPtr = 0n;
|
|
9
|
+
this.dataSize = 0n;
|
|
10
|
+
this.metadata = 0;
|
|
11
|
+
this._command = 0;
|
|
12
|
+
this.stateBitmask = 0;
|
|
13
|
+
this.x = 0;
|
|
14
|
+
this.y = 0;
|
|
15
|
+
this.z = 0;
|
|
16
|
+
this.tx = 0;
|
|
17
|
+
this.ty = 0;
|
|
18
|
+
this.tz = 0;
|
|
19
|
+
this.currentFrame = 0n;
|
|
20
|
+
}
|
|
21
|
+
internalSetCommand(cmd, data = 0) {
|
|
22
|
+
this.metadata = data;
|
|
23
|
+
this._command = cmd;
|
|
24
|
+
}
|
|
25
|
+
setCommand(cmd, data = 0) {
|
|
26
|
+
if (cmd < 100) {
|
|
27
|
+
throw new Error("OXP FATAL: Access Denied. Commands 0-99 are System Reserved.");
|
|
28
|
+
}
|
|
29
|
+
this.metadata = data;
|
|
30
|
+
this._command = cmd;
|
|
31
|
+
}
|
|
32
|
+
get command() { return this._command; }
|
|
33
|
+
pack() {
|
|
34
|
+
const buffer = new ArrayBuffer(64);
|
|
35
|
+
const view = new DataView(buffer);
|
|
36
|
+
view.setBigUint64(0, this.typeHash, true);
|
|
37
|
+
view.setBigUint64(8, this.dataPtr, true);
|
|
38
|
+
view.setBigUint64(16, this.dataSize, true);
|
|
39
|
+
view.setUint16(24, this.metadata, true);
|
|
40
|
+
view.setUint16(26, this._command, true);
|
|
41
|
+
view.setUint32(28, this.stateBitmask, true);
|
|
42
|
+
view.setFloat32(32, this.x, true);
|
|
43
|
+
view.setFloat32(36, this.y, true);
|
|
44
|
+
view.setFloat32(40, this.z, true);
|
|
45
|
+
view.setFloat32(44, this.tx, true);
|
|
46
|
+
view.setFloat32(48, this.ty, true);
|
|
47
|
+
view.setFloat32(52, this.tz, true);
|
|
48
|
+
view.setBigInt64(56, this.currentFrame, true);
|
|
49
|
+
return buffer;
|
|
50
|
+
}
|
|
51
|
+
}
|
package/ACTBase.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base struct (Abstraction) of the ACT state engine.
|
|
3
|
+
* Manages the 64-byte hardware register mapping.
|
|
4
|
+
*/
|
|
5
|
+
export class ACTBase {
|
|
6
|
+
public typeHash: bigint = 0n;
|
|
7
|
+
public dataPtr: bigint = 0n;
|
|
8
|
+
public dataSize: bigint = 0n;
|
|
9
|
+
public metadata: number = 0;
|
|
10
|
+
private _command: number = 0;
|
|
11
|
+
public stateBitmask: number = 0;
|
|
12
|
+
public x: number = 0;
|
|
13
|
+
public y: number = 0;
|
|
14
|
+
public z: number = 0;
|
|
15
|
+
public tx: number = 0;
|
|
16
|
+
public ty: number = 0;
|
|
17
|
+
public tz: number = 0;
|
|
18
|
+
public currentFrame: bigint = 0n;
|
|
19
|
+
|
|
20
|
+
public internalSetCommand(cmd: number, data: number = 0): void {
|
|
21
|
+
this.metadata = data;
|
|
22
|
+
this._command = cmd;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public setCommand(cmd: number, data: number = 0): void {
|
|
26
|
+
if (cmd < 100) {
|
|
27
|
+
throw new Error("OXP FATAL: Access Denied. Commands 0-99 are System Reserved.");
|
|
28
|
+
}
|
|
29
|
+
this.metadata = data;
|
|
30
|
+
this._command = cmd;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public get command(): number { return this._command; }
|
|
34
|
+
|
|
35
|
+
public pack(): ArrayBuffer {
|
|
36
|
+
const buffer = new ArrayBuffer(64);
|
|
37
|
+
const view = new DataView(buffer);
|
|
38
|
+
view.setBigUint64(0, this.typeHash, true);
|
|
39
|
+
view.setBigUint64(8, this.dataPtr, true);
|
|
40
|
+
view.setBigUint64(16, this.dataSize, true);
|
|
41
|
+
view.setUint16(24, this.metadata, true);
|
|
42
|
+
view.setUint16(26, this._command, true);
|
|
43
|
+
view.setUint32(28, this.stateBitmask, true);
|
|
44
|
+
view.setFloat32(32, this.x, true);
|
|
45
|
+
view.setFloat32(36, this.y, true);
|
|
46
|
+
view.setFloat32(40, this.z, true);
|
|
47
|
+
view.setFloat32(44, this.tx, true);
|
|
48
|
+
view.setFloat32(48, this.ty, true);
|
|
49
|
+
view.setFloat32(52, this.tz, true);
|
|
50
|
+
view.setBigInt64(56, this.currentFrame, true);
|
|
51
|
+
return buffer;
|
|
52
|
+
}
|
|
53
|
+
}
|
package/OXP.d.ts
ADDED
package/OXP.js
ADDED
package/OXP.ts
ADDED
package/Readme.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# OQUEN (OKEN) ACT: Hardware Accelerated Logic (OXP)
|
|
2
|
+
|
|
3
|
+
Welcome to a new paradigm in system architecture. With **OQUEN OXP**, we erase layers of software, API gateways, and JSON parsing. Your Next.js app doesn't communicate with a server—it writes directly into hardware registers via the **ZERO Master Node**.
|
|
4
|
+
|
|
5
|
+
## The Architecture
|
|
6
|
+
|
|
7
|
+
An **ACT** (Accelerated Control Template) is a 64-byte binary container mirrored to the silicon in real-time. You program in TypeScript; you execute at silicon speed.
|
|
8
|
+
|
|
9
|
+
- **No REST/GraphQL:** No endpoints to manage.
|
|
10
|
+
- **No JSON:** Zero software overhead.
|
|
11
|
+
- **Hardware Sandbox:** The silicon ignores invalid commands. The server cannot crash.
|
|
12
|
+
- **0.5ns Precision:** Time and Identity are the same thing.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
In OQUEN, you don't use a fixed API. You build a **TypeScript Class** that wraps the raw **ACTBase** register. You map your own methods to Command IDs.
|
|
17
|
+
|
|
18
|
+
## 🧠 Persistent Silicon Memory
|
|
19
|
+
|
|
20
|
+
Unlike traditional stateless APIs, OQUEN is **Stateful by Design**.
|
|
21
|
+
|
|
22
|
+
- **Sticky State**: Once you set a value (like `x = 440`), it stays in the hardware register. You don't need to re-send it in every pulse.
|
|
23
|
+
- **Session Lifetime**: Your state lives as long as your app is open.
|
|
24
|
+
- **Automatic Cleanup**: The moment the user closes the tab or the Space client, the register is zeroed out (Unregistered).
|
|
25
|
+
- Save state can be handled by using a local OQUEN if you want to remain states (At least for now).
|
|
26
|
+
|
|
27
|
+
**Think of the ZERO Register as your app's physical memory in the cloud.**
|
|
28
|
+
|
|
29
|
+
### 1. Build your Custom ACT Class
|
|
30
|
+
|
|
31
|
+
This is where you define what your commands (501, 502, etc.) actually do.
|
|
32
|
+
|
|
33
|
+
## Quick Start: Building your first Synth-ACT
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
# OQUEN: Custom ACT Implementation
|
|
37
|
+
|
|
38
|
+
import { ACTBase } from '@oquen/protocol';
|
|
39
|
+
|
|
40
|
+
export class ACTSynth {
|
|
41
|
+
constructor(private base: ACTBase) {}
|
|
42
|
+
|
|
43
|
+
// Continuous updates (Direct Register Mapping)
|
|
44
|
+
set frequency(val: number) { this.base.x = val; }
|
|
45
|
+
set resonance(val: number) { this.base.y = val; }
|
|
46
|
+
|
|
47
|
+
// Discrete Commands (Direct Hardware Triggers)
|
|
48
|
+
play(note: number) {
|
|
49
|
+
this.base.metadata = note;
|
|
50
|
+
this.base.command = 501; // Command: START
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
pause() {
|
|
54
|
+
this.base.command = 502; // Command: PAUSE
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
setWaveform(type: number) {
|
|
58
|
+
this.base.metadata = type;
|
|
59
|
+
this.base.command = 504; // Command: WAVEFORM
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
# ⚡ OQUEN: React State Integration
|
|
66
|
+
|
|
67
|
+
To make development effortless in Next.js, OQUEN mirrors your **React State** directly into the **Silicon Register**. You don't manage buffers; you manage state.
|
|
68
|
+
|
|
69
|
+
## 1. The Controller Logic
|
|
70
|
+
|
|
71
|
+
Create a hook or a class that syncs your UI state with the hardware offsets.
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
import { useState, useEffect } from 'react';
|
|
75
|
+
import { OXP, ACTBase } from '@oquen/protocol';
|
|
76
|
+
|
|
77
|
+
export function useOquenSynth() {
|
|
78
|
+
const [synth, setSynth] = useState<ACTSynth | null>(null);
|
|
79
|
+
|
|
80
|
+
// Initialize the Hardware Bridge
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
OXP.connect('auto').then(stream => {
|
|
83
|
+
setSynth(new ACTSynth(stream));
|
|
84
|
+
});
|
|
85
|
+
}, []);
|
|
86
|
+
|
|
87
|
+
// The Magic: A single function to update UI and Silicon simultaneously
|
|
88
|
+
const updateFrequency = (value: number) => {
|
|
89
|
+
if (!synth) return;
|
|
90
|
+
|
|
91
|
+
// 1. Update Native Hardware Register
|
|
92
|
+
synth.frequency = value;
|
|
93
|
+
|
|
94
|
+
// 2. Update React State for UI feedback
|
|
95
|
+
// (Optional: only if you need to display the value in text)
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
return { synth, updateFrequency };
|
|
99
|
+
}
|
|
100
|
+
```
|
package/go.mod
ADDED
package/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OXPHeader v2.2 - Hardware Mapping
|
|
3
|
+
*/
|
|
4
|
+
export declare const OXPHeader: any;
|
|
5
|
+
/**
|
|
6
|
+
* execute_pulse: Bryggan till din C# OnPulse-logik
|
|
7
|
+
*/
|
|
8
|
+
export declare const onPulse: (header: any) => any;
|
|
9
|
+
import { OXP } from './OXP';
|
|
10
|
+
import { ACTBase } from './ACTBase';
|
|
11
|
+
export { OXP, ACTBase };
|
package/index.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
// Vi använder require för koffi för att undvika problem i miljöer där det inte finns
|
|
3
|
+
const koffi = typeof window === 'undefined' ? require('koffi') : null;
|
|
4
|
+
// Sökväg till din Master-kärna
|
|
5
|
+
const dllPath = path.resolve(__dirname, '../OXP.Protocol/bin/Release/net10.0/win-x64/OXPProtocol.dll');
|
|
6
|
+
const isNode = typeof window === 'undefined';
|
|
7
|
+
let lib = null;
|
|
8
|
+
// Försök ladda DLL endast om vi är i Node (Lokal Master/Test)
|
|
9
|
+
if (isNode && koffi) {
|
|
10
|
+
try {
|
|
11
|
+
lib = koffi.load(dllPath);
|
|
12
|
+
}
|
|
13
|
+
catch (e) {
|
|
14
|
+
console.warn("OXP: Local DLL not found, running in Network Mode.");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* OXPHeader v2.2 - Hardware Mapping
|
|
19
|
+
*/
|
|
20
|
+
export const OXPHeader = (isNode && koffi) ? koffi.struct('OXPHeader', {
|
|
21
|
+
AppKeyHash: 'uint64', // 8b
|
|
22
|
+
Timestamp: 'int64', // 8b
|
|
23
|
+
EntryCount: 'int64', // 8b
|
|
24
|
+
Version: 'uint8', // 1b
|
|
25
|
+
CpuTemp: 'uint8', // 1b
|
|
26
|
+
AutoPilot: 'uint8', // 1b
|
|
27
|
+
NextPulse: 'uint16', // 2b
|
|
28
|
+
ClientSessionId: 'uint32', // 4b
|
|
29
|
+
PerformanceNs: 'double', // 8b
|
|
30
|
+
PulseState: 'uint8', // 1b
|
|
31
|
+
Zone: 'uint8', // 1b (New v2.2)
|
|
32
|
+
ProviderID: 'uint64' // 8b (New v2.2)
|
|
33
|
+
}) : null;
|
|
34
|
+
/**
|
|
35
|
+
* execute_pulse: Bryggan till din C# OnPulse-logik
|
|
36
|
+
*/
|
|
37
|
+
export const onPulse = (header) => {
|
|
38
|
+
if (!lib || !OXPHeader) {
|
|
39
|
+
// Om vi kör i browsern (Next.js), skickar vi bara till ZERO MASTER via WSS
|
|
40
|
+
return { status: 'WEB_MODE', msg: 'Streaming to zero.oquen.net' };
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
// Anropa din NativeAOT-binary direkt i kisel-fart
|
|
44
|
+
const execute_pulse = lib.func('execute_pulse', 'int', [koffi.pointer(OXPHeader)]);
|
|
45
|
+
return execute_pulse(header);
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
console.error("OXP: Native Pulse Failure", err);
|
|
49
|
+
return -1;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
// Exponera ACTBase-motorn
|
|
53
|
+
import { OXP } from './OXP';
|
|
54
|
+
import { ACTBase } from './ACTBase';
|
|
55
|
+
export { OXP, ACTBase };
|
package/index.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
// Vi använder require för koffi för att undvika problem i miljöer där det inte finns
|
|
3
|
+
const koffi = typeof window === 'undefined' ? require('koffi') : null;
|
|
4
|
+
|
|
5
|
+
// Sökväg till din Master-kärna
|
|
6
|
+
const dllPath = path.resolve(__dirname, '../OXP.Protocol/bin/Release/net10.0/win-x64/OXPProtocol.dll');
|
|
7
|
+
|
|
8
|
+
const isNode = typeof window === 'undefined';
|
|
9
|
+
let lib: any = null;
|
|
10
|
+
|
|
11
|
+
// Försök ladda DLL endast om vi är i Node (Lokal Master/Test)
|
|
12
|
+
if (isNode && koffi) {
|
|
13
|
+
try {
|
|
14
|
+
lib = koffi.load(dllPath);
|
|
15
|
+
} catch (e) {
|
|
16
|
+
console.warn("OXP: Local DLL not found, running in Network Mode.");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* OXPHeader v2.2 - Hardware Mapping
|
|
22
|
+
*/
|
|
23
|
+
export const OXPHeader = (isNode && koffi) ? koffi.struct('OXPHeader', {
|
|
24
|
+
AppKeyHash: 'uint64', // 8b
|
|
25
|
+
Timestamp: 'int64', // 8b
|
|
26
|
+
EntryCount: 'int64', // 8b
|
|
27
|
+
Version: 'uint8', // 1b
|
|
28
|
+
CpuTemp: 'uint8', // 1b
|
|
29
|
+
AutoPilot: 'uint8', // 1b
|
|
30
|
+
NextPulse: 'uint16', // 2b
|
|
31
|
+
ClientSessionId: 'uint32', // 4b
|
|
32
|
+
PerformanceNs: 'double', // 8b
|
|
33
|
+
PulseState: 'uint8', // 1b
|
|
34
|
+
Zone: 'uint8', // 1b (New v2.2)
|
|
35
|
+
ProviderID: 'uint64' // 8b (New v2.2)
|
|
36
|
+
}) : null;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* execute_pulse: Bryggan till din C# OnPulse-logik
|
|
40
|
+
*/
|
|
41
|
+
export const onPulse = (header: any) => {
|
|
42
|
+
if (!lib || !OXPHeader) {
|
|
43
|
+
// Om vi kör i browsern (Next.js), skickar vi bara till ZERO MASTER via WSS
|
|
44
|
+
return { status: 'WEB_MODE', msg: 'Streaming to zero.oquen.net' };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
// Anropa din NativeAOT-binary direkt i kisel-fart
|
|
49
|
+
const execute_pulse = lib.func('execute_pulse', 'int', [koffi.pointer(OXPHeader)]);
|
|
50
|
+
return execute_pulse(header);
|
|
51
|
+
} catch (err) {
|
|
52
|
+
console.error("OXP: Native Pulse Failure", err);
|
|
53
|
+
return -1;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// Exponera ACTBase-motorn
|
|
58
|
+
import { OXP } from './OXP';
|
|
59
|
+
import { ACTBase } from './ACTBase';
|
|
60
|
+
|
|
61
|
+
export { OXP, ACTBase };
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@oquen/protocol",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"types": "index.d.ts",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"koffi": "^2.15.6"
|
|
8
|
+
},
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://git.oquen.net/OQUEN/protocol"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@types/node": "^25.6.0",
|
|
18
|
+
"eslint": "^10.2.0",
|
|
19
|
+
"ts-node": "^10.9.2",
|
|
20
|
+
"typescript": "^5.9.3"
|
|
21
|
+
}
|
|
22
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"lib": [ "ES2020", "DOM", "DOM.Iterable" ],
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"allowSyntheticDefaultImports": true,
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"strict": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"moduleResolution": "node"
|
|
12
|
+
},
|
|
13
|
+
"include": [ "*.ts" ]
|
|
14
|
+
}
|