@blueharford/scrypted-spatial-awareness 0.5.6 → 0.5.7
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 +36 -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 +36 -20
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
|
/**
|
|
@@ -35107,30 +35077,45 @@ const { systemManager, mediaManager } = sdk_1.default;
|
|
|
35107
35077
|
async function mediaObjectToBase64(mediaObject) {
|
|
35108
35078
|
try {
|
|
35109
35079
|
console.log(`[Image] Converting MediaObject, mimeType=${mediaObject?.mimeType}`);
|
|
35110
|
-
//
|
|
35111
|
-
const
|
|
35112
|
-
|
|
35113
|
-
|
|
35114
|
-
|
|
35115
|
-
|
|
35116
|
-
|
|
35117
|
-
|
|
35118
|
-
|
|
35080
|
+
// First convert to JPEG to ensure consistent format
|
|
35081
|
+
const jpegMediaObject = await mediaManager.convertMediaObject(mediaObject, 'image/jpeg');
|
|
35082
|
+
console.log(`[Image] Converted to JPEG MediaObject`);
|
|
35083
|
+
// Get the buffer from the converted media object
|
|
35084
|
+
const buffer = await mediaManager.convertMediaObjectToBuffer(jpegMediaObject, 'image/jpeg');
|
|
35085
|
+
// Check if we got an actual Buffer (not a proxy)
|
|
35086
|
+
const isRealBuffer = Buffer.isBuffer(buffer);
|
|
35087
|
+
const bufferLength = isRealBuffer ? buffer.length : 0;
|
|
35088
|
+
console.log(`[Image] Buffer: isBuffer=${isRealBuffer}, length=${bufferLength}`);
|
|
35089
|
+
if (!isRealBuffer || bufferLength === 0) {
|
|
35090
|
+
console.warn('[Image] Did not receive a valid Buffer');
|
|
35091
|
+
// Try alternate approach: get raw data using any type
|
|
35092
|
+
try {
|
|
35093
|
+
const anyMedia = mediaObject;
|
|
35094
|
+
if (typeof anyMedia.getData === 'function') {
|
|
35095
|
+
const data = await anyMedia.getData();
|
|
35096
|
+
if (data && Buffer.isBuffer(data)) {
|
|
35097
|
+
console.log(`[Image] Got data from getData(): ${data.length} bytes`);
|
|
35098
|
+
if (data.length > 1000) {
|
|
35099
|
+
const base64 = data.toString('base64');
|
|
35100
|
+
return { base64, mediaType: 'image/jpeg' };
|
|
35101
|
+
}
|
|
35102
|
+
}
|
|
35103
|
+
}
|
|
35104
|
+
}
|
|
35105
|
+
catch (dataErr) {
|
|
35106
|
+
console.warn('[Image] getData() failed:', dataErr);
|
|
35107
|
+
}
|
|
35119
35108
|
return null;
|
|
35120
35109
|
}
|
|
35121
35110
|
// 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}`);
|
|
35111
|
+
if (bufferLength < 1000) {
|
|
35112
|
+
console.warn(`[Image] Buffer too small: ${bufferLength} bytes`);
|
|
35126
35113
|
return null;
|
|
35127
35114
|
}
|
|
35128
35115
|
// Convert buffer to base64 (raw, no data URL prefix)
|
|
35129
35116
|
const base64 = buffer.toString('base64');
|
|
35130
|
-
|
|
35131
|
-
|
|
35132
|
-
console.log(`[Image] Converted to base64: ${base64.length} chars, type=${mediaType}`);
|
|
35133
|
-
return { base64, mediaType };
|
|
35117
|
+
console.log(`[Image] Converted to base64: ${base64.length} chars`);
|
|
35118
|
+
return { base64, mediaType: 'image/jpeg' };
|
|
35134
35119
|
}
|
|
35135
35120
|
catch (e) {
|
|
35136
35121
|
console.warn('[Image] Failed to convert MediaObject to base64:', e);
|