@blueharford/scrypted-spatial-awareness 0.5.6 → 0.5.8
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/dist/main.nodejs.js +1 -1
- package/dist/main.nodejs.js.map +1 -1
- package/dist/plugin.zip +0 -0
- package/out/main.nodejs.js +49 -51
- package/out/main.nodejs.js.map +1 -1
- package/out/plugin.zip +0 -0
- package/package.json +1 -1
- package/src/core/spatial-reasoning.ts +43 -18
package/dist/plugin.zip
CHANGED
|
Binary file
|
package/out/main.nodejs.js
CHANGED
|
@@ -35058,45 +35058,15 @@ exports.ObjectCorrelator = ObjectCorrelator;
|
|
|
35058
35058
|
* Uses RAG (Retrieval Augmented Generation) to provide rich contextual understanding
|
|
35059
35059
|
* of movement across the property topology
|
|
35060
35060
|
*/
|
|
35061
|
-
var
|
|
35062
|
-
|
|
35063
|
-
|
|
35064
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
35065
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
35066
|
-
}
|
|
35067
|
-
Object.defineProperty(o, k2, desc);
|
|
35068
|
-
}) : (function(o, m, k, k2) {
|
|
35069
|
-
if (k2 === undefined) k2 = k;
|
|
35070
|
-
o[k2] = m[k];
|
|
35071
|
-
}));
|
|
35072
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
35073
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
35074
|
-
}) : function(o, v) {
|
|
35075
|
-
o["default"] = v;
|
|
35076
|
-
});
|
|
35077
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
35078
|
-
var ownKeys = function(o) {
|
|
35079
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
35080
|
-
var ar = [];
|
|
35081
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
35082
|
-
return ar;
|
|
35083
|
-
};
|
|
35084
|
-
return ownKeys(o);
|
|
35085
|
-
};
|
|
35086
|
-
return function (mod) {
|
|
35087
|
-
if (mod && mod.__esModule) return mod;
|
|
35088
|
-
var result = {};
|
|
35089
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35090
|
-
__setModuleDefault(result, mod);
|
|
35091
|
-
return result;
|
|
35092
|
-
};
|
|
35093
|
-
})();
|
|
35061
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35062
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
35063
|
+
};
|
|
35094
35064
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
35095
35065
|
exports.SpatialReasoningEngine = void 0;
|
|
35096
35066
|
exports.mediaObjectToBase64 = mediaObjectToBase64;
|
|
35097
35067
|
exports.buildImageContent = buildImageContent;
|
|
35098
35068
|
exports.isVisionFormatError = isVisionFormatError;
|
|
35099
|
-
const sdk_1 =
|
|
35069
|
+
const sdk_1 = __importDefault(__webpack_require__(/*! @scrypted/sdk */ "./node_modules/@scrypted/sdk/dist/src/index.js"));
|
|
35100
35070
|
const topology_1 = __webpack_require__(/*! ../models/topology */ "./src/models/topology.ts");
|
|
35101
35071
|
const { systemManager, mediaManager } = sdk_1.default;
|
|
35102
35072
|
/**
|
|
@@ -35106,31 +35076,59 @@ const { systemManager, mediaManager } = sdk_1.default;
|
|
|
35106
35076
|
*/
|
|
35107
35077
|
async function mediaObjectToBase64(mediaObject) {
|
|
35108
35078
|
try {
|
|
35109
|
-
|
|
35110
|
-
|
|
35111
|
-
|
|
35112
|
-
|
|
35113
|
-
|
|
35114
|
-
|
|
35079
|
+
const mimeType = mediaObject?.mimeType || 'image/jpeg';
|
|
35080
|
+
console.log(`[Image] Converting MediaObject, mimeType=${mimeType}`);
|
|
35081
|
+
// Use createMediaObject to ensure we have a proper MediaObject with mimeType
|
|
35082
|
+
// Then convert to buffer - this should handle the conversion internally
|
|
35083
|
+
let buffer;
|
|
35084
|
+
try {
|
|
35085
|
+
// Try direct conversion with the source mime type
|
|
35086
|
+
buffer = await mediaManager.convertMediaObjectToBuffer(mediaObject, mimeType);
|
|
35087
|
+
}
|
|
35088
|
+
catch (convErr) {
|
|
35089
|
+
console.warn(`[Image] Direct conversion failed, trying with explicit JPEG:`, convErr);
|
|
35090
|
+
// Try creating a new MediaObject with explicit mimeType
|
|
35091
|
+
try {
|
|
35092
|
+
// Get raw data if available
|
|
35093
|
+
const anyMedia = mediaObject;
|
|
35094
|
+
if (typeof anyMedia.getData === 'function') {
|
|
35095
|
+
const rawData = await anyMedia.getData();
|
|
35096
|
+
if (rawData && Buffer.isBuffer(rawData) && rawData.length > 1000) {
|
|
35097
|
+
console.log(`[Image] Got raw data: ${rawData.length} bytes`);
|
|
35098
|
+
buffer = rawData;
|
|
35099
|
+
}
|
|
35100
|
+
else {
|
|
35101
|
+
console.warn(`[Image] getData returned invalid data`);
|
|
35102
|
+
return null;
|
|
35103
|
+
}
|
|
35104
|
+
}
|
|
35105
|
+
else {
|
|
35106
|
+
console.warn('[Image] No getData method available');
|
|
35107
|
+
return null;
|
|
35108
|
+
}
|
|
35109
|
+
}
|
|
35110
|
+
catch (dataErr) {
|
|
35111
|
+
console.warn('[Image] Alternate data fetch failed:', dataErr);
|
|
35112
|
+
return null;
|
|
35113
|
+
}
|
|
35115
35114
|
}
|
|
35116
|
-
|
|
35117
|
-
|
|
35118
|
-
|
|
35115
|
+
// Check if we got an actual Buffer (not a proxy)
|
|
35116
|
+
const isRealBuffer = Buffer.isBuffer(buffer);
|
|
35117
|
+
const bufferLength = isRealBuffer ? buffer.length : 0;
|
|
35118
|
+
console.log(`[Image] Buffer: isBuffer=${isRealBuffer}, length=${bufferLength}`);
|
|
35119
|
+
if (!isRealBuffer || bufferLength === 0) {
|
|
35120
|
+
console.warn('[Image] Did not receive a valid Buffer');
|
|
35119
35121
|
return null;
|
|
35120
35122
|
}
|
|
35121
35123
|
// Check if buffer is too small to be a valid image (< 1KB is suspicious)
|
|
35122
|
-
if (
|
|
35123
|
-
|
|
35124
|
-
const bufferContent = buffer.toString('utf8').substring(0, 100);
|
|
35125
|
-
console.warn(`[Image] Buffer too small (${buffer.length} bytes), content: ${bufferContent}`);
|
|
35124
|
+
if (bufferLength < 1000) {
|
|
35125
|
+
console.warn(`[Image] Buffer too small: ${bufferLength} bytes`);
|
|
35126
35126
|
return null;
|
|
35127
35127
|
}
|
|
35128
35128
|
// Convert buffer to base64 (raw, no data URL prefix)
|
|
35129
35129
|
const base64 = buffer.toString('base64');
|
|
35130
|
-
|
|
35131
|
-
|
|
35132
|
-
console.log(`[Image] Converted to base64: ${base64.length} chars, type=${mediaType}`);
|
|
35133
|
-
return { base64, mediaType };
|
|
35130
|
+
console.log(`[Image] Converted to base64: ${base64.length} chars`);
|
|
35131
|
+
return { base64, mediaType: 'image/jpeg' };
|
|
35134
35132
|
}
|
|
35135
35133
|
catch (e) {
|
|
35136
35134
|
console.warn('[Image] Failed to convert MediaObject to base64:', e);
|