stelo 1.0.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.
Files changed (141) hide show
  1. package/LICENSE +184 -0
  2. package/README.md +853 -0
  3. package/dist/accessibility.d.ts +227 -0
  4. package/dist/accessibility.d.ts.map +1 -0
  5. package/dist/accessibility.js +602 -0
  6. package/dist/accessibility.js.map +1 -0
  7. package/dist/agent.d.ts +870 -0
  8. package/dist/agent.d.ts.map +1 -0
  9. package/dist/agent.js +1107 -0
  10. package/dist/agent.js.map +1 -0
  11. package/dist/audio-stream.d.ts +114 -0
  12. package/dist/audio-stream.d.ts.map +1 -0
  13. package/dist/audio-stream.js +167 -0
  14. package/dist/audio-stream.js.map +1 -0
  15. package/dist/clipboard.d.ts +99 -0
  16. package/dist/clipboard.d.ts.map +1 -0
  17. package/dist/clipboard.js +352 -0
  18. package/dist/clipboard.js.map +1 -0
  19. package/dist/config.d.ts +183 -0
  20. package/dist/config.d.ts.map +1 -0
  21. package/dist/config.js +477 -0
  22. package/dist/config.js.map +1 -0
  23. package/dist/context.d.ts +213 -0
  24. package/dist/context.d.ts.map +1 -0
  25. package/dist/context.js +387 -0
  26. package/dist/context.js.map +1 -0
  27. package/dist/cortex.d.ts +548 -0
  28. package/dist/cortex.d.ts.map +1 -0
  29. package/dist/cortex.js +1479 -0
  30. package/dist/cortex.js.map +1 -0
  31. package/dist/errors.d.ts +133 -0
  32. package/dist/errors.d.ts.map +1 -0
  33. package/dist/errors.js +278 -0
  34. package/dist/errors.js.map +1 -0
  35. package/dist/events.d.ts +227 -0
  36. package/dist/events.d.ts.map +1 -0
  37. package/dist/events.js +429 -0
  38. package/dist/events.js.map +1 -0
  39. package/dist/executor.d.ts +212 -0
  40. package/dist/executor.d.ts.map +1 -0
  41. package/dist/executor.js +545 -0
  42. package/dist/executor.js.map +1 -0
  43. package/dist/index.d.ts +69 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +167 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/integration.d.ts +159 -0
  48. package/dist/integration.d.ts.map +1 -0
  49. package/dist/integration.js +533 -0
  50. package/dist/integration.js.map +1 -0
  51. package/dist/keyboard.d.ts +276 -0
  52. package/dist/keyboard.d.ts.map +1 -0
  53. package/dist/keyboard.js +404 -0
  54. package/dist/keyboard.js.map +1 -0
  55. package/dist/logger.d.ts +198 -0
  56. package/dist/logger.d.ts.map +1 -0
  57. package/dist/logger.js +516 -0
  58. package/dist/logger.js.map +1 -0
  59. package/dist/middleware.d.ts +183 -0
  60. package/dist/middleware.d.ts.map +1 -0
  61. package/dist/middleware.js +493 -0
  62. package/dist/middleware.js.map +1 -0
  63. package/dist/monitor.d.ts +136 -0
  64. package/dist/monitor.d.ts.map +1 -0
  65. package/dist/monitor.js +341 -0
  66. package/dist/monitor.js.map +1 -0
  67. package/dist/mouse.d.ts +290 -0
  68. package/dist/mouse.d.ts.map +1 -0
  69. package/dist/mouse.js +466 -0
  70. package/dist/mouse.js.map +1 -0
  71. package/dist/plugin.d.ts +157 -0
  72. package/dist/plugin.d.ts.map +1 -0
  73. package/dist/plugin.js +409 -0
  74. package/dist/plugin.js.map +1 -0
  75. package/dist/process.d.ts +106 -0
  76. package/dist/process.d.ts.map +1 -0
  77. package/dist/process.js +326 -0
  78. package/dist/process.js.map +1 -0
  79. package/dist/recorder.d.ts +100 -0
  80. package/dist/recorder.d.ts.map +1 -0
  81. package/dist/recorder.js +258 -0
  82. package/dist/recorder.js.map +1 -0
  83. package/dist/safety.d.ts +59 -0
  84. package/dist/safety.d.ts.map +1 -0
  85. package/dist/safety.js +98 -0
  86. package/dist/safety.js.map +1 -0
  87. package/dist/scheduler.d.ts +152 -0
  88. package/dist/scheduler.d.ts.map +1 -0
  89. package/dist/scheduler.js +615 -0
  90. package/dist/scheduler.js.map +1 -0
  91. package/dist/screen.d.ts +96 -0
  92. package/dist/screen.d.ts.map +1 -0
  93. package/dist/screen.js +154 -0
  94. package/dist/screen.js.map +1 -0
  95. package/dist/session.d.ts +209 -0
  96. package/dist/session.d.ts.map +1 -0
  97. package/dist/session.js +479 -0
  98. package/dist/session.js.map +1 -0
  99. package/dist/stream.d.ts +168 -0
  100. package/dist/stream.d.ts.map +1 -0
  101. package/dist/stream.js +298 -0
  102. package/dist/stream.js.map +1 -0
  103. package/dist/telemetry.d.ts +223 -0
  104. package/dist/telemetry.d.ts.map +1 -0
  105. package/dist/telemetry.js +433 -0
  106. package/dist/telemetry.js.map +1 -0
  107. package/dist/types.d.ts +165 -0
  108. package/dist/types.d.ts.map +1 -0
  109. package/dist/types.js +8 -0
  110. package/dist/types.js.map +1 -0
  111. package/dist/utils/bezier.d.ts +51 -0
  112. package/dist/utils/bezier.d.ts.map +1 -0
  113. package/dist/utils/bezier.js +117 -0
  114. package/dist/utils/bezier.js.map +1 -0
  115. package/dist/utils/helpers.d.ts +90 -0
  116. package/dist/utils/helpers.d.ts.map +1 -0
  117. package/dist/utils/helpers.js +143 -0
  118. package/dist/utils/helpers.js.map +1 -0
  119. package/dist/utils/index.d.ts +4 -0
  120. package/dist/utils/index.d.ts.map +1 -0
  121. package/dist/utils/index.js +18 -0
  122. package/dist/utils/index.js.map +1 -0
  123. package/dist/validation.d.ts +254 -0
  124. package/dist/validation.d.ts.map +1 -0
  125. package/dist/validation.js +478 -0
  126. package/dist/validation.js.map +1 -0
  127. package/dist/vision.d.ts +719 -0
  128. package/dist/vision.d.ts.map +1 -0
  129. package/dist/vision.js +1197 -0
  130. package/dist/vision.js.map +1 -0
  131. package/dist/window.d.ts +80 -0
  132. package/dist/window.d.ts.map +1 -0
  133. package/dist/window.js +170 -0
  134. package/dist/window.js.map +1 -0
  135. package/dist/workflow.d.ts +224 -0
  136. package/dist/workflow.d.ts.map +1 -0
  137. package/dist/workflow.js +578 -0
  138. package/dist/workflow.js.map +1 -0
  139. package/index.d.ts +840 -0
  140. package/index.js +495 -0
  141. package/package.json +91 -0
