@props-labs/mesh-os 0.2.3 → 0.2.6
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/core/client.d.ts +1 -0
- package/dist/core/client.js +11 -22
- package/dist/core/memories.d.ts +20 -1
- package/dist/core/memories.js +37 -2
- package/package.json +1 -1
package/dist/core/client.d.ts
CHANGED
package/dist/core/client.js
CHANGED
@@ -8,8 +8,6 @@ exports.MeshOS = exports.InvalidSlugError = exports.GraphQLError = void 0;
|
|
8
8
|
* Core functionality for MeshOS.
|
9
9
|
*/
|
10
10
|
const openai_1 = __importDefault(require("openai"));
|
11
|
-
const chalk_1 = __importDefault(require("chalk"));
|
12
|
-
const boxen_1 = __importDefault(require("boxen"));
|
13
11
|
const taxonomy_1 = require("./taxonomy");
|
14
12
|
const workflows_1 = require("./workflows");
|
15
13
|
const memories_1 = require("./memories");
|
@@ -41,28 +39,19 @@ exports.InvalidSlugError = InvalidSlugError;
|
|
41
39
|
*/
|
42
40
|
class MeshOS {
|
43
41
|
constructor(config = {}) {
|
44
|
-
|
45
|
-
this.headers = {
|
46
|
-
'Content-Type': 'application/json',
|
47
|
-
'x-hasura-admin-secret': config.apiKey || 'meshos'
|
48
|
-
};
|
49
|
-
// Set up OpenAI
|
50
|
-
const openaiApiKey = config.openaiApiKey || process.env.OPENAI_API_KEY;
|
42
|
+
const { url = 'http://localhost:8080/v1/graphql', apiKey = 'meshos', openaiApiKey = process.env.OPENAI_API_KEY, dangerouslyAllowBrowser = false } = config;
|
51
43
|
if (!openaiApiKey) {
|
52
|
-
|
53
|
-
title: 'Missing API Key',
|
54
|
-
titleAlignment: 'center',
|
55
|
-
padding: 1,
|
56
|
-
borderColor: 'yellow',
|
57
|
-
borderStyle: 'round'
|
58
|
-
};
|
59
|
-
console.error((0, boxen_1.default)(chalk_1.default.yellow('⚠️ OpenAI API key not found!\n\n') +
|
60
|
-
'Please set your OpenAI API key in the environment:\n' +
|
61
|
-
chalk_1.default.green('OPENAI_API_KEY=your-key-here') + '\n\n' +
|
62
|
-
'You can get an API key at: ' + chalk_1.default.blue('https://platform.openai.com/api-keys'), boxOptions));
|
63
|
-
throw new Error('OpenAI API key is required');
|
44
|
+
throw new Error('OpenAI API key is required. Please provide it in the config or set OPENAI_API_KEY environment variable.');
|
64
45
|
}
|
65
|
-
this.
|
46
|
+
this.url = url;
|
47
|
+
this.headers = {
|
48
|
+
'x-hasura-admin-secret': apiKey,
|
49
|
+
'Content-Type': 'application/json'
|
50
|
+
};
|
51
|
+
this.openai = new openai_1.default({
|
52
|
+
apiKey: openaiApiKey,
|
53
|
+
dangerouslyAllowBrowser
|
54
|
+
});
|
66
55
|
// Initialize managers
|
67
56
|
this.workflows = new workflows_1.WorkflowManager(this.url, this.headers);
|
68
57
|
this.memories = new memories_1.MemoryManager(this.url, this.headers, this.createEmbedding.bind(this));
|
package/dist/core/memories.d.ts
CHANGED
@@ -77,7 +77,7 @@ export interface SearchMemoryOptions {
|
|
77
77
|
createdAtFilter?: Record<string, any>;
|
78
78
|
}
|
79
79
|
export interface ListMemoriesOptions {
|
80
|
-
type?: string;
|
80
|
+
type?: string | string[];
|
81
81
|
status?: 'active' | 'archived' | 'deleted';
|
82
82
|
limit?: number;
|
83
83
|
offset?: number;
|
@@ -97,6 +97,21 @@ export interface UpdateMemoryResult {
|
|
97
97
|
memory: Memory;
|
98
98
|
chunkCount?: number;
|
99
99
|
}
|
100
|
+
export interface CreateTypeSchemaInput {
|
101
|
+
type: string;
|
102
|
+
schema: Record<string, any>;
|
103
|
+
metadata_schema?: Record<string, any>;
|
104
|
+
embedding_config?: {
|
105
|
+
model: string;
|
106
|
+
dimensions: number;
|
107
|
+
};
|
108
|
+
chunking_config?: {
|
109
|
+
chunk_size: number;
|
110
|
+
chunk_overlap: number;
|
111
|
+
};
|
112
|
+
validation_rules?: Record<string, any>;
|
113
|
+
behaviors?: Record<string, any>;
|
114
|
+
}
|
100
115
|
export declare class MemoryManager {
|
101
116
|
private url;
|
102
117
|
private headers;
|
@@ -150,4 +165,8 @@ export declare class MemoryManager {
|
|
150
165
|
* List memories with optional filtering and pagination
|
151
166
|
*/
|
152
167
|
listMemories(options?: ListMemoriesOptions): Promise<Memory[]>;
|
168
|
+
/**
|
169
|
+
* Create a new type schema
|
170
|
+
*/
|
171
|
+
createTypeSchema(input: CreateTypeSchemaInput): Promise<TypeSchema>;
|
153
172
|
}
|
package/dist/core/memories.js
CHANGED
@@ -420,8 +420,11 @@ class MemoryManager {
|
|
420
420
|
const { type, status, limit = 10, offset = 0, agentId, orderBy = [{ field: 'created_at', direction: 'desc' }] } = options;
|
421
421
|
// Build where clause
|
422
422
|
const where = {};
|
423
|
-
if (type)
|
424
|
-
where.type =
|
423
|
+
if (type) {
|
424
|
+
where.type = Array.isArray(type)
|
425
|
+
? { _in: type } // If array, use _in operator
|
426
|
+
: { _eq: type }; // If single string, use _eq operator
|
427
|
+
}
|
425
428
|
if (status)
|
426
429
|
where.status = { _eq: status };
|
427
430
|
if (agentId)
|
@@ -462,5 +465,37 @@ class MemoryManager {
|
|
462
465
|
});
|
463
466
|
return result.memories.map(memory => memorySchema.parse(memory));
|
464
467
|
}
|
468
|
+
/**
|
469
|
+
* Create a new type schema
|
470
|
+
*/
|
471
|
+
async createTypeSchema(input) {
|
472
|
+
const query = `
|
473
|
+
mutation CreateTypeSchema($schema: type_schemas_insert_input!) {
|
474
|
+
insert_type_schemas_one(object: $schema) {
|
475
|
+
type
|
476
|
+
schema
|
477
|
+
metadata_schema
|
478
|
+
embedding_config
|
479
|
+
chunking_config
|
480
|
+
validation_rules
|
481
|
+
behaviors
|
482
|
+
created_at
|
483
|
+
updated_at
|
484
|
+
}
|
485
|
+
}
|
486
|
+
`;
|
487
|
+
const result = await this.executeQuery(query, {
|
488
|
+
schema: {
|
489
|
+
type: input.type,
|
490
|
+
schema: input.schema,
|
491
|
+
metadata_schema: input.metadata_schema || null,
|
492
|
+
embedding_config: input.embedding_config || null,
|
493
|
+
chunking_config: input.chunking_config || null,
|
494
|
+
validation_rules: input.validation_rules || null,
|
495
|
+
behaviors: input.behaviors || null
|
496
|
+
}
|
497
|
+
});
|
498
|
+
return typeSchemaSchema.parse(result.insert_type_schemas_one);
|
499
|
+
}
|
465
500
|
}
|
466
501
|
exports.MemoryManager = MemoryManager;
|