@olane/os 0.7.1

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.
Files changed (68) hide show
  1. package/README.md +947 -0
  2. package/dist/src/index.d.ts +3 -0
  3. package/dist/src/index.d.ts.map +1 -0
  4. package/dist/src/index.js +2 -0
  5. package/dist/src/network/config/default.config.d.ts +3 -0
  6. package/dist/src/network/config/default.config.d.ts.map +1 -0
  7. package/dist/src/network/config/default.config.js +32 -0
  8. package/dist/src/network/index.d.ts +5 -0
  9. package/dist/src/network/index.d.ts.map +1 -0
  10. package/dist/src/network/index.js +4 -0
  11. package/dist/src/network/interfaces/network-status.enum.d.ts +7 -0
  12. package/dist/src/network/interfaces/network-status.enum.d.ts.map +1 -0
  13. package/dist/src/network/interfaces/network-status.enum.js +7 -0
  14. package/dist/src/network/interfaces/network.interface.d.ts +18 -0
  15. package/dist/src/network/interfaces/network.interface.d.ts.map +1 -0
  16. package/dist/src/network/interfaces/network.interface.js +1 -0
  17. package/dist/src/network/o-network.d.ts +34 -0
  18. package/dist/src/network/o-network.d.ts.map +1 -0
  19. package/dist/src/network/o-network.js +247 -0
  20. package/dist/src/o-olane-os/config/default.config.d.ts +3 -0
  21. package/dist/src/o-olane-os/config/default.config.d.ts.map +1 -0
  22. package/dist/src/o-olane-os/config/default.config.js +32 -0
  23. package/dist/src/o-olane-os/enum/o-os.status-enum.d.ts +7 -0
  24. package/dist/src/o-olane-os/enum/o-os.status-enum.d.ts.map +1 -0
  25. package/dist/src/o-olane-os/enum/o-os.status-enum.js +7 -0
  26. package/dist/src/o-olane-os/index.d.ts +5 -0
  27. package/dist/src/o-olane-os/index.d.ts.map +1 -0
  28. package/dist/src/o-olane-os/index.js +4 -0
  29. package/dist/src/o-olane-os/interfaces/o-os.config.d.ts +18 -0
  30. package/dist/src/o-olane-os/interfaces/o-os.config.d.ts.map +1 -0
  31. package/dist/src/o-olane-os/interfaces/o-os.config.js +1 -0
  32. package/dist/src/o-olane-os/o-os.d.ts +32 -0
  33. package/dist/src/o-olane-os/o-os.d.ts.map +1 -0
  34. package/dist/src/o-olane-os/o-os.js +207 -0
  35. package/dist/src/utils/config.d.ts +35 -0
  36. package/dist/src/utils/config.d.ts.map +1 -0
  37. package/dist/src/utils/config.js +82 -0
  38. package/dist/test/basic/basic-usage.spec.d.ts +1 -0
  39. package/dist/test/basic/basic-usage.spec.d.ts.map +1 -0
  40. package/dist/test/basic/basic-usage.spec.js +115 -0
  41. package/dist/test/basic/resolvers.spec.d.ts +1 -0
  42. package/dist/test/basic/resolvers.spec.d.ts.map +1 -0
  43. package/dist/test/basic/resolvers.spec.js +36 -0
  44. package/dist/test/benchmarks/benchmark.spec.d.ts +2 -0
  45. package/dist/test/benchmarks/benchmark.spec.d.ts.map +1 -0
  46. package/dist/test/benchmarks/benchmark.spec.js +65 -0
  47. package/dist/test/benchmarks/github/github.test-cases.d.ts +3 -0
  48. package/dist/test/benchmarks/github/github.test-cases.d.ts.map +1 -0
  49. package/dist/test/benchmarks/github/github.test-cases.js +236 -0
  50. package/dist/test/benchmarks/interfaces/test-case.interface.d.ts +10 -0
  51. package/dist/test/benchmarks/interfaces/test-case.interface.d.ts.map +1 -0
  52. package/dist/test/benchmarks/interfaces/test-case.interface.js +1 -0
  53. package/dist/test/local-mcp.spec.d.ts +1 -0
  54. package/dist/test/local-mcp.spec.d.ts.map +1 -0
  55. package/dist/test/local-mcp.spec.js +155 -0
  56. package/dist/test/utils/default.network.d.ts +3 -0
  57. package/dist/test/utils/default.network.d.ts.map +1 -0
  58. package/dist/test/utils/default.network.js +33 -0
  59. package/dist/test/utils/mcp-repo.d.ts +2 -0
  60. package/dist/test/utils/mcp-repo.d.ts.map +1 -0
  61. package/dist/test/utils/mcp-repo.js +5 -0
  62. package/dist/test/utils/models.d.ts +9 -0
  63. package/dist/test/utils/models.d.ts.map +1 -0
  64. package/dist/test/utils/models.js +8 -0
  65. package/dist/test/utils/os.default.d.ts +3 -0
  66. package/dist/test/utils/os.default.d.ts.map +1 -0
  67. package/dist/test/utils/os.default.js +33 -0
  68. package/package.json +79 -0
