@eyeglass/types 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.
@@ -0,0 +1,93 @@
1
+ export type InteractionStatus = 'idle' | 'pending' | 'fixing' | 'success' | 'failed';
2
+ export interface SemanticSnapshot {
3
+ role: string;
4
+ name: string;
5
+ tagName: string;
6
+ id?: string;
7
+ className?: string;
8
+ dataAttributes?: Record<string, string>;
9
+ framework: {
10
+ name: 'react' | 'vue' | 'svelte' | 'vanilla';
11
+ componentName?: string;
12
+ filePath?: string;
13
+ lineNumber?: number;
14
+ props?: Record<string, unknown>;
15
+ ancestry?: string[];
16
+ };
17
+ a11y: {
18
+ label: string | null;
19
+ description: string | null;
20
+ disabled: boolean;
21
+ expanded?: boolean;
22
+ checked?: boolean | 'mixed';
23
+ hidden: boolean;
24
+ };
25
+ geometry: {
26
+ x: number;
27
+ y: number;
28
+ width: number;
29
+ height: number;
30
+ visible: boolean;
31
+ };
32
+ styles: {
33
+ display: string;
34
+ position: string;
35
+ flexDirection?: string;
36
+ gridTemplate?: string;
37
+ padding: string;
38
+ margin: string;
39
+ color: string;
40
+ backgroundColor: string;
41
+ fontFamily: string;
42
+ zIndex: string;
43
+ };
44
+ timestamp: number;
45
+ url: string;
46
+ }
47
+ export interface FocusPayload {
48
+ interactionId: string;
49
+ snapshot?: SemanticSnapshot;
50
+ snapshots?: SemanticSnapshot[];
51
+ userNote: string;
52
+ }
53
+ export type ActivityEventType = 'status' | 'thought' | 'question' | 'action';
54
+ export interface BaseActivityEvent {
55
+ interactionId: string;
56
+ timestamp: number;
57
+ }
58
+ export interface StatusEvent extends BaseActivityEvent {
59
+ type: 'status';
60
+ status: InteractionStatus;
61
+ message?: string;
62
+ }
63
+ export interface ThoughtEvent extends BaseActivityEvent {
64
+ type: 'thought';
65
+ content: string;
66
+ }
67
+ export interface QuestionEvent extends BaseActivityEvent {
68
+ type: 'question';
69
+ questionId: string;
70
+ question: string;
71
+ options: Array<{
72
+ id: string;
73
+ label: string;
74
+ }>;
75
+ }
76
+ export interface AnswerPayload {
77
+ interactionId: string;
78
+ questionId: string;
79
+ answerId: string;
80
+ answerLabel: string;
81
+ }
82
+ export interface ActionEvent extends BaseActivityEvent {
83
+ type: 'action';
84
+ action: 'reading' | 'writing' | 'searching' | 'thinking';
85
+ target: string;
86
+ complete?: boolean;
87
+ }
88
+ export type ActivityEvent = StatusEvent | ThoughtEvent | QuestionEvent | ActionEvent;
89
+ export interface StatusUpdate {
90
+ interactionId: string;
91
+ status: InteractionStatus;
92
+ agentMessage?: string;
93
+ }
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,221 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vitest_1 = require("vitest");
4
+ (0, vitest_1.describe)('@eyeglass/types', () => {
5
+ (0, vitest_1.describe)('InteractionStatus', () => {
6
+ (0, vitest_1.it)('should allow valid status values', () => {
7
+ const statuses = ['idle', 'pending', 'fixing', 'success', 'failed'];
8
+ (0, vitest_1.expect)(statuses).toHaveLength(5);
9
+ });
10
+ });
11
+ (0, vitest_1.describe)('SemanticSnapshot', () => {
12
+ (0, vitest_1.it)('should conform to the expected shape', () => {
13
+ const snapshot = {
14
+ role: 'button',
15
+ name: 'Submit',
16
+ tagName: 'button',
17
+ framework: {
18
+ name: 'react',
19
+ componentName: 'SubmitButton',
20
+ filePath: 'src/components/SubmitButton.tsx',
21
+ lineNumber: 42,
22
+ },
23
+ a11y: {
24
+ label: 'Submit form',
25
+ description: null,
26
+ disabled: false,
27
+ hidden: false,
28
+ },
29
+ geometry: {
30
+ x: 100,
31
+ y: 200,
32
+ width: 120,
33
+ height: 40,
34
+ visible: true,
35
+ },
36
+ styles: {
37
+ display: 'inline-flex',
38
+ position: 'relative',
39
+ padding: '8px 16px',
40
+ margin: '0px',
41
+ color: 'rgb(255, 255, 255)',
42
+ backgroundColor: 'rgb(59, 130, 246)',
43
+ fontFamily: 'Inter, sans-serif',
44
+ zIndex: 'auto',
45
+ },
46
+ timestamp: Date.now(),
47
+ url: 'http://localhost:3000/',
48
+ };
49
+ (0, vitest_1.expect)(snapshot.role).toBe('button');
50
+ (0, vitest_1.expect)(snapshot.framework.name).toBe('react');
51
+ (0, vitest_1.expect)(snapshot.a11y.disabled).toBe(false);
52
+ (0, vitest_1.expect)(snapshot.geometry.visible).toBe(true);
53
+ });
54
+ (0, vitest_1.it)('should support optional fields', () => {
55
+ const snapshot = {
56
+ role: 'generic',
57
+ name: '',
58
+ tagName: 'div',
59
+ id: 'my-div',
60
+ className: 'container main',
61
+ dataAttributes: { 'data-testid': 'main-container' },
62
+ framework: {
63
+ name: 'vanilla',
64
+ },
65
+ a11y: {
66
+ label: null,
67
+ description: null,
68
+ disabled: false,
69
+ expanded: true,
70
+ checked: 'mixed',
71
+ hidden: false,
72
+ },
73
+ geometry: {
74
+ x: 0,
75
+ y: 0,
76
+ width: 800,
77
+ height: 600,
78
+ visible: true,
79
+ },
80
+ styles: {
81
+ display: 'block',
82
+ position: 'static',
83
+ padding: '0px',
84
+ margin: '0px',
85
+ color: 'rgb(0, 0, 0)',
86
+ backgroundColor: 'rgba(0, 0, 0, 0)',
87
+ fontFamily: 'system-ui',
88
+ zIndex: 'auto',
89
+ },
90
+ timestamp: Date.now(),
91
+ url: 'http://localhost:3000/',
92
+ };
93
+ (0, vitest_1.expect)(snapshot.id).toBe('my-div');
94
+ (0, vitest_1.expect)(snapshot.className).toBe('container main');
95
+ (0, vitest_1.expect)(snapshot.dataAttributes).toEqual({ 'data-testid': 'main-container' });
96
+ (0, vitest_1.expect)(snapshot.a11y.expanded).toBe(true);
97
+ (0, vitest_1.expect)(snapshot.a11y.checked).toBe('mixed');
98
+ });
99
+ });
100
+ (0, vitest_1.describe)('FocusPayload', () => {
101
+ (0, vitest_1.it)('should support single snapshot (backwards compat)', () => {
102
+ const payload = {
103
+ interactionId: 'abc-123',
104
+ snapshot: {
105
+ role: 'button',
106
+ name: 'Click me',
107
+ tagName: 'button',
108
+ framework: { name: 'react' },
109
+ a11y: { label: null, description: null, disabled: false, hidden: false },
110
+ geometry: { x: 0, y: 0, width: 100, height: 40, visible: true },
111
+ styles: {
112
+ display: 'block',
113
+ position: 'static',
114
+ padding: '0px',
115
+ margin: '0px',
116
+ color: 'black',
117
+ backgroundColor: 'white',
118
+ fontFamily: 'Arial',
119
+ zIndex: 'auto',
120
+ },
121
+ timestamp: Date.now(),
122
+ url: 'http://localhost/',
123
+ },
124
+ userNote: 'Make this blue',
125
+ };
126
+ (0, vitest_1.expect)(payload.snapshot).toBeDefined();
127
+ (0, vitest_1.expect)(payload.snapshots).toBeUndefined();
128
+ });
129
+ (0, vitest_1.it)('should support multiple snapshots (multi-select)', () => {
130
+ const baseSnapshot = {
131
+ role: 'button',
132
+ name: '',
133
+ tagName: 'button',
134
+ framework: { name: 'react' },
135
+ a11y: { label: null, description: null, disabled: false, hidden: false },
136
+ geometry: { x: 0, y: 0, width: 100, height: 40, visible: true },
137
+ styles: {
138
+ display: 'block',
139
+ position: 'static',
140
+ padding: '0px',
141
+ margin: '0px',
142
+ color: 'black',
143
+ backgroundColor: 'white',
144
+ fontFamily: 'Arial',
145
+ zIndex: 'auto',
146
+ },
147
+ timestamp: Date.now(),
148
+ url: 'http://localhost/',
149
+ };
150
+ const payload = {
151
+ interactionId: 'abc-123',
152
+ snapshots: [
153
+ { ...baseSnapshot, name: 'Button 1' },
154
+ { ...baseSnapshot, name: 'Button 2' },
155
+ ],
156
+ userNote: 'Style these buttons consistently',
157
+ };
158
+ (0, vitest_1.expect)(payload.snapshots).toHaveLength(2);
159
+ (0, vitest_1.expect)(payload.snapshot).toBeUndefined();
160
+ });
161
+ });
162
+ (0, vitest_1.describe)('ActivityEvent types', () => {
163
+ (0, vitest_1.it)('should create valid StatusEvent', () => {
164
+ const event = {
165
+ type: 'status',
166
+ interactionId: 'abc-123',
167
+ status: 'fixing',
168
+ message: 'Working on it...',
169
+ timestamp: Date.now(),
170
+ };
171
+ (0, vitest_1.expect)(event.type).toBe('status');
172
+ (0, vitest_1.expect)(event.status).toBe('fixing');
173
+ });
174
+ (0, vitest_1.it)('should create valid ThoughtEvent', () => {
175
+ const event = {
176
+ type: 'thought',
177
+ interactionId: 'abc-123',
178
+ content: 'I need to change the background color',
179
+ timestamp: Date.now(),
180
+ };
181
+ (0, vitest_1.expect)(event.type).toBe('thought');
182
+ (0, vitest_1.expect)(event.content).toContain('background color');
183
+ });
184
+ (0, vitest_1.it)('should create valid QuestionEvent', () => {
185
+ const event = {
186
+ type: 'question',
187
+ interactionId: 'abc-123',
188
+ questionId: 'q-1',
189
+ question: 'Which shade of blue?',
190
+ options: [
191
+ { id: 'light', label: 'Light blue' },
192
+ { id: 'dark', label: 'Dark blue' },
193
+ ],
194
+ timestamp: Date.now(),
195
+ };
196
+ (0, vitest_1.expect)(event.type).toBe('question');
197
+ (0, vitest_1.expect)(event.options).toHaveLength(2);
198
+ });
199
+ (0, vitest_1.it)('should create valid ActionEvent', () => {
200
+ const event = {
201
+ type: 'action',
202
+ interactionId: 'abc-123',
203
+ action: 'writing',
204
+ target: 'src/components/Button.tsx',
205
+ complete: false,
206
+ timestamp: Date.now(),
207
+ };
208
+ (0, vitest_1.expect)(event.type).toBe('action');
209
+ (0, vitest_1.expect)(event.action).toBe('writing');
210
+ });
211
+ (0, vitest_1.it)('should allow ActivityEvent union', () => {
212
+ const events = [
213
+ { type: 'status', interactionId: 'a', status: 'idle', timestamp: 1 },
214
+ { type: 'thought', interactionId: 'a', content: 'thinking', timestamp: 2 },
215
+ { type: 'question', interactionId: 'a', questionId: 'q', question: '?', options: [], timestamp: 3 },
216
+ { type: 'action', interactionId: 'a', action: 'reading', target: 'file.ts', timestamp: 4 },
217
+ ];
218
+ (0, vitest_1.expect)(events).toHaveLength(4);
219
+ });
220
+ });
221
+ });
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@eyeglass/types",
3
+ "version": "0.1.0",
4
+ "description": "Shared TypeScript types for Eyeglass",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "scripts": {
12
+ "build": "tsc",
13
+ "test": "vitest run --project node --testNamePattern types",
14
+ "prepublishOnly": "npm run build"
15
+ },
16
+ "keywords": [
17
+ "eyeglass",
18
+ "types",
19
+ "typescript"
20
+ ],
21
+ "license": "MIT",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/donutboyband/eyeglass.git",
25
+ "directory": "packages/types"
26
+ },
27
+ "devDependencies": {
28
+ "typescript": "^5.3.0"
29
+ }
30
+ }