@elizaos/plugin-vision 1.2.1 → 2.0.0-alpha.2
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/LICENSE +21 -0
- package/build.config.ts +53 -53
- package/dist/index.js +6716 -67
- package/dist/index.js.map +33 -1
- package/dist/workers/florence2-worker.js +111763 -307
- package/dist/workers/florence2-worker.js.map +92 -1
- package/dist/workers/ocr-worker.js +119177 -339
- package/dist/workers/ocr-worker.js.map +137 -1
- package/dist/workers/screen-capture-worker.js +350 -418
- package/dist/workers/screen-capture-worker.js.map +11 -1
- package/package.json +15 -20
- package/README.md +0 -270
- package/dist/action.d.ts +0 -8
- package/dist/action.js +0 -1212
- package/dist/action.js.map +0 -1
- package/dist/audio-capture-stream.d.ts +0 -42
- package/dist/audio-capture-stream.js +0 -516
- package/dist/audio-capture-stream.js.map +0 -1
- package/dist/audio-capture.d.ts +0 -25
- package/dist/audio-capture.js +0 -412
- package/dist/audio-capture.js.map +0 -1
- package/dist/basic.test.d.ts +0 -1
- package/dist/basic.test.js +0 -97
- package/dist/basic.test.js.map +0 -1
- package/dist/config.d.ts +0 -73
- package/dist/config.js +0 -254
- package/dist/config.js.map +0 -1
- package/dist/entity-tracker.d.ts +0 -32
- package/dist/entity-tracker.js +0 -361
- package/dist/entity-tracker.js.map +0 -1
- package/dist/errors.d.ts +0 -67
- package/dist/errors.js +0 -395
- package/dist/errors.js.map +0 -1
- package/dist/face-recognition.d.ts +0 -31
- package/dist/face-recognition.js +0 -332
- package/dist/face-recognition.js.map +0 -1
- package/dist/florence2-local.d.ts +0 -25
- package/dist/florence2-local.js +0 -280
- package/dist/florence2-local.js.map +0 -1
- package/dist/florence2-model.d.ts +0 -36
- package/dist/florence2-model.js +0 -503
- package/dist/florence2-model.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/ocr-service-real.d.ts +0 -32
- package/dist/ocr-service-real.js +0 -396
- package/dist/ocr-service-real.js.map +0 -1
- package/dist/ocr-service.d.ts +0 -28
- package/dist/ocr-service.js +0 -216
- package/dist/ocr-service.js.map +0 -1
- package/dist/provider.d.ts +0 -2
- package/dist/provider.js +0 -285
- package/dist/provider.js.map +0 -1
- package/dist/screen-capture.d.ts +0 -16
- package/dist/screen-capture.js +0 -302
- package/dist/screen-capture.js.map +0 -1
- package/dist/service.d.ts +0 -73
- package/dist/service.js +0 -1662
- package/dist/service.js.map +0 -1
- package/dist/tests/e2e/index.d.ts +0 -8
- package/dist/tests/e2e/index.js +0 -33
- package/dist/tests/e2e/index.js.map +0 -1
- package/dist/tests/e2e/run-local.d.ts +0 -2
- package/dist/tests/e2e/run-local.js +0 -166
- package/dist/tests/e2e/run-local.js.map +0 -1
- package/dist/tests/e2e/screen-vision.d.ts +0 -11
- package/dist/tests/e2e/screen-vision.js +0 -384
- package/dist/tests/e2e/screen-vision.js.map +0 -1
- package/dist/tests/e2e/vision-autonomy.d.ts +0 -11
- package/dist/tests/e2e/vision-autonomy.js +0 -375
- package/dist/tests/e2e/vision-autonomy.js.map +0 -1
- package/dist/tests/e2e/vision-basic.d.ts +0 -11
- package/dist/tests/e2e/vision-basic.js +0 -434
- package/dist/tests/e2e/vision-basic.js.map +0 -1
- package/dist/tests/e2e/vision-capture-log.d.ts +0 -11
- package/dist/tests/e2e/vision-capture-log.js +0 -302
- package/dist/tests/e2e/vision-capture-log.js.map +0 -1
- package/dist/tests/e2e/vision-runtime.d.ts +0 -11
- package/dist/tests/e2e/vision-runtime.js +0 -357
- package/dist/tests/e2e/vision-runtime.js.map +0 -1
- package/dist/tests/e2e/vision-worker-tests.d.ts +0 -11
- package/dist/tests/e2e/vision-worker-tests.js +0 -466
- package/dist/tests/e2e/vision-worker-tests.js.map +0 -1
- package/dist/tests/test-pattern-generator.d.ts +0 -40
- package/dist/tests/test-pattern-generator.js +0 -191
- package/dist/tests/test-pattern-generator.js.map +0 -1
- package/dist/tests.d.ts +0 -3
- package/dist/tests.js +0 -11
- package/dist/tests.js.map +0 -1
- package/dist/types.d.ts +0 -222
- package/dist/types.js +0 -16
- package/dist/types.js.map +0 -1
- package/dist/vision-models.d.ts +0 -47
- package/dist/vision-models.js +0 -501
- package/dist/vision-models.js.map +0 -1
- package/dist/vision-worker-manager.d.ts +0 -61
- package/dist/vision-worker-manager.js +0 -668
- package/dist/vision-worker-manager.js.map +0 -1
- package/dist/workers/florence2-worker-simple.d.ts +0 -13
- package/dist/workers/florence2-worker-simple.js +0 -121
- package/dist/workers/florence2-worker-simple.js.map +0 -1
- package/dist/workers/florence2-worker.d.ts +0 -1
- package/dist/workers/ocr-worker.d.ts +0 -1
- package/dist/workers/screen-capture-worker.d.ts +0 -1
- package/dist/workers/worker-logger.d.ts +0 -9
- package/dist/workers/worker-logger.js +0 -95
- package/dist/workers/worker-logger.js.map +0 -1
package/dist/ocr-service.js
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.OCRService = void 0;
|
|
40
|
-
var core_1 = require("@elizaos/core");
|
|
41
|
-
var ocr_service_real_1 = require("./ocr-service-real");
|
|
42
|
-
var OCRService = /** @class */ (function () {
|
|
43
|
-
function OCRService() {
|
|
44
|
-
this.realOCR = null;
|
|
45
|
-
this.initialized = false;
|
|
46
|
-
this.useFallback = false;
|
|
47
|
-
}
|
|
48
|
-
OCRService.prototype.initialize = function () {
|
|
49
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
50
|
-
var error_1;
|
|
51
|
-
return __generator(this, function (_a) {
|
|
52
|
-
switch (_a.label) {
|
|
53
|
-
case 0:
|
|
54
|
-
if (this.initialized) {
|
|
55
|
-
return [2 /*return*/];
|
|
56
|
-
}
|
|
57
|
-
_a.label = 1;
|
|
58
|
-
case 1:
|
|
59
|
-
_a.trys.push([1, 3, , 4]);
|
|
60
|
-
core_1.logger.info('[OCR] Initializing OCR service...');
|
|
61
|
-
// Try to use real OCR first
|
|
62
|
-
this.realOCR = new ocr_service_real_1.RealOCRService();
|
|
63
|
-
return [4 /*yield*/, this.realOCR.initialize()];
|
|
64
|
-
case 2:
|
|
65
|
-
_a.sent();
|
|
66
|
-
this.initialized = true;
|
|
67
|
-
this.useFallback = false;
|
|
68
|
-
core_1.logger.info('[OCR] Real OCR service initialized successfully');
|
|
69
|
-
return [3 /*break*/, 4];
|
|
70
|
-
case 3:
|
|
71
|
-
error_1 = _a.sent();
|
|
72
|
-
core_1.logger.error('[OCR] Failed to initialize real OCR:', error_1);
|
|
73
|
-
// Fallback to basic OCR simulation
|
|
74
|
-
core_1.logger.warn('[OCR] Using fallback OCR implementation');
|
|
75
|
-
this.useFallback = true;
|
|
76
|
-
this.initialized = true;
|
|
77
|
-
return [3 /*break*/, 4];
|
|
78
|
-
case 4: return [2 /*return*/];
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
OCRService.prototype.extractText = function (imageBuffer) {
|
|
84
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
85
|
-
var error_2;
|
|
86
|
-
return __generator(this, function (_a) {
|
|
87
|
-
switch (_a.label) {
|
|
88
|
-
case 0:
|
|
89
|
-
if (!!this.initialized) return [3 /*break*/, 2];
|
|
90
|
-
return [4 /*yield*/, this.initialize()];
|
|
91
|
-
case 1:
|
|
92
|
-
_a.sent();
|
|
93
|
-
_a.label = 2;
|
|
94
|
-
case 2:
|
|
95
|
-
if (!(this.realOCR && !this.useFallback)) return [3 /*break*/, 6];
|
|
96
|
-
_a.label = 3;
|
|
97
|
-
case 3:
|
|
98
|
-
_a.trys.push([3, 5, , 6]);
|
|
99
|
-
return [4 /*yield*/, this.realOCR.extractText(imageBuffer)];
|
|
100
|
-
case 4: return [2 /*return*/, _a.sent()];
|
|
101
|
-
case 5:
|
|
102
|
-
error_2 = _a.sent();
|
|
103
|
-
core_1.logger.error('[OCR] Real OCR failed, falling back:', error_2);
|
|
104
|
-
this.useFallback = true;
|
|
105
|
-
return [3 /*break*/, 6];
|
|
106
|
-
case 6:
|
|
107
|
-
// Fallback implementation
|
|
108
|
-
return [2 /*return*/, this.fallbackOCR(imageBuffer)];
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
};
|
|
113
|
-
OCRService.prototype.extractFromTile = function (tile) {
|
|
114
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
115
|
-
return __generator(this, function (_a) {
|
|
116
|
-
if (!tile.data) {
|
|
117
|
-
return [2 /*return*/, {
|
|
118
|
-
text: '',
|
|
119
|
-
blocks: [],
|
|
120
|
-
fullText: '',
|
|
121
|
-
}];
|
|
122
|
-
}
|
|
123
|
-
return [2 /*return*/, this.extractText(tile.data)];
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
};
|
|
127
|
-
OCRService.prototype.extractFromImage = function (imageBuffer) {
|
|
128
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
129
|
-
return __generator(this, function (_a) {
|
|
130
|
-
return [2 /*return*/, this.extractText(imageBuffer)];
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
};
|
|
134
|
-
OCRService.prototype.fallbackOCR = function (_imageBuffer) {
|
|
135
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
136
|
-
var blocks, mockTexts, _i, mockTexts_1, mock, fullText;
|
|
137
|
-
return __generator(this, function (_a) {
|
|
138
|
-
// Fallback implementation for when Tesseract is not available
|
|
139
|
-
core_1.logger.debug('[OCR] Using fallback OCR implementation');
|
|
140
|
-
blocks = [];
|
|
141
|
-
mockTexts = [
|
|
142
|
-
{ text: 'File Edit View Window Help', x: 10, y: 5, width: 300, height: 20 },
|
|
143
|
-
{ text: 'Welcome to the application', x: 100, y: 100, width: 400, height: 40 },
|
|
144
|
-
{ text: 'Click here to continue', x: 200, y: 300, width: 200, height: 30 },
|
|
145
|
-
];
|
|
146
|
-
for (_i = 0, mockTexts_1 = mockTexts; _i < mockTexts_1.length; _i++) {
|
|
147
|
-
mock = mockTexts_1[_i];
|
|
148
|
-
blocks.push({
|
|
149
|
-
text: mock.text,
|
|
150
|
-
bbox: { x: mock.x, y: mock.y, width: mock.width, height: mock.height },
|
|
151
|
-
confidence: 0.85 + Math.random() * 0.1,
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
fullText = blocks.map(function (b) { return b.text; }).join('\n');
|
|
155
|
-
return [2 /*return*/, {
|
|
156
|
-
text: fullText,
|
|
157
|
-
blocks: blocks,
|
|
158
|
-
fullText: fullText,
|
|
159
|
-
}];
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
};
|
|
163
|
-
OCRService.prototype.extractStructuredData = function (imageBuffer) {
|
|
164
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
165
|
-
var error_3;
|
|
166
|
-
return __generator(this, function (_a) {
|
|
167
|
-
switch (_a.label) {
|
|
168
|
-
case 0:
|
|
169
|
-
if (!(this.realOCR && !this.useFallback)) return [3 /*break*/, 4];
|
|
170
|
-
_a.label = 1;
|
|
171
|
-
case 1:
|
|
172
|
-
_a.trys.push([1, 3, , 4]);
|
|
173
|
-
return [4 /*yield*/, this.realOCR.extractStructuredData(imageBuffer)];
|
|
174
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
175
|
-
case 3:
|
|
176
|
-
error_3 = _a.sent();
|
|
177
|
-
core_1.logger.error('[OCR] Structured data extraction failed:', error_3);
|
|
178
|
-
return [3 /*break*/, 4];
|
|
179
|
-
case 4:
|
|
180
|
-
// Fallback: return empty structured data
|
|
181
|
-
return [2 /*return*/, {
|
|
182
|
-
tables: [],
|
|
183
|
-
forms: [],
|
|
184
|
-
lists: [],
|
|
185
|
-
}];
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
};
|
|
190
|
-
OCRService.prototype.isInitialized = function () {
|
|
191
|
-
return this.initialized;
|
|
192
|
-
};
|
|
193
|
-
OCRService.prototype.dispose = function () {
|
|
194
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
195
|
-
return __generator(this, function (_a) {
|
|
196
|
-
switch (_a.label) {
|
|
197
|
-
case 0:
|
|
198
|
-
if (!this.realOCR) return [3 /*break*/, 2];
|
|
199
|
-
return [4 /*yield*/, this.realOCR.dispose()];
|
|
200
|
-
case 1:
|
|
201
|
-
_a.sent();
|
|
202
|
-
this.realOCR = null;
|
|
203
|
-
_a.label = 2;
|
|
204
|
-
case 2:
|
|
205
|
-
this.initialized = false;
|
|
206
|
-
this.useFallback = false;
|
|
207
|
-
core_1.logger.info('[OCR] Service disposed');
|
|
208
|
-
return [2 /*return*/];
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
};
|
|
213
|
-
return OCRService;
|
|
214
|
-
}());
|
|
215
|
-
exports.OCRService = OCRService;
|
|
216
|
-
//# sourceMappingURL=ocr-service.js.map
|
package/dist/ocr-service.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ocr-service.js","sourceRoot":"","sources":["../src/ocr-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAAuC;AAEvC,uDAAoD;AAEpD;IAAA;QACU,YAAO,GAA0B,IAAI,CAAC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IAAI,CAAC,wBAAwB,CAAC,CAAC;;;;;KACvC;IACH,iBAAC;AAAD,CAAC,AA1ID,IA0IC;AA1IY,gCAAU","sourcesContent":["import { logger } from '@elizaos/core';\nimport type { OCRResult, ScreenTile, BoundingBox } from './types';\nimport { RealOCRService } from './ocr-service-real';\n\nexport class OCRService {\n private realOCR: RealOCRService | null = null;\n private initialized = false;\n private useFallback = false;\n\n async initialize(): Promise<void> {\n if (this.initialized) {\n return;\n }\n\n try {\n logger.info('[OCR] Initializing OCR service...');\n\n // Try to use real OCR first\n this.realOCR = new RealOCRService();\n await this.realOCR.initialize();\n\n this.initialized = true;\n this.useFallback = false;\n logger.info('[OCR] Real OCR service initialized successfully');\n } catch (error) {\n logger.error('[OCR] Failed to initialize real OCR:', error);\n\n // Fallback to basic OCR simulation\n logger.warn('[OCR] Using fallback OCR implementation');\n this.useFallback = true;\n this.initialized = true;\n }\n }\n\n async extractText(imageBuffer: Buffer): Promise<OCRResult> {\n if (!this.initialized) {\n await this.initialize();\n }\n\n // Use real OCR if available\n if (this.realOCR && !this.useFallback) {\n try {\n return await this.realOCR.extractText(imageBuffer);\n } catch (error) {\n logger.error('[OCR] Real OCR failed, falling back:', error);\n this.useFallback = true;\n }\n }\n\n // Fallback implementation\n return this.fallbackOCR(imageBuffer);\n }\n\n async extractFromTile(tile: ScreenTile): Promise<OCRResult> {\n if (!tile.data) {\n return {\n text: '',\n blocks: [],\n fullText: '',\n };\n }\n\n return this.extractText(tile.data);\n }\n\n async extractFromImage(imageBuffer: Buffer): Promise<OCRResult> {\n return this.extractText(imageBuffer);\n }\n\n private async fallbackOCR(_imageBuffer: Buffer): Promise<OCRResult> {\n // Fallback implementation for when Tesseract is not available\n logger.debug('[OCR] Using fallback OCR implementation');\n\n const blocks: Array<{\n text: string;\n bbox: BoundingBox;\n confidence: number;\n words?: Array<{\n text: string;\n bbox: BoundingBox;\n confidence: number;\n }>;\n }> = [];\n\n // Simulate finding common UI text\n const mockTexts = [\n { text: 'File Edit View Window Help', x: 10, y: 5, width: 300, height: 20 },\n { text: 'Welcome to the application', x: 100, y: 100, width: 400, height: 40 },\n { text: 'Click here to continue', x: 200, y: 300, width: 200, height: 30 },\n ];\n\n for (const mock of mockTexts) {\n blocks.push({\n text: mock.text,\n bbox: { x: mock.x, y: mock.y, width: mock.width, height: mock.height },\n confidence: 0.85 + Math.random() * 0.1,\n });\n }\n\n const fullText = blocks.map((b) => b.text).join('\\n');\n\n return {\n text: fullText,\n blocks,\n fullText,\n };\n }\n\n async extractStructuredData(imageBuffer: Buffer): Promise<{\n tables?: Array<{ rows: string[][]; bbox: BoundingBox }>;\n forms?: Array<{ label: string; value: string; bbox: BoundingBox }>;\n lists?: Array<{ items: string[]; bbox: BoundingBox }>;\n }> {\n if (this.realOCR && !this.useFallback) {\n try {\n return await this.realOCR.extractStructuredData(imageBuffer);\n } catch (error) {\n logger.error('[OCR] Structured data extraction failed:', error);\n }\n }\n\n // Fallback: return empty structured data\n return {\n tables: [],\n forms: [],\n lists: [],\n };\n }\n\n isInitialized(): boolean {\n return this.initialized;\n }\n\n async dispose(): Promise<void> {\n if (this.realOCR) {\n await this.realOCR.dispose();\n this.realOCR = null;\n }\n this.initialized = false;\n this.useFallback = false;\n logger.info('[OCR] Service disposed');\n }\n}\n"]}
|
package/dist/provider.d.ts
DELETED
package/dist/provider.js
DELETED
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40
|
-
if (ar || !(i in from)) {
|
|
41
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
-
ar[i] = from[i];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
|
-
};
|
|
47
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.visionProvider = void 0;
|
|
49
|
-
// Vision provider - provides current visual perception data to the agent
|
|
50
|
-
var core_1 = require("@elizaos/core");
|
|
51
|
-
exports.visionProvider = {
|
|
52
|
-
name: 'VISION_PERCEPTION',
|
|
53
|
-
description: 'Provides current visual perception data including scene description, detected objects, people, and entity tracking. This provider is always active and provides real-time visual awareness.',
|
|
54
|
-
position: 99, // High priority for vision context
|
|
55
|
-
dynamic: false, // Always included - vision is a constant sense
|
|
56
|
-
get: function (runtime, message, _state) { return __awaiter(void 0, void 0, void 0, function () {
|
|
57
|
-
var visionService, sceneDescription, _a, cameraInfo, isActive, visionMode, screenCapture, _worldId, entityTracker, entityData, activeEntities, recentlyLeft, stats, perceptionText, values, data, ageInSeconds, secondsAgo, poses, facings, poseCounts, facingCounts, objectTypes, uniqueObjects, _i, _b, entity, name_1, duration, _c, _d, departed, name_2, timeStr, screenAge, screenSecondsAgo, enhanced, tileAnalysis, uiElements, uniqueElements;
|
|
58
|
-
var _e;
|
|
59
|
-
return __generator(this, function (_f) {
|
|
60
|
-
switch (_f.label) {
|
|
61
|
-
case 0:
|
|
62
|
-
visionService = runtime.getService('VISION');
|
|
63
|
-
if (!visionService) {
|
|
64
|
-
core_1.logger.warn('[visionProvider] VisionService not found.');
|
|
65
|
-
return [2 /*return*/, {
|
|
66
|
-
values: {
|
|
67
|
-
visionAvailable: false,
|
|
68
|
-
sceneDescription: 'Vision service is not available.',
|
|
69
|
-
cameraStatus: 'No camera connected',
|
|
70
|
-
},
|
|
71
|
-
text: (0, core_1.addHeader)('# Visual Perception', 'Vision service is not available.'),
|
|
72
|
-
data: { hasVision: false },
|
|
73
|
-
}];
|
|
74
|
-
}
|
|
75
|
-
return [4 /*yield*/, visionService.getEnhancedSceneDescription()];
|
|
76
|
-
case 1:
|
|
77
|
-
_a = (_f.sent());
|
|
78
|
-
if (_a) return [3 /*break*/, 3];
|
|
79
|
-
return [4 /*yield*/, visionService.getSceneDescription()];
|
|
80
|
-
case 2:
|
|
81
|
-
_a = (_f.sent());
|
|
82
|
-
_f.label = 3;
|
|
83
|
-
case 3:
|
|
84
|
-
sceneDescription = _a;
|
|
85
|
-
cameraInfo = visionService.getCameraInfo();
|
|
86
|
-
isActive = visionService.isActive();
|
|
87
|
-
visionMode = visionService.getVisionMode();
|
|
88
|
-
return [4 /*yield*/, visionService.getScreenCapture()];
|
|
89
|
-
case 4:
|
|
90
|
-
screenCapture = _f.sent();
|
|
91
|
-
_worldId = message.worldId || 'default-world';
|
|
92
|
-
entityTracker = visionService.getEntityTracker();
|
|
93
|
-
entityData = null;
|
|
94
|
-
if (!(sceneDescription && entityTracker)) return [3 /*break*/, 6];
|
|
95
|
-
// Update entities with current detections
|
|
96
|
-
return [4 /*yield*/, entityTracker.updateEntities(sceneDescription.objects, sceneDescription.people, undefined, runtime)];
|
|
97
|
-
case 5:
|
|
98
|
-
// Update entities with current detections
|
|
99
|
-
_f.sent();
|
|
100
|
-
activeEntities = entityTracker.getActiveEntities();
|
|
101
|
-
recentlyLeft = entityTracker.getRecentlyLeft();
|
|
102
|
-
stats = entityTracker.getStatistics();
|
|
103
|
-
entityData = {
|
|
104
|
-
activeEntities: activeEntities.map(function (e) { return ({
|
|
105
|
-
id: e.id,
|
|
106
|
-
type: e.entityType,
|
|
107
|
-
name: e.attributes.name,
|
|
108
|
-
firstSeen: e.firstSeen,
|
|
109
|
-
duration: Date.now() - e.firstSeen,
|
|
110
|
-
position: e.lastPosition,
|
|
111
|
-
attributes: e.attributes,
|
|
112
|
-
}); }),
|
|
113
|
-
recentlyLeft: recentlyLeft.map(function (_a) {
|
|
114
|
-
var entity = _a.entity, leftAt = _a.leftAt;
|
|
115
|
-
return ({
|
|
116
|
-
id: entity.id,
|
|
117
|
-
name: entity.attributes.name,
|
|
118
|
-
leftAt: leftAt,
|
|
119
|
-
timeAgo: Date.now() - leftAt,
|
|
120
|
-
});
|
|
121
|
-
}),
|
|
122
|
-
statistics: stats,
|
|
123
|
-
};
|
|
124
|
-
_f.label = 6;
|
|
125
|
-
case 6:
|
|
126
|
-
perceptionText = '';
|
|
127
|
-
values = {};
|
|
128
|
-
data = {};
|
|
129
|
-
if (!isActive) {
|
|
130
|
-
perceptionText = "Vision mode: ".concat(visionMode, "\n");
|
|
131
|
-
if (visionMode === 'OFF') {
|
|
132
|
-
perceptionText += 'Vision is disabled.';
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
perceptionText += 'Vision service is initializing...';
|
|
136
|
-
}
|
|
137
|
-
values = {
|
|
138
|
-
visionAvailable: false,
|
|
139
|
-
visionMode: visionMode,
|
|
140
|
-
sceneDescription: 'Vision not active',
|
|
141
|
-
cameraStatus: cameraInfo
|
|
142
|
-
? "Camera \"".concat(cameraInfo.name, "\" detected but not active")
|
|
143
|
-
: 'No camera',
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
perceptionText = "Vision mode: ".concat(visionMode, "\n\n");
|
|
148
|
-
// Camera vision data
|
|
149
|
-
if ((visionMode === 'CAMERA' || visionMode === 'BOTH') && sceneDescription) {
|
|
150
|
-
ageInSeconds = (Date.now() - sceneDescription.timestamp) / 1000;
|
|
151
|
-
secondsAgo = Math.round(ageInSeconds);
|
|
152
|
-
perceptionText += "Camera view (".concat(secondsAgo, "s ago):\n").concat(sceneDescription.description);
|
|
153
|
-
if (sceneDescription.people.length > 0) {
|
|
154
|
-
perceptionText += "\n\nPeople detected: ".concat(sceneDescription.people.length);
|
|
155
|
-
poses = sceneDescription.people.map(function (p) { return p.pose; }).filter(function (p) { return p !== 'unknown'; });
|
|
156
|
-
facings = sceneDescription.people
|
|
157
|
-
.map(function (p) { return p.facing; })
|
|
158
|
-
.filter(function (f) { return f !== 'unknown'; });
|
|
159
|
-
if (poses.length > 0) {
|
|
160
|
-
poseCounts = poses.reduce(function (acc, pose) {
|
|
161
|
-
acc[pose] = (acc[pose] || 0) + 1;
|
|
162
|
-
return acc;
|
|
163
|
-
}, {});
|
|
164
|
-
perceptionText += "\n Poses: ".concat(Object.entries(poseCounts)
|
|
165
|
-
.map(function (_a) {
|
|
166
|
-
var pose = _a[0], count = _a[1];
|
|
167
|
-
return "".concat(count, " ").concat(pose);
|
|
168
|
-
})
|
|
169
|
-
.join(', '));
|
|
170
|
-
}
|
|
171
|
-
if (facings.length > 0) {
|
|
172
|
-
facingCounts = facings.reduce(function (acc, facing) {
|
|
173
|
-
acc[facing] = (acc[facing] || 0) + 1;
|
|
174
|
-
return acc;
|
|
175
|
-
}, {});
|
|
176
|
-
perceptionText += "\n Facing: ".concat(Object.entries(facingCounts)
|
|
177
|
-
.map(function (_a) {
|
|
178
|
-
var facing = _a[0], count = _a[1];
|
|
179
|
-
return "".concat(count, " facing ").concat(facing);
|
|
180
|
-
})
|
|
181
|
-
.join(', '));
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
if (sceneDescription.objects.length > 0) {
|
|
185
|
-
objectTypes = sceneDescription.objects.map(function (o) { return o.type; });
|
|
186
|
-
uniqueObjects = __spreadArray([], new Set(objectTypes), true);
|
|
187
|
-
perceptionText += "\n\nObjects detected: ".concat(uniqueObjects.join(', '));
|
|
188
|
-
}
|
|
189
|
-
if (sceneDescription.sceneChanged) {
|
|
190
|
-
perceptionText += "\n\nScene change: ".concat(sceneDescription.changePercentage.toFixed(1), "% of pixels changed");
|
|
191
|
-
}
|
|
192
|
-
// Add entity tracking information
|
|
193
|
-
if (entityData) {
|
|
194
|
-
if (entityData.activeEntities.length > 0) {
|
|
195
|
-
perceptionText += '\n\nCurrently tracking:';
|
|
196
|
-
for (_i = 0, _b = entityData.activeEntities; _i < _b.length; _i++) {
|
|
197
|
-
entity = _b[_i];
|
|
198
|
-
name_1 = entity.name || "Unknown ".concat(entity.type);
|
|
199
|
-
duration = entity.duration < 60000
|
|
200
|
-
? "".concat(Math.round(entity.duration / 1000), "s")
|
|
201
|
-
: "".concat(Math.round(entity.duration / 60000), "m");
|
|
202
|
-
perceptionText += "\n- ".concat(name_1, " (present for ").concat(duration, ")");
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
if (entityData.recentlyLeft.length > 0) {
|
|
206
|
-
perceptionText += '\n\nRecently left:';
|
|
207
|
-
for (_c = 0, _d = entityData.recentlyLeft; _c < _d.length; _c++) {
|
|
208
|
-
departed = _d[_c];
|
|
209
|
-
name_2 = departed.name || 'Unknown person';
|
|
210
|
-
timeStr = departed.timeAgo < 60000
|
|
211
|
-
? "".concat(Math.round(departed.timeAgo / 1000), "s ago")
|
|
212
|
-
: "".concat(Math.round(departed.timeAgo / 60000), "m ago");
|
|
213
|
-
perceptionText += "\n- ".concat(name_2, " left ").concat(timeStr);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
// Screen vision data
|
|
219
|
-
if ((visionMode === 'SCREEN' || visionMode === 'BOTH') && screenCapture) {
|
|
220
|
-
screenAge = (Date.now() - screenCapture.timestamp) / 1000;
|
|
221
|
-
screenSecondsAgo = Math.round(screenAge);
|
|
222
|
-
if (visionMode === 'BOTH') {
|
|
223
|
-
perceptionText += '\n\n---\n\n';
|
|
224
|
-
}
|
|
225
|
-
perceptionText += "Screen capture (".concat(screenSecondsAgo, "s ago):\n");
|
|
226
|
-
perceptionText += "Resolution: ".concat(screenCapture.width, "x").concat(screenCapture.height, "\n");
|
|
227
|
-
enhanced = sceneDescription;
|
|
228
|
-
if (enhanced === null || enhanced === void 0 ? void 0 : enhanced.screenAnalysis) {
|
|
229
|
-
if ((_e = enhanced.screenAnalysis.activeTile) === null || _e === void 0 ? void 0 : _e.analysis) {
|
|
230
|
-
tileAnalysis = enhanced.screenAnalysis.activeTile.analysis;
|
|
231
|
-
if (tileAnalysis.summary) {
|
|
232
|
-
perceptionText += "\nActive area: ".concat(tileAnalysis.summary);
|
|
233
|
-
}
|
|
234
|
-
if (tileAnalysis.text) {
|
|
235
|
-
perceptionText += "\n\nVisible text:\n\"".concat(tileAnalysis.text.substring(0, 200)).concat(tileAnalysis.text.length > 200 ? '...' : '', "\"");
|
|
236
|
-
}
|
|
237
|
-
if (tileAnalysis.objects && tileAnalysis.objects.length > 0) {
|
|
238
|
-
uiElements = tileAnalysis.objects.map(function (o) { return o.type; });
|
|
239
|
-
uniqueElements = __spreadArray([], new Set(uiElements), true);
|
|
240
|
-
perceptionText += "\n\nUI elements: ".concat(uniqueElements.join(', '));
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
if (enhanced.screenAnalysis.focusedApp) {
|
|
244
|
-
perceptionText += "\n\nActive application: ".concat(enhanced.screenAnalysis.focusedApp);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
values = {
|
|
249
|
-
visionAvailable: true,
|
|
250
|
-
visionMode: visionMode,
|
|
251
|
-
sceneDescription: (sceneDescription === null || sceneDescription === void 0 ? void 0 : sceneDescription.description) || 'Processing...',
|
|
252
|
-
cameraStatus: cameraInfo ? "Connected to ".concat(cameraInfo.name) : 'No camera',
|
|
253
|
-
cameraId: cameraInfo === null || cameraInfo === void 0 ? void 0 : cameraInfo.id,
|
|
254
|
-
peopleCount: (sceneDescription === null || sceneDescription === void 0 ? void 0 : sceneDescription.people.length) || 0,
|
|
255
|
-
objectCount: (sceneDescription === null || sceneDescription === void 0 ? void 0 : sceneDescription.objects.length) || 0,
|
|
256
|
-
sceneAge: sceneDescription
|
|
257
|
-
? Math.round((Date.now() - sceneDescription.timestamp) / 1000)
|
|
258
|
-
: null,
|
|
259
|
-
lastChange: (sceneDescription === null || sceneDescription === void 0 ? void 0 : sceneDescription.sceneChanged) ? sceneDescription.changePercentage : 0,
|
|
260
|
-
hasScreenCapture: !!screenCapture,
|
|
261
|
-
screenResolution: screenCapture ? "".concat(screenCapture.width, "x").concat(screenCapture.height) : null,
|
|
262
|
-
// Entity tracking values
|
|
263
|
-
activeEntities: (entityData === null || entityData === void 0 ? void 0 : entityData.activeEntities) || [],
|
|
264
|
-
recentlyLeft: (entityData === null || entityData === void 0 ? void 0 : entityData.recentlyLeft) || [],
|
|
265
|
-
entityStatistics: (entityData === null || entityData === void 0 ? void 0 : entityData.statistics) || null,
|
|
266
|
-
};
|
|
267
|
-
data = {
|
|
268
|
-
objects: (sceneDescription === null || sceneDescription === void 0 ? void 0 : sceneDescription.objects) || [],
|
|
269
|
-
people: (sceneDescription === null || sceneDescription === void 0 ? void 0 : sceneDescription.people) || [],
|
|
270
|
-
screenCapture: screenCapture || null,
|
|
271
|
-
enhancedData: (sceneDescription === null || sceneDescription === void 0 ? void 0 : sceneDescription.screenAnalysis) || null,
|
|
272
|
-
trackedEntities: (entityData === null || entityData === void 0 ? void 0 : entityData.activeEntities) || [],
|
|
273
|
-
worldState: entityData || null,
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
return [2 /*return*/, {
|
|
277
|
-
values: values,
|
|
278
|
-
text: (0, core_1.addHeader)('# Visual Perception', perceptionText),
|
|
279
|
-
data: data,
|
|
280
|
-
}];
|
|
281
|
-
}
|
|
282
|
-
});
|
|
283
|
-
}); },
|
|
284
|
-
};
|
|
285
|
-
//# sourceMappingURL=provider.js.map
|
package/dist/provider.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"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BAAhB,gBAAgB,CAAE,OAAO,KAAI,EAAE;4BACxC,MAAM,EAAE,CAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,MAAM,KAAI,EAAE;4BACtC,aAAa,EAAE,aAAa,IAAI,IAAI;4BACpC,YAAY,EAAE,CAAC,gBAAwB,aAAxB,gBAAgB,uBAAhB,gBAAgB,CAAU,cAAc,KAAI,IAAI;4BAC/D,eAAe,EAAE,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,cAAc,KAAI,EAAE;4BACjD,UAAU,EAAE,UAAU,IAAI,IAAI;yBAC/B,CAAC;oBACJ,CAAC;oBAED,sBAAO;4BACL,MAAM,QAAA;4BACN,IAAI,EAAE,IAAA,gBAAS,EAAC,qBAAqB,EAAE,cAAc,CAAC;4BACtD,IAAI,MAAA;yBACL,EAAC;;;SACH;CACF,CAAC","sourcesContent":["// Vision provider - provides current visual perception data to the agent\nimport {\n type IAgentRuntime,\n type Memory,\n type Provider,\n type State,\n addHeader,\n logger,\n} from '@elizaos/core';\nimport { type VisionService } from './service';\nimport { type BoundingBox, type EntityAttributes } from './types';\n\nexport const visionProvider: Provider = {\n name: 'VISION_PERCEPTION',\n description:\n 'Provides current visual perception data including scene description, detected objects, people, and entity tracking. This provider is always active and provides real-time visual awareness.',\n position: 99, // High priority for vision context\n dynamic: false, // Always included - vision is a constant sense\n\n get: async (runtime: IAgentRuntime, message: Memory, _state: State) => {\n const visionService = runtime.getService<VisionService>('VISION');\n\n if (!visionService) {\n logger.warn('[visionProvider] VisionService not found.');\n return {\n values: {\n visionAvailable: false,\n sceneDescription: 'Vision service is not available.',\n cameraStatus: 'No camera connected',\n },\n text: addHeader('# Visual Perception', 'Vision service is not available.'),\n data: { hasVision: false },\n };\n }\n\n // Get current scene description (enhanced if screen is enabled)\n const sceneDescription =\n (await visionService.getEnhancedSceneDescription()) ||\n (await visionService.getSceneDescription());\n const cameraInfo = visionService.getCameraInfo();\n const isActive = visionService.isActive();\n const visionMode = visionService.getVisionMode();\n const screenCapture = await visionService.getScreenCapture();\n\n // Get entity tracking data\n const _worldId = message.worldId || 'default-world';\n const entityTracker = visionService.getEntityTracker();\n\n let entityData: {\n activeEntities: Array<{\n id: string;\n type: 'person' | 'object' | 'pet';\n name: string | undefined;\n firstSeen: number;\n duration: number;\n position: BoundingBox;\n attributes: EntityAttributes;\n }>;\n recentlyLeft: Array<{\n id: string;\n name: string | undefined;\n leftAt: number;\n timeAgo: number;\n }>;\n statistics: {\n totalEntities: number;\n activeEntities: number;\n recentlyLeft: number;\n people: number;\n objects: number;\n };\n } | null = null;\n\n if (sceneDescription && entityTracker) {\n // Update entities with current detections\n await entityTracker.updateEntities(\n sceneDescription.objects,\n sceneDescription.people,\n undefined,\n runtime\n );\n\n const activeEntities = entityTracker.getActiveEntities();\n const recentlyLeft = entityTracker.getRecentlyLeft();\n const stats = entityTracker.getStatistics();\n\n entityData = {\n activeEntities: activeEntities.map((e) => ({\n id: e.id,\n type: e.entityType,\n name: e.attributes.name,\n firstSeen: e.firstSeen,\n duration: Date.now() - e.firstSeen,\n position: e.lastPosition,\n attributes: e.attributes,\n })),\n recentlyLeft: recentlyLeft.map(({ entity, leftAt }) => ({\n id: entity.id,\n name: entity.attributes.name,\n leftAt,\n timeAgo: Date.now() - leftAt,\n })),\n statistics: stats,\n };\n }\n\n let perceptionText = '';\n let values = {};\n let data = {};\n\n if (!isActive) {\n perceptionText = `Vision mode: ${visionMode}\\n`;\n if (visionMode === 'OFF') {\n perceptionText += 'Vision is disabled.';\n } else {\n perceptionText += 'Vision service is initializing...';\n }\n\n values = {\n visionAvailable: false,\n visionMode,\n sceneDescription: 'Vision not active',\n cameraStatus: cameraInfo\n ? `Camera \"${cameraInfo.name}\" detected but not active`\n : 'No camera',\n };\n } else {\n perceptionText = `Vision mode: ${visionMode}\\n\\n`;\n\n // Camera vision data\n if ((visionMode === 'CAMERA' || visionMode === 'BOTH') && sceneDescription) {\n const ageInSeconds = (Date.now() - sceneDescription.timestamp) / 1000;\n const secondsAgo = Math.round(ageInSeconds);\n\n perceptionText += `Camera view (${secondsAgo}s ago):\\n${sceneDescription.description}`;\n\n if (sceneDescription.people.length > 0) {\n perceptionText += `\\n\\nPeople detected: ${sceneDescription.people.length}`;\n const poses = sceneDescription.people.map((p) => p.pose).filter((p) => p !== 'unknown');\n const facings = sceneDescription.people\n .map((p) => p.facing)\n .filter((f) => f !== 'unknown');\n\n if (poses.length > 0) {\n const poseCounts = poses.reduce(\n (acc, pose) => {\n acc[pose] = (acc[pose] || 0) + 1;\n return acc;\n },\n {} as Record<string, number>\n );\n perceptionText += `\\n Poses: ${Object.entries(poseCounts)\n .map(([pose, count]) => `${count} ${pose}`)\n .join(', ')}`;\n }\n\n if (facings.length > 0) {\n const facingCounts = facings.reduce(\n (acc, facing) => {\n acc[facing] = (acc[facing] || 0) + 1;\n return acc;\n },\n {} as Record<string, number>\n );\n perceptionText += `\\n Facing: ${Object.entries(facingCounts)\n .map(([facing, count]) => `${count} facing ${facing}`)\n .join(', ')}`;\n }\n }\n\n if (sceneDescription.objects.length > 0) {\n const objectTypes = sceneDescription.objects.map((o) => o.type);\n const uniqueObjects = [...new Set(objectTypes)];\n perceptionText += `\\n\\nObjects detected: ${uniqueObjects.join(', ')}`;\n }\n\n if (sceneDescription.sceneChanged) {\n perceptionText += `\\n\\nScene change: ${sceneDescription.changePercentage.toFixed(1)}% of pixels changed`;\n }\n\n // Add entity tracking information\n if (entityData) {\n if (entityData.activeEntities.length > 0) {\n perceptionText += '\\n\\nCurrently tracking:';\n for (const entity of entityData.activeEntities) {\n const name = entity.name || `Unknown ${entity.type}`;\n const duration =\n entity.duration < 60000\n ? `${Math.round(entity.duration / 1000)}s`\n : `${Math.round(entity.duration / 60000)}m`;\n perceptionText += `\\n- ${name} (present for ${duration})`;\n }\n }\n\n if (entityData.recentlyLeft.length > 0) {\n perceptionText += '\\n\\nRecently left:';\n for (const departed of entityData.recentlyLeft) {\n const name = departed.name || 'Unknown person';\n const timeStr =\n departed.timeAgo < 60000\n ? `${Math.round(departed.timeAgo / 1000)}s ago`\n : `${Math.round(departed.timeAgo / 60000)}m ago`;\n perceptionText += `\\n- ${name} left ${timeStr}`;\n }\n }\n }\n }\n\n // Screen vision data\n if ((visionMode === 'SCREEN' || visionMode === 'BOTH') && screenCapture) {\n const screenAge = (Date.now() - screenCapture.timestamp) / 1000;\n const screenSecondsAgo = Math.round(screenAge);\n\n if (visionMode === 'BOTH') {\n perceptionText += '\\n\\n---\\n\\n';\n }\n\n perceptionText += `Screen capture (${screenSecondsAgo}s ago):\\n`;\n perceptionText += `Resolution: ${screenCapture.width}x${screenCapture.height}\\n`;\n\n // Enhanced scene data if available\n const enhanced = sceneDescription as any;\n if (enhanced?.screenAnalysis) {\n if (enhanced.screenAnalysis.activeTile?.analysis) {\n const tileAnalysis = enhanced.screenAnalysis.activeTile.analysis;\n\n if (tileAnalysis.summary) {\n perceptionText += `\\nActive area: ${tileAnalysis.summary}`;\n }\n\n if (tileAnalysis.text) {\n perceptionText += `\\n\\nVisible text:\\n\"${tileAnalysis.text.substring(0, 200)}${tileAnalysis.text.length > 200 ? '...' : ''}\"`;\n }\n\n if (tileAnalysis.objects && tileAnalysis.objects.length > 0) {\n const uiElements = tileAnalysis.objects.map((o: any) => o.type);\n const uniqueElements = [...new Set(uiElements)];\n perceptionText += `\\n\\nUI elements: ${uniqueElements.join(', ')}`;\n }\n }\n\n if (enhanced.screenAnalysis.focusedApp) {\n perceptionText += `\\n\\nActive application: ${enhanced.screenAnalysis.focusedApp}`;\n }\n }\n }\n\n values = {\n visionAvailable: true,\n visionMode,\n sceneDescription: sceneDescription?.description || 'Processing...',\n cameraStatus: cameraInfo ? `Connected to ${cameraInfo.name}` : 'No camera',\n cameraId: cameraInfo?.id,\n peopleCount: sceneDescription?.people.length || 0,\n objectCount: sceneDescription?.objects.length || 0,\n sceneAge: sceneDescription\n ? Math.round((Date.now() - sceneDescription.timestamp) / 1000)\n : null,\n lastChange: sceneDescription?.sceneChanged ? sceneDescription.changePercentage : 0,\n hasScreenCapture: !!screenCapture,\n screenResolution: screenCapture ? `${screenCapture.width}x${screenCapture.height}` : null,\n // Entity tracking values\n activeEntities: entityData?.activeEntities || [],\n recentlyLeft: entityData?.recentlyLeft || [],\n entityStatistics: entityData?.statistics || null,\n };\n\n data = {\n objects: sceneDescription?.objects || [],\n people: sceneDescription?.people || [],\n screenCapture: screenCapture || null,\n enhancedData: (sceneDescription as any)?.screenAnalysis || null,\n trackedEntities: entityData?.activeEntities || [],\n worldState: entityData || null,\n };\n }\n\n return {\n values,\n text: addHeader('# Visual Perception', perceptionText),\n data,\n };\n },\n};\n"]}
|
package/dist/screen-capture.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { ScreenCapture, ScreenTile, VisionConfig } from './types';
|
|
2
|
-
export declare class ScreenCaptureService {
|
|
3
|
-
private config;
|
|
4
|
-
private activeTileIndex;
|
|
5
|
-
private lastCapture;
|
|
6
|
-
constructor(config: VisionConfig);
|
|
7
|
-
getScreenInfo(): Promise<{
|
|
8
|
-
width: number;
|
|
9
|
-
height: number;
|
|
10
|
-
} | null>;
|
|
11
|
-
captureScreen(): Promise<ScreenCapture>;
|
|
12
|
-
private captureScreenToFile;
|
|
13
|
-
getActiveTile(): ScreenTile | null;
|
|
14
|
-
getAllTiles(): ScreenTile[];
|
|
15
|
-
getProcessedTiles(): ScreenTile[];
|
|
16
|
-
}
|