@@ -0,0 +1,207 @@
1
+ import { OlaneOSSystemStatus } from './enum/o-os.status-enum.js';
2
+ import touch from 'touch';
3
+ import { readFile } from 'fs/promises';
4
+ import { oLeaderNode } from '@olane/o-leader';
5
+ import { oAddress, oObject } from '@olane/o-core';
6
+ import { NodeType } from '@olane/o-core';
7
+ import { initCommonTools } from '@olane/o-tools-common';
8
+ import { initRegistryTools } from '@olane/o-tool-registry';
9
+ import { ConfigManager } from '../utils/config.js';
10
+ import { oLaneTool } from '@olane/o-lane';
11
+ import { oLaneStorage } from '@olane/o-storage';
12
+ import { oNodeAddress } from '@olane/o-node';
13
+ export class OlaneOS extends oObject {
14
+ constructor(config) {
15
+ super();
16
+ this.leaders = []; // clones of leader for scale
17
+ this.nodes = []; // clones of node for scale
18
+ this.rootLeader = null; // the root leader node
19
+ this.roundRobinIndex = 0;
20
+ this.config = config;
21
+ }
22
+ entryNode() {
23
+ const node = this.nodes[this.roundRobinIndex];
24
+ this.roundRobinIndex = (this.roundRobinIndex + 1) % this.nodes.length;
25
+ return node;
26
+ }
27
+ addLeader(leader) {
28
+ this.leaders.push(leader);
29
+ if (!this.rootLeader) {
30
+ this.rootLeader = leader;
31
+ }
32
+ }
33
+ async addNode(node) {
34
+ if (this.status !== OlaneOSSystemStatus.RUNNING) {
35
+ throw new Error('OS instance is not running, cannot add node');
36
+ }
37
+ // TODO: how do we handle multiple leaders?
38
+ // TODO: how do we handle multiple nodes?
39
+ if (this.nodes.length === 0) {
40
+ throw new Error('No non-leader nodes found, cannot add node');
41
+ }
42
+ const selection = this.entryNode();
43
+ selection.addChildNode(node);
44
+ await selection.start();
45
+ const parent = this.entryNode();
46
+ parent.addChildNode(node);
47
+ }
48
+ async loadConfig() {
49
+ // TODO make this a promise based function
50
+ if (this.config.configFilePath) {
51
+ try {
52
+ await touch(this.config.configFilePath);
53
+ this.logger.debug('Config file path: ' + this.config.configFilePath);
54
+ // let's load the config
55
+ const config = await readFile(this.config.configFilePath, 'utf8');
56
+ this.logger.debug('Config file contents: ' + config);
57
+ if (config?.length === 0) {
58
+ // no contents, let's create a new config
59
+ throw new Error('No config file found, cannot start OS instance');
60
+ }
61
+ const json = JSON.parse(config);
62
+ this.logger.debug('Config file parsed: ' + json);
63
+ const osConfig = json.oNetworkConfig;
64
+ this.config = {
65
+ ...osConfig,
66
+ nodes: (osConfig.nodes || []).map((node) => ({
67
+ ...node,
68
+ address: new oNodeAddress(node.address.value),
69
+ })),
70
+ network: {
71
+ ...osConfig.network,
72
+ port: osConfig.network?.port || 4999,
73
+ },
74
+ configFilePath: this.config.configFilePath, // persist the config file path
75
+ };
76
+ }
77
+ catch (error) {
78
+ this.logger.error('Failed to initialize config folder', error);
79
+ throw new Error('Failed to initialize config folder');
80
+ }
81
+ }
82
+ else {
83
+ this.logger.warn('No config file path provided, using default config');
84
+ }
85
+ }
86
+ async getOSInstanceName() {
87
+ if (this.config.configFilePath) {
88
+ const osConfig = await ConfigManager.getOSConfigFromPath(this.config.configFilePath);
89
+ return osConfig?.name;
90
+ }
91
+ }
92
+ async startNodes(type) {
93
+ this.logger.debug('Starting nodes');
94
+ if (!this.config.nodes || this.config.nodes?.length === 0) {
95
+ throw new Error('No nodes found in config, cannot start OS instance');
96
+ }
97
+ const filtered = this.config.nodes.filter((node) => node.type === type);
98
+ const osInstanceName = await this.getOSInstanceName();
99
+ // check the config for any leaders
100
+ for (const node of filtered) {
101
+ if (node.type === NodeType.LEADER) {
102
+ this.logger.debug('Starting leader: ' + node.address.toString());
103
+ const leaderNode = new oLeaderNode({
104
+ ...node,
105
+ systemName: osInstanceName,
106
+ });
107
+ if (!this.rootLeader) {
108
+ this.rootLeader = leaderNode;
109
+ }
110
+ await leaderNode.start();
111
+ await initCommonTools(leaderNode);
112
+ this.leaders.push(leaderNode);
113
+ }
114
+ else {
115
+ this.logger.debug('Starting non-leader node: ' + node.address.toString());
116
+ const commonNode = new oLaneTool({
117
+ ...node,
118
+ address: node.address,
119
+ leader: this.rootLeader?.address || null,
120
+ parent: this.rootLeader?.address || null,
121
+ });
122
+ await commonNode.start();
123
+ this.rootLeader?.addChildNode(commonNode);
124
+ const olaneStorage = new oLaneStorage({
125
+ name: 'lane-storage',
126
+ parent: commonNode.address,
127
+ leader: this.rootLeader?.address || null,
128
+ });
129
+ await olaneStorage.start();
130
+ commonNode.addChildNode(olaneStorage);
131
+ await initCommonTools(commonNode);
132
+ await initRegistryTools(commonNode);
133
+ this.nodes.push(commonNode);
134
+ }
135
+ }
136
+ }
137
+ async runSavedPlans() {
138
+ const plans = Array.from(new Set(this.config?.lanes || []));
139
+ for (const plan of plans) {
140
+ this.logger.debug('Running saved plan: ' + plan);
141
+ await this.use(new oAddress(plan), {
142
+ method: 'use',
143
+ });
144
+ }
145
+ }
146
+ async use(oAddress, params) {
147
+ const entryNode = this.entryNode();
148
+ if (!entryNode) {
149
+ throw new Error('Entry node not found');
150
+ }
151
+ this.logger.debug('Using address: ' + oAddress.toString());
152
+ return entryNode.use(oAddress, params);
153
+ }
154
+ async start() {
155
+ this.logger.debug('Starting OS instance');
156
+ this.status = OlaneOSSystemStatus.STARTING;
157
+ // initialize config folder
158
+ await this.loadConfig();
159
+ this.logger.debug('OS instance config loaded');
160
+ // start leaders (and consequentially, the rest of the OS instance)
161
+ await this.startNodes(NodeType.LEADER);
162
+ this.logger.debug('Leaders started...');
163
+ await this.startNodes(NodeType.NODE);
164
+ this.logger.debug('Nodes started...');
165
+ await this.runSavedPlans();
166
+ this.logger.debug('Saved plans run...');
167
+ this.logger.debug('OS instance started...');
168
+ // index the OS instance
169
+ if (!this.config.noIndexNetwork) {
170
+ await this.use(oAddress.leader(), {
171
+ method: 'index_network',
172
+ params: {},
173
+ });
174
+ }
175
+ this.status = OlaneOSSystemStatus.RUNNING;
176
+ return {
177
+ peerId: this.rootLeader?.peerId.toString() || '',
178
+ transports: this.rootLeader?.transports || [],
179
+ };
180
+ }
181
+ async stop() {
182
+ this.logger.debug('Stopping OS instance');
183
+ this.status = OlaneOSSystemStatus.STOPPING;
184
+ const stopPromises = [];
185
+ try {
186
+ if (!this.rootLeader) {
187
+ throw new Error('Root leader not found');
188
+ }
189
+ stopPromises.push(this.rootLeader.stop());
190
+ // Wait for all stop operations to complete
191
+ await Promise.all(stopPromises);
192
+ this.logger.debug('OS instance stopped successfully');
193
+ }
194
+ catch (error) {
195
+ this.logger.error('Error while stopping OS instance:', error);
196
+ }
197
+ finally {
198
+ this.status = OlaneOSSystemStatus.STOPPED;
199
+ this.roundRobinIndex = 0;
200
+ }
201
+ }
202
+ async restart() {
203
+ this.logger.debug('Restarting OS instance');
204
+ await this.stop();
205
+ await this.start();
206
+ }
207
+ }
@@ -0,0 +1,35 @@
1
+ import { OlaneOSSystemStatus } from '../o-olane-os/enum/o-os.status-enum.js';
2
+ import { OlaneOSConfig } from '../o-olane-os/index.js';
3
+ export interface OlaneOSInstanceConfig {
4
+ name: string;
5
+ version: string;
6
+ description: string;
7
+ port: number;
8
+ status: OlaneOSSystemStatus;
9
+ path?: string;
10
+ createdAt?: string;
11
+ pid?: number;
12
+ peerId?: string;
13
+ transports?: string[];
14
+ oNetworkConfig?: OlaneOSConfig;
15
+ }
16
+ export interface CLIConfig {
17
+ instancesPath: string;
18
+ }
19
+ export declare const CONFIG_FILE_NAME = "config.json";
20
+ export declare class ConfigManager {
21
+ private static configPath;
22
+ private static instancesPath;
23
+ private static configFile;
24
+ static initialize(): Promise<void>;
25
+ static getDefaultConfig(): CLIConfig;
26
+ static getConfig(): Promise<CLIConfig>;
27
+ static saveConfig(config: Partial<CLIConfig>): Promise<void>;
28
+ static writeConfig(config: Partial<CLIConfig>): Promise<void>;
29
+ static getOSConfigFromPath(path: string): Promise<OlaneOSInstanceConfig | null>;
30
+ static getOSConfig(name: string): Promise<OlaneOSInstanceConfig | null>;
31
+ static saveOSConfig(config: OlaneOSInstanceConfig): Promise<void>;
32
+ static listOSInstances(): Promise<OlaneOSInstanceConfig[]>;
33
+ static deleteOSInstance(name: string): Promise<void>;
34
+ }
35
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/utils/config.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,mBAAmB,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,cAAc,CAAC,EAAE,aAAa,CAAC;CAChC;AAED,MAAM,WAAW,SAAS;IACxB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAE9C,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAC,UAAU,CAAuB;IAChD,OAAO,CAAC,MAAM,CAAC,aAAa,CAAyB;IACrD,OAAO,CAAC,MAAM,CAAC,UAAU,CAAuB;WAEnC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IASxC,MAAM,CAAC,gBAAgB,IAAI,SAAS;WAMvB,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC;WAM/B,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;WAOrD,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;WAItD,mBAAmB,CAC9B,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;WAO3B,WAAW,CACtB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;WAY3B,YAAY,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;WAQ1D,eAAe,IAAI,OAAO,CAAC,qBAAqB,EAAE,CAAC;WAuBnD,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAM3D"}
@@ -0,0 +1,82 @@
1
+ import fs from 'fs-extra';
2
+ import path from 'path';
3
+ import { DEFAULT_CONFIG_PATH, DEFAULT_INSTANCE_PATH, DEFAULT_CONFIG_FILE, } from '@olane/o-core';
4
+ export const CONFIG_FILE_NAME = 'config.json';
5
+ export class ConfigManager {
6
+ static async initialize() {
7
+ await fs.ensureDir(ConfigManager.configPath);
8
+ await fs.ensureDir(ConfigManager.instancesPath);
9
+ if (!(await fs.pathExists(ConfigManager.configFile))) {
10
+ await this.writeConfig(this.getDefaultConfig());
11
+ }
12
+ }
13
+ static getDefaultConfig() {
14
+ return {
15
+ instancesPath: ConfigManager.instancesPath,
16
+ };
17
+ }
18
+ static async getConfig() {
19
+ await this.initialize();
20
+ const config = await fs.readJson(ConfigManager.configFile);
21
+ return { ...this.getDefaultConfig(), ...config };
22
+ }
23
+ static async saveConfig(config) {
24
+ await this.initialize();
25
+ const currentConfig = await this.getConfig();
26
+ const newConfig = { ...currentConfig, ...config };
27
+ await this.writeConfig(newConfig);
28
+ }
29
+ static async writeConfig(config) {
30
+ await fs.writeJson(ConfigManager.configFile, config, { spaces: 2 });
31
+ }
32
+ static async getOSConfigFromPath(path) {
33
+ if (await fs.pathExists(path)) {
34
+ return await fs.readJson(path);
35
+ }
36
+ return null;
37
+ }
38
+ static async getOSConfig(name) {
39
+ const configPath = path.join(ConfigManager.instancesPath, name, CONFIG_FILE_NAME);
40
+ if (await fs.pathExists(configPath)) {
41
+ return await fs.readJson(configPath);
42
+ }
43
+ return null;
44
+ }
45
+ static async saveOSConfig(config) {
46
+ const osPath = path.join(ConfigManager.instancesPath, config.name);
47
+ await fs.ensureDir(osPath);
48
+ await fs.writeJson(path.join(osPath, CONFIG_FILE_NAME), config, {
49
+ spaces: 2,
50
+ });
51
+ }
52
+ static async listOSInstances() {
53
+ try {
54
+ await this.initialize();
55
+ const osInstances = [];
56
+ const osInstanceNames = await fs.readdir(ConfigManager.instancesPath);
57
+ for (const osInstanceName of osInstanceNames) {
58
+ const config = await this.getOSConfig(osInstanceName);
59
+ if (config) {
60
+ osInstances.push(config);
61
+ }
62
+ }
63
+ return osInstances;
64
+ }
65
+ catch (error) {
66
+ // if the default path for config does not exist, return an empty array
67
+ if (error instanceof Error && error.message.includes('ENOENT')) {
68
+ return [];
69
+ }
70
+ throw error;
71
+ }
72
+ }
73
+ static async deleteOSInstance(name) {
74
+ const osInstancePath = path.join(ConfigManager.instancesPath, name);
75
+ if (await fs.pathExists(osInstancePath)) {
76
+ await fs.remove(osInstancePath);
77
+ }
78
+ }
79
+ }
80
+ ConfigManager.configPath = DEFAULT_CONFIG_PATH;
81
+ ConfigManager.instancesPath = DEFAULT_INSTANCE_PATH;
82
+ ConfigManager.configFile = DEFAULT_CONFIG_FILE;
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=basic-usage.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"basic-usage.spec.d.ts","sourceRoot":"","sources":["../../../test/basic/basic-usage.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ // import { oAddress, NodeState } from '@olane/o-core';
3
+ // import { expect } from 'chai';
4
+ // import dotenv from 'dotenv';
5
+ // import { defaultOSInstance } from '../utils/os.default.js';
6
+ // import { OlaneOSSystemStatus } from '../../src/o-olane-os/enum/o-os.status-enum.js';
7
+ // dotenv.config();
8
+ // const network = defaultOSInstance;
9
+ // describe('basic-usage @initialize', async () => {
10
+ // it('should be able to startup the network', async () => {
11
+ // await network.start();
12
+ // expect(network.status).to.equal(OlaneOSSystemStatus.RUNNING);
13
+ // });
14
+ // // disabled for now, to avoid unecessary indexing costs
15
+ // // it('should be able to index the network', async () => {
16
+ // // const entryNode = network.entryNode();
17
+ // // expect(entryNode).to.exist;
18
+ // // expect(entryNode.state).to.equal(NodeState.RUNNING);
19
+ // // const response = await entryNode.use(new oAddress('o://leader'), {
20
+ // // method: 'index_network',
21
+ // // params: {},
22
+ // // });
23
+ // // const data = response.result.data;
24
+ // // expect(data).to.exist;
25
+ // // expect(data.error).to.be.undefined;
26
+ // // expect(data.message).to.equal('Network indexed!');
27
+ // // });
28
+ // it('should be able to use olane remote services', async () => {
29
+ // const entryNode = network.entryNode();
30
+ // expect(entryNode).to.exist;
31
+ // expect(entryNode.state).to.equal(NodeState.RUNNING);
32
+ // // configure the intelligence tool
33
+ // // await entryNode.use(new oAddress('o://intelligence'), {
34
+ // // method: 'configure',
35
+ // // params: {
36
+ // // modelProvider: 'anthropic',
37
+ // // hostingProvider: 'olane',
38
+ // // accessToken: 'test',
39
+ // // address: 'o://leader/intelligence',
40
+ // // },
41
+ // // });
42
+ // // use the intelligence tool
43
+ // const response2 = await entryNode.use(new oAddress('o://perplexity'), {
44
+ // method: 'completion',
45
+ // params: {
46
+ // model: 'sonar',
47
+ // messages: [
48
+ // {
49
+ // role: 'user',
50
+ // content: 'What is the weather in Tokyo?',
51
+ // },
52
+ // ],
53
+ // },
54
+ // });
55
+ // console.log(response2.result.data);
56
+ // });
57
+ // });
58
+ // // describe('olane network usage', async () => {
59
+ // // it('should be able to use the olane network', async () => {
60
+ // // // let's dial the other network
61
+ // // const response = await network.use(
62
+ // // new oAddress('o://leader', [
63
+ // // multiaddr('/dns4/leader.olane.com/tcp/4000/tls/ws'),
64
+ // // ]),
65
+ // // {
66
+ // // method: 'intent',
67
+ // // params: {
68
+ // // intent: 'What can I do?',
69
+ // // },
70
+ // // },
71
+ // // );
72
+ // // console.log(response.result.data);
73
+ // // });
74
+ // // });
75
+ // // describe('external-networks', async () => {
76
+ // // it('should be able to use an external network', async () => {
77
+ // // const network2 = new oNetwork({
78
+ // // // configFilePath: path.join(os.homedir(), '.olane', 'config.json'),
79
+ // // nodes: [
80
+ // // {
81
+ // // type: NodeType.LEADER,
82
+ // // address: new oAddress('o://leader'),
83
+ // // leader: null,
84
+ // // parent: null,
85
+ // // },
86
+ // // {
87
+ // // type: NodeType.NODE,
88
+ // // address: new oAddress('o://node2'),
89
+ // // leader: null,
90
+ // // parent: null,
91
+ // // },
92
+ // // ],
93
+ // // plans: [],
94
+ // // noIndexNetwork: true,
95
+ // // });
96
+ // // await network2.start();
97
+ // // expect(network2.status).to.equal(NetworkStatus.RUNNING);
98
+ // // // let's dial the other network
99
+ // // await network2.use(
100
+ // // new oAddress('o://leader', [
101
+ // // ...(network?.rootLeader?.address.libp2pTransports || []),
102
+ // // ]),
103
+ // // {
104
+ // // method: 'index_network',
105
+ // // params: {},
106
+ // // },
107
+ // // );
108
+ // // });
109
+ // // });
110
+ // describe('basic-usage @stop-network', async () => {
111
+ // it('should be able to stop the network', async () => {
112
+ // await network.stop();
113
+ // expect(network.status).to.equal(OlaneOSSystemStatus.STOPPED);
114
+ // });
115
+ // });
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=resolvers.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolvers.spec.d.ts","sourceRoot":"","sources":["../../../test/basic/resolvers.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ // import { oAddress, NodeState } from '@olane/o-core';
3
+ // import { expect } from 'chai';
4
+ // import dotenv from 'dotenv';
5
+ // import { defaultOSInstance } from '../utils/os.default.js';
6
+ // import { OlaneOSSystemStatus } from '../../src/o-olane-os/enum/o-os.status-enum.js';
7
+ // dotenv.config();
8
+ // const network = defaultOSInstance;
9
+ // describe('basic-usage @initialize', async () => {
10
+ // it('should be able to startup the network', async () => {
11
+ // await network.start();
12
+ // expect(network.status).to.equal(OlaneOSSystemStatus.RUNNING);
13
+ // });
14
+ // it('should be able to handshake with a method address', async () => {
15
+ // const entryNode = network.entryNode();
16
+ // expect(entryNode).to.exist;
17
+ // expect(entryNode.state).to.equal(NodeState.RUNNING);
18
+ // // configure the intelligence tool
19
+ // const response = await entryNode.use(
20
+ // new oAddress('o://leader/node/mcp/validate_url'),
21
+ // {
22
+ // method: 'handshake',
23
+ // params: {
24
+ // intent: 'Validate the URL of an MCP server',
25
+ // },
26
+ // },
27
+ // );
28
+ // console.log(response.result.data);
29
+ // });
30
+ // });
31
+ // describe('basic-usage @stop-network', async () => {
32
+ // it('should be able to stop the network', async () => {
33
+ // await network.stop();
34
+ // expect(network.status).to.equal(OlaneOSSystemStatus.STOPPED);
35
+ // });
36
+ // });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=benchmark.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"benchmark.spec.d.ts","sourceRoot":"","sources":["../../../test/benchmarks/benchmark.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,65 @@
1
+ import dotenv from 'dotenv';
2
+ import { expect } from 'chai';
3
+ import { defaultOSInstance } from '../utils/os.default.js';
4
+ import { OlaneOSSystemStatus } from '../../src/o-olane-os/enum/o-os.status-enum.js';
5
+ import { oAddress } from '@olane/o-core';
6
+ import { GITHUB_TEST_CASES } from './github/github.test-cases.js';
7
+ dotenv.config();
8
+ const olaneOSInstance = defaultOSInstance;
9
+ describe('basic-usage @initialize', async () => {
10
+ it('should be able to startup the OS instance', async () => {
11
+ await olaneOSInstance.start();
12
+ expect(olaneOSInstance.status).to.equal(OlaneOSSystemStatus.RUNNING);
13
+ });
14
+ });
15
+ // describe('intelligence @configure-intelligence', async () => {
16
+ // it('should be able to set the intelligence preference to ollama', async () => {
17
+ // await network.use(new oAddress('o://memory'), {
18
+ // method: 'put',
19
+ // params: {
20
+ // key: 'intelligence-preference',
21
+ // value: 'o://ollama',
22
+ // },
23
+ // });
24
+ // });
25
+ // });
26
+ describe('o-mcp github-benchmarks', () => {
27
+ // it('should be able to create a branch', async () => {
28
+ // const response = await network.use(new oAddress('o://leader'), {
29
+ // method: 'intent',
30
+ // params: {
31
+ // intent: `Create a branch called "test-branch" in the repo "travel-planner-app"`,
32
+ // },
33
+ // });
34
+ // console.log(response.result.data);
35
+ // }, 300_000);
36
+ it('should be able to test github benchmarks', async () => {
37
+ const response = await olaneOSInstance.use(oAddress.leader(), {
38
+ method: 'intent',
39
+ params: {
40
+ intent: `Add the MCP server https://api.githubcopilot.com/mcp/ use the headers "Authorization: Bearer ${process.env.GITHUB_API_KEY}"`,
41
+ },
42
+ });
43
+ console.log('Setup MCP server response:');
44
+ console.log(response.result.data);
45
+ for (const testCase of GITHUB_TEST_CASES) {
46
+ console.log(testCase.input);
47
+ const handshakeResponse = await olaneOSInstance.use(oAddress.leader(), {
48
+ method: 'intent',
49
+ params: {
50
+ intent: testCase.input,
51
+ },
52
+ });
53
+ console.log(`Finished with ${handshakeResponse.result.data.cycles} cycles`);
54
+ console.log(handshakeResponse.result.data);
55
+ // const result = await testCase.output;
56
+ // expect(result).to.contain(testCase.output.contains);
57
+ }
58
+ }, 300000);
59
+ });
60
+ describe('basic-usage @stop-network', async () => {
61
+ it('should be able to stop the network', async () => {
62
+ await olaneOSInstance.stop();
63
+ expect(olaneOSInstance.status).to.equal(OlaneOSSystemStatus.STOPPED);
64
+ });
65
+ });
@@ -0,0 +1,3 @@
1
+ import { TestCase } from '../interfaces/test-case.interface';
2
+ export declare const GITHUB_TEST_CASES: TestCase[];
3
+ //# sourceMappingURL=github.test-cases.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github.test-cases.d.ts","sourceRoot":"","sources":["../../../../test/benchmarks/github/github.test-cases.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAE7D,eAAO,MAAM,iBAAiB,EAAE,QAAQ,EAgPvC,CAAC"}