@@ -0,0 +1,96 @@
1
+ import type { DisplayInfo, PixelColor, Region, ScreenCapture, ScreenSize } from './types';
2
+ /**
3
+ * Screen analysis and capture interface.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * import { screen } from 'stelo';
8
+ *
9
+ * const size = screen.getSize();
10
+ * console.log(`Screen: ${size.width}x${size.height}`);
11
+ *
12
+ * const color = screen.getPixelColor(100, 200);
13
+ * console.log(`Color at (100,200): ${color.hex}`);
14
+ *
15
+ * const capture = screen.capture({ x: 0, y: 0, width: 800, height: 600 });
16
+ * ```
17
+ */
18
+ export declare const screen: {
19
+ /**
20
+ * Get the primary screen dimensions.
21
+ */
22
+ getSize(): ScreenSize;
23
+ /**
24
+ * Get the screen width.
25
+ */
26
+ readonly width: number;
27
+ /**
28
+ * Get the screen height.
29
+ */
30
+ readonly height: number;
31
+ /**
32
+ * Get the color of a pixel at the given screen coordinates.
33
+ */
34
+ getPixelColor(x: number, y: number): PixelColor;
35
+ /**
36
+ * Capture a region of the screen as raw RGBA pixel data.
37
+ * If no region is specified, captures the entire primary screen.
38
+ */
39
+ capture(region?: Region): ScreenCapture;
40
+ /**
41
+ * Capture a region of the screen as raw BGRA pixel data (no color conversion).
42
+ * Faster than `capture()` since BGRA is the native format on all platforms.
43
+ * Ideal for vision model pipelines, real-time streaming, or when you don't
44
+ * need standard RGBA ordering.
45
+ */
46
+ captureBgra(region?: Region): ScreenCapture;
47
+ /**
48
+ * Get information about all connected displays/monitors.
49
+ */
50
+ getAllDisplays(): DisplayInfo[];
51
+ /**
52
+ * Search for a pixel of a specific color within a region.
53
+ * Returns the coordinates of the first match, or null if not found.
54
+ *
55
+ * @param color - Color to search for (r, g, b)
56
+ * @param tolerance - Color distance tolerance (default: 0, exact match)
57
+ * @param region - Optional region to search within
58
+ */
59
+ findColor(color: {
60
+ r: number;
61
+ g: number;
62
+ b: number;
63
+ }, tolerance?: number, region?: Region): {
64
+ x: number;
65
+ y: number;
66
+ } | null;
67
+ /**
68
+ * Check if a pixel matches an expected color.
69
+ * @param x - X coordinate
70
+ * @param y - Y coordinate
71
+ * @param color - Expected color (hex string like '#FF0000' or { r, g, b } object)
72
+ * @param tolerance - Acceptable color distance (default: 0)
73
+ */
74
+ pixelMatches(x: number, y: number, color: string | {
75
+ r: number;
76
+ g: number;
77
+ b: number;
78
+ }, tolerance?: number): boolean;
79
+ /**
80
+ * Wait until a pixel matches a color (with polling).
81
+ * @param x - X coordinate
82
+ * @param y - Y coordinate
83
+ * @param color - Expected color (hex string or { r, g, b } object)
84
+ * @param options - Wait options: tolerance, timeoutMs, intervalMs
85
+ */
86
+ waitForColor(x: number, y: number, color: string | {
87
+ r: number;
88
+ g: number;
89
+ b: number;
90
+ }, options?: {
91
+ tolerance?: number;
92
+ timeoutMs?: number;
93
+ intervalMs?: number;
94
+ }): Promise<void>;
95
+ };
96
+ //# sourceMappingURL=screen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screen.d.ts","sourceRoot":"","sources":["../ts/screen.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAc1F;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,MAAM;IACjB;;OAEG;eACQ,UAAU;IAIrB;;OAEG;oBACU,MAAM;IAInB;;OAEG;qBACW,MAAM;IAIpB;;OAEG;qBACc,MAAM,KAAK,MAAM,GAAG,UAAU;IAI/C;;;OAGG;qBACc,MAAM,GAAG,aAAa;IAOvC;;;;;OAKG;yBACkB,MAAM,GAAG,aAAa;IAO3C;;OAEG;sBACe,WAAW,EAAE;IAc/B;;;;;;;OAOG;qBAEM;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,cAC9B,MAAM,WACT,MAAM,GACd;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAclC;;;;;;OAMG;oBAEE,MAAM,KACN,MAAM,SACF,MAAM,GAAG;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,cACxC,MAAM,GAChB,OAAO;IAUV;;;;;;OAMG;oBAEE,MAAM,KACN,MAAM,SACF,MAAM,GAAG;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,YACzC;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GACxE,OAAO,CAAC,IAAI,CAAC;CAoBjB,CAAC"}
package/dist/screen.js ADDED
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Stelo — Screen Control API
4
+ // ============================================================================
5
+ // Screen capture, pixel analysis, display information.
6
+ // ============================================================================
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.screen = void 0;
9
+ const native = require('../index.js');
10
+ /** Parse a hex color string like '#FF0000' into { r, g, b }. */
11
+ function parseHexColor(hex) {
12
+ const h = hex.replace(/^#/, '');
13
+ return {
14
+ r: parseInt(h.substring(0, 2), 16),
15
+ g: parseInt(h.substring(2, 4), 16),
16
+ b: parseInt(h.substring(4, 6), 16),
17
+ };
18
+ }
19
+ /**
20
+ * Screen analysis and capture interface.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * import { screen } from 'stelo';
25
+ *
26
+ * const size = screen.getSize();
27
+ * console.log(`Screen: ${size.width}x${size.height}`);
28
+ *
29
+ * const color = screen.getPixelColor(100, 200);
30
+ * console.log(`Color at (100,200): ${color.hex}`);
31
+ *
32
+ * const capture = screen.capture({ x: 0, y: 0, width: 800, height: 600 });
33
+ * ```
34
+ */
35
+ exports.screen = {
36
+ /**
37
+ * Get the primary screen dimensions.
38
+ */
39
+ getSize() {
40
+ return native.screenSize();
41
+ },
42
+ /**
43
+ * Get the screen width.
44
+ */
45
+ get width() {
46
+ return native.screenSize().width;
47
+ },
48
+ /**
49
+ * Get the screen height.
50
+ */
51
+ get height() {
52
+ return native.screenSize().height;
53
+ },
54
+ /**
55
+ * Get the color of a pixel at the given screen coordinates.
56
+ */
57
+ getPixelColor(x, y) {
58
+ return native.screenPixelColor(x, y);
59
+ },
60
+ /**
61
+ * Capture a region of the screen as raw RGBA pixel data.
62
+ * If no region is specified, captures the entire primary screen.
63
+ */
64
+ capture(region) {
65
+ if (region) {
66
+ return native.screenCapture(region.x, region.y, region.width, region.height);
67
+ }
68
+ return native.screenCapture();
69
+ },
70
+ /**
71
+ * Capture a region of the screen as raw BGRA pixel data (no color conversion).
72
+ * Faster than `capture()` since BGRA is the native format on all platforms.
73
+ * Ideal for vision model pipelines, real-time streaming, or when you don't
74
+ * need standard RGBA ordering.
75
+ */
76
+ captureBgra(region) {
77
+ if (region) {
78
+ return native.screenCaptureBgra(region.x, region.y, region.width, region.height);
79
+ }
80
+ return native.screenCaptureBgra();
81
+ },
82
+ /**
83
+ * Get information about all connected displays/monitors.
84
+ */
85
+ getAllDisplays() {
86
+ const displays = native.screenDisplays();
87
+ return displays.map((d) => ({
88
+ id: d.id,
89
+ x: d.x,
90
+ y: d.y,
91
+ width: d.width,
92
+ height: d.height,
93
+ isPrimary: d.isPrimary,
94
+ scaleFactor: d.scaleFactor,
95
+ name: d.name,
96
+ }));
97
+ },
98
+ /**
99
+ * Search for a pixel of a specific color within a region.
100
+ * Returns the coordinates of the first match, or null if not found.
101
+ *
102
+ * @param color - Color to search for (r, g, b)
103
+ * @param tolerance - Color distance tolerance (default: 0, exact match)
104
+ * @param region - Optional region to search within
105
+ */
106
+ findColor(color, tolerance, region) {
107
+ const result = native.screenFindColor(color.r, color.g, color.b, tolerance ?? undefined, region?.x ?? undefined, region?.y ?? undefined, region?.width ?? undefined, region?.height ?? undefined);
108
+ return result ?? null;
109
+ },
110
+ /**
111
+ * Check if a pixel matches an expected color.
112
+ * @param x - X coordinate
113
+ * @param y - Y coordinate
114
+ * @param color - Expected color (hex string like '#FF0000' or { r, g, b } object)
115
+ * @param tolerance - Acceptable color distance (default: 0)
116
+ */
117
+ pixelMatches(x, y, color, tolerance = 0) {
118
+ const actual = native.screenPixelColor(x, y);
119
+ const expected = typeof color === 'string' ? parseHexColor(color) : color;
120
+ const dr = actual.r - expected.r;
121
+ const dg = actual.g - expected.g;
122
+ const db = actual.b - expected.b;
123
+ const distance = Math.sqrt(dr * dr + dg * dg + db * db);
124
+ return distance <= tolerance;
125
+ },
126
+ /**
127
+ * Wait until a pixel matches a color (with polling).
128
+ * @param x - X coordinate
129
+ * @param y - Y coordinate
130
+ * @param color - Expected color (hex string or { r, g, b } object)
131
+ * @param options - Wait options: tolerance, timeoutMs, intervalMs
132
+ */
133
+ waitForColor(x, y, color, options) {
134
+ const tolerance = options?.tolerance ?? 0;
135
+ const timeout = options?.timeoutMs ?? 5000;
136
+ const interval = options?.intervalMs ?? 100;
137
+ return new Promise((resolve, reject) => {
138
+ const start = Date.now();
139
+ const check = () => {
140
+ if (exports.screen.pixelMatches(x, y, color, tolerance)) {
141
+ resolve();
142
+ return;
143
+ }
144
+ if (Date.now() - start >= timeout) {
145
+ reject(new Error(`waitForColor timed out after ${timeout}ms`));
146
+ return;
147
+ }
148
+ setTimeout(check, interval);
149
+ };
150
+ check();
151
+ });
152
+ },
153
+ };
154
+ //# sourceMappingURL=screen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screen.js","sourceRoot":"","sources":["../ts/screen.ts"],"names":[],"mappings":";AAAA,+EAA+E;AAC/E,6BAA6B;AAC7B,+EAA+E;AAC/E,uDAAuD;AACvD,+EAA+E;;;AAI/E,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAEtC,gEAAgE;AAChE,SAAS,aAAa,CAAC,GAAW;IAChC,MAAM,CAAC,G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KAAK,EAAE,QAAQ,CAAC,CAAC;YAC9B,CAAC,CAAC;YACF,KAAK,EAAE,CAAC;QACV,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
@@ -0,0 +1,209 @@
1
+ export type SessionStatus = 'idle' | 'active' | 'paused' | 'completed' | 'failed' | 'rolled_back';
2
+ export interface SessionMetadata {
3
+ /** Session ID */
4
+ id: string;
5
+ /** Human-readable name */
6
+ name: string;
7
+ /** Session status */
8
+ status: SessionStatus;
9
+ /** Creation time */
10
+ createdAt: string;
11
+ /** Last updated time */
12
+ updatedAt: string;
13
+ /** Number of checkpoints */
14
+ checkpointCount: number;
15
+ /** Number of recorded actions */
16
+ actionCount: number;
17
+ /** Tags/labels */
18
+ tags: string[];
19
+ /** Custom metadata */
20
+ custom: Record<string, any>;
21
+ }
22
+ export interface Checkpoint {
23
+ /** Checkpoint ID */
24
+ id: string;
25
+ /** Label */
26
+ label: string;
27
+ /** Timestamp */
28
+ timestamp: string;
29
+ /** Index into action history */
30
+ actionIndex: number;
31
+ /** Serialized state snapshot */
32
+ state: Record<string, any>;
33
+ /** Arbitrary metadata */
34
+ metadata?: Record<string, any>;
35
+ }
36
+ export interface RecordedAction {
37
+ /** Action index */
38
+ index: number;
39
+ /** Type of action (mouse.click, keyboard.type, etc.) */
40
+ type: string;
41
+ /** Action arguments */
42
+ args: any;
43
+ /** When the action occurred */
44
+ timestamp: string;
45
+ /** Duration of the action (ms) */
46
+ durationMs: number;
47
+ /** Result of the action */
48
+ result?: any;
49
+ /** Error, if the action failed */
50
+ error?: string;
51
+ /** Can this action be undone? */
52
+ undoable: boolean;
53
+ /** Undo function serialization hint */
54
+ undoHint?: string;
55
+ }
56
+ export interface SessionSnapshot {
57
+ /** Session metadata */
58
+ metadata: SessionMetadata;
59
+ /** All checkpoints */
60
+ checkpoints: Checkpoint[];
61
+ /** Action history */
62
+ actions: RecordedAction[];
63
+ /** Custom stored state */
64
+ store: Record<string, any>;
65
+ /** Format version */
66
+ version: number;
67
+ }
68
+ export interface SessionOptions {
69
+ /** Session name */
70
+ name?: string;
71
+ /** Auto-checkpoint every N actions. 0 = disabled. Default: 0 */
72
+ autoCheckpointInterval?: number;
73
+ /** Maximum number of checkpoints to keep. Default: 50 */
74
+ maxCheckpoints?: number;
75
+ /** Maximum action history size. Default: 10000 */
76
+ maxActions?: number;
77
+ /** Tags */
78
+ tags?: string[];
79
+ /** Custom metadata */
80
+ custom?: Record<string, any>;
81
+ }
82
+ export declare const session: {
83
+ /**
84
+ * Start a new session.
85
+ */
86
+ start(options?: SessionOptions): string;
87
+ /**
88
+ * Get the active session ID (or null).
89
+ */
90
+ getActiveId(): string | null;
91
+ /**
92
+ * Get the active session metadata.
93
+ */
94
+ getActive(): SessionMetadata | null;
95
+ /**
96
+ * Switch to a different (existing) session.
97
+ */
98
+ switchTo(sessionId: string): boolean;
99
+ /**
100
+ * Pause the active session.
101
+ */
102
+ pause(): boolean;
103
+ /**
104
+ * Resume the active session.
105
+ */
106
+ resume(): boolean;
107
+ /**
108
+ * End the active session.
109
+ */
110
+ end(status?: "completed" | "failed"): SessionMetadata | null;
111
+ /**
112
+ * Record an action in the active session.
113
+ */
114
+ recordAction(type: string, args: any, options?: {
115
+ durationMs?: number;
116
+ result?: any;
117
+ error?: string;
118
+ undoable?: boolean;
119
+ undoFn?: () => void | Promise<void>;
120
+ undoHint?: string;
121
+ }): number;
122
+ /**
123
+ * Get the action history from the active session.
124
+ */
125
+ getActions(filter?: {
126
+ type?: string;
127
+ since?: string;
128
+ limit?: number;
129
+ }): RecordedAction[];
130
+ /**
131
+ * Create a checkpoint (snapshot) at the current point.
132
+ */
133
+ checkpoint(label?: string, metadata?: Record<string, any>): string | null;
134
+ /**
135
+ * List all checkpoints in the active session.
136
+ */
137
+ listCheckpoints(): Checkpoint[];
138
+ /**
139
+ * Restore state from a checkpoint (does NOT undo actions — use rollback for that).
140
+ */
141
+ restoreCheckpoint(checkpointId: string): boolean;
142
+ /**
143
+ * Rollback: undo actions back to a checkpoint.
144
+ * This calls the undo functions for actions recorded since the checkpoint.
145
+ */
146
+ rollback(checkpointId: string): Promise<{
147
+ undone: number;
148
+ errors: number;
149
+ }>;
150
+ /**
151
+ * Undo the last undoable action.
152
+ */
153
+ undo(): Promise<boolean>;
154
+ /**
155
+ * Set a key in the session store.
156
+ */
157
+ set(key: string, value: any): void;
158
+ /**
159
+ * Get a value from the session store.
160
+ */
161
+ get<T = any>(key: string, defaultValue?: T): T;
162
+ /**
163
+ * Check if a key exists in the session store.
164
+ */
165
+ has(key: string): boolean;
166
+ /**
167
+ * Delete a key from the session store.
168
+ */
169
+ delete(key: string): boolean;
170
+ /**
171
+ * Get all keys in the session store.
172
+ */
173
+ keys(): string[];
174
+ /**
175
+ * Export the active session as a JSON-serializable snapshot.
176
+ */
177
+ export(): SessionSnapshot | null;
178
+ /**
179
+ * Export session as a JSON string.
180
+ */
181
+ toJSON(pretty?: boolean): string | null;
182
+ /**
183
+ * Import a session from a snapshot (creates a new session).
184
+ */
185
+ import(snapshot: SessionSnapshot): string;
186
+ /**
187
+ * Import session from a JSON string.
188
+ */
189
+ fromJSON(json: string): string;
190
+ /**
191
+ * List all sessions.
192
+ */
193
+ listSessions(): SessionMetadata[];
194
+ /**
195
+ * Delete a session.
196
+ */
197
+ deleteSession(sessionId: string): boolean;
198
+ /**
199
+ * Get session duration (ms) for the active session.
200
+ */
201
+ getDuration(): number;
202
+ /**
203
+ * Get a summary of the active session (for display/logging).
204
+ */
205
+ getSummary(): string;
206
+ /** Reset all session state */
207
+ reset(): void;
208
+ };
209
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../ts/session.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,aAAa,CAAC;AAElG,MAAM,WAAW,eAAe;IAC9B,iBAAiB;IACjB,E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