@dg-kit/core 0.1.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 ADDED
@@ -0,0 +1,15 @@
1
+ # @dg-kit/core
2
+
3
+ Shared types and contract interfaces for DG-Lab Coyote control libraries.
4
+
5
+ This package is runtime-agnostic — it has no DOM or Node-only dependencies. It defines the data shapes (`DeviceState`, `DeviceCommand`, `WaveformDefinition`, etc.) and the abstract interfaces (`DeviceClient`, `WaveformLibrary`, `Logger`) that the rest of `@dg-kit/*` and downstream consumers (`DG-Agent`, `DG-MCP`, `DG-Chat`) depend on.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @dg-kit/core
11
+ ```
12
+
13
+ ## Stability
14
+
15
+ `DeviceCommand`, `DeviceState`, `WaveformDefinition`, and the `DeviceClient` / `WaveformLibrary` interfaces are part of the public contract. Breaking changes to these shapes bump the major version. Internal helpers (e.g. `createEmptyDeviceState`) follow the same versioning policy.
@@ -0,0 +1,115 @@
1
+ /**
2
+ * @dg-kit/core — shared types and contract interfaces.
3
+ *
4
+ * Runtime-agnostic. Consumed by every other @dg-kit package and by the three
5
+ * downstream apps (DG-Agent, DG-MCP, DG-Chat).
6
+ */
7
+ export type Channel = 'A' | 'B';
8
+ /** A single 25 ms wave step: `[encodedFrequency, intensity]`. */
9
+ export type WaveFrame = [number, number];
10
+ export interface WaveformDefinition {
11
+ id: string;
12
+ name: string;
13
+ description?: string;
14
+ /** Sequence of 25 ms steps. */
15
+ frames: WaveFrame[];
16
+ }
17
+ export interface DeviceState {
18
+ connected: boolean;
19
+ deviceName?: string;
20
+ address?: string;
21
+ battery?: number;
22
+ strengthA: number;
23
+ strengthB: number;
24
+ limitA: number;
25
+ limitB: number;
26
+ waveActiveA: boolean;
27
+ waveActiveB: boolean;
28
+ currentWaveA?: string;
29
+ currentWaveB?: string;
30
+ }
31
+ export declare function createEmptyDeviceState(): DeviceState;
32
+ export type DeviceCommand = {
33
+ type: 'start';
34
+ channel: Channel;
35
+ strength: number;
36
+ waveform: WaveformDefinition;
37
+ loop: boolean;
38
+ } | {
39
+ type: 'stop';
40
+ channel?: Channel;
41
+ } | {
42
+ type: 'adjustStrength';
43
+ channel: Channel;
44
+ delta: number;
45
+ } | {
46
+ type: 'changeWave';
47
+ channel: Channel;
48
+ waveform: WaveformDefinition;
49
+ loop: boolean;
50
+ } | {
51
+ type: 'burst';
52
+ channel: Channel;
53
+ strength: number;
54
+ durationMs: number;
55
+ } | {
56
+ type: 'emergencyStop';
57
+ };
58
+ export interface TimerCommand {
59
+ type: 'timer';
60
+ seconds: number;
61
+ label: string;
62
+ }
63
+ export interface DeviceCommandResult {
64
+ state: DeviceState;
65
+ notes?: string[];
66
+ }
67
+ export interface ToolCall {
68
+ id: string;
69
+ name: string;
70
+ displayName?: string;
71
+ args: Record<string, unknown>;
72
+ }
73
+ export interface ToolDefinition {
74
+ name: string;
75
+ displayName?: string;
76
+ description: string;
77
+ /** JSON Schema for the tool parameters. */
78
+ parameters: Record<string, unknown>;
79
+ }
80
+ export type ToolExecutionPlan = {
81
+ type: 'device';
82
+ command: DeviceCommand;
83
+ } | {
84
+ type: 'timer';
85
+ command: TimerCommand;
86
+ } | {
87
+ type: 'inline';
88
+ output: string;
89
+ summary?: string;
90
+ };
91
+ export declare function isDeviceToolName(name: string): boolean;
92
+ export interface DeviceClient {
93
+ connect(): Promise<void>;
94
+ disconnect(): Promise<void>;
95
+ getState(): Promise<DeviceState>;
96
+ execute(command: DeviceCommand): Promise<DeviceCommandResult>;
97
+ emergencyStop(): Promise<void>;
98
+ onStateChanged(listener: (state: DeviceState) => void): () => void;
99
+ }
100
+ export interface WaveformLibrary {
101
+ getById(id: string): Promise<WaveformDefinition | null>;
102
+ list(): Promise<WaveformDefinition[]>;
103
+ /**
104
+ * Persist a new or updated waveform. Optional because not every library
105
+ * implementation supports writing (e.g. a read-only Node bundle); design
106
+ * tools should branch on its presence.
107
+ */
108
+ save?(waveform: WaveformDefinition): Promise<void>;
109
+ }
110
+ export interface Logger {
111
+ info(message: string, meta?: Record<string, unknown>): void;
112
+ warn(message: string, meta?: Record<string, unknown>): void;
113
+ error(message: string, meta?: Record<string, unknown>): void;
114
+ }
115
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,MAAM,OAAO,GAAG,GAAG,GAAG,GAAG,CAAC;AAEhC,iEAAiE;AACjE,MAAM,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEzC,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+BAA+B;IAC/B,MAAM,EAAE,SAAS,EAAE,CAAC;CACrB;AAMD,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,sBAAsB,IAAI,WAAW,CAWpD;AAMD,MAAM,MAAM,aAAa,GACrB;IACE,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,IAAI,EAAE,OAAO,CAAC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AAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAC9D"}
package/dist/index.js ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @dg-kit/core — shared types and contract interfaces.
3
+ *
4
+ * Runtime-agnostic. Consumed by every other @dg-kit package and by the three
5
+ * downstream apps (DG-Agent, DG-MCP, DG-Chat).
6
+ */
7
+ export function createEmptyDeviceState() {
8
+ return {
9
+ connected: false,
10
+ battery: 0,
11
+ strengthA: 0,
12
+ strengthB: 0,
13
+ limitA: 200,
14
+ limitB: 200,
15
+ waveActiveA: false,
16
+ waveActiveB: false,
17
+ };
18
+ }
19
+ export function isDeviceToolName(name) {
20
+ return (name === 'start' ||
21
+ name === 'stop' ||
22
+ name === 'adjust_strength' ||
23
+ name === 'change_wave' ||
24
+ name === 'burst');
25
+ }
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAsCH,MAAM,UAAU,sBAAsB;IACpC,OAAO;QACL,SAAS,EAAE,KAAK;QAChB,OAAO,EAAE,CAAC;QACV,SAAS,EAAE,CAAC;QACZ,SAAS,EAAE,CAAC;QACZ,MAAM,EAAE,GAAG;QACX,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,KAAK;QAClB,WAAW,EAAE,KAAK;KACnB,CAAC;AACJ,CAAC;AAuDD,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,OAAO,CACL,IAAI,KAAK,OAAO;QAChB,IAAI,KAAK,MAAM;QACf,IAAI,KAAK,iBAAiB;QAC1B,IAAI,KAAK,aAAa;QACtB,IAAI,KAAK,OAAO,CACjB,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@dg-kit/core",
3
+ "version": "0.1.0",
4
+ "description": "Shared types and contract interfaces for DG-Lab Coyote control libraries",
5
+ "license": "MIT",
6
+ "author": "0xNullAI",
7
+ "homepage": "https://github.com/0xNullAI/DG-Kit/tree/main/packages/core",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/0xNullAI/DG-Kit.git",
11
+ "directory": "packages/core"
12
+ },
13
+ "type": "module",
14
+ "main": "./src/index.ts",
15
+ "types": "./src/index.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./src/index.ts",
19
+ "import": "./src/index.ts"
20
+ }
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "README.md"
25
+ ],
26
+ "publishConfig": {
27
+ "access": "public",
28
+ "main": "./dist/index.js",
29
+ "types": "./dist/index.d.ts",
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "import": "./dist/index.js"
34
+ }
35
+ }
36
+ },
37
+ "scripts": {
38
+ "build": "tsc -p tsconfig.json",
39
+ "typecheck": "tsc -p tsconfig.json --noEmit"
40
+ },
41
+ "keywords": [
42
+ "dg-lab",
43
+ "coyote",
44
+ "ble",
45
+ "bluetooth"
46
+ ]
47
+ }