@ultrst-armada/kloks 1.4.3 → 1.4.4
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/package.json +8 -20
- package/packages/audio-midi/dist/index.d.ts +23 -14
- package/packages/audio-midi/dist/index.js +170 -45
- package/packages/audio-midi/kloks.manifest.json +8 -8
- package/packages/audio-midi/package.json +1 -1
- package/packages/backend/dist/{WebSocketTransport-CxUzUfwl.d.ts → WebSocketTransport-CHmkJ0tj.d.ts} +109 -2
- package/packages/backend/dist/auth/index.js +6 -6
- package/packages/backend/dist/chunk-5336MTXD.js +597 -0
- package/packages/backend/dist/{chunk-T3NYNBDC.js → chunk-5E6JRFUH.js} +201 -3
- package/packages/backend/dist/{chunk-XTWHEZWS.js → chunk-7B24ZWB3.js} +16 -1
- package/packages/backend/dist/{chunk-DZ4ZGIZM.js → chunk-JXUSBKJ2.js} +91 -654
- package/packages/backend/dist/{chunk-FO6WYLW4.js → chunk-KI3LHMUN.js} +133 -46
- package/packages/backend/dist/{chunk-4ZFXEFOE.js → chunk-MPYASJ5A.js} +2 -87
- package/packages/backend/dist/{chunk-KX3OTBQ3.js → chunk-OZDYAEH4.js} +0 -114
- package/packages/backend/dist/chunk-TY32TUNI.js +376 -0
- package/packages/backend/dist/chunk-VDROUXFT.js +116 -0
- package/packages/backend/dist/chunk-ZDH4XI7W.js +140 -0
- package/packages/backend/dist/client/index.d.ts +2 -3
- package/packages/backend/dist/connectivity/index.d.ts +18 -6
- package/packages/backend/dist/connectivity/index.js +3 -7
- package/packages/backend/dist/index.d.ts +3 -6
- package/packages/backend/dist/index.js +101 -91
- package/packages/backend/dist/krnl-services.d.ts +84 -7
- package/packages/backend/dist/krnl-services.js +40 -12
- package/packages/backend/dist/services/index.d.ts +4 -6
- package/packages/backend/dist/services/index.js +2 -2
- package/packages/backend/dist/srkl/index.js +6 -4
- package/packages/backend/dist/storage/index.js +7 -7
- package/packages/backend/dist/workspace/index.js +2 -2
- package/packages/backend/kloks.manifest.json +47 -45
- package/packages/backend/package.json +3 -8
- package/packages/client/package.json +1 -1
- package/packages/contracts/dist/index.js +5 -10
- package/packages/contracts/package.json +1 -1
- package/packages/functions/dist/index.d.ts +12 -1
- package/packages/functions/dist/index.js +132 -24
- package/packages/functions/package.json +1 -1
- package/packages/orchestrations/dist/index.d.ts +33 -31
- package/packages/orchestrations/dist/index.js +81 -203
- package/packages/orchestrations/kloks.manifest.json +10 -2
- package/packages/orchestrations/package.json +2 -2
- package/packages/services/dist/index.d.ts +51 -1
- package/packages/services/dist/index.js +234 -36
- package/packages/services/kloks.manifest.json +69 -33
- package/packages/services/package.json +1 -1
- package/packages/state-graph/dist/{BaseGraph-BvkSYOTw.d.ts → BaseGraph-Bd5F1NMP.d.ts} +1 -1
- package/packages/state-graph/dist/{BaseNode-DTcd3K1B.d.ts → BaseNode-DKpGXMy8.d.ts} +6 -0
- package/packages/state-graph/dist/{CompatibilityMatrix-Dj-tCWUA.d.ts → CompatibilityMatrix-TiEJ3j3_.d.ts} +1 -1
- package/packages/state-graph/dist/domain/index.d.ts +3 -3
- package/packages/state-graph/dist/domain/index.js +0 -1
- package/packages/state-graph/dist/index.d.ts +40 -8
- package/packages/state-graph/dist/index.js +214 -65
- package/packages/state-graph/dist/rules/index.d.ts +3 -3
- package/packages/state-graph/dist/rules/index.js +0 -1
- package/packages/state-graph/dist/spatial/index.d.ts +4 -4
- package/packages/state-graph/dist/spatial/index.js +0 -1
- package/packages/state-graph/dist/state/index.js +1 -3
- package/packages/state-graph/dist/store/index.d.ts +4 -4
- package/packages/state-graph/dist/store/index.js +0 -1
- package/packages/state-graph/dist/{types-VDoc4FIc.d.ts → types-D5kQSa65.d.ts} +2 -2
- package/packages/state-graph/kloks.manifest.json +26 -10
- package/packages/state-graph/package.json +2 -8
- package/packages/backend/dist/IdempotencyManager-B5MjK871.d.ts +0 -16
- package/packages/backend/dist/chunk-25Y7AVTP.js +0 -55
- package/packages/backend/dist/chunk-3EPY34R6.js +0 -67
- package/packages/backend/dist/chunk-7KNGX522.js +0 -220
- package/packages/backend/dist/chunk-FZKBTF34.js +0 -15
- package/packages/backend/dist/chunk-QGHDJGYS.js +0 -92
- package/packages/backend/dist/chunk-UPFKBBQI.js +0 -138
- package/packages/backend/dist/chunk-VQEFULWT.js +0 -88
- package/packages/backend/dist/execution/index.d.ts +0 -124
- package/packages/backend/dist/execution/index.js +0 -20
- package/packages/backend/dist/types-BERZJ93O.d.ts +0 -110
- package/packages/state-graph/dist/chunk-3RG5ZIWI.js +0 -10
- package/packages/state-graph/dist/chunk-Q5I42UX7.js +0 -0
- package/packages/state-graph/dist/chunk-ZTHBPV24.js +0 -267
- package/packages/state-graph/dist/execution/index.d.ts +0 -152
- package/packages/state-graph/dist/execution/index.js +0 -16
- /package/packages/state-graph/dist/{chunk-SHIBCPGQ.js → chunk-EW4ACSZB.js} +0 -0
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultrst-armada/kloks",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"registry": "https://registry.npmjs.org/"
|
|
8
8
|
},
|
|
9
|
-
"description": "Kloks
|
|
9
|
+
"description": "Kloks \u2014 Public Backend, State-Graph, Audio/MIDI & Service Package Library built on KrnlTS (@kloks/*)",
|
|
10
10
|
"type": "module",
|
|
11
11
|
"main": "./index.js",
|
|
12
12
|
"module": "./index.js",
|
|
@@ -39,11 +39,6 @@
|
|
|
39
39
|
"import": "./packages/state-graph/dist/state/index.js",
|
|
40
40
|
"default": "./packages/state-graph/dist/state/index.js"
|
|
41
41
|
},
|
|
42
|
-
"./state-graph/execution": {
|
|
43
|
-
"types": "./packages/state-graph/dist/execution/index.d.ts",
|
|
44
|
-
"import": "./packages/state-graph/dist/execution/index.js",
|
|
45
|
-
"default": "./packages/state-graph/dist/execution/index.js"
|
|
46
|
-
},
|
|
47
42
|
"./state-graph/domain": {
|
|
48
43
|
"types": "./packages/state-graph/dist/domain/index.d.ts",
|
|
49
44
|
"import": "./packages/state-graph/dist/domain/index.js",
|
|
@@ -79,11 +74,6 @@
|
|
|
79
74
|
"import": "./packages/backend/dist/index.js",
|
|
80
75
|
"default": "./packages/backend/dist/index.js"
|
|
81
76
|
},
|
|
82
|
-
"./backend/execution": {
|
|
83
|
-
"types": "./packages/backend/dist/execution/index.d.ts",
|
|
84
|
-
"import": "./packages/backend/dist/execution/index.js",
|
|
85
|
-
"default": "./packages/backend/dist/execution/index.js"
|
|
86
|
-
},
|
|
87
77
|
"./backend/krnl-services": {
|
|
88
78
|
"types": "./packages/backend/dist/krnl-services.d.ts",
|
|
89
79
|
"import": "./packages/backend/dist/krnl-services.js",
|
|
@@ -113,11 +103,6 @@
|
|
|
113
103
|
"types": "./packages/client/dist/index.d.ts",
|
|
114
104
|
"import": "./packages/client/dist/index.js",
|
|
115
105
|
"default": "./packages/client/dist/index.js"
|
|
116
|
-
},
|
|
117
|
-
"./backend/worker": {
|
|
118
|
-
"types": "./packages/backend/dist/execution/WorkerExecutionBoundary.d.ts",
|
|
119
|
-
"import": "./packages/backend/dist/execution/WorkerExecutionBoundary.js",
|
|
120
|
-
"default": "./packages/backend/dist/execution/WorkerExecutionBoundary.js"
|
|
121
106
|
}
|
|
122
107
|
},
|
|
123
108
|
"scripts": {
|
|
@@ -131,7 +116,6 @@
|
|
|
131
116
|
"dependencies": {
|
|
132
117
|
"@aws-sdk/client-s3": "^3.600.0",
|
|
133
118
|
"bcryptjs": "^2.4.3",
|
|
134
|
-
"bullmq": "^6.3.8",
|
|
135
119
|
"ws": "^8.18.0",
|
|
136
120
|
"zod": "^3.24.1",
|
|
137
121
|
"zustand": "^5.0.15"
|
|
@@ -165,7 +149,7 @@
|
|
|
165
149
|
"@types/better-sqlite3": "^7.6.0",
|
|
166
150
|
"@types/node": "^22.0.0",
|
|
167
151
|
"@types/react": "^19.0.0",
|
|
168
|
-
"@ultrst-armada/krnl": "^1.0.
|
|
152
|
+
"@ultrst-armada/krnl": "^1.0.3",
|
|
169
153
|
"bcryptjs": "^2.4.3",
|
|
170
154
|
"better-sqlite3": "^11.0.0",
|
|
171
155
|
"react": "^19.0.1",
|
|
@@ -173,5 +157,9 @@
|
|
|
173
157
|
"typescript": "^5.7.3",
|
|
174
158
|
"vitest": "^3.1.0"
|
|
175
159
|
},
|
|
176
|
-
"packageManager": "pnpm@9.15.0"
|
|
160
|
+
"packageManager": "pnpm@9.15.0",
|
|
161
|
+
"repository": {
|
|
162
|
+
"type": "git",
|
|
163
|
+
"url": "git+https://github.com/dinilmusick/Kloks.git"
|
|
164
|
+
}
|
|
177
165
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _ultrst_armada_krnl from '@ultrst-armada/krnl';
|
|
2
|
-
import { ServiceDefinition, IService } from '@ultrst-armada/krnl';
|
|
2
|
+
import { ServiceDefinition, IService, OrchestrationDefinition } from '@ultrst-armada/krnl';
|
|
3
3
|
import { INodeVisuals, SpaceNode, NodeConnection, MidiNote, SynthPreset, ContainerNode, PlayerNode, SamplePresetType, AudioTrackData, HardwareChannelInfo, NamedAudioBus, AudioDeviceInfo, ConnectionsConfig, MidiInputDevice, StoredPacket, RecorderNode, CurveTrackData, CurvePoint, EffectNode, CompressorEffectConfig, MultibandCompressorEffectConfig } from '@ultrst-armada/kloks/state-graph';
|
|
4
4
|
export { AudioConcepts, BufferConcepts, BufferCycleCalculation } from '@ultrst-armada/kloks/state-graph';
|
|
5
5
|
|
|
@@ -969,21 +969,30 @@ declare const MidiServiceFacade: {
|
|
|
969
969
|
createInstance: typeof createMidiService;
|
|
970
970
|
execute: <TIn = unknown, TOut = unknown>(op: string, input?: TIn) => Promise<TOut>;
|
|
971
971
|
};
|
|
972
|
-
|
|
972
|
+
|
|
973
|
+
declare const AudioMidiOrchestratorDefinition: OrchestrationDefinition;
|
|
974
|
+
declare const krnlAudioHardwareServiceDefinition: ServiceDefinition<Record<string, unknown>, Record<string, unknown>>;
|
|
975
|
+
declare const krnlAudioHardwareServiceFacade: {
|
|
973
976
|
id: string;
|
|
974
977
|
name: string;
|
|
975
978
|
version: string;
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
979
|
+
runtime: "client";
|
|
980
|
+
deployment: "local";
|
|
981
|
+
definition: ServiceDefinition<Record<string, unknown>, Record<string, unknown>>;
|
|
982
|
+
createInstance: typeof createAudioHardwareService;
|
|
983
|
+
execute: <TIn = unknown, TOut = unknown>(op: string, input?: TIn) => Promise<TOut>;
|
|
984
|
+
};
|
|
985
|
+
declare const krnlMidiServiceDefinition: ServiceDefinition<Record<string, unknown>, Record<string, unknown>>;
|
|
986
|
+
declare const krnlMidiServiceFacade: {
|
|
987
|
+
id: string;
|
|
988
|
+
name: string;
|
|
989
|
+
version: string;
|
|
990
|
+
runtime: "client";
|
|
991
|
+
deployment: "local";
|
|
992
|
+
definition: ServiceDefinition<Record<string, unknown>, Record<string, unknown>>;
|
|
993
|
+
createInstance: typeof createMidiService;
|
|
994
|
+
execute: <TIn = unknown, TOut = unknown>(op: string, input?: TIn) => Promise<TOut>;
|
|
987
995
|
};
|
|
996
|
+
declare const krnlAudioMidiOrchestratorDefinition: OrchestrationDefinition<unknown, unknown>;
|
|
988
997
|
|
|
989
|
-
export { type ActiveAuditionPlayback, type ActiveTrackPlayback, type AudioBusConfig, AudioClipEngine, AudioContainerGraphNode, AudioContextManager, type AudioDeviceDescriptor, type AudioEffectProcessorInstance, AudioEffects, type AudioEffectsState, type AudioEngineConfig, AudioHardwareServiceDefinition, AudioHardwareServiceFacade, type AudioHardwareState, AudioInputManager$1 as AudioInputManager,
|
|
998
|
+
export { type ActiveAuditionPlayback, type ActiveTrackPlayback, type AudioBusConfig, AudioClipEngine, AudioContainerGraphNode, AudioContextManager, type AudioDeviceDescriptor, type AudioEffectProcessorInstance, AudioEffects, type AudioEffectsState, type AudioEngineConfig, AudioHardwareServiceDefinition, AudioHardwareServiceFacade, type AudioHardwareState, AudioInputManager$1 as AudioInputManager, AudioMidiOrchestratorDefinition, type AudioServiceEvents, type AudioStateListener, BaseAudioGraphNode, BaseProcessorAudioGraphNode, BaseSourceAudioGraphNode, type BufferedAudioPeak, type BufferedCurvePoint, type BufferedMidiEvent, type CrossoverBandNodes, CurveEngine, DEFAULT_AUDIO_CONFIG, DEFAULT_NAMED_BUSSES, DEFAULT_NAMED_INPUTS, DEFAULT_OSC_DEVICES, type DeviceListener, EffectProcessorGraphNode, type MidiEventPayload as EngineMidiEventPayload, type HardwareProfileResult, KNOWN_PATTERNS, type KnownDevicePattern, MasterAudioOutputGraphNode, type MidiCommandType, MidiContainerGraphNode, type MidiEventListener, type MidiEventPayload$1 as MidiEventPayload, MidiInstrumentGraphNode, type MidiListener, MidiManager$1 as MidiManager, type MidiPortDescriptor, MidiServiceDefinition, type MidiServiceEvents, MidiServiceFacade, type MidiStateListener, type MidiStatus, type MidiSubsystemState, MultiChannelOutputRouter, type MultibandCompressorInstance, type OscDevice, type OscDeviceListener, type OscDeviceType, type OscListener, OscManager, type OscMessage, OscServiceDefinition, OscServiceFacade, type OutputChannelInfo, RetrospectiveBufferEngine, type RetrospectiveCycleInfo, STORAGE_KEY_AUDIO_CONFIG, SequencerEngine, SequencerEngineServiceDefinition, SequencerEngineServiceFacade, type SidechainCompressorInstance, SignalRouterGraphNode, type SnapshotListener, type StatusListener, SynthConfigManager, SynthEngine, SynthEngineServiceDefinition, SynthEngineServiceFacade, type SynthEngineState, audioClipEngine, audioEffectsEntity, audioInputManager, buildInputChannelList, buildOutputChannelList, create3BandCrossover, createAudioEffectProcessor, createAudioGraphNode, createAudioHardwareService, createCosmicImpulseBuffer, createMidiService, createMultibandCompressor, createSidechainCompressor, curveEngine, detectHardwareProfile, generatePresetAudioBuffer, generateReverbImpulse, generateSaturationCurve, krnlAudioHardwareServiceDefinition, krnlAudioHardwareServiceFacade, krnlAudioMidiOrchestratorDefinition, krnlMidiServiceDefinition, krnlMidiServiceFacade, midiManager, multiChannelOutputRouter, oscManager, playContainerNoteWithEffects, playSyntheticDrumVoice, processActiveContainers, retrospectiveBufferEngine, sequencerEngine, synthEngine };
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
synthEngine
|
|
38
38
|
} from "./chunk-3GRGELA4.js";
|
|
39
39
|
|
|
40
|
-
// ../../node_modules/.pnpm/@ultrst-armada+krnl@1.0.
|
|
40
|
+
// ../../node_modules/.pnpm/@ultrst-armada+krnl@1.0.3/node_modules/@ultrst-armada/krnl/packages/core/dist/index.js
|
|
41
41
|
var ServiceStateStore = class {
|
|
42
42
|
state;
|
|
43
43
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -91,17 +91,37 @@ var ServiceEventBus = class {
|
|
|
91
91
|
this.handlers.clear();
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
|
+
var TRANSITIONS = {
|
|
95
|
+
uninitialized: ["initializing"],
|
|
96
|
+
initializing: ["ready", "uninitialized"],
|
|
97
|
+
ready: ["starting"],
|
|
98
|
+
starting: ["running", "ready"],
|
|
99
|
+
running: ["stopping"],
|
|
100
|
+
stopping: ["stopped", "running"],
|
|
101
|
+
stopped: ["starting"]
|
|
102
|
+
};
|
|
94
103
|
var LifecycleManager = class {
|
|
95
104
|
status = "uninitialized";
|
|
96
105
|
getStatus() {
|
|
97
106
|
return this.status;
|
|
98
107
|
}
|
|
99
|
-
|
|
108
|
+
canTransitionTo(next) {
|
|
109
|
+
return TRANSITIONS[this.status].includes(next);
|
|
110
|
+
}
|
|
111
|
+
transitionTo(next) {
|
|
112
|
+
if (!this.canTransitionTo(next)) {
|
|
113
|
+
throw new Error("[Lifecycle] Invalid transition '" + this.status + "' -> '" + next + "'.");
|
|
114
|
+
}
|
|
100
115
|
this.status = next;
|
|
101
116
|
}
|
|
117
|
+
setStatus(next) {
|
|
118
|
+
this.transitionTo(next);
|
|
119
|
+
}
|
|
102
120
|
assertRunning(serviceName) {
|
|
103
121
|
if (this.status !== "running") {
|
|
104
|
-
throw new Error(
|
|
122
|
+
throw new Error(
|
|
123
|
+
"[Service:" + serviceName + "] Cannot invoke operation while status is '" + this.status + "' (expected 'running')."
|
|
124
|
+
);
|
|
105
125
|
}
|
|
106
126
|
}
|
|
107
127
|
};
|
|
@@ -113,7 +133,7 @@ var ServiceInstance = class {
|
|
|
113
133
|
this.version = definition.version;
|
|
114
134
|
this.lifecycle = new LifecycleManager();
|
|
115
135
|
this.eventBus = new ServiceEventBus();
|
|
116
|
-
if (definition.state
|
|
136
|
+
if (definition.state) {
|
|
117
137
|
this.stateStore = new ServiceStateStore(definition.state.initial);
|
|
118
138
|
}
|
|
119
139
|
}
|
|
@@ -124,46 +144,76 @@ var ServiceInstance = class {
|
|
|
124
144
|
stateStore;
|
|
125
145
|
eventBus;
|
|
126
146
|
lifecycle;
|
|
147
|
+
initialized = false;
|
|
148
|
+
disposed = false;
|
|
127
149
|
getDefinition() {
|
|
128
150
|
return this.definition;
|
|
129
151
|
}
|
|
152
|
+
getStatus() {
|
|
153
|
+
return this.lifecycle.getStatus();
|
|
154
|
+
}
|
|
130
155
|
async start() {
|
|
131
|
-
this.
|
|
132
|
-
|
|
133
|
-
|
|
156
|
+
if (this.disposed) throw new Error("[Service:" + this.name + "] Cannot start a disposed service.");
|
|
157
|
+
const current = this.lifecycle.getStatus();
|
|
158
|
+
if (current === "running") return;
|
|
159
|
+
if (current === "initializing" || current === "starting" || current === "stopping") {
|
|
160
|
+
throw new Error("[Service:" + this.name + "] Cannot start while status is '" + current + "'.");
|
|
161
|
+
}
|
|
162
|
+
if (!this.initialized) {
|
|
163
|
+
this.lifecycle.transitionTo("initializing");
|
|
164
|
+
try {
|
|
165
|
+
await this.definition.lifecycle?.onInit?.();
|
|
166
|
+
this.initialized = true;
|
|
167
|
+
this.lifecycle.transitionTo("ready");
|
|
168
|
+
} catch (error) {
|
|
169
|
+
this.lifecycle.transitionTo("uninitialized");
|
|
170
|
+
throw error;
|
|
171
|
+
}
|
|
134
172
|
}
|
|
135
|
-
|
|
136
|
-
|
|
173
|
+
this.lifecycle.transitionTo("starting");
|
|
174
|
+
try {
|
|
175
|
+
await this.definition.lifecycle?.onStart?.();
|
|
176
|
+
this.lifecycle.transitionTo("running");
|
|
177
|
+
} catch (error) {
|
|
178
|
+
this.lifecycle.transitionTo("ready");
|
|
179
|
+
throw error;
|
|
137
180
|
}
|
|
138
|
-
this.lifecycle.setStatus("running");
|
|
139
181
|
}
|
|
140
182
|
async stop() {
|
|
141
|
-
this.lifecycle.
|
|
142
|
-
if (
|
|
143
|
-
|
|
183
|
+
const current = this.lifecycle.getStatus();
|
|
184
|
+
if (current === "stopped") return;
|
|
185
|
+
if (current !== "running") {
|
|
186
|
+
throw new Error("[Service:" + this.name + "] Cannot stop while status is '" + current + "'.");
|
|
144
187
|
}
|
|
145
|
-
|
|
146
|
-
|
|
188
|
+
this.lifecycle.transitionTo("stopping");
|
|
189
|
+
try {
|
|
190
|
+
await this.definition.lifecycle?.onStop?.();
|
|
191
|
+
this.lifecycle.transitionTo("stopped");
|
|
192
|
+
} catch (error) {
|
|
193
|
+
this.lifecycle.transitionTo("running");
|
|
194
|
+
throw error;
|
|
147
195
|
}
|
|
148
|
-
|
|
196
|
+
}
|
|
197
|
+
async dispose() {
|
|
198
|
+
if (this.disposed) return;
|
|
199
|
+
if (this.lifecycle.getStatus() === "running") await this.stop();
|
|
200
|
+
await this.definition.lifecycle?.onDispose?.();
|
|
201
|
+
this.disposed = true;
|
|
149
202
|
}
|
|
150
203
|
async call(op, input, ctx = {}) {
|
|
151
204
|
this.lifecycle.assertRunning(this.name);
|
|
152
205
|
const operation = this.definition.operations[op];
|
|
153
206
|
if (!operation) {
|
|
154
|
-
throw new Error(
|
|
207
|
+
throw new Error("[Service:" + this.name + "] Operation '" + op + "' not found.");
|
|
155
208
|
}
|
|
156
209
|
return await operation.handler(input, ctx);
|
|
157
210
|
}
|
|
158
211
|
getState() {
|
|
159
|
-
|
|
160
|
-
return Object.freeze({});
|
|
161
|
-
}
|
|
162
|
-
return this.stateStore.getState();
|
|
212
|
+
return this.stateStore?.getState() ?? Object.freeze({});
|
|
163
213
|
}
|
|
164
214
|
setState(mutation) {
|
|
165
215
|
if (!this.stateStore) {
|
|
166
|
-
this.stateStore = new ServiceStateStore(mutation);
|
|
216
|
+
this.stateStore = new ServiceStateStore({ ...mutation });
|
|
167
217
|
return;
|
|
168
218
|
}
|
|
169
219
|
this.stateStore.setState(mutation);
|
|
@@ -175,12 +225,66 @@ var ServiceInstance = class {
|
|
|
175
225
|
this.eventBus.emit(event, payload);
|
|
176
226
|
}
|
|
177
227
|
};
|
|
178
|
-
function
|
|
228
|
+
function assertRecord(value, field) {
|
|
229
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
230
|
+
throw new Error("[KrnlTS] Invalid service definition: '" + field + "' must be an object.");
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
function assertNonEmptyString(value, field) {
|
|
234
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
235
|
+
throw new Error("[KrnlTS] Invalid service definition: '" + field + "' must be a non-empty string.");
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function validateServiceDefinition(definition) {
|
|
239
|
+
if (!definition || typeof definition !== "object") {
|
|
240
|
+
throw new Error("[KrnlTS] Invalid service definition: expected an object.");
|
|
241
|
+
}
|
|
242
|
+
assertNonEmptyString(definition.id, "id");
|
|
243
|
+
assertNonEmptyString(definition.name, "name");
|
|
244
|
+
assertNonEmptyString(definition.version, "version");
|
|
245
|
+
if (!definition.operations || typeof definition.operations !== "object") {
|
|
246
|
+
throw new Error("[Service:" + definition.name + "] Invalid operations: expected an object.");
|
|
247
|
+
}
|
|
248
|
+
for (const [key, operation] of Object.entries(definition.operations)) {
|
|
249
|
+
if (!operation || typeof operation !== "object") {
|
|
250
|
+
throw new Error("[Service:" + definition.name + "] Invalid operation '" + key + "'.");
|
|
251
|
+
}
|
|
252
|
+
assertNonEmptyString(operation.id, "operations." + key + ".id");
|
|
253
|
+
assertNonEmptyString(operation.name, "operations." + key + ".name");
|
|
254
|
+
if (operation.inputSchema !== void 0) assertRecord(operation.inputSchema, "operations." + key + ".inputSchema");
|
|
255
|
+
if (operation.outputSchema !== void 0) assertRecord(operation.outputSchema, "operations." + key + ".outputSchema");
|
|
256
|
+
if (typeof operation.handler !== "function") {
|
|
257
|
+
throw new Error("[Service:" + definition.name + "] Operation '" + key + "' must define a handler.");
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
for (const [key, event] of Object.entries(definition.events ?? {})) {
|
|
261
|
+
if (!event || typeof event !== "object") {
|
|
262
|
+
throw new Error("[Service:" + definition.name + "] Invalid event '" + key + "'.");
|
|
263
|
+
}
|
|
264
|
+
assertNonEmptyString(event.name, "events." + key + ".name");
|
|
265
|
+
}
|
|
266
|
+
for (const [key, schema] of Object.entries(definition.inputs ?? {})) assertRecord(schema, "inputs." + key);
|
|
267
|
+
for (const [key, schema] of Object.entries(definition.outputs ?? {})) assertRecord(schema, "outputs." + key);
|
|
268
|
+
if (definition.state?.schema !== void 0) assertRecord(definition.state.schema, "state.schema");
|
|
269
|
+
for (const capability of definition.capabilities ?? []) {
|
|
270
|
+
assertNonEmptyString(capability.id, "capability.id");
|
|
271
|
+
assertNonEmptyString(capability.name, "capability.name");
|
|
272
|
+
if (!Array.isArray(capability.protocols)) {
|
|
273
|
+
throw new Error("[Service:" + definition.name + "] Capability '" + capability.name + "' protocols must be an array.");
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
for (const dependency of definition.dependencies ?? []) {
|
|
277
|
+
assertNonEmptyString(dependency.serviceId, "dependency.serviceId");
|
|
278
|
+
}
|
|
179
279
|
return definition;
|
|
180
280
|
}
|
|
281
|
+
function createServiceDefinition(definition) {
|
|
282
|
+
return validateServiceDefinition(definition);
|
|
283
|
+
}
|
|
181
284
|
function createService(definition) {
|
|
182
|
-
return new ServiceInstance(definition);
|
|
285
|
+
return new ServiceInstance(validateServiceDefinition(definition));
|
|
183
286
|
}
|
|
287
|
+
var asyncHooks = globalThis.process?.getBuiltinModule?.("node:async_hooks");
|
|
184
288
|
|
|
185
289
|
// src/audioInputManager.ts
|
|
186
290
|
var AudioInputManager = class {
|
|
@@ -2362,7 +2466,14 @@ function createAudioHardwareService(manager = new AudioInputManager()) {
|
|
|
2362
2466
|
getState: {
|
|
2363
2467
|
id: "AudioHardwareService.getState",
|
|
2364
2468
|
name: "getState",
|
|
2365
|
-
handler: async () =>
|
|
2469
|
+
handler: async (input) => {
|
|
2470
|
+
const state = manager.getState();
|
|
2471
|
+
return {
|
|
2472
|
+
...state,
|
|
2473
|
+
...input && typeof input === "object" ? input : {},
|
|
2474
|
+
audioState: state
|
|
2475
|
+
};
|
|
2476
|
+
}
|
|
2366
2477
|
},
|
|
2367
2478
|
dispose: {
|
|
2368
2479
|
id: "AudioHardwareService.dispose",
|
|
@@ -2450,12 +2561,13 @@ function createMidiService(manager = new MidiManager()) {
|
|
|
2450
2561
|
const unsub = manager.subscribeEvents((ev) => {
|
|
2451
2562
|
captured = ev;
|
|
2452
2563
|
});
|
|
2453
|
-
|
|
2564
|
+
const cmd = payload.command || payload.midiCommand || "NOTE_ON";
|
|
2565
|
+
manager.emitVirtualMidi({ ...payload, command: cmd });
|
|
2454
2566
|
unsub();
|
|
2455
2567
|
if (captured && svcRef) {
|
|
2456
2568
|
svcRef.emit("midiEvent", captured);
|
|
2457
2569
|
}
|
|
2458
|
-
return captured;
|
|
2570
|
+
return { midiEvent: captured, success: true };
|
|
2459
2571
|
}
|
|
2460
2572
|
},
|
|
2461
2573
|
parseRawBytes: {
|
|
@@ -2505,28 +2617,36 @@ var MidiServiceFacade = {
|
|
|
2505
2617
|
return defaultMidiService.call(op, input);
|
|
2506
2618
|
}
|
|
2507
2619
|
};
|
|
2508
|
-
var
|
|
2620
|
+
var AudioMidiOrchestratorDefinition = {
|
|
2509
2621
|
id: "kloks.orchestrator.audioMidi",
|
|
2510
2622
|
name: "AudioMidiOrchestrator",
|
|
2511
2623
|
version: "1.0.0",
|
|
2624
|
+
description: "Pure serializable orchestration definition: Midi -> AudioHardware",
|
|
2625
|
+
scope: "service",
|
|
2512
2626
|
dependencies: [AudioHardwareServiceFacade.id, MidiServiceFacade.id],
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2627
|
+
steps: [
|
|
2628
|
+
{
|
|
2629
|
+
id: "step_midi",
|
|
2630
|
+
name: "Emit Virtual MIDI",
|
|
2631
|
+
type: "task",
|
|
2632
|
+
target: MidiServiceFacade.id,
|
|
2633
|
+
operation: "emitVirtualMidi"
|
|
2634
|
+
},
|
|
2635
|
+
{
|
|
2636
|
+
id: "step_audio",
|
|
2637
|
+
name: "Get Audio Hardware State",
|
|
2638
|
+
type: "task",
|
|
2639
|
+
target: AudioHardwareServiceFacade.id,
|
|
2640
|
+
operation: "getState",
|
|
2641
|
+
dependsOn: ["step_midi"]
|
|
2642
|
+
}
|
|
2643
|
+
]
|
|
2529
2644
|
};
|
|
2645
|
+
var krnlAudioHardwareServiceDefinition = AudioHardwareServiceDefinition;
|
|
2646
|
+
var krnlAudioHardwareServiceFacade = AudioHardwareServiceFacade;
|
|
2647
|
+
var krnlMidiServiceDefinition = MidiServiceDefinition;
|
|
2648
|
+
var krnlMidiServiceFacade = MidiServiceFacade;
|
|
2649
|
+
var krnlAudioMidiOrchestratorDefinition = AudioMidiOrchestratorDefinition;
|
|
2530
2650
|
export {
|
|
2531
2651
|
AudioClipEngine,
|
|
2532
2652
|
AudioConcepts,
|
|
@@ -2536,7 +2656,7 @@ export {
|
|
|
2536
2656
|
AudioHardwareServiceDefinition,
|
|
2537
2657
|
AudioHardwareServiceFacade,
|
|
2538
2658
|
AudioInputManager,
|
|
2539
|
-
|
|
2659
|
+
AudioMidiOrchestratorDefinition,
|
|
2540
2660
|
BaseAudioGraphNode,
|
|
2541
2661
|
BaseProcessorAudioGraphNode,
|
|
2542
2662
|
BaseSourceAudioGraphNode,
|
|
@@ -2586,6 +2706,11 @@ export {
|
|
|
2586
2706
|
generatePresetAudioBuffer,
|
|
2587
2707
|
generateReverbImpulse,
|
|
2588
2708
|
generateSaturationCurve,
|
|
2709
|
+
krnlAudioHardwareServiceDefinition,
|
|
2710
|
+
krnlAudioHardwareServiceFacade,
|
|
2711
|
+
krnlAudioMidiOrchestratorDefinition,
|
|
2712
|
+
krnlMidiServiceDefinition,
|
|
2713
|
+
krnlMidiServiceFacade,
|
|
2589
2714
|
midiManager,
|
|
2590
2715
|
multiChannelOutputRouter,
|
|
2591
2716
|
oscManager,
|
|
@@ -13,12 +13,6 @@
|
|
|
13
13
|
"export": "AudioHardwareServiceFacade",
|
|
14
14
|
"facade": "AudioHardwareServiceFacade"
|
|
15
15
|
},
|
|
16
|
-
"ui": {
|
|
17
|
-
"package": "@floks/ui",
|
|
18
|
-
"components": [
|
|
19
|
-
"BaseCard"
|
|
20
|
-
]
|
|
21
|
-
},
|
|
22
16
|
"modes": [
|
|
23
17
|
"backend",
|
|
24
18
|
"fullstack"
|
|
@@ -31,7 +25,13 @@
|
|
|
31
25
|
"App.main-content"
|
|
32
26
|
]
|
|
33
27
|
},
|
|
34
|
-
"dependencies": []
|
|
28
|
+
"dependencies": [],
|
|
29
|
+
"defaultFrontend": {
|
|
30
|
+
"component": "BaseCard",
|
|
31
|
+
"package": "@ultrst-armada/floks/ui",
|
|
32
|
+
"export": "BaseCard",
|
|
33
|
+
"relationship": "recommended"
|
|
34
|
+
}
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
37
|
"id": "midi",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"name": "Audio & MIDI Orchestrator",
|
|
61
61
|
"version": "1.0.0",
|
|
62
62
|
"package": "@kloks/audio-midi",
|
|
63
|
-
"export": "
|
|
63
|
+
"export": "AudioMidiOrchestratorDefinition",
|
|
64
64
|
"targetTypes": [
|
|
65
65
|
"BackendFacade.orchestrations"
|
|
66
66
|
]
|
package/packages/backend/dist/{WebSocketTransport-CxUzUfwl.d.ts → WebSocketTransport-CHmkJ0tj.d.ts}
RENAMED
|
@@ -1,4 +1,111 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @file types.ts
|
|
3
|
+
* @description Canonical protocol types, messages, jobs, callbacks, and resolution interfaces.
|
|
4
|
+
*/
|
|
5
|
+
type MessageType = 'COMMAND' | 'QUERY' | 'RESULT' | 'EVENT' | 'CALLBACK_REQUEST' | 'CALLBACK_RESULT' | 'JOB_SUBMIT' | 'JOB_PROGRESS' | 'JOB_RESULT' | 'ERROR' | 'ACK';
|
|
6
|
+
interface AuthContext {
|
|
7
|
+
userId?: string;
|
|
8
|
+
role?: string;
|
|
9
|
+
permissions?: string[];
|
|
10
|
+
token?: string;
|
|
11
|
+
}
|
|
12
|
+
interface CapabilityContext {
|
|
13
|
+
domain: string;
|
|
14
|
+
capability: string;
|
|
15
|
+
scope?: string;
|
|
16
|
+
}
|
|
17
|
+
interface Message<T = unknown> {
|
|
18
|
+
id: string;
|
|
19
|
+
type: MessageType;
|
|
20
|
+
operation: string;
|
|
21
|
+
payload?: T;
|
|
22
|
+
sessionId?: string;
|
|
23
|
+
correlationId?: string;
|
|
24
|
+
causationId?: string;
|
|
25
|
+
sequence?: number;
|
|
26
|
+
timestamp: number;
|
|
27
|
+
authContext?: AuthContext;
|
|
28
|
+
capabilityContext?: CapabilityContext;
|
|
29
|
+
error?: {
|
|
30
|
+
code: string;
|
|
31
|
+
message: string;
|
|
32
|
+
details?: unknown;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
interface CallbackHandle {
|
|
36
|
+
id: string;
|
|
37
|
+
sessionId: string;
|
|
38
|
+
capability: string;
|
|
39
|
+
expiration: number;
|
|
40
|
+
}
|
|
41
|
+
interface Delegation<T = unknown> {
|
|
42
|
+
target: string;
|
|
43
|
+
operation: string;
|
|
44
|
+
payload: T;
|
|
45
|
+
callbackHandle?: CallbackHandle;
|
|
46
|
+
eventChannel?: string;
|
|
47
|
+
sessionId?: string;
|
|
48
|
+
correlationId?: string;
|
|
49
|
+
}
|
|
50
|
+
type JobState = 'PENDING' | 'QUEUED' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELLED';
|
|
51
|
+
type JobPriority = 'LOW' | 'NORMAL' | 'HIGH' | 'CRITICAL';
|
|
52
|
+
interface Job<TPayload = unknown, TResult = unknown> {
|
|
53
|
+
id: string;
|
|
54
|
+
type: string;
|
|
55
|
+
payload: TPayload;
|
|
56
|
+
priority?: JobPriority;
|
|
57
|
+
sequence?: number;
|
|
58
|
+
sequenceKey?: string;
|
|
59
|
+
dependencies?: string[];
|
|
60
|
+
sessionId?: string;
|
|
61
|
+
correlationId?: string;
|
|
62
|
+
state: JobState;
|
|
63
|
+
progress?: number;
|
|
64
|
+
result?: TResult;
|
|
65
|
+
error?: string;
|
|
66
|
+
createdAt: number;
|
|
67
|
+
updatedAt: number;
|
|
68
|
+
}
|
|
69
|
+
type ResolutionStrategy = 'LOCAL' | 'REMOTE' | 'REMOTE_FIRST' | 'LOCAL_FIRST';
|
|
70
|
+
interface ResourceVersion {
|
|
71
|
+
version: number;
|
|
72
|
+
updatedAt: number;
|
|
73
|
+
checksum?: string;
|
|
74
|
+
}
|
|
75
|
+
interface DistributedLock {
|
|
76
|
+
key: string;
|
|
77
|
+
ownerId: string;
|
|
78
|
+
leaseId: string;
|
|
79
|
+
expiration: number;
|
|
80
|
+
}
|
|
81
|
+
interface BackendInstance {
|
|
82
|
+
id: string;
|
|
83
|
+
url: string;
|
|
84
|
+
healthy: boolean;
|
|
85
|
+
capacity: number;
|
|
86
|
+
activeJobs: number;
|
|
87
|
+
activeConnections: number;
|
|
88
|
+
latencyMs: number;
|
|
89
|
+
lastHeartbeat: number;
|
|
90
|
+
weight?: number;
|
|
91
|
+
}
|
|
92
|
+
type RoutingStrategy = 'roundRobin' | 'weighted' | 'leastConnections' | 'latencyAware' | 'capacityAware';
|
|
93
|
+
interface IdempotentRequest<T = unknown> {
|
|
94
|
+
id: string;
|
|
95
|
+
idempotencyKey: string;
|
|
96
|
+
operation: string;
|
|
97
|
+
payload: T;
|
|
98
|
+
timestamp: number;
|
|
99
|
+
}
|
|
100
|
+
interface BackendExecutor {
|
|
101
|
+
execute<T = unknown, R = unknown>(command: Message<T>): Promise<R>;
|
|
102
|
+
query<T = unknown, R = unknown>(query: Message<T>): Promise<R>;
|
|
103
|
+
subscribe(channel: string, handler: (event: Message) => void): () => void;
|
|
104
|
+
emit(event: Message): Promise<void>;
|
|
105
|
+
registerCallback(callback: (...args: unknown[]) => unknown): CallbackHandle;
|
|
106
|
+
delegate<T = unknown, R = unknown>(delegation: Delegation<T>): Promise<R>;
|
|
107
|
+
submitJob<T = unknown, R = unknown>(job: Partial<Job<T, R>>): Promise<Job<T, R>>;
|
|
108
|
+
}
|
|
2
109
|
|
|
3
110
|
/**
|
|
4
111
|
* @file BackendResolver.ts
|
|
@@ -252,4 +359,4 @@ declare class WebSocketTransport implements ITransport {
|
|
|
252
359
|
getReconnectDelay(): number;
|
|
253
360
|
}
|
|
254
361
|
|
|
255
|
-
export { BackendClient as B, type CallbackFn as C, type
|
|
362
|
+
export { type AuthContext as A, BackendClient as B, type CallbackFn as C, type Delegation as D, type ErrorHandler as E, FrontendSession as F, type GapHandler as G, HTTPTransport as H, type ITransport as I, type Job as J, type Message as M, type ResolutionStrategy as R, type SequenceCheckResult as S, WebSocketTransport as W, type BackendClientOptions as a, type BackendExecutor as b, type BackendInstance as c, BackendResolver as d, type BackendResolverOptions as e, type CallbackHandle as f, CallbackRegistry as g, type CapabilityContext as h, type DistributedLock as i, type DomainProxy as j, EventBus as k, type EventHandler as l, type FrontendSessionOptions as m, type HTTPTransportOptions as n, type IdempotentRequest as o, type JobPriority as p, type JobState as q, type MessageHandler as r, type MessageType as s, type ResourceVersion as t, type RoutingStrategy as u, SequenceTracker as v, type WebSocketTransportOptions as w, createBackendClient as x };
|
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
AdminGuard,
|
|
3
3
|
BaseAccountProvider,
|
|
4
4
|
LocalAccountProvider,
|
|
5
|
-
PasswordHasher
|
|
6
|
-
|
|
7
|
-
resolveUserFromToken
|
|
8
|
-
} from "../chunk-4ZFXEFOE.js";
|
|
5
|
+
PasswordHasher
|
|
6
|
+
} from "../chunk-MPYASJ5A.js";
|
|
9
7
|
import {
|
|
10
8
|
RateLimiter,
|
|
11
|
-
SessionManager
|
|
12
|
-
|
|
9
|
+
SessionManager,
|
|
10
|
+
loginSystemUser,
|
|
11
|
+
resolveUserFromToken
|
|
12
|
+
} from "../chunk-ZDH4XI7W.js";
|
|
13
13
|
export {
|
|
14
14
|
AdminGuard,
|
|
15
15
|
BaseAccountProvider,
|