@olane/os 0.7.12-alpha.9 → 0.7.13-alpha.0
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/o-olane-os/config/default.config.js +1 -1
- package/dist/src/o-olane-os/o-os.d.ts +1 -1
- package/dist/src/o-olane-os/o-os.d.ts.map +1 -1
- package/dist/src/o-olane-os/o-os.js +7 -5
- package/dist/src/utils/config.d.ts.map +1 -1
- package/dist/src/utils/config.js +2 -2
- package/dist/test/basic/basic-usage.spec.d.ts +0 -1
- package/dist/test/basic/basic-usage.spec.js +137 -107
- package/dist/test/basic/playground.spec.d.ts +2 -0
- package/dist/test/basic/playground.spec.d.ts.map +1 -0
- package/dist/test/basic/playground.spec.js +110 -0
- package/dist/test/capabilities/base-capability.spec.d.ts +2 -0
- package/dist/test/capabilities/base-capability.spec.d.ts.map +1 -0
- package/dist/test/capabilities/base-capability.spec.js +174 -0
- package/dist/test/capabilities/capability-errors.spec.d.ts +2 -0
- package/dist/test/capabilities/capability-errors.spec.d.ts.map +1 -0
- package/dist/test/capabilities/capability-errors.spec.js +340 -0
- package/dist/test/capabilities/capability-integration.spec.d.ts +2 -0
- package/dist/test/capabilities/capability-integration.spec.d.ts.map +1 -0
- package/dist/test/capabilities/capability-integration.spec.js +463 -0
- package/dist/test/capabilities/capability-registry.spec.d.ts +2 -0
- package/dist/test/capabilities/capability-registry.spec.d.ts.map +1 -0
- package/dist/test/capabilities/capability-registry.spec.js +261 -0
- package/dist/test/capabilities/configure-capability.spec.d.ts +2 -0
- package/dist/test/capabilities/configure-capability.spec.d.ts.map +1 -0
- package/dist/test/capabilities/configure-capability.spec.js +366 -0
- package/dist/test/capabilities/evaluate-capability.spec.d.ts +2 -0
- package/dist/test/capabilities/evaluate-capability.spec.d.ts.map +1 -0
- package/dist/test/capabilities/evaluate-capability.spec.js +323 -0
- package/dist/test/capabilities/intelligence-capability.spec.d.ts +2 -0
- package/dist/test/capabilities/intelligence-capability.spec.d.ts.map +1 -0
- package/dist/test/capabilities/intelligence-capability.spec.js +171 -0
- package/dist/test/capabilities/multiple-step-capability.spec.d.ts +2 -0
- package/dist/test/capabilities/multiple-step-capability.spec.d.ts.map +1 -0
- package/dist/test/capabilities/multiple-step-capability.spec.js +441 -0
- package/dist/test/capabilities/search-capability.spec.d.ts +2 -0
- package/dist/test/capabilities/search-capability.spec.d.ts.map +1 -0
- package/dist/test/capabilities/search-capability.spec.js +337 -0
- package/dist/test/capabilities/task-capability.spec.d.ts +2 -0
- package/dist/test/capabilities/task-capability.spec.d.ts.map +1 -0
- package/dist/test/capabilities/task-capability.spec.js +335 -0
- package/dist/test/capabilities/utils/capability-test-utils.d.ts +68 -0
- package/dist/test/capabilities/utils/capability-test-utils.d.ts.map +1 -0
- package/dist/test/capabilities/utils/capability-test-utils.js +161 -0
- package/dist/test/utils/tmp.node.d.ts +3 -0
- package/dist/test/utils/tmp.node.d.ts.map +1 -0
- package/dist/test/utils/tmp.node.js +8 -0
- package/package.json +15 -12
- package/dist/src/network/config/default.config.d.ts +0 -3
- package/dist/src/network/config/default.config.d.ts.map +0 -1
- package/dist/src/network/config/default.config.js +0 -32
- package/dist/src/network/index.d.ts +0 -5
- package/dist/src/network/index.d.ts.map +0 -1
- package/dist/src/network/index.js +0 -4
- package/dist/src/network/interfaces/network-status.enum.d.ts +0 -7
- package/dist/src/network/interfaces/network-status.enum.d.ts.map +0 -1
- package/dist/src/network/interfaces/network-status.enum.js +0 -7
- package/dist/src/network/interfaces/network.interface.d.ts +0 -18
- package/dist/src/network/interfaces/network.interface.d.ts.map +0 -1
- package/dist/src/network/interfaces/network.interface.js +0 -1
- package/dist/src/network/o-network.d.ts +0 -34
- package/dist/src/network/o-network.d.ts.map +0 -1
- package/dist/src/network/o-network.js +0 -247
- package/dist/test/utils/default.network.d.ts +0 -3
- package/dist/test/utils/default.network.d.ts.map +0 -1
- package/dist/test/utils/default.network.js +0 -33
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { ALL_CAPABILITIES, oCapabilityTask, oCapabilitySearch, oCapabilityEvaluate, oCapabilityMultipleStep, oCapabilityConfigure, oCapabilityType } from '@olane/o-lane';
|
|
3
|
+
describe('Capability Registry @capability @registry', () => {
|
|
4
|
+
describe('ALL_CAPABILITIES array', () => {
|
|
5
|
+
it('should export ALL_CAPABILITIES array', () => {
|
|
6
|
+
expect(ALL_CAPABILITIES).to.exist;
|
|
7
|
+
expect(ALL_CAPABILITIES).to.be.an('array');
|
|
8
|
+
});
|
|
9
|
+
it('should contain all capability classes', () => {
|
|
10
|
+
expect(ALL_CAPABILITIES.length).to.be.greaterThan(0);
|
|
11
|
+
});
|
|
12
|
+
it('should include oCapabilityTask', () => {
|
|
13
|
+
expect(ALL_CAPABILITIES).to.include(oCapabilityTask);
|
|
14
|
+
});
|
|
15
|
+
it('should include oCapabilitySearch', () => {
|
|
16
|
+
expect(ALL_CAPABILITIES).to.include(oCapabilitySearch);
|
|
17
|
+
});
|
|
18
|
+
it('should include oCapabilityEvaluate', () => {
|
|
19
|
+
expect(ALL_CAPABILITIES).to.include(oCapabilityEvaluate);
|
|
20
|
+
});
|
|
21
|
+
it('should include oCapabilityMultipleStep', () => {
|
|
22
|
+
expect(ALL_CAPABILITIES).to.include(oCapabilityMultipleStep);
|
|
23
|
+
});
|
|
24
|
+
it('should include oCapabilityConfigure', () => {
|
|
25
|
+
expect(ALL_CAPABILITIES).to.include(oCapabilityConfigure);
|
|
26
|
+
});
|
|
27
|
+
it('should have exactly 5 capabilities', () => {
|
|
28
|
+
expect(ALL_CAPABILITIES.length).to.equal(5);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
describe('Capability class registration', () => {
|
|
32
|
+
it('should allow instantiation of oCapabilityTask', () => {
|
|
33
|
+
const capability = new oCapabilityTask();
|
|
34
|
+
expect(capability).to.exist;
|
|
35
|
+
expect(capability.type).to.equal(oCapabilityType.TASK);
|
|
36
|
+
});
|
|
37
|
+
it('should allow instantiation of oCapabilitySearch', () => {
|
|
38
|
+
const capability = new oCapabilitySearch();
|
|
39
|
+
expect(capability).to.exist;
|
|
40
|
+
expect(capability.type).to.equal(oCapabilityType.SEARCH);
|
|
41
|
+
});
|
|
42
|
+
it('should allow instantiation of oCapabilityEvaluate', () => {
|
|
43
|
+
const capability = new oCapabilityEvaluate();
|
|
44
|
+
expect(capability).to.exist;
|
|
45
|
+
expect(capability.type).to.equal(oCapabilityType.EVALUATE);
|
|
46
|
+
});
|
|
47
|
+
it('should allow instantiation of oCapabilityMultipleStep', () => {
|
|
48
|
+
const capability = new oCapabilityMultipleStep();
|
|
49
|
+
expect(capability).to.exist;
|
|
50
|
+
expect(capability.type).to.equal(oCapabilityType.MULTIPLE_STEP);
|
|
51
|
+
});
|
|
52
|
+
it('should allow instantiation of oCapabilityConfigure', () => {
|
|
53
|
+
const capability = new oCapabilityConfigure();
|
|
54
|
+
expect(capability).to.exist;
|
|
55
|
+
expect(capability.type).to.equal(oCapabilityType.CONFIGURE);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
describe('Capability type mapping', () => {
|
|
59
|
+
it('should map each capability to its type', () => {
|
|
60
|
+
const typeMap = new Map([
|
|
61
|
+
[oCapabilityTask, oCapabilityType.TASK],
|
|
62
|
+
[oCapabilitySearch, oCapabilityType.SEARCH],
|
|
63
|
+
[oCapabilityEvaluate, oCapabilityType.EVALUATE],
|
|
64
|
+
[oCapabilityMultipleStep, oCapabilityType.MULTIPLE_STEP],
|
|
65
|
+
[oCapabilityConfigure, oCapabilityType.CONFIGURE]
|
|
66
|
+
]);
|
|
67
|
+
ALL_CAPABILITIES.forEach(CapabilityClass => {
|
|
68
|
+
const expectedType = typeMap.get(CapabilityClass);
|
|
69
|
+
expect(CapabilityClass.type).to.equal(expectedType);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
it('should have unique types for each capability', () => {
|
|
73
|
+
const types = ALL_CAPABILITIES.map(Cap => Cap.type);
|
|
74
|
+
const uniqueTypes = new Set(types);
|
|
75
|
+
expect(uniqueTypes.size).to.equal(ALL_CAPABILITIES.length);
|
|
76
|
+
});
|
|
77
|
+
it('should use static type getter', () => {
|
|
78
|
+
ALL_CAPABILITIES.forEach(CapabilityClass => {
|
|
79
|
+
expect(CapabilityClass.type).to.exist;
|
|
80
|
+
expect(CapabilityClass.type).to.be.a('string');
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
it('should match instance type with static type', () => {
|
|
84
|
+
ALL_CAPABILITIES.forEach(CapabilityClass => {
|
|
85
|
+
const instance = new CapabilityClass();
|
|
86
|
+
expect(instance.type).to.equal(CapabilityClass.type);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
describe('Capability type enumeration', () => {
|
|
91
|
+
it('should define TASK type', () => {
|
|
92
|
+
expect(oCapabilityType.TASK).to.exist;
|
|
93
|
+
expect(oCapabilityType.TASK).to.be.a('string');
|
|
94
|
+
});
|
|
95
|
+
it('should define SEARCH type', () => {
|
|
96
|
+
expect(oCapabilityType.SEARCH).to.exist;
|
|
97
|
+
expect(oCapabilityType.SEARCH).to.be.a('string');
|
|
98
|
+
});
|
|
99
|
+
it('should define MULTIPLE_STEP type', () => {
|
|
100
|
+
expect(oCapabilityType.MULTIPLE_STEP).to.exist;
|
|
101
|
+
expect(oCapabilityType.MULTIPLE_STEP).to.be.a('string');
|
|
102
|
+
});
|
|
103
|
+
it('should define CONFIGURE type', () => {
|
|
104
|
+
expect(oCapabilityType.CONFIGURE).to.exist;
|
|
105
|
+
expect(oCapabilityType.CONFIGURE).to.be.a('string');
|
|
106
|
+
});
|
|
107
|
+
it('should define HANDSHAKE type', () => {
|
|
108
|
+
expect(oCapabilityType.HANDSHAKE).to.exist;
|
|
109
|
+
expect(oCapabilityType.HANDSHAKE).to.be.a('string');
|
|
110
|
+
});
|
|
111
|
+
it('should define EVALUATE type', () => {
|
|
112
|
+
expect(oCapabilityType.EVALUATE).to.exist;
|
|
113
|
+
expect(oCapabilityType.EVALUATE).to.be.a('string');
|
|
114
|
+
});
|
|
115
|
+
it('should define STOP type', () => {
|
|
116
|
+
expect(oCapabilityType.STOP).to.exist;
|
|
117
|
+
expect(oCapabilityType.STOP).to.be.a('string');
|
|
118
|
+
});
|
|
119
|
+
it('should define ERROR type', () => {
|
|
120
|
+
expect(oCapabilityType.ERROR).to.exist;
|
|
121
|
+
expect(oCapabilityType.ERROR).to.be.a('string');
|
|
122
|
+
});
|
|
123
|
+
it('should define UNKNOWN type', () => {
|
|
124
|
+
expect(oCapabilityType.UNKNOWN).to.exist;
|
|
125
|
+
expect(oCapabilityType.UNKNOWN).to.be.a('string');
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
describe('Capability discovery', () => {
|
|
129
|
+
it('should find capability by type', () => {
|
|
130
|
+
const findByType = (type) => {
|
|
131
|
+
return ALL_CAPABILITIES.find(Cap => Cap.type === type);
|
|
132
|
+
};
|
|
133
|
+
const taskCap = findByType(oCapabilityType.TASK);
|
|
134
|
+
expect(taskCap).to.equal(oCapabilityTask);
|
|
135
|
+
const searchCap = findByType(oCapabilityType.SEARCH);
|
|
136
|
+
expect(searchCap).to.equal(oCapabilitySearch);
|
|
137
|
+
const evaluateCap = findByType(oCapabilityType.EVALUATE);
|
|
138
|
+
expect(evaluateCap).to.equal(oCapabilityEvaluate);
|
|
139
|
+
const multiStepCap = findByType(oCapabilityType.MULTIPLE_STEP);
|
|
140
|
+
expect(multiStepCap).to.equal(oCapabilityMultipleStep);
|
|
141
|
+
const configureCap = findByType(oCapabilityType.CONFIGURE);
|
|
142
|
+
expect(configureCap).to.equal(oCapabilityConfigure);
|
|
143
|
+
});
|
|
144
|
+
it('should return undefined for unregistered type', () => {
|
|
145
|
+
const findByType = (type) => {
|
|
146
|
+
return ALL_CAPABILITIES.find(Cap => Cap.type === type);
|
|
147
|
+
};
|
|
148
|
+
const unknownCap = findByType(oCapabilityType.HANDSHAKE);
|
|
149
|
+
expect(unknownCap).to.be.undefined;
|
|
150
|
+
});
|
|
151
|
+
it('should list all registered capability types', () => {
|
|
152
|
+
const registeredTypes = ALL_CAPABILITIES.map(Cap => Cap.type);
|
|
153
|
+
expect(registeredTypes).to.include(oCapabilityType.TASK);
|
|
154
|
+
expect(registeredTypes).to.include(oCapabilityType.SEARCH);
|
|
155
|
+
expect(registeredTypes).to.include(oCapabilityType.EVALUATE);
|
|
156
|
+
expect(registeredTypes).to.include(oCapabilityType.MULTIPLE_STEP);
|
|
157
|
+
expect(registeredTypes).to.include(oCapabilityType.CONFIGURE);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
describe('Capability order', () => {
|
|
161
|
+
it('should maintain consistent order', () => {
|
|
162
|
+
const expectedOrder = [
|
|
163
|
+
oCapabilityTask,
|
|
164
|
+
oCapabilitySearch,
|
|
165
|
+
oCapabilityEvaluate,
|
|
166
|
+
oCapabilityMultipleStep,
|
|
167
|
+
oCapabilityConfigure
|
|
168
|
+
];
|
|
169
|
+
expect(ALL_CAPABILITIES).to.deep.equal(expectedOrder);
|
|
170
|
+
});
|
|
171
|
+
it('should have TASK as first capability', () => {
|
|
172
|
+
expect(ALL_CAPABILITIES[0]).to.equal(oCapabilityTask);
|
|
173
|
+
});
|
|
174
|
+
it('should have CONFIGURE as last capability', () => {
|
|
175
|
+
expect(ALL_CAPABILITIES[ALL_CAPABILITIES.length - 1]).to.equal(oCapabilityConfigure);
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
describe('Capability interface compliance', () => {
|
|
179
|
+
it('should have execute method on all capabilities', () => {
|
|
180
|
+
ALL_CAPABILITIES.forEach(CapabilityClass => {
|
|
181
|
+
const instance = new CapabilityClass();
|
|
182
|
+
expect(instance.execute).to.be.a('function');
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
it('should have run method on all capabilities', () => {
|
|
186
|
+
ALL_CAPABILITIES.forEach(CapabilityClass => {
|
|
187
|
+
const instance = new CapabilityClass();
|
|
188
|
+
expect(instance.run).to.be.a('function');
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
it('should have type getter on all capabilities', () => {
|
|
192
|
+
ALL_CAPABILITIES.forEach(CapabilityClass => {
|
|
193
|
+
const instance = new CapabilityClass();
|
|
194
|
+
expect(instance.type).to.exist;
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
it('should have cancel method on all capabilities', () => {
|
|
198
|
+
ALL_CAPABILITIES.forEach(CapabilityClass => {
|
|
199
|
+
const instance = new CapabilityClass();
|
|
200
|
+
expect(instance.cancel).to.be.a('function');
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
describe('Capability extensibility', () => {
|
|
205
|
+
it('should allow extending capabilities array', () => {
|
|
206
|
+
const extendedCapabilities = [...ALL_CAPABILITIES];
|
|
207
|
+
expect(extendedCapabilities.length).to.equal(ALL_CAPABILITIES.length);
|
|
208
|
+
expect(extendedCapabilities).to.deep.equal(ALL_CAPABILITIES);
|
|
209
|
+
});
|
|
210
|
+
it('should allow filtering capabilities', () => {
|
|
211
|
+
const intelligenceCapabilities = ALL_CAPABILITIES.filter(CapabilityClass => {
|
|
212
|
+
const instance = new CapabilityClass();
|
|
213
|
+
return 'intelligence' in instance;
|
|
214
|
+
});
|
|
215
|
+
// Configure, Evaluate, and MultipleStep extend oCapabilityIntelligence
|
|
216
|
+
expect(intelligenceCapabilities.length).to.be.greaterThan(0);
|
|
217
|
+
});
|
|
218
|
+
it('should allow mapping capabilities', () => {
|
|
219
|
+
const capabilityInfo = ALL_CAPABILITIES.map(CapabilityClass => ({
|
|
220
|
+
type: CapabilityClass.type,
|
|
221
|
+
name: CapabilityClass.name
|
|
222
|
+
}));
|
|
223
|
+
expect(capabilityInfo.length).to.equal(ALL_CAPABILITIES.length);
|
|
224
|
+
expect(capabilityInfo[0].type).to.equal(oCapabilityType.TASK);
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
describe('Capability metadata', () => {
|
|
228
|
+
it('should have class names', () => {
|
|
229
|
+
expect(oCapabilityTask.name).to.equal('oCapabilityTask');
|
|
230
|
+
expect(oCapabilitySearch.name).to.equal('oCapabilitySearch');
|
|
231
|
+
expect(oCapabilityEvaluate.name).to.equal('oCapabilityEvaluate');
|
|
232
|
+
expect(oCapabilityMultipleStep.name).to.equal('oCapabilityMultipleStep');
|
|
233
|
+
expect(oCapabilityConfigure.name).to.equal('oCapabilityConfigure');
|
|
234
|
+
});
|
|
235
|
+
it('should be constructable', () => {
|
|
236
|
+
ALL_CAPABILITIES.forEach(CapabilityClass => {
|
|
237
|
+
expect(() => new CapabilityClass()).to.not.throw();
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
it('should have prototype methods', () => {
|
|
241
|
+
ALL_CAPABILITIES.forEach(CapabilityClass => {
|
|
242
|
+
expect(CapabilityClass.prototype.execute).to.exist;
|
|
243
|
+
expect(CapabilityClass.prototype.run).to.exist;
|
|
244
|
+
expect(CapabilityClass.prototype.cancel).to.exist;
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
describe('Registry immutability', () => {
|
|
249
|
+
it('should not modify original array when extended', () => {
|
|
250
|
+
const originalLength = ALL_CAPABILITIES.length;
|
|
251
|
+
const extended = [...ALL_CAPABILITIES, oCapabilityTask];
|
|
252
|
+
expect(ALL_CAPABILITIES.length).to.equal(originalLength);
|
|
253
|
+
expect(extended.length).to.equal(originalLength + 1);
|
|
254
|
+
});
|
|
255
|
+
it('should maintain array reference', () => {
|
|
256
|
+
const reference1 = ALL_CAPABILITIES;
|
|
257
|
+
const reference2 = ALL_CAPABILITIES;
|
|
258
|
+
expect(reference1).to.equal(reference2);
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configure-capability.spec.d.ts","sourceRoot":"","sources":["../../../test/capabilities/configure-capability.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { oCapabilityConfigure, oCapabilityType } from '@olane/o-lane';
|
|
3
|
+
import { createTestOS, createTestLaneTool, createMockCapabilityConfig } from './utils/capability-test-utils.js';
|
|
4
|
+
describe('oCapabilityConfigure @capability @configure', () => {
|
|
5
|
+
let os;
|
|
6
|
+
let laneTool;
|
|
7
|
+
let configureCapability;
|
|
8
|
+
before(async () => {
|
|
9
|
+
os = await createTestOS();
|
|
10
|
+
laneTool = await createTestLaneTool(os);
|
|
11
|
+
});
|
|
12
|
+
after(async () => {
|
|
13
|
+
if (laneTool) {
|
|
14
|
+
await laneTool.stop();
|
|
15
|
+
}
|
|
16
|
+
if (os) {
|
|
17
|
+
await os.stop();
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
configureCapability = new oCapabilityConfigure();
|
|
22
|
+
});
|
|
23
|
+
describe('type identification', () => {
|
|
24
|
+
it('should return CONFIGURE type from instance getter', () => {
|
|
25
|
+
expect(configureCapability.type).to.equal(oCapabilityType.CONFIGURE);
|
|
26
|
+
});
|
|
27
|
+
it('should return CONFIGURE type from static getter', () => {
|
|
28
|
+
expect(oCapabilityConfigure.type).to.equal(oCapabilityType.CONFIGURE);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
describe('inheritance', () => {
|
|
32
|
+
it('should extend oCapabilityIntelligence', async () => {
|
|
33
|
+
expect(configureCapability).to.respondTo('intelligence');
|
|
34
|
+
});
|
|
35
|
+
it('should have access to intelligence method', async () => {
|
|
36
|
+
const params = {
|
|
37
|
+
toolAddress: 'o://test-tool',
|
|
38
|
+
intent: 'Test intent'
|
|
39
|
+
};
|
|
40
|
+
const config = createMockCapabilityConfig(laneTool, 'Configure intent', params);
|
|
41
|
+
await configureCapability.execute(config);
|
|
42
|
+
expect(configureCapability.intelligence).to.be.a('function');
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
describe('generatePrompt() method', () => {
|
|
46
|
+
it('should generate prompt with tools and methods', async () => {
|
|
47
|
+
const params = {
|
|
48
|
+
toolAddress: 'o://test-tool',
|
|
49
|
+
intent: 'Test configuration intent'
|
|
50
|
+
};
|
|
51
|
+
const config = createMockCapabilityConfig(laneTool, 'Configure intent', params);
|
|
52
|
+
config.history = 'Previous execution history';
|
|
53
|
+
await configureCapability.execute(config);
|
|
54
|
+
const tools = ['method1', 'method2', 'method3'];
|
|
55
|
+
const methods = {
|
|
56
|
+
method1: {
|
|
57
|
+
name: 'method1',
|
|
58
|
+
description: 'First method',
|
|
59
|
+
params: {}
|
|
60
|
+
},
|
|
61
|
+
method2: {
|
|
62
|
+
name: 'method2',
|
|
63
|
+
description: 'Second method',
|
|
64
|
+
params: {}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const prompt = configureCapability.generatePrompt(tools, methods);
|
|
68
|
+
expect(prompt).to.be.a('string');
|
|
69
|
+
expect(prompt.length).to.be.greaterThan(0);
|
|
70
|
+
});
|
|
71
|
+
it('should include tool address in prompt', async () => {
|
|
72
|
+
const toolAddress = 'o://specific-test-tool';
|
|
73
|
+
const params = {
|
|
74
|
+
toolAddress,
|
|
75
|
+
intent: 'Test intent'
|
|
76
|
+
};
|
|
77
|
+
const config = createMockCapabilityConfig(laneTool, 'Configure intent', params);
|
|
78
|
+
await configureCapability.execute(config);
|
|
79
|
+
const tools = ['testMethod'];
|
|
80
|
+
const methods = {
|
|
81
|
+
testMethod: {
|
|
82
|
+
name: 'testMethod',
|
|
83
|
+
description: 'Test method',
|
|
84
|
+
params: {}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const prompt = configureCapability.generatePrompt(tools, methods);
|
|
88
|
+
expect(prompt).to.include(toolAddress);
|
|
89
|
+
});
|
|
90
|
+
it('should include user intent in prompt', async () => {
|
|
91
|
+
const userIntent = 'Configure the calculator to add two numbers';
|
|
92
|
+
const params = {
|
|
93
|
+
toolAddress: 'o://calculator',
|
|
94
|
+
intent: userIntent
|
|
95
|
+
};
|
|
96
|
+
const config = createMockCapabilityConfig(laneTool, 'Configure intent', params);
|
|
97
|
+
await configureCapability.execute(config);
|
|
98
|
+
const tools = ['add'];
|
|
99
|
+
const methods = {
|
|
100
|
+
add: {
|
|
101
|
+
name: 'add',
|
|
102
|
+
description: 'Add two numbers',
|
|
103
|
+
params: { a: 'number', b: 'number' }
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const prompt = configureCapability.generatePrompt(tools, methods);
|
|
107
|
+
expect(prompt).to.include(userIntent);
|
|
108
|
+
});
|
|
109
|
+
it('should include history in prompt', async () => {
|
|
110
|
+
const params = {
|
|
111
|
+
toolAddress: 'o://test-tool',
|
|
112
|
+
intent: 'Test intent'
|
|
113
|
+
};
|
|
114
|
+
const history = 'Previous steps:\n1. Evaluated intent\n2. Found tool';
|
|
115
|
+
const config = createMockCapabilityConfig(laneTool, 'Configure intent', params);
|
|
116
|
+
config.history = history;
|
|
117
|
+
await configureCapability.execute(config);
|
|
118
|
+
const tools = ['method1'];
|
|
119
|
+
const methods = {
|
|
120
|
+
method1: {
|
|
121
|
+
name: 'method1',
|
|
122
|
+
description: 'Method 1',
|
|
123
|
+
params: {}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const prompt = configureCapability.generatePrompt(tools, methods);
|
|
127
|
+
expect(prompt).to.be.a('string');
|
|
128
|
+
// History should be incorporated into the prompt
|
|
129
|
+
});
|
|
130
|
+
it('should handle empty tools array', async () => {
|
|
131
|
+
const params = {
|
|
132
|
+
toolAddress: 'o://test-tool',
|
|
133
|
+
intent: 'Test intent'
|
|
134
|
+
};
|
|
135
|
+
const config = createMockCapabilityConfig(laneTool, 'Configure intent', params);
|
|
136
|
+
await configureCapability.execute(config);
|
|
137
|
+
const tools = [];
|
|
138
|
+
const methods = {};
|
|
139
|
+
const prompt = configureCapability.generatePrompt(tools, methods);
|
|
140
|
+
expect(prompt).to.be.a('string');
|
|
141
|
+
expect(prompt.length).to.be.greaterThan(0);
|
|
142
|
+
});
|
|
143
|
+
it('should handle methods with complex parameters', async () => {
|
|
144
|
+
const params = {
|
|
145
|
+
toolAddress: 'o://test-tool',
|
|
146
|
+
intent: 'Test intent'
|
|
147
|
+
};
|
|
148
|
+
const config = createMockCapabilityConfig(laneTool, 'Configure intent', params);
|
|
149
|
+
await configureCapability.execute(config);
|
|
150
|
+
const tools = ['complexMethod'];
|
|
151
|
+
const methods = {
|
|
152
|
+
complexMethod: {
|
|
153
|
+
name: 'complexMethod',
|
|
154
|
+
description: 'Complex method with many params',
|
|
155
|
+
params: {
|
|
156
|
+
stringParam: 'string',
|
|
157
|
+
numberParam: 'number',
|
|
158
|
+
boolParam: 'boolean',
|
|
159
|
+
objectParam: 'object',
|
|
160
|
+
arrayParam: 'array'
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
const prompt = configureCapability.generatePrompt(tools, methods);
|
|
165
|
+
expect(prompt).to.be.a('string');
|
|
166
|
+
expect(prompt).to.include('complexMethod');
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
describe('handshake() method', () => {
|
|
170
|
+
it('should attempt handshake with tool address', async () => {
|
|
171
|
+
const params = {
|
|
172
|
+
toolAddress: 'o://test-tool',
|
|
173
|
+
intent: 'Test handshake'
|
|
174
|
+
};
|
|
175
|
+
const config = createMockCapabilityConfig(laneTool, 'Configure intent', params);
|
|
176
|
+
await configureCapability.execute(config);
|
|
177
|
+
// Handshake may fail if tool doesn't exist
|
|
178
|
+
try {
|
|
179
|
+
const result = await configureCapability.handshake();
|
|
180
|
+
expect(result).to.exist;
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
// Expected if tool is not available
|
|
184
|
+
expect(error).to.exist;
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
it('should include intent in handshake', async () => {
|
|
188
|
+
const params = {
|
|
189
|
+
toolAddress: 'o://test-tool',
|
|
190
|
+
intent: 'Handshake with specific intent'
|
|
191
|
+
};
|
|
192
|
+
const config = createMockCapabilityConfig(laneTool, 'Configure intent', params);
|
|
193
|
+
await configureCapability.execute(config);
|
|
194
|
+
try {
|
|
195
|
+
await configureCapability.handshake();
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
// Expected if tool is not available
|
|
199
|
+
// Test validates structure
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
it('should return handshake result with tools and methods', async () => {
|
|
203
|
+
const params = {
|
|
204
|
+
toolAddress: 'o://test-tool',
|
|
205
|
+
intent: 'Get tool capabilities'
|
|
206
|
+
};
|
|
207
|
+
const config = createMockCapabilityConfig(laneTool, 'Configure intent', params);
|
|
208
|
+
await configureCapability.execute(config);
|
|
209
|
+
try {
|
|
210
|
+
const result = await configureCapability.handshake();
|
|
211
|
+
if (result.result) {
|
|
212
|
+
expect(result.result).to.have.property('tools');
|
|
213
|
+
expect(result.result).to.have.property('methods');
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
// Expected if tool is not available
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
describe('run() method', () => {
|
|
222
|
+
it('should execute handshake and intelligence', async () => {
|
|
223
|
+
const params = {
|
|
224
|
+
toolAddress: 'o://test-tool',
|
|
225
|
+
intent: 'Configure tool usage'
|
|
226
|
+
};
|
|
227
|
+
const config = createMockCapabilityConfig(laneTool, 'Configure intent', params);
|
|
228
|
+
// May fail if tool or intelligence service not available
|
|
229
|
+
try {
|
|
230
|
+
const result = await configureCapability.execute(config);
|
|
231
|
+
expect(result).to.exist;
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
// Expected if services are not configured
|
|
235
|
+
expect(error).to.exist;
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
it('should handle handshake failure', async () => {
|
|
239
|
+
const params = {
|
|
240
|
+
toolAddress: 'o://nonexistent-tool',
|
|
241
|
+
intent: 'Try to configure nonexistent tool'
|
|
242
|
+
};
|
|
243
|
+
const config = createMockCapabilityConfig(laneTool, 'Configure intent', params);
|
|
244
|
+
try {
|
|
245
|
+
const result = await configureCapability.execute(config);
|
|
246
|
+
// If it doesn't throw, check for error in result
|
|
247
|
+
if (result.error) {
|
|
248
|
+
expect(result.error).to.exist;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
catch (error) {
|
|
252
|
+
// Expected
|
|
253
|
+
expect(error).to.exist;
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
it('should handle replay mode', async () => {
|
|
257
|
+
const params = {
|
|
258
|
+
toolAddress: 'o://test-tool',
|
|
259
|
+
intent: 'Replay configuration'
|
|
260
|
+
};
|
|
261
|
+
const config = createMockCapabilityConfig(laneTool, 'Configure intent', params, { isReplay: true });
|
|
262
|
+
try {
|
|
263
|
+
const result = await configureCapability.execute(config);
|
|
264
|
+
expect(result).to.exist;
|
|
265
|
+
expect(config.isReplay).to.be.true;
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
// Expected if services not available
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
describe('result structure', () => {
|
|
273
|
+
it('should return capability result', async () => {
|
|
274
|
+
const params = {
|
|
275
|
+
toolAddress: 'o://test-tool',
|
|
276
|
+
intent: 'Test result structure'
|
|
277
|
+
};
|
|
278
|
+
const config = createMockCapabilityConfig(laneTool, 'Configure intent', params);
|
|
279
|
+
try {
|
|
280
|
+
const result = await configureCapability.execute(config);
|
|
281
|
+
expect(result).to.exist;
|
|
282
|
+
expect(result).to.have.property('type');
|
|
283
|
+
}
|
|
284
|
+
catch (error) {
|
|
285
|
+
// Expected if services not available
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
it('should include config in result', async () => {
|
|
289
|
+
const params = {
|
|
290
|
+
toolAddress: 'o://test-tool',
|
|
291
|
+
intent: 'Test config inclusion'
|
|
292
|
+
};
|
|
293
|
+
const config = createMockCapabilityConfig(laneTool, 'Configure intent', params);
|
|
294
|
+
try {
|
|
295
|
+
const result = await configureCapability.execute(config);
|
|
296
|
+
if (result.config) {
|
|
297
|
+
expect(result.config).to.exist;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
catch (error) {
|
|
301
|
+
// Expected if services not available
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
describe('configuration parameters', () => {
|
|
306
|
+
it('should require toolAddress parameter', async () => {
|
|
307
|
+
const params = {
|
|
308
|
+
intent: 'Missing tool address'
|
|
309
|
+
};
|
|
310
|
+
const config = createMockCapabilityConfig(laneTool, 'Configure intent', params);
|
|
311
|
+
try {
|
|
312
|
+
await configureCapability.execute(config);
|
|
313
|
+
// If no error, validate that params are accessible
|
|
314
|
+
}
|
|
315
|
+
catch (error) {
|
|
316
|
+
// Should fail without tool address
|
|
317
|
+
expect(error).to.exist;
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
it('should use intent parameter', async () => {
|
|
321
|
+
const params = {
|
|
322
|
+
toolAddress: 'o://test-tool',
|
|
323
|
+
intent: 'Specific configuration intent'
|
|
324
|
+
};
|
|
325
|
+
const config = createMockCapabilityConfig(laneTool, 'Configure intent', params);
|
|
326
|
+
await configureCapability.execute(config);
|
|
327
|
+
expect(configureCapability.config.params.intent).to.equal('Specific configuration intent');
|
|
328
|
+
});
|
|
329
|
+
it('should handle additional parameters', async () => {
|
|
330
|
+
const params = {
|
|
331
|
+
toolAddress: 'o://test-tool',
|
|
332
|
+
intent: 'Test intent',
|
|
333
|
+
customParam1: 'value1',
|
|
334
|
+
customParam2: 123
|
|
335
|
+
};
|
|
336
|
+
const config = createMockCapabilityConfig(laneTool, 'Configure intent', params);
|
|
337
|
+
await configureCapability.execute(config);
|
|
338
|
+
expect(configureCapability.config.params).to.deep.include({
|
|
339
|
+
toolAddress: 'o://test-tool',
|
|
340
|
+
intent: 'Test intent',
|
|
341
|
+
customParam1: 'value1',
|
|
342
|
+
customParam2: 123
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
describe('streaming support', () => {
|
|
347
|
+
it('should support streaming configuration', async () => {
|
|
348
|
+
const chunks = [];
|
|
349
|
+
const params = {
|
|
350
|
+
toolAddress: 'o://test-tool',
|
|
351
|
+
intent: 'Streaming configuration'
|
|
352
|
+
};
|
|
353
|
+
const config = createMockCapabilityConfig(laneTool, 'Configure intent', params, {
|
|
354
|
+
useStream: true,
|
|
355
|
+
onChunk: (chunk) => chunks.push(chunk)
|
|
356
|
+
});
|
|
357
|
+
try {
|
|
358
|
+
await configureCapability.execute(config);
|
|
359
|
+
expect(config.useStream).to.be.true;
|
|
360
|
+
}
|
|
361
|
+
catch (error) {
|
|
362
|
+
// Expected if services not available
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
});
|
|
366
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluate-capability.spec.d.ts","sourceRoot":"","sources":["../../../test/capabilities/evaluate-capability.spec.ts"],"names":[],"mappings":""}
|