@olane/os 0.7.12-alpha.6 → 0.7.12-alpha.60

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 (66) hide show
  1. package/dist/src/o-olane-os/config/default.config.js +1 -1
  2. package/dist/src/o-olane-os/o-os.d.ts +1 -1
  3. package/dist/src/o-olane-os/o-os.d.ts.map +1 -1
  4. package/dist/src/o-olane-os/o-os.js +1 -2
  5. package/dist/src/utils/config.d.ts.map +1 -1
  6. package/dist/src/utils/config.js +2 -2
  7. package/dist/test/basic/basic-usage.spec.d.ts +0 -1
  8. package/dist/test/basic/basic-usage.spec.js +137 -107
  9. package/dist/test/basic/playground.spec.d.ts +2 -0
  10. package/dist/test/basic/playground.spec.d.ts.map +1 -0
  11. package/dist/test/basic/playground.spec.js +108 -0
  12. package/dist/test/capabilities/base-capability.spec.d.ts +2 -0
  13. package/dist/test/capabilities/base-capability.spec.d.ts.map +1 -0
  14. package/dist/test/capabilities/base-capability.spec.js +174 -0
  15. package/dist/test/capabilities/capability-errors.spec.d.ts +2 -0
  16. package/dist/test/capabilities/capability-errors.spec.d.ts.map +1 -0
  17. package/dist/test/capabilities/capability-errors.spec.js +340 -0
  18. package/dist/test/capabilities/capability-integration.spec.d.ts +2 -0
  19. package/dist/test/capabilities/capability-integration.spec.d.ts.map +1 -0
  20. package/dist/test/capabilities/capability-integration.spec.js +463 -0
  21. package/dist/test/capabilities/capability-registry.spec.d.ts +2 -0
  22. package/dist/test/capabilities/capability-registry.spec.d.ts.map +1 -0
  23. package/dist/test/capabilities/capability-registry.spec.js +261 -0
  24. package/dist/test/capabilities/configure-capability.spec.d.ts +2 -0
  25. package/dist/test/capabilities/configure-capability.spec.d.ts.map +1 -0
  26. package/dist/test/capabilities/configure-capability.spec.js +366 -0
  27. package/dist/test/capabilities/evaluate-capability.spec.d.ts +2 -0
  28. package/dist/test/capabilities/evaluate-capability.spec.d.ts.map +1 -0
  29. package/dist/test/capabilities/evaluate-capability.spec.js +323 -0
  30. package/dist/test/capabilities/intelligence-capability.spec.d.ts +2 -0
  31. package/dist/test/capabilities/intelligence-capability.spec.d.ts.map +1 -0
  32. package/dist/test/capabilities/intelligence-capability.spec.js +171 -0
  33. package/dist/test/capabilities/multiple-step-capability.spec.d.ts +2 -0
  34. package/dist/test/capabilities/multiple-step-capability.spec.d.ts.map +1 -0
  35. package/dist/test/capabilities/multiple-step-capability.spec.js +441 -0
  36. package/dist/test/capabilities/search-capability.spec.d.ts +2 -0
  37. package/dist/test/capabilities/search-capability.spec.d.ts.map +1 -0
  38. package/dist/test/capabilities/search-capability.spec.js +337 -0
  39. package/dist/test/capabilities/task-capability.spec.d.ts +2 -0
  40. package/dist/test/capabilities/task-capability.spec.d.ts.map +1 -0
  41. package/dist/test/capabilities/task-capability.spec.js +335 -0
  42. package/dist/test/capabilities/utils/capability-test-utils.d.ts +68 -0
  43. package/dist/test/capabilities/utils/capability-test-utils.d.ts.map +1 -0
  44. package/dist/test/capabilities/utils/capability-test-utils.js +161 -0
  45. package/dist/test/utils/tmp.node.d.ts +3 -0
  46. package/dist/test/utils/tmp.node.d.ts.map +1 -0
  47. package/dist/test/utils/tmp.node.js +8 -0
  48. package/package.json +15 -12
  49. package/dist/src/network/config/default.config.d.ts +0 -3
  50. package/dist/src/network/config/default.config.d.ts.map +0 -1
  51. package/dist/src/network/config/default.config.js +0 -32
  52. package/dist/src/network/index.d.ts +0 -5
  53. package/dist/src/network/index.d.ts.map +0 -1
  54. package/dist/src/network/index.js +0 -4
  55. package/dist/src/network/interfaces/network-status.enum.d.ts +0 -7
  56. package/dist/src/network/interfaces/network-status.enum.d.ts.map +0 -1
  57. package/dist/src/network/interfaces/network-status.enum.js +0 -7
  58. package/dist/src/network/interfaces/network.interface.d.ts +0 -18
  59. package/dist/src/network/interfaces/network.interface.d.ts.map +0 -1
  60. package/dist/src/network/interfaces/network.interface.js +0 -1
  61. package/dist/src/network/o-network.d.ts +0 -34
  62. package/dist/src/network/o-network.d.ts.map +0 -1
  63. package/dist/src/network/o-network.js +0 -247
  64. package/dist/test/utils/default.network.d.ts +0 -3
  65. package/dist/test/utils/default.network.d.ts.map +0 -1
  66. package/dist/test/utils/default.network.js +0 -33
