@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.
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 +7 -5
  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 +110 -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
@@ -0,0 +1,463 @@
1
+ import { expect } from 'chai';
2
+ import { oCapabilityTask, oCapabilitySearch, oCapabilityEvaluate, oCapabilityMultipleStep, oCapabilityConfigure, ALL_CAPABILITIES } from '@olane/o-lane';
3
+ import { createTestOS, createTestLaneTool, createMockCapabilityConfig, createMockIntent, ChunkCapture } from './utils/capability-test-utils.js';
4
+ describe('Capability Integration Tests @capability @integration', () => {
5
+ let os;
6
+ let laneTool;
7
+ before(async () => {
8
+ os = await createTestOS();
9
+ laneTool = await createTestLaneTool(os);
10
+ });
11
+ after(async () => {
12
+ if (laneTool) {
13
+ await laneTool.stop();
14
+ }
15
+ if (os) {
16
+ await os.stop();
17
+ }
18
+ });
19
+ describe('Capability lifecycle', () => {
20
+ it('should create, execute, and complete a capability', async () => {
21
+ const capability = new oCapabilityEvaluate();
22
+ const config = createMockCapabilityConfig(laneTool, 'Test lifecycle');
23
+ try {
24
+ const result = await capability.execute(config);
25
+ expect(result).to.exist;
26
+ expect(capability.config).to.equal(config);
27
+ }
28
+ catch (error) {
29
+ // Expected if services unavailable
30
+ }
31
+ });
32
+ it('should support cancellation during execution', async () => {
33
+ const capability = new oCapabilityMultipleStep();
34
+ const params = {
35
+ intents: [
36
+ createMockIntent('Step 1', {}),
37
+ createMockIntent('Step 2', {})
38
+ ],
39
+ explanation: 'Cancellation test'
40
+ };
41
+ const config = createMockCapabilityConfig(laneTool, 'Test cancellation', params);
42
+ // Start execution
43
+ const executionPromise = capability.execute(config);
44
+ // Cancel immediately
45
+ capability.cancel();
46
+ try {
47
+ await executionPromise;
48
+ }
49
+ catch (error) {
50
+ // May error during cancellation
51
+ }
52
+ });
53
+ it('should allow re-execution of a capability', async () => {
54
+ const capability = new oCapabilityEvaluate();
55
+ const config1 = createMockCapabilityConfig(laneTool, 'First execution');
56
+ const config2 = createMockCapabilityConfig(laneTool, 'Second execution');
57
+ try {
58
+ await capability.execute(config1);
59
+ await capability.execute(config2);
60
+ expect(capability.config).to.equal(config2);
61
+ }
62
+ catch (error) {
63
+ // Expected if services unavailable
64
+ }
65
+ });
66
+ });
67
+ describe('Capability sequencing', () => {
68
+ it('should execute EVALUATE → CONFIGURE → TASK sequence', async () => {
69
+ const results = [];
70
+ // Step 1: Evaluate
71
+ const evaluateCapability = new oCapabilityEvaluate();
72
+ const evaluateConfig = createMockCapabilityConfig(laneTool, 'What tool should I use?');
73
+ try {
74
+ const evaluateResult = await evaluateCapability.execute(evaluateConfig);
75
+ results.push({ type: 'EVALUATE', result: evaluateResult });
76
+ // Step 2: Configure (would normally use result from evaluate)
77
+ const configureCapability = new oCapabilityConfigure();
78
+ const configureParams = {
79
+ toolAddress: 'o://test-tool',
80
+ intent: 'Configure the tool'
81
+ };
82
+ const configureConfig = createMockCapabilityConfig(laneTool, 'Configure tool', configureParams);
83
+ try {
84
+ const configureResult = await configureCapability.execute(configureConfig);
85
+ results.push({ type: 'CONFIGURE', result: configureResult });
86
+ }
87
+ catch (error) {
88
+ // Expected if tool doesn't exist
89
+ }
90
+ // Step 3: Task (would normally use result from configure)
91
+ const taskCapability = new oCapabilityTask();
92
+ const taskParams = {
93
+ task: {
94
+ address: 'o://test-tool',
95
+ payload: {
96
+ method: 'testMethod',
97
+ params: {}
98
+ }
99
+ }
100
+ };
101
+ const taskConfig = createMockCapabilityConfig(laneTool, 'Execute task', taskParams);
102
+ try {
103
+ const taskResult = await taskCapability.execute(taskConfig);
104
+ results.push({ type: 'TASK', result: taskResult });
105
+ }
106
+ catch (error) {
107
+ // Expected if tool doesn't exist
108
+ }
109
+ // Should have attempted all three steps
110
+ expect(results.length).to.be.greaterThan(0);
111
+ }
112
+ catch (error) {
113
+ // Expected if services unavailable
114
+ }
115
+ });
116
+ it('should handle SEARCH → EVALUATE sequence', async () => {
117
+ const results = [];
118
+ // Step 1: Search
119
+ const searchCapability = new oCapabilitySearch();
120
+ const searchParams = {
121
+ isExternal: false,
122
+ queries: [{ query: 'test search' }],
123
+ explanation: 'Search for information'
124
+ };
125
+ const searchConfig = createMockCapabilityConfig(laneTool, 'Search intent', searchParams);
126
+ try {
127
+ const searchResult = await searchCapability.execute(searchConfig);
128
+ results.push({ type: 'SEARCH', result: searchResult });
129
+ // Step 2: Evaluate with search results
130
+ const evaluateCapability = new oCapabilityEvaluate();
131
+ const evaluateConfig = createMockCapabilityConfig(laneTool, 'Analyze search results');
132
+ evaluateConfig.history = `Search completed with results: ${JSON.stringify(searchResult.humanResult)}`;
133
+ try {
134
+ const evaluateResult = await evaluateCapability.execute(evaluateConfig);
135
+ results.push({ type: 'EVALUATE', result: evaluateResult });
136
+ }
137
+ catch (error) {
138
+ // Expected if intelligence service unavailable
139
+ }
140
+ expect(results.length).to.be.greaterThan(0);
141
+ }
142
+ catch (error) {
143
+ // Expected if services unavailable
144
+ }
145
+ });
146
+ it('should handle EVALUATE → MULTIPLE_STEP sequence', async () => {
147
+ // Step 1: Evaluate to determine steps needed
148
+ const evaluateCapability = new oCapabilityEvaluate();
149
+ const evaluateConfig = createMockCapabilityConfig(laneTool, 'What steps are needed?');
150
+ try {
151
+ await evaluateCapability.execute(evaluateConfig);
152
+ // Step 2: Execute multiple steps
153
+ const multiStepCapability = new oCapabilityMultipleStep();
154
+ const multiStepParams = {
155
+ intents: [
156
+ createMockIntent('First step', {}),
157
+ createMockIntent('Second step', {})
158
+ ],
159
+ explanation: 'Execute the determined steps'
160
+ };
161
+ const multiStepConfig = createMockCapabilityConfig(laneTool, 'Execute steps', multiStepParams);
162
+ try {
163
+ await multiStepCapability.execute(multiStepConfig);
164
+ }
165
+ catch (error) {
166
+ // Expected if services unavailable
167
+ }
168
+ }
169
+ catch (error) {
170
+ // Expected if services unavailable
171
+ }
172
+ });
173
+ });
174
+ describe('Capability chaining with history', () => {
175
+ it('should pass history between capabilities', async () => {
176
+ let history = '';
177
+ // Step 1
178
+ const capability1 = new oCapabilityEvaluate();
179
+ const config1 = createMockCapabilityConfig(laneTool, 'Step 1');
180
+ config1.history = history;
181
+ try {
182
+ const result1 = await capability1.execute(config1);
183
+ history += `\nStep 1 completed: ${result1.type}`;
184
+ // Step 2 with updated history
185
+ const capability2 = new oCapabilityEvaluate();
186
+ const config2 = createMockCapabilityConfig(laneTool, 'Step 2');
187
+ config2.history = history;
188
+ const result2 = await capability2.execute(config2);
189
+ history += `\nStep 2 completed: ${result2.type}`;
190
+ expect(history).to.include('Step 1 completed');
191
+ expect(history).to.include('Step 2 completed');
192
+ }
193
+ catch (error) {
194
+ // Expected if services unavailable
195
+ }
196
+ });
197
+ it('should accumulate context across capabilities', async () => {
198
+ const contextData = [];
199
+ const capabilities = [
200
+ new oCapabilityEvaluate(),
201
+ new oCapabilitySearch(),
202
+ new oCapabilityEvaluate()
203
+ ];
204
+ for (const capability of capabilities) {
205
+ const config = createMockCapabilityConfig(laneTool, 'Accumulate context');
206
+ config.history = contextData.map(d => d.type).join(' → ');
207
+ try {
208
+ const result = await capability.execute(config);
209
+ contextData.push({ type: result.type, capability: capability.constructor.name });
210
+ }
211
+ catch (error) {
212
+ // Continue even if individual capability fails
213
+ }
214
+ }
215
+ expect(contextData.length).to.be.greaterThan(0);
216
+ });
217
+ });
218
+ describe('Capability streaming integration', () => {
219
+ it('should support streaming across capability chain', async () => {
220
+ const chunkCapture = new ChunkCapture();
221
+ const capabilities = [
222
+ new oCapabilityEvaluate(),
223
+ new oCapabilitySearch()
224
+ ];
225
+ for (const capability of capabilities) {
226
+ const params = capability instanceof oCapabilitySearch
227
+ ? { isExternal: false, queries: [{ query: 'test' }], explanation: 'test' }
228
+ : {};
229
+ const config = createMockCapabilityConfig(laneTool, 'Streaming test', params, {
230
+ useStream: true,
231
+ onChunk: chunkCapture.onChunk
232
+ });
233
+ try {
234
+ await capability.execute(config);
235
+ }
236
+ catch (error) {
237
+ // Expected if services unavailable
238
+ }
239
+ }
240
+ expect(chunkCapture.allChunks).to.be.an('array');
241
+ });
242
+ it('should handle mixed streaming and non-streaming capabilities', async () => {
243
+ const streamedResults = [];
244
+ const nonStreamedResults = [];
245
+ // Streaming capability
246
+ const config1 = createMockCapabilityConfig(laneTool, 'Streaming', {}, {
247
+ useStream: true,
248
+ onChunk: (chunk) => streamedResults.push(chunk)
249
+ });
250
+ // Non-streaming capability
251
+ const config2 = createMockCapabilityConfig(laneTool, 'Non-streaming');
252
+ const capability1 = new oCapabilityEvaluate();
253
+ const capability2 = new oCapabilityEvaluate();
254
+ try {
255
+ const result1 = await capability1.execute(config1);
256
+ nonStreamedResults.push(result1);
257
+ const result2 = await capability2.execute(config2);
258
+ nonStreamedResults.push(result2);
259
+ expect(nonStreamedResults.length).to.equal(2);
260
+ }
261
+ catch (error) {
262
+ // Expected if services unavailable
263
+ }
264
+ });
265
+ });
266
+ describe('Capability error propagation', () => {
267
+ it('should propagate errors up the capability chain', async () => {
268
+ const errors = [];
269
+ // Capability that will likely fail
270
+ const taskCapability = new oCapabilityTask();
271
+ const taskConfig = createMockCapabilityConfig(laneTool, 'Failing task', {});
272
+ try {
273
+ await taskCapability.execute(taskConfig);
274
+ }
275
+ catch (error) {
276
+ errors.push({ capability: 'TASK', error });
277
+ }
278
+ // Should attempt to recover with evaluation
279
+ const evaluateCapability = new oCapabilityEvaluate();
280
+ const evaluateConfig = createMockCapabilityConfig(laneTool, 'Recover from error');
281
+ try {
282
+ await evaluateCapability.execute(evaluateConfig);
283
+ }
284
+ catch (error) {
285
+ errors.push({ capability: 'EVALUATE', error });
286
+ }
287
+ expect(errors.length).to.be.greaterThan(0);
288
+ });
289
+ it('should handle capability failures gracefully', async () => {
290
+ const results = [];
291
+ const capabilities = [
292
+ { cap: new oCapabilityTask(), config: createMockCapabilityConfig(laneTool, 'May fail', {}) },
293
+ { cap: new oCapabilityEvaluate(), config: createMockCapabilityConfig(laneTool, 'Should continue') }
294
+ ];
295
+ for (const { cap, config } of capabilities) {
296
+ try {
297
+ const result = await cap.execute(config);
298
+ results.push({ success: true, result });
299
+ }
300
+ catch (error) {
301
+ results.push({ success: false, error });
302
+ }
303
+ }
304
+ // Should have attempted both
305
+ expect(results.length).to.equal(2);
306
+ });
307
+ });
308
+ describe('Capability registry integration', () => {
309
+ it('should instantiate all registered capabilities', () => {
310
+ ALL_CAPABILITIES.forEach(CapabilityClass => {
311
+ const instance = new CapabilityClass();
312
+ expect(instance).to.exist;
313
+ expect(instance.type).to.be.a('string');
314
+ });
315
+ });
316
+ it('should execute capabilities from registry', async () => {
317
+ const results = [];
318
+ for (const CapabilityClass of ALL_CAPABILITIES) {
319
+ const instance = new CapabilityClass();
320
+ // Create appropriate config for each type
321
+ let params = {};
322
+ if (instance instanceof oCapabilitySearch) {
323
+ params = { isExternal: false, queries: [], explanation: 'test' };
324
+ }
325
+ else if (instance instanceof oCapabilityMultipleStep) {
326
+ params = { intents: [], explanation: 'test' };
327
+ }
328
+ else if (instance instanceof oCapabilityConfigure) {
329
+ params = { toolAddress: 'o://test', intent: 'test' };
330
+ }
331
+ else if (instance instanceof oCapabilityTask) {
332
+ params = { task: { address: 'o://test', payload: { method: 'test', params: {} } } };
333
+ }
334
+ const config = createMockCapabilityConfig(laneTool, 'Registry test', params);
335
+ try {
336
+ const result = await instance.execute(config);
337
+ results.push({ type: instance.type, success: true });
338
+ }
339
+ catch (error) {
340
+ results.push({ type: instance.type, success: false, error });
341
+ }
342
+ }
343
+ expect(results.length).to.equal(ALL_CAPABILITIES.length);
344
+ });
345
+ });
346
+ describe('Complex capability workflows', () => {
347
+ it('should handle a realistic workflow: Evaluate → Search → Evaluate → Configure → Task', async () => {
348
+ const workflow = [];
349
+ // 1. Evaluate initial intent
350
+ const evaluate1 = new oCapabilityEvaluate();
351
+ try {
352
+ const result = await evaluate1.execute(createMockCapabilityConfig(laneTool, 'Find and use a calculator'));
353
+ workflow.push({ step: 'Initial Evaluation', type: result.type });
354
+ }
355
+ catch (error) {
356
+ workflow.push({ step: 'Initial Evaluation', error });
357
+ }
358
+ // 2. Search for calculator tool
359
+ const search = new oCapabilitySearch();
360
+ const searchParams = {
361
+ isExternal: false,
362
+ queries: [{ query: 'calculator tool' }],
363
+ explanation: 'Find calculator'
364
+ };
365
+ try {
366
+ const result = await search.execute(createMockCapabilityConfig(laneTool, 'Search', searchParams));
367
+ workflow.push({ step: 'Search', type: result.type });
368
+ }
369
+ catch (error) {
370
+ workflow.push({ step: 'Search', error });
371
+ }
372
+ // 3. Evaluate search results
373
+ const evaluate2 = new oCapabilityEvaluate();
374
+ try {
375
+ const result = await evaluate2.execute(createMockCapabilityConfig(laneTool, 'Analyze results'));
376
+ workflow.push({ step: 'Result Analysis', type: result.type });
377
+ }
378
+ catch (error) {
379
+ workflow.push({ step: 'Result Analysis', error });
380
+ }
381
+ // 4. Configure tool
382
+ const configure = new oCapabilityConfigure();
383
+ const configureParams = {
384
+ toolAddress: 'o://calculator',
385
+ intent: 'Add 2 and 2'
386
+ };
387
+ try {
388
+ const result = await configure.execute(createMockCapabilityConfig(laneTool, 'Configure', configureParams));
389
+ workflow.push({ step: 'Configure', type: result.type });
390
+ }
391
+ catch (error) {
392
+ workflow.push({ step: 'Configure', error });
393
+ }
394
+ // 5. Execute task
395
+ const task = new oCapabilityTask();
396
+ const taskParams = {
397
+ task: {
398
+ address: 'o://calculator',
399
+ payload: {
400
+ method: 'add',
401
+ params: { a: 2, b: 2 }
402
+ }
403
+ }
404
+ };
405
+ try {
406
+ const result = await task.execute(createMockCapabilityConfig(laneTool, 'Execute', taskParams));
407
+ workflow.push({ step: 'Execute Task', type: result.type });
408
+ }
409
+ catch (error) {
410
+ workflow.push({ step: 'Execute Task', error });
411
+ }
412
+ // Should have attempted all 5 steps
413
+ expect(workflow.length).to.equal(5);
414
+ });
415
+ it('should handle parallel capability execution', async () => {
416
+ const searches = [
417
+ { isExternal: false, queries: [{ query: 'query 1' }], explanation: 'Search 1' },
418
+ { isExternal: false, queries: [{ query: 'query 2' }], explanation: 'Search 2' },
419
+ { isExternal: false, queries: [{ query: 'query 3' }], explanation: 'Search 3' }
420
+ ];
421
+ const promises = searches.map(params => {
422
+ const capability = new oCapabilitySearch();
423
+ const config = createMockCapabilityConfig(laneTool, 'Parallel search', params);
424
+ return capability.execute(config).catch(err => ({ error: err }));
425
+ });
426
+ const results = await Promise.all(promises);
427
+ expect(results.length).to.equal(3);
428
+ });
429
+ });
430
+ describe('Capability state management', () => {
431
+ it('should maintain separate state for concurrent capabilities', async () => {
432
+ const cap1 = new oCapabilityEvaluate();
433
+ const cap2 = new oCapabilityEvaluate();
434
+ const config1 = createMockCapabilityConfig(laneTool, 'Intent 1');
435
+ const config2 = createMockCapabilityConfig(laneTool, 'Intent 2');
436
+ const promises = [
437
+ cap1.execute(config1).catch(err => ({ error: err })),
438
+ cap2.execute(config2).catch(err => ({ error: err }))
439
+ ];
440
+ await Promise.all(promises);
441
+ // Each capability should have its own config
442
+ expect(cap1.config).to.equal(config1);
443
+ expect(cap2.config).to.equal(config2);
444
+ expect(cap1.config).to.not.equal(cap2.config);
445
+ });
446
+ it('should reset state on re-execution', async () => {
447
+ const capability = new oCapabilityEvaluate();
448
+ const config1 = createMockCapabilityConfig(laneTool, 'First');
449
+ const config2 = createMockCapabilityConfig(laneTool, 'Second');
450
+ try {
451
+ await capability.execute(config1);
452
+ const firstConfig = capability.config;
453
+ await capability.execute(config2);
454
+ const secondConfig = capability.config;
455
+ expect(secondConfig).to.equal(config2);
456
+ expect(secondConfig).to.not.equal(firstConfig);
457
+ }
458
+ catch (error) {
459
+ // Expected if services unavailable
460
+ }
461
+ });
462
+ });
463
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=capability-registry.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability-registry.spec.d.ts","sourceRoot":"","sources":["../../../test/capabilities/capability-registry.spec.ts"],"names":[],"mappings":""}