@olane/os 0.8.15 → 0.8.17
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/src/address/address-factory.d.ts +23 -0
- package/dist/src/address/address-factory.d.ts.map +1 -0
- package/dist/src/address/address-factory.js +42 -0
- package/dist/src/address-book/address-book.d.ts +32 -0
- package/dist/src/address-book/address-book.d.ts.map +1 -0
- package/dist/src/address-book/address-book.js +65 -0
- package/dist/src/auth/os-auth-guard.d.ts +20 -0
- package/dist/src/auth/os-auth-guard.d.ts.map +1 -0
- package/dist/src/auth/os-auth-guard.js +39 -0
- package/dist/src/identity/copass-id.d.ts +23 -0
- package/dist/src/identity/copass-id.d.ts.map +1 -0
- package/dist/src/identity/copass-id.js +37 -0
- package/dist/src/index.d.ts +12 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +12 -0
- package/dist/src/lifecycle/os-lifecycle.d.ts +36 -0
- package/dist/src/lifecycle/os-lifecycle.d.ts.map +1 -0
- package/dist/src/lifecycle/os-lifecycle.js +99 -0
- package/dist/src/mcp/os-mcp-server.d.ts +29 -0
- package/dist/src/mcp/os-mcp-server.d.ts.map +1 -0
- package/dist/src/mcp/os-mcp-server.js +244 -0
- package/dist/src/memory/memory-harness.d.ts +38 -0
- package/dist/src/memory/memory-harness.d.ts.map +1 -0
- package/dist/src/memory/memory-harness.js +100 -0
- package/dist/src/nodes/relay-node.d.ts +31 -0
- package/dist/src/nodes/relay-node.d.ts.map +1 -0
- package/dist/src/nodes/relay-node.js +85 -0
- package/dist/src/o-olane-os/interfaces/o-os.config.d.ts +15 -1
- package/dist/src/o-olane-os/interfaces/o-os.config.d.ts.map +1 -1
- package/dist/src/o-olane-os/o-os.d.ts +22 -0
- package/dist/src/o-olane-os/o-os.d.ts.map +1 -1
- package/dist/src/o-olane-os/o-os.js +109 -9
- package/dist/src/tools/filesystem.tool.d.ts +24 -0
- package/dist/src/tools/filesystem.tool.d.ts.map +1 -0
- package/dist/src/tools/filesystem.tool.js +163 -0
- package/dist/src/utils/config.d.ts +7 -1
- package/dist/src/utils/config.d.ts.map +1 -1
- package/dist/src/utils/config.js +40 -19
- package/dist/src/vector-store/copass-vector-store.tool.d.ts +29 -0
- package/dist/src/vector-store/copass-vector-store.tool.d.ts.map +1 -0
- package/dist/src/vector-store/copass-vector-store.tool.js +152 -0
- package/dist/src/worlds/world-instance.tool.d.ts +30 -0
- package/dist/src/worlds/world-instance.tool.d.ts.map +1 -0
- package/dist/src/worlds/world-instance.tool.js +179 -0
- package/dist/src/worlds/world-manager.tool.d.ts +61 -0
- package/dist/src/worlds/world-manager.tool.d.ts.map +1 -0
- package/dist/src/worlds/world-manager.tool.js +270 -0
- package/dist/src/worlds/world.types.d.ts +23 -0
- package/dist/src/worlds/world.types.d.ts.map +1 -0
- package/dist/src/worlds/world.types.js +1 -0
- package/package.json +15 -14
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { oNodeAddress } from '@olane/o-node';
|
|
2
|
+
export interface AddressCreateOptions {
|
|
3
|
+
name: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Factory for creating and validating o:// addresses.
|
|
8
|
+
*/
|
|
9
|
+
export declare class AddressFactory {
|
|
10
|
+
/**
|
|
11
|
+
* Create a validated o:// address from a name.
|
|
12
|
+
*/
|
|
13
|
+
static createAddress(name: string): oNodeAddress;
|
|
14
|
+
/**
|
|
15
|
+
* Generate a unique address with a random suffix.
|
|
16
|
+
*/
|
|
17
|
+
static generateUniqueAddress(prefix: string): oNodeAddress;
|
|
18
|
+
/**
|
|
19
|
+
* Validate that a string is a well-formed o:// address.
|
|
20
|
+
*/
|
|
21
|
+
static validate(value: string): boolean;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=address-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address-factory.d.ts","sourceRoot":"","sources":["../../../src/address/address-factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,qBAAa,cAAc;IACzB;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY;IAehD;;OAEG;IACH,MAAM,CAAC,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY;IAM1D;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;CAQxC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { oAddress } from '@olane/o-core';
|
|
2
|
+
import { oNodeAddress } from '@olane/o-node';
|
|
3
|
+
/**
|
|
4
|
+
* Factory for creating and validating o:// addresses.
|
|
5
|
+
*/
|
|
6
|
+
export class AddressFactory {
|
|
7
|
+
/**
|
|
8
|
+
* Create a validated o:// address from a name.
|
|
9
|
+
*/
|
|
10
|
+
static createAddress(name) {
|
|
11
|
+
// Normalize: strip surrounding quotes, then ensure o:// prefix
|
|
12
|
+
const cleaned = name.replace(/^['"]|['"]$/g, '').trim();
|
|
13
|
+
const value = cleaned.startsWith('o://') ? cleaned : `o://${cleaned}`;
|
|
14
|
+
// Use oAddress validation: must start with o:// and must not be nested
|
|
15
|
+
const addr = new oAddress(value);
|
|
16
|
+
if (!addr.validate()) {
|
|
17
|
+
throw new Error(`Invalid address '${value}': must use o:// protocol`);
|
|
18
|
+
}
|
|
19
|
+
addr.validateNotNested();
|
|
20
|
+
return new oNodeAddress(value);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Generate a unique address with a random suffix.
|
|
24
|
+
*/
|
|
25
|
+
static generateUniqueAddress(prefix) {
|
|
26
|
+
const suffix = Math.random().toString(36).substring(2, 8);
|
|
27
|
+
const name = `${prefix}-${suffix}`;
|
|
28
|
+
return AddressFactory.createAddress(name);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Validate that a string is a well-formed o:// address.
|
|
32
|
+
*/
|
|
33
|
+
static validate(value) {
|
|
34
|
+
try {
|
|
35
|
+
new oAddress(value.startsWith('o://') ? value : `o://${value}`);
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type AddressBookEntryType = 'internal' | 'external';
|
|
2
|
+
export interface AddressBookEntry {
|
|
3
|
+
address: string;
|
|
4
|
+
type: AddressBookEntryType;
|
|
5
|
+
alias?: string;
|
|
6
|
+
copassId?: string;
|
|
7
|
+
worldId?: string;
|
|
8
|
+
lastSeen?: string;
|
|
9
|
+
metadata?: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
export interface AddressBookData {
|
|
12
|
+
version: string;
|
|
13
|
+
entries: AddressBookEntry[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Persistent address book for tracking internal and external network addresses.
|
|
17
|
+
*/
|
|
18
|
+
export declare class AddressBook {
|
|
19
|
+
private storagePath;
|
|
20
|
+
private data;
|
|
21
|
+
constructor(instanceName: string, basePath?: string);
|
|
22
|
+
load(): Promise<void>;
|
|
23
|
+
private persist;
|
|
24
|
+
add(entry: AddressBookEntry): Promise<void>;
|
|
25
|
+
remove(address: string): Promise<boolean>;
|
|
26
|
+
get(address: string): AddressBookEntry | undefined;
|
|
27
|
+
list(type?: AddressBookEntryType): AddressBookEntry[];
|
|
28
|
+
findByAlias(alias: string): AddressBookEntry | undefined;
|
|
29
|
+
findByCopassId(copassId: string): AddressBookEntry | undefined;
|
|
30
|
+
findByWorld(worldId: string): AddressBookEntry[];
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=address-book.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address-book.d.ts","sourceRoot":"","sources":["../../../src/address-book/address-book.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,oBAAoB,GAAG,UAAU,GAAG,UAAU,CAAC;AAE3D,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,oBAAoB,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,gBAAgB,EAAE,CAAC;CAC7B;AAID;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,IAAI,CAAmD;gBAEnD,YAAY,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;IAK7C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;YAUb,OAAO;IAKf,GAAG,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAY3C,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAU/C,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS;IAIlD,IAAI,CAAC,IAAI,CAAC,EAAE,oBAAoB,GAAG,gBAAgB,EAAE;IAOrD,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS;IAIxD,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS;IAI9D,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,EAAE;CAGjD"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as fs from 'fs-extra';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { DEFAULT_INSTANCE_PATH } from '@olane/o-core';
|
|
4
|
+
const EMPTY_BOOK = { version: '1.0', entries: [] };
|
|
5
|
+
/**
|
|
6
|
+
* Persistent address book for tracking internal and external network addresses.
|
|
7
|
+
*/
|
|
8
|
+
export class AddressBook {
|
|
9
|
+
constructor(instanceName, basePath) {
|
|
10
|
+
this.data = { ...EMPTY_BOOK, entries: [] };
|
|
11
|
+
const base = basePath ?? path.join(DEFAULT_INSTANCE_PATH, '..', 'storage');
|
|
12
|
+
this.storagePath = path.join(base, instanceName, 'address-book.json');
|
|
13
|
+
}
|
|
14
|
+
async load() {
|
|
15
|
+
try {
|
|
16
|
+
if (await fs.pathExists(this.storagePath)) {
|
|
17
|
+
this.data = await fs.readJson(this.storagePath);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
this.data = { ...EMPTY_BOOK, entries: [] };
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async persist() {
|
|
25
|
+
await fs.ensureDir(path.dirname(this.storagePath));
|
|
26
|
+
await fs.writeJson(this.storagePath, this.data, { spaces: 2 });
|
|
27
|
+
}
|
|
28
|
+
async add(entry) {
|
|
29
|
+
const existing = this.data.entries.findIndex((e) => e.address === entry.address);
|
|
30
|
+
if (existing >= 0) {
|
|
31
|
+
this.data.entries[existing] = { ...this.data.entries[existing], ...entry };
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
this.data.entries.push(entry);
|
|
35
|
+
}
|
|
36
|
+
await this.persist();
|
|
37
|
+
}
|
|
38
|
+
async remove(address) {
|
|
39
|
+
const before = this.data.entries.length;
|
|
40
|
+
this.data.entries = this.data.entries.filter((e) => e.address !== address);
|
|
41
|
+
if (this.data.entries.length < before) {
|
|
42
|
+
await this.persist();
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
get(address) {
|
|
48
|
+
return this.data.entries.find((e) => e.address === address);
|
|
49
|
+
}
|
|
50
|
+
list(type) {
|
|
51
|
+
if (type) {
|
|
52
|
+
return this.data.entries.filter((e) => e.type === type);
|
|
53
|
+
}
|
|
54
|
+
return [...this.data.entries];
|
|
55
|
+
}
|
|
56
|
+
findByAlias(alias) {
|
|
57
|
+
return this.data.entries.find((e) => e.alias === alias);
|
|
58
|
+
}
|
|
59
|
+
findByCopassId(copassId) {
|
|
60
|
+
return this.data.entries.find((e) => e.copassId === copassId);
|
|
61
|
+
}
|
|
62
|
+
findByWorld(worldId) {
|
|
63
|
+
return this.data.entries.filter((e) => e.worldId === worldId);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { oTokenManager } from '@olane/o-core';
|
|
2
|
+
/**
|
|
3
|
+
* Auth guard for OS operations.
|
|
4
|
+
* Verifies a valid token exists before allowing network-facing operations.
|
|
5
|
+
*/
|
|
6
|
+
export declare class OSAuthGuard {
|
|
7
|
+
private tokenManager;
|
|
8
|
+
constructor(tokenManager?: oTokenManager);
|
|
9
|
+
/**
|
|
10
|
+
* Verify that a valid auth token exists.
|
|
11
|
+
* Throws if no token manager is configured or no valid token is found.
|
|
12
|
+
*/
|
|
13
|
+
ensureAuth(): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Check whether auth is available (non-throwing).
|
|
16
|
+
*/
|
|
17
|
+
isAuthenticated(): Promise<boolean>;
|
|
18
|
+
setTokenManager(tokenManager: oTokenManager): void;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=os-auth-guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"os-auth-guard.d.ts","sourceRoot":"","sources":["../../../src/auth/os-auth-guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C;;;GAGG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,YAAY,CAAuB;gBAE/B,YAAY,CAAC,EAAE,aAAa;IAIxC;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAejC;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAUzC,eAAe,CAAC,YAAY,EAAE,aAAa,GAAG,IAAI;CAGnD"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth guard for OS operations.
|
|
3
|
+
* Verifies a valid token exists before allowing network-facing operations.
|
|
4
|
+
*/
|
|
5
|
+
export class OSAuthGuard {
|
|
6
|
+
constructor(tokenManager) {
|
|
7
|
+
this.tokenManager = tokenManager ?? null;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Verify that a valid auth token exists.
|
|
11
|
+
* Throws if no token manager is configured or no valid token is found.
|
|
12
|
+
*/
|
|
13
|
+
async ensureAuth() {
|
|
14
|
+
if (!this.tokenManager) {
|
|
15
|
+
throw new Error('Authentication required: no token manager configured for this OS instance.');
|
|
16
|
+
}
|
|
17
|
+
const token = await this.tokenManager.getToken();
|
|
18
|
+
if (!token) {
|
|
19
|
+
throw new Error('Authentication required: no valid token found. Please log in first.');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Check whether auth is available (non-throwing).
|
|
24
|
+
*/
|
|
25
|
+
async isAuthenticated() {
|
|
26
|
+
if (!this.tokenManager)
|
|
27
|
+
return false;
|
|
28
|
+
try {
|
|
29
|
+
const token = await this.tokenManager.getToken();
|
|
30
|
+
return !!token;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
setTokenManager(tokenManager) {
|
|
37
|
+
this.tokenManager = tokenManager;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copass ID validation and resolution.
|
|
3
|
+
*
|
|
4
|
+
* Copass IDs are human-readable identifiers linked to o:// addresses.
|
|
5
|
+
* Validation rules: 3-30 chars, lowercase alphanumeric + hyphens/underscores,
|
|
6
|
+
* no consecutive special chars, must start/end with alphanumeric.
|
|
7
|
+
*/
|
|
8
|
+
export interface CopassIdValidationResult {
|
|
9
|
+
valid: boolean;
|
|
10
|
+
errors: string[];
|
|
11
|
+
}
|
|
12
|
+
export declare function validateCopassId(id: string): CopassIdValidationResult;
|
|
13
|
+
/**
|
|
14
|
+
* Link a Copass ID to an address in the address book.
|
|
15
|
+
* This is a convenience wrapper — the actual storage is in the AddressBook.
|
|
16
|
+
*/
|
|
17
|
+
export interface CopassIdMapping {
|
|
18
|
+
copassId: string;
|
|
19
|
+
address: string;
|
|
20
|
+
linkedAt: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function createCopassIdMapping(copassId: string, address: string): CopassIdMapping;
|
|
23
|
+
//# sourceMappingURL=copass-id.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copass-id.d.ts","sourceRoot":"","sources":["../../../src/identity/copass-id.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,wBAAwB,CAmBrE;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,eAAe,CAYjB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copass ID validation and resolution.
|
|
3
|
+
*
|
|
4
|
+
* Copass IDs are human-readable identifiers linked to o:// addresses.
|
|
5
|
+
* Validation rules: 3-30 chars, lowercase alphanumeric + hyphens/underscores,
|
|
6
|
+
* no consecutive special chars, must start/end with alphanumeric.
|
|
7
|
+
*/
|
|
8
|
+
const COPASS_ID_REGEX = /^[a-z0-9]([a-z0-9_-]*[a-z0-9])?$/;
|
|
9
|
+
const MIN_LENGTH = 3;
|
|
10
|
+
const MAX_LENGTH = 30;
|
|
11
|
+
export function validateCopassId(id) {
|
|
12
|
+
const errors = [];
|
|
13
|
+
if (id.length < MIN_LENGTH) {
|
|
14
|
+
errors.push(`Must be at least ${MIN_LENGTH} characters`);
|
|
15
|
+
}
|
|
16
|
+
if (id.length > MAX_LENGTH) {
|
|
17
|
+
errors.push(`Must be at most ${MAX_LENGTH} characters`);
|
|
18
|
+
}
|
|
19
|
+
if (!COPASS_ID_REGEX.test(id)) {
|
|
20
|
+
errors.push('Must be lowercase alphanumeric with hyphens/underscores, starting and ending with alphanumeric');
|
|
21
|
+
}
|
|
22
|
+
if (/[-_]{2,}/.test(id)) {
|
|
23
|
+
errors.push('Cannot contain consecutive special characters');
|
|
24
|
+
}
|
|
25
|
+
return { valid: errors.length === 0, errors };
|
|
26
|
+
}
|
|
27
|
+
export function createCopassIdMapping(copassId, address) {
|
|
28
|
+
const validation = validateCopassId(copassId);
|
|
29
|
+
if (!validation.valid) {
|
|
30
|
+
throw new Error(`Invalid Copass ID '${copassId}': ${validation.errors.join(', ')}`);
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
copassId,
|
|
34
|
+
address,
|
|
35
|
+
linkedAt: new Date().toISOString(),
|
|
36
|
+
};
|
|
37
|
+
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
1
|
export * from './o-olane-os/index.js';
|
|
2
2
|
export * from './utils/config.js';
|
|
3
|
+
export * from './address/address-factory.js';
|
|
4
|
+
export * from './address-book/address-book.js';
|
|
5
|
+
export * from './memory/memory-harness.js';
|
|
6
|
+
export * from './lifecycle/os-lifecycle.js';
|
|
7
|
+
export * from './worlds/world.types.js';
|
|
8
|
+
export * from './worlds/world-instance.tool.js';
|
|
9
|
+
export * from './worlds/world-manager.tool.js';
|
|
10
|
+
export * from './nodes/relay-node.js';
|
|
11
|
+
export * from './vector-store/copass-vector-store.tool.js';
|
|
12
|
+
export * from './tools/filesystem.tool.js';
|
|
13
|
+
export * from './identity/copass-id.js';
|
|
14
|
+
export * from './mcp/os-mcp-server.js';
|
|
3
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4CAA4C,CAAC;AAC3D,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,2 +1,14 @@
|
|
|
1
1
|
export * from './o-olane-os/index.js';
|
|
2
2
|
export * from './utils/config.js';
|
|
3
|
+
export * from './address/address-factory.js';
|
|
4
|
+
export * from './address-book/address-book.js';
|
|
5
|
+
export * from './memory/memory-harness.js';
|
|
6
|
+
export * from './lifecycle/os-lifecycle.js';
|
|
7
|
+
export * from './worlds/world.types.js';
|
|
8
|
+
export * from './worlds/world-instance.tool.js';
|
|
9
|
+
export * from './worlds/world-manager.tool.js';
|
|
10
|
+
export * from './nodes/relay-node.js';
|
|
11
|
+
export * from './vector-store/copass-vector-store.tool.js';
|
|
12
|
+
export * from './tools/filesystem.tool.js';
|
|
13
|
+
export * from './identity/copass-id.js';
|
|
14
|
+
export * from './mcp/os-mcp-server.js';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { OlaneOS } from '../o-olane-os/o-os.js';
|
|
2
|
+
import { OlaneOSConfig } from '../o-olane-os/interfaces/o-os.config.js';
|
|
3
|
+
import { OlaneOSInstanceConfig } from '../utils/config.js';
|
|
4
|
+
export interface OSStartResult {
|
|
5
|
+
peerId: string;
|
|
6
|
+
transports: string[];
|
|
7
|
+
instanceName: string;
|
|
8
|
+
pid: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Start an OlaneOS instance and persist its PID/state.
|
|
12
|
+
* If an instance with this name is already running, stops it first.
|
|
13
|
+
*/
|
|
14
|
+
export declare function startOS(instanceName: string, osConfig: OlaneOSConfig): Promise<{
|
|
15
|
+
os: OlaneOS;
|
|
16
|
+
result: OSStartResult;
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* Stop a running OS instance by name. Sends SIGTERM to its PID.
|
|
20
|
+
*/
|
|
21
|
+
export declare function stopOS(instanceName: string): Promise<boolean>;
|
|
22
|
+
/**
|
|
23
|
+
* Check liveness of an OS instance by name.
|
|
24
|
+
*/
|
|
25
|
+
export declare function statusOS(instanceName: string): Promise<{
|
|
26
|
+
config: OlaneOSInstanceConfig;
|
|
27
|
+
alive: boolean;
|
|
28
|
+
} | null>;
|
|
29
|
+
/**
|
|
30
|
+
* List all instances with live PID checks.
|
|
31
|
+
*/
|
|
32
|
+
export declare function listOS(): Promise<Array<{
|
|
33
|
+
config: OlaneOSInstanceConfig;
|
|
34
|
+
alive: boolean;
|
|
35
|
+
}>>;
|
|
36
|
+
//# sourceMappingURL=os-lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"os-lifecycle.d.ts","sourceRoot":"","sources":["../../../src/lifecycle/os-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAExE,OAAO,EAAiB,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE1E,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;GAGG;AACH,wBAAsB,OAAO,CAC3B,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,aAAa,GACtB,OAAO,CAAC;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,aAAa,CAAA;CAAE,CAAC,CAqCjD;AAED;;GAEG;AACH,wBAAsB,MAAM,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAiBnE;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAC5B,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC;IAAE,MAAM,EAAE,qBAAqB,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAAC,CAoBnE;AAED;;GAEG;AACH,wBAAsB,MAAM,IAAI,OAAO,CACrC,KAAK,CAAC;IAAE,MAAM,EAAE,qBAAqB,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,CACzD,CAMA"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { OlaneOS } from '../o-olane-os/o-os.js';
|
|
2
|
+
import { OlaneOSSystemStatus } from '../o-olane-os/enum/o-os.status-enum.js';
|
|
3
|
+
import { ConfigManager } from '../utils/config.js';
|
|
4
|
+
/**
|
|
5
|
+
* Start an OlaneOS instance and persist its PID/state.
|
|
6
|
+
* If an instance with this name is already running, stops it first.
|
|
7
|
+
*/
|
|
8
|
+
export async function startOS(instanceName, osConfig) {
|
|
9
|
+
// Check for an existing running instance and clean up
|
|
10
|
+
const existing = await ConfigManager.getOSConfig(instanceName);
|
|
11
|
+
if (existing?.pid && isProcessAlive(existing.pid) && existing.pid !== process.pid) {
|
|
12
|
+
process.kill(existing.pid, 'SIGTERM');
|
|
13
|
+
await ConfigManager.updateOSConfig({
|
|
14
|
+
...existing,
|
|
15
|
+
status: OlaneOSSystemStatus.STOPPED,
|
|
16
|
+
pid: undefined,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
const os = new OlaneOS(osConfig);
|
|
20
|
+
const { peerId, transports } = await os.start();
|
|
21
|
+
const instanceConfig = {
|
|
22
|
+
name: instanceName,
|
|
23
|
+
version: osConfig.network?.version || '0.0.1',
|
|
24
|
+
description: osConfig.network?.description || '',
|
|
25
|
+
port: osConfig.network?.port || 0,
|
|
26
|
+
status: OlaneOSSystemStatus.RUNNING,
|
|
27
|
+
createdAt: new Date().toISOString(),
|
|
28
|
+
pid: process.pid,
|
|
29
|
+
peerId,
|
|
30
|
+
transports: transports.map((t) => String(t)),
|
|
31
|
+
oNetworkConfig: osConfig,
|
|
32
|
+
};
|
|
33
|
+
await ConfigManager.saveOSConfig(instanceConfig);
|
|
34
|
+
const result = {
|
|
35
|
+
peerId,
|
|
36
|
+
transports: instanceConfig.transports || [],
|
|
37
|
+
instanceName,
|
|
38
|
+
pid: process.pid,
|
|
39
|
+
};
|
|
40
|
+
return { os, result };
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Stop a running OS instance by name. Sends SIGTERM to its PID.
|
|
44
|
+
*/
|
|
45
|
+
export async function stopOS(instanceName) {
|
|
46
|
+
const config = await ConfigManager.getOSConfig(instanceName);
|
|
47
|
+
if (!config) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
if (config.pid && isProcessAlive(config.pid)) {
|
|
51
|
+
process.kill(config.pid, 'SIGTERM');
|
|
52
|
+
}
|
|
53
|
+
await ConfigManager.updateOSConfig({
|
|
54
|
+
...config,
|
|
55
|
+
status: OlaneOSSystemStatus.STOPPED,
|
|
56
|
+
pid: undefined,
|
|
57
|
+
});
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Check liveness of an OS instance by name.
|
|
62
|
+
*/
|
|
63
|
+
export async function statusOS(instanceName) {
|
|
64
|
+
const config = await ConfigManager.getOSConfig(instanceName);
|
|
65
|
+
if (!config) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
const alive = config.pid ? isProcessAlive(config.pid) : false;
|
|
69
|
+
// Clean up stale status
|
|
70
|
+
if (!alive && config.status === OlaneOSSystemStatus.RUNNING) {
|
|
71
|
+
await ConfigManager.updateOSConfig({
|
|
72
|
+
...config,
|
|
73
|
+
status: OlaneOSSystemStatus.STOPPED,
|
|
74
|
+
pid: undefined,
|
|
75
|
+
});
|
|
76
|
+
config.status = OlaneOSSystemStatus.STOPPED;
|
|
77
|
+
config.pid = undefined;
|
|
78
|
+
}
|
|
79
|
+
return { config, alive };
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* List all instances with live PID checks.
|
|
83
|
+
*/
|
|
84
|
+
export async function listOS() {
|
|
85
|
+
const instances = await ConfigManager.listOSInstances();
|
|
86
|
+
return instances.map((config) => ({
|
|
87
|
+
config,
|
|
88
|
+
alive: config.pid ? isProcessAlive(config.pid) : false,
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
function isProcessAlive(pid) {
|
|
92
|
+
try {
|
|
93
|
+
process.kill(pid, 0);
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OS-level MCP tool definitions.
|
|
3
|
+
*
|
|
4
|
+
* These are meant to be registered on an MCP server by the CLI layer.
|
|
5
|
+
* Each handler receives an OlaneOS instance and returns structured results.
|
|
6
|
+
*/
|
|
7
|
+
import type { OlaneOS } from '../o-olane-os/o-os.js';
|
|
8
|
+
import type { AddressBook } from '../address-book/address-book.js';
|
|
9
|
+
import type { MemoryHarness } from '../memory/memory-harness.js';
|
|
10
|
+
import type { WorldManagerTool } from '../worlds/world-manager.tool.js';
|
|
11
|
+
export interface OSMcpContext {
|
|
12
|
+
os?: OlaneOS;
|
|
13
|
+
addressBook?: AddressBook;
|
|
14
|
+
memory?: MemoryHarness;
|
|
15
|
+
worldManager?: WorldManagerTool;
|
|
16
|
+
}
|
|
17
|
+
export interface McpToolDefinition {
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
inputSchema: Record<string, any>;
|
|
21
|
+
handler: (params: any, ctx: OSMcpContext) => Promise<{
|
|
22
|
+
content: Array<{
|
|
23
|
+
type: string;
|
|
24
|
+
text: string;
|
|
25
|
+
}>;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
export declare const OS_MCP_TOOLS: McpToolDefinition[];
|
|
29
|
+
//# sourceMappingURL=os-mcp-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"os-mcp-server.d.ts","sourceRoot":"","sources":["../../../src/mcp/os-mcp-server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAKxE,MAAM,WAAW,YAAY;IAC3B,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,YAAY,CAAC,EAAE,gBAAgB,CAAC;CACjC;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,OAAO,EAAE,CACP,MAAM,EAAE,GAAG,EACX,GAAG,EAAE,YAAY,KACd,OAAO,CAAC;QAAE,OAAO,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC,CAAC;CAClE;AAMD,eAAO,MAAM,YAAY,EAAE,iBAAiB,EAsO3C,CAAC"}
|