@@ -1,5 +1,5 @@
1
1
  import { DEFAULT_INSTANCE_PATH, NodeType, oAddress } from '@olane/o-core';
2
- import path from 'path';
2
+ import * as path from 'path';
3
3
  export const defaultOSInstanceConfig = (port) => {
4
4
  return {
5
5
  configFilePath: path.join(DEFAULT_INSTANCE_PATH, 'my-olane-os', 'config.json'),
@@ -20,7 +20,7 @@ export declare class OlaneOS extends oObject {
20
20
  getOSInstanceName(): Promise<string | undefined>;
21
21
  startNodes(type: NodeType): Promise<void>;
22
22
  runSavedPlans(): Promise<void>;
23
- use(oAddress: oAddress, params: any): Promise<any>;
23
+ use(oAddress: oAddress, params: any): Promise<import("@olane/o-core").oResponse>;
24
24
  start(): Promise<{
25
25
  peerId: string;
26
26
  transports: oTransport[];
@@ -1 +1 @@
1
- {"version":3,"file":"o-os.d.ts","sourceRoot":"","sources":["../../../src/o-olane-os/o-os.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG5D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAU,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAIzC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAK1C,KAAK,WAAW,GAAG,SAAS,GAAG,WAAW,CAAC;AAC3C,qBAAa,OAAQ,SAAQ,OAAO;IAClC,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,KAAK,CAAqB;IAC3B,UAAU,EAAE,WAAW,GAAG,IAAI,CAAQ;IACtC,MAAM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Aa;IAKjC,SAAS,IAAI,SAAS,GAAG,WAAW;IAMpC,SAAS,CAAC,MAAM,EAAE,WAAW;IAOvB,OAAO,CAAC,IAAI,EAAE,WAAW;YAiBjB,UAAU;IAwClB,iBAAiB;IASjB,UAAU,CAAC,IAAI,EAAE,QAAQ;IAmDzB,aAAa;IA6Bb,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG;IASnC,KAAK,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,UAAU,EAAE,CAAA;KAAE,CAAC;IAiC9D,IAAI;IAwBJ,OAAO;CAKd"}
@@ -1,5 +1,5 @@
1
1
  import { OlaneOSSystemStatus } from './enum/o-os.status-enum.js';
2
- import touch from 'touch';
2
+ import * as touch from 'touch';
3
3
  import { readFile } from 'fs/promises';
4
4
  import { oLeaderNode } from '@olane/o-leader';
5
5
  import { oAddress, oObject } from '@olane/o-core';
@@ -163,7 +163,6 @@ export class OlaneOS extends oObject {
163
163
  if (!entryNode) {
164
164
  throw new Error('Entry node not found');
165
165
  }
166
- this.logger.debug('Using address: ' + oAddress.toString());
167
166
  const result = await entryNode.use(oAddress, params);
168
167
  return result;
169
168
  }
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/utils/config.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,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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;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,cAAc,CACzB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;WAQ3B,YAAY,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;WAS1D,eAAe,IAAI,OAAO,CAAC,qBAAqB,EAAE,CAAC;WAuBnD,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAM3D"}
@@ -1,5 +1,5 @@
1
- import fs from 'fs-extra';
2
- import path from 'path';
1
+ import * as fs from 'fs-extra';
2
+ import * as path from 'path';
3
3
  import { DEFAULT_CONFIG_PATH, DEFAULT_INSTANCE_PATH, DEFAULT_CONFIG_FILE, } from '@olane/o-core';
4
4
  export const CONFIG_FILE_NAME = 'config.json';
5
5
  export class ConfigManager {
@@ -1,2 +1 @@
1
- export {};
2
1
  //# sourceMappingURL=basic-usage.spec.d.ts.map
@@ -1,118 +1,148 @@
1
- import { NodeState } from '@olane/o-core';
2
- import { expect } from 'chai';
3
- import dotenv from 'dotenv';
4
- import { defaultOSInstance } from '../utils/os.default.js';
5
- import { OlaneOSSystemStatus } from '../../src/o-olane-os/enum/o-os.status-enum.js';
6
- import { oNodeAddress, oNodeTransport } from '@olane/o-node';
7
- import { multiaddr } from '@olane/o-config';
8
- dotenv.config();
9
- const network = defaultOSInstance;
10
- describe('basic-usage @initialize', async () => {
11
- it('should be able to startup the network', async () => {
12
- await network.start();
13
- expect(network.status).to.equal(OlaneOSSystemStatus.RUNNING);
14
- });
15
- // disabled for now, to avoid unecessary indexing costs
16
- // it('should be able to index the network', async () => {
17
- // const entryNode = network.entryNode();
18
- // expect(entryNode).to.exist;
19
- // expect(entryNode.state).to.equal(NodeState.RUNNING);
20
- // const response = await entryNode.use(new oAddress('o://leader'), {
21
- // method: 'index_network',
22
- // params: {},
23
- // });
24
- // const data = response.result.data;
25
- // expect(data).to.exist;
26
- // expect(data.error).to.be.undefined;
27
- // expect(data.message).to.equal('Network indexed!');
28
- // });
29
- it('should be able to use olane remote services', async () => {
30
- const entryNode = network.entryNode();
31
- expect(entryNode).to.exist;
32
- expect(entryNode.state).to.equal(NodeState.RUNNING);
33
- // configure the intelligence tool
34
- // await entryNode.use(new oAddress('o://intelligence'), {
35
- // method: 'configure',
36
- // params: {
37
- // modelProvider: 'anthropic',
38
- // hostingProvider: 'olane',
39
- // accessToken: 'test',
40
- // address: 'o://leader/intelligence',
41
- // },
42
- // });
43
- // use the intelligence tool
44
- const response2 = await entryNode.use(new oNodeAddress('o://perplexity', [
45
- new oNodeTransport(multiaddr('/ip4/127.0.0.1/tcp/4000/ws/p2p/12D3KooWPHdsHhEdyBd9DS2zHJ1vRSyqSkZ97iT7F8ByYJ7U7bw8')),
46
- ]), {
47
- method: 'completion',
48
- params: {
49
- model: 'sonar',
50
- messages: [
51
- {
52
- role: 'user',
53
- content: 'What is the weather in Tokyo?',
54
- },
55
- ],
56
- },
57
- });
58
- console.log(response2.result.data);
59
- });
60
- });
61
- // describe('olane network usage', async () => {
62
- // it('should be able to use the olane network', async () => {
63
- // // let's dial the other network
64
- // const response = await network.use(
65
- // new oAddress('o://leader', [
66
- // multiaddr('/dns4/leader.olane.com/tcp/4000/tls/ws'),
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
+ // import { oNodeAddress, oNodeTransport } from '@olane/o-node';
8
+ // import { multiaddr } from '@olane/o-config';
9
+ // dotenv.config();
10
+ // const network = defaultOSInstance;
11
+ // describe('basic-usage @initialize', async () => {
12
+ // it('should be able to startup the network', async () => {
13
+ // await network.start();
14
+ // expect(network.status).to.equal(OlaneOSSystemStatus.RUNNING);
15
+ // });
16
+ // // disabled for now, to avoid unecessary indexing costs
17
+ // // it('should be able to index the network', async () => {
18
+ // // const entryNode = network.entryNode();
19
+ // // expect(entryNode).to.exist;
20
+ // // expect(entryNode.state).to.equal(NodeState.RUNNING);
21
+ // // const response = await entryNode.use(new oAddress('o://leader'), {
22
+ // // method: 'index_network',
23
+ // // params: {},
24
+ // // });
25
+ // // const data = response.result.data;
26
+ // // expect(data).to.exist;
27
+ // // expect(data.error).to.be.undefined;
28
+ // // expect(data.message).to.equal('Network indexed!');
29
+ // // });
30
+ // it('should be able to use stream from a provider service', async () => {
31
+ // const entryNode = network.entryNode();
32
+ // expect(entryNode).to.exist;
33
+ // expect(entryNode.state).to.equal(NodeState.RUNNING);
34
+ // // configure the intelligence tool
35
+ // // await entryNode.use(new oAddress('o://intelligence'), {
36
+ // // method: 'configure',
37
+ // // params: {
38
+ // // modelProvider: 'anthropic',
39
+ // // hostingProvider: 'olane',
40
+ // // accessToken: 'test',
41
+ // // address: 'o://leader/intelligence',
42
+ // // },
43
+ // // });
44
+ // // console.log('Pinging relay');
45
+ // // await (entryNode.p2pNode.services as any).ping.ping(
46
+ // // multiaddr('/dns4/relay.olane.com/tcp/4000/tls/ws'),
47
+ // // );
48
+ // console.log('Pinged relay');
49
+ // // use the intelligence tool
50
+ // await entryNode.useStream(
51
+ // new oNodeAddress('o://leader', [
52
+ // new oNodeTransport(
53
+ // '/ip4/127.0.0.1/tcp/4000/ws/p2p/12D3KooWPHdsHhEdyBd9DS2zHJ1vRSyqSkZ97iT7F8ByYJ7U7bw8',
54
+ // ),
67
55
  // ]),
68
56
  // {
69
57
  // method: 'intent',
70
58
  // params: {
71
- // intent: 'What can I do?',
59
+ // _isStream: true,
60
+ // intent: 'What is the official endpoint for github mcp server?',
72
61
  // },
73
62
  // },
74
- // );
75
- // console.log(response.result.data);
76
- // });
77
- // });
78
- // describe('external-networks', async () => {
79
- // it('should be able to use an external network', async () => {
80
- // const network2 = new oNetwork({
81
- // // configFilePath: path.join(os.homedir(), '.olane', 'config.json'),
82
- // nodes: [
83
- // {
84
- // type: NodeType.LEADER,
85
- // address: new oAddress('o://leader'),
86
- // leader: null,
87
- // parent: null,
88
- // },
89
- // {
90
- // type: NodeType.NODE,
91
- // address: new oAddress('o://node2'),
92
- // leader: null,
93
- // parent: null,
94
- // },
95
- // ],
96
- // plans: [],
97
- // noIndexNetwork: true,
98
- // });
99
- // await network2.start();
100
- // expect(network2.status).to.equal(NetworkStatus.RUNNING);
101
- // // let's dial the other network
102
- // await network2.use(
103
- // new oAddress('o://leader', [
104
- // ...(network?.rootLeader?.address.libp2pTransports || []),
105
- // ]),
106
63
  // {
107
- // method: 'index_network',
108
- // params: {},
64
+ // onChunk: (chunk) => {
65
+ // console.log(
66
+ // 'Received chunk: ',
67
+ // JSON.stringify(chunk.result.data, null, 2),
68
+ // );
69
+ // },
109
70
  // },
110
71
  // );
72
+ // // await entryNode.use(
73
+ // // new oNodeAddress('o://intelligence'),
74
+ // // {
75
+ // // method: 'prompt',
76
+ // // params: {
77
+ // // _isStream: true,
78
+ // // prompt: 'What is the capital of France?',
79
+ // // },
80
+ // // },
81
+ // // {
82
+ // // isStream: true,
83
+ // // onChunk: (chunk) => {
84
+ // // console.log('FINAL Received chunk: ', JSON.stringify(chunk, null, 2));
85
+ // // },
86
+ // // },
87
+ // // );
88
+ // // await new Promise((resolve) => setTimeout(resolve, 20_000));
89
+ // });
90
+ // });
91
+ // // describe('olane network usage', async () => {
92
+ // // it('should be able to use the olane network', async () => {
93
+ // // // let's dial the other network
94
+ // // const response = await network.use(
95
+ // // new oAddress('o://leader', [
96
+ // // multiaddr('/dns4/leader.olane.com/tcp/4000/tls/ws'),
97
+ // // ]),
98
+ // // {
99
+ // // method: 'intent',
100
+ // // params: {
101
+ // // intent: 'What can I do?',
102
+ // // },
103
+ // // },
104
+ // // );
105
+ // // console.log(response.result.data);
106
+ // // });
107
+ // // });
108
+ // // describe('external-networks', async () => {
109
+ // // it('should be able to use an external network', async () => {
110
+ // // const network2 = new oNetwork({
111
+ // // // configFilePath: path.join(os.homedir(), '.olane', 'config.json'),
112
+ // // nodes: [
113
+ // // {
114
+ // // type: NodeType.LEADER,
115
+ // // address: new oAddress('o://leader'),
116
+ // // leader: null,
117
+ // // parent: null,
118
+ // // },
119
+ // // {
120
+ // // type: NodeType.NODE,
121
+ // // address: new oAddress('o://node2'),
122
+ // // leader: null,
123
+ // // parent: null,
124
+ // // },
125
+ // // ],
126
+ // // plans: [],
127
+ // // noIndexNetwork: true,
128
+ // // });
129
+ // // await network2.start();
130
+ // // expect(network2.status).to.equal(NetworkStatus.RUNNING);
131
+ // // // let's dial the other network
132
+ // // await network2.use(
133
+ // // new oAddress('o://leader', [
134
+ // // ...(network?.rootLeader?.address.libp2pTransports || []),
135
+ // // ]),
136
+ // // {
137
+ // // method: 'index_network',
138
+ // // params: {},
139
+ // // },
140
+ // // );
141
+ // // });
142
+ // // });
143
+ // describe('basic-usage @stop-network', async () => {
144
+ // it('should be able to stop the network', async () => {
145
+ // await network.stop();
146
+ // expect(network.status).to.equal(OlaneOSSystemStatus.STOPPED);
111
147
  // });
112
148
  // });
113
- describe('basic-usage @stop-network', async () => {
114
- it('should be able to stop the network', async () => {
115
- await network.stop();
116
- expect(network.status).to.equal(OlaneOSSystemStatus.STOPPED);
117
- });
118
- });
@@ -0,0 +1,2 @@
1
+ import 'dotenv/config';
2
+ //# sourceMappingURL=playground.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"playground.spec.d.ts","sourceRoot":"","sources":["../../../test/basic/playground.spec.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC"}
@@ -0,0 +1,108 @@
1
+ import 'dotenv/config';
2
+ import { NodeState } from '@olane/o-core';
3
+ import { expect } from 'chai';
4
+ import { defaultOSInstance } from '../utils/os.default.js';
5
+ import { oNodeAddress, oNodeTransport } from '@olane/o-node';
6
+ import { tmpNode } from '../utils/tmp.node.js';
7
+ const network = defaultOSInstance;
8
+ const entryNode = tmpNode;
9
+ let humanNode;
10
+ describe('playground running', async () => {
11
+ it('should be able to use stream from a provider service', async () => {
12
+ await entryNode.start();
13
+ expect(entryNode).to.exist;
14
+ expect(entryNode.state).to.equal(NodeState.RUNNING);
15
+ const leader = new oNodeAddress('o://leader', [
16
+ new oNodeTransport(
17
+ // '/dns4/leader.olane.com/tcp/4000/tls/ws',
18
+ '/ip4/127.0.0.1/tcp/4000/ws/p2p/12D3KooWPHdsHhEdyBd9DS2zHJ1vRSyqSkZ97iT7F8ByYJ7U7bw8'),
19
+ ]);
20
+ // const joinedNode = new oLimitedTool({
21
+ // address: new oNodeAddress('o://joined'),
22
+ // leader: leader,
23
+ // parent: leader,
24
+ // joinToken: 'test',
25
+ // });
26
+ // await joinedNode.start(); // should join the network
27
+ // humanNode = new oHumanLoginTool({
28
+ // address: new oNodeAddress('o://human'),
29
+ // leader: leader,
30
+ // parent: leader,
31
+ // respond: async (intent: string) => {
32
+ // return 'Request approved';
33
+ // },
34
+ // answer: async (question: string) => {
35
+ // return 'Request approved';
36
+ // },
37
+ // receiveStream: async (data: any) => {
38
+ // console.log('Received stream:', data);
39
+ // },
40
+ // });
41
+ // await humanNode.start();
42
+ const response = await entryNode.useStream(leader, {
43
+ method: 'intent',
44
+ params: {
45
+ _isStreaming: true,
46
+ intent: 'Use o://intelligence to generate the expo react native code for a new table view with example data populated',
47
+ _token: 'test',
48
+ },
49
+ }, {
50
+ abortSignal: AbortSignal.timeout(5000),
51
+ onChunk: (chunk) => {
52
+ console.log('Received chunk:', JSON.stringify(chunk.result.data, null, 2));
53
+ },
54
+ });
55
+ console.log('Response:', JSON.stringify(response, null, 2));
56
+ // const response = await entryNode.use(
57
+ // new oNodeAddress('o://leader/joined', leader.transports),
58
+ // {
59
+ // method: 'ping',
60
+ // params: {},
61
+ // },
62
+ // );
63
+ // console.log('Response:', response.result.data);
64
+ await entryNode.stop();
65
+ });
66
+ // it('should fail when action is not approved', async () => {
67
+ // const entryNode = tmpNode;
68
+ // // await entryNode.start();
69
+ // expect(entryNode).to.exist;
70
+ // expect(entryNode.state).to.equal(NodeState.RUNNING);
71
+ // console.log('Setting approval preference to deny a specific action');
72
+ // // Set a preference to deny a specific tool/method combination
73
+ // const setPreferenceResponse = await entryNode.use(
74
+ // new oNodeAddress('o://approval'),
75
+ // {
76
+ // method: 'set_preference',
77
+ // params: {
78
+ // toolMethod: 'o://storage/delete',
79
+ // preference: 'deny',
80
+ // },
81
+ // },
82
+ // );
83
+ // console.log('Set preference response:', setPreferenceResponse.result.data);
84
+ // expect(setPreferenceResponse.result.data).to.exist;
85
+ // console.log('Attempting to request approval for denied action');
86
+ // // Now request approval for the denied action
87
+ // const approvalResponse = await entryNode.use(
88
+ // new oNodeAddress('o://approval'),
89
+ // {
90
+ // method: 'request_approval',
91
+ // params: {
92
+ // toolAddress: 'o://storage',
93
+ // method: 'delete',
94
+ // params: { key: 'test-key' },
95
+ // intent: 'Testing approval denial',
96
+ // },
97
+ // },
98
+ // );
99
+ // console.log('Approval response:', approvalResponse.result.data);
100
+ // // Verify the action was denied
101
+ // expect(approvalResponse.result.data).to.exist;
102
+ // expect((approvalResponse.result.data as any).approved).to.be.false;
103
+ // expect((approvalResponse.result.data as any).decision).to.equal('deny');
104
+ // console.log('✓ Action was successfully denied by approval system');
105
+ // await entryNode.stop();
106
+ // await humanNode.stop();
107
+ // });
108
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=base-capability.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-capability.spec.d.ts","sourceRoot":"","sources":["../../../test/capabilities/base-capability.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,174 @@
1
+ import { expect } from 'chai';
2
+ import { oCapability, oCapabilityType, oCapabilityResult } from '@olane/o-lane';
3
+ import { createTestOS, createTestLaneTool, createMockCapabilityConfig } from './utils/capability-test-utils.js';
4
+ /**
5
+ * Test implementation of oCapability for testing base functionality
6
+ */
7
+ class TestCapability extends oCapability {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.runCalled = false;
11
+ this.cancelCalled = false;
12
+ this.shouldThrowError = false;
13
+ this.customResult = { data: 'test result' };
14
+ }
15
+ async run() {
16
+ this.runCalled = true;
17
+ if (this.shouldThrowError) {
18
+ throw new Error('Test error from capability');
19
+ }
20
+ return new oCapabilityResult({
21
+ type: oCapabilityType.TASK,
22
+ result: this.customResult,
23
+ humanResult: 'Test capability executed successfully'
24
+ });
25
+ }
26
+ cancel() {
27
+ this.cancelCalled = true;
28
+ }
29
+ get type() {
30
+ return oCapabilityType.TASK;
31
+ }
32
+ static get type() {
33
+ return oCapabilityType.TASK;
34
+ }
35
+ }
36
+ describe('oCapability Base Class @capability @base', () => {
37
+ let os;
38
+ let laneTool;
39
+ let testCapability;
40
+ before(async () => {
41
+ os = await createTestOS();
42
+ laneTool = await createTestLaneTool(os);
43
+ });
44
+ after(async () => {
45
+ if (laneTool) {
46
+ await laneTool.stop();
47
+ }
48
+ if (os) {
49
+ await os.stop();
50
+ }
51
+ });
52
+ beforeEach(() => {
53
+ testCapability = new TestCapability();
54
+ });
55
+ describe('execute() method', () => {
56
+ it('should execute the capability and call run()', async () => {
57
+ const config = createMockCapabilityConfig(laneTool, 'Test intent');
58
+ const result = await testCapability.execute(config);
59
+ expect(testCapability.runCalled).to.be.true;
60
+ expect(result).to.exist;
61
+ expect(result.type).to.equal(oCapabilityType.TASK);
62
+ });
63
+ it('should store the config in the capability', async () => {
64
+ const config = createMockCapabilityConfig(laneTool, 'Test intent');
65
+ await testCapability.execute(config);
66
+ expect(testCapability.config).to.equal(config);
67
+ });
68
+ it('should return the result from run()', async () => {
69
+ const config = createMockCapabilityConfig(laneTool, 'Test intent');
70
+ testCapability.customResult = { custom: 'data', value: 123 };
71
+ const result = await testCapability.execute(config);
72
+ expect(result.result).to.deep.equal({ custom: 'data', value: 123 });
73
+ expect(result.humanResult).to.equal('Test capability executed successfully');
74
+ });
75
+ it('should propagate errors from run()', async () => {
76
+ const config = createMockCapabilityConfig(laneTool, 'Test intent');
77
+ testCapability.shouldThrowError = true;
78
+ try {
79
+ await testCapability.execute(config);
80
+ expect.fail('Should have thrown an error');
81
+ }
82
+ catch (error) {
83
+ expect(error.message).to.equal('Test error from capability');
84
+ }
85
+ });
86
+ });
87
+ describe('getter methods', () => {
88
+ it('should provide access to node via getter', async () => {
89
+ const config = createMockCapabilityConfig(laneTool, 'Test intent');
90
+ await testCapability.execute(config);
91
+ expect(testCapability.node).to.equal(laneTool);
92
+ });
93
+ it('should provide access to intent via getter', async () => {
94
+ const config = createMockCapabilityConfig(laneTool, 'Test intent with params', { param1: 'value1' });
95
+ await testCapability.execute(config);
96
+ expect(testCapability.intent).to.exist;
97
+ expect(testCapability.intent.value).to.equal('Test intent with params');
98
+ expect(testCapability.config.params).to.deep.equal({ param1: 'value1' });
99
+ });
100
+ it('should provide access to type via instance getter', () => {
101
+ expect(testCapability.type).to.equal(oCapabilityType.TASK);
102
+ });
103
+ it('should provide access to type via static getter', () => {
104
+ expect(TestCapability.type).to.equal(oCapabilityType.TASK);
105
+ });
106
+ });
107
+ describe('cancel() method', () => {
108
+ it('should call cancel on the capability', async () => {
109
+ const config = createMockCapabilityConfig(laneTool, 'Test intent');
110
+ await testCapability.execute(config);
111
+ testCapability.cancel();
112
+ expect(testCapability.cancelCalled).to.be.true;
113
+ });
114
+ it('should be callable before execution', () => {
115
+ testCapability.cancel();
116
+ expect(testCapability.cancelCalled).to.be.true;
117
+ });
118
+ });
119
+ describe('config handling', () => {
120
+ it('should handle config with streaming enabled', async () => {
121
+ const chunks = [];
122
+ const config = createMockCapabilityConfig(laneTool, 'Test intent', {}, {
123
+ useStream: true,
124
+ onChunk: (chunk) => chunks.push(chunk)
125
+ });
126
+ await testCapability.execute(config);
127
+ expect(testCapability.config.useStream).to.be.true;
128
+ expect(testCapability.config.onChunk).to.be.a('function');
129
+ });
130
+ it('should handle config with replay flag', async () => {
131
+ const config = createMockCapabilityConfig(laneTool, 'Test intent', {}, { isReplay: true });
132
+ await testCapability.execute(config);
133
+ expect(testCapability.config.isReplay).to.be.true;
134
+ });
135
+ it('should handle config with history', async () => {
136
+ const config = createMockCapabilityConfig(laneTool, 'Test intent');
137
+ config.history = 'Previous execution context';
138
+ await testCapability.execute(config);
139
+ expect(testCapability.config.history).to.equal('Previous execution context');
140
+ });
141
+ it('should handle config with custom params', async () => {
142
+ const customParams = {
143
+ toolAddress: 'o://test-tool',
144
+ method: 'testMethod',
145
+ methodParams: { arg1: 'value1', arg2: 123 }
146
+ };
147
+ const config = createMockCapabilityConfig(laneTool, 'Test intent', customParams);
148
+ await testCapability.execute(config);
149
+ expect(testCapability.config.params).to.deep.equal(customParams);
150
+ });
151
+ });
152
+ describe('lifecycle', () => {
153
+ it('should be able to execute multiple times', async () => {
154
+ const config1 = createMockCapabilityConfig(laneTool, 'First intent');
155
+ const config2 = createMockCapabilityConfig(laneTool, 'Second intent');
156
+ const result1 = await testCapability.execute(config1);
157
+ testCapability.runCalled = false; // Reset flag
158
+ const result2 = await testCapability.execute(config2);
159
+ expect(result1).to.exist;
160
+ expect(result2).to.exist;
161
+ expect(testCapability.config).to.equal(config2);
162
+ });
163
+ it('should allow cancellation between executions', async () => {
164
+ const config1 = createMockCapabilityConfig(laneTool, 'First intent');
165
+ await testCapability.execute(config1);
166
+ testCapability.cancel();
167
+ expect(testCapability.cancelCalled).to.be.true;
168
+ testCapability.cancelCalled = false;
169
+ const config2 = createMockCapabilityConfig(laneTool, 'Second intent');
170
+ await testCapability.execute(config2);
171
+ expect(testCapability.runCalled).to.be.true;
172
+ });
173
+ });
174
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=capability-errors.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability-errors.spec.d.ts","sourceRoot":"","sources":["../../../test/capabilities/capability-errors.spec.ts"],"names":[],"mappings":""}