@olane/o-lane 0.7.12-alpha.9 → 0.7.12
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/capabilities/enums/o-capability.type-enum.d.ts +1 -0
- package/dist/src/capabilities/enums/o-capability.type-enum.d.ts.map +1 -1
- package/dist/src/capabilities/enums/o-capability.type-enum.js +1 -0
- package/dist/src/capabilities/interfaces/o-capability.config.d.ts +4 -2
- package/dist/src/capabilities/interfaces/o-capability.config.d.ts.map +1 -1
- package/dist/src/capabilities/interfaces/o-capability.result-interface.d.ts +1 -0
- package/dist/src/capabilities/interfaces/o-capability.result-interface.d.ts.map +1 -1
- package/dist/src/capabilities/o-capability.d.ts +3 -2
- package/dist/src/capabilities/o-capability.d.ts.map +1 -1
- package/dist/src/capabilities/o-capability.intelligence.d.ts.map +1 -1
- package/dist/src/capabilities/o-capability.intelligence.js +33 -8
- package/dist/src/capabilities/o-capability.js +3 -0
- package/dist/src/capabilities/o-capability.result.d.ts +2 -0
- package/dist/src/capabilities/o-capability.result.d.ts.map +1 -1
- package/dist/src/capabilities/o-capability.result.js +2 -0
- package/dist/src/capabilities/utils/result-stream-parser.d.ts +37 -0
- package/dist/src/capabilities/utils/result-stream-parser.d.ts.map +1 -0
- package/dist/src/capabilities/utils/result-stream-parser.js +90 -0
- package/dist/src/capabilities-multiple-step/interfaces/o-capability.multiple-step-config.d.ts +1 -0
- package/dist/src/capabilities-multiple-step/interfaces/o-capability.multiple-step-config.d.ts.map +1 -1
- package/dist/src/capabilities-multiple-step/o-capability.multiple-step.d.ts +2 -0
- package/dist/src/capabilities-multiple-step/o-capability.multiple-step.d.ts.map +1 -1
- package/dist/src/capabilities-multiple-step/o-capability.multiple-step.js +12 -0
- package/dist/src/capabilities-search/interfaces/o-capability.search-config.d.ts +1 -0
- package/dist/src/capabilities-search/interfaces/o-capability.search-config.d.ts.map +1 -1
- package/dist/src/capabilities-search/o-capability.search.d.ts.map +1 -1
- package/dist/src/capabilities-search/o-capability.search.js +24 -6
- package/dist/src/capabilities-task/interfaces/o-capability.task-config.d.ts +1 -0
- package/dist/src/capabilities-task/interfaces/o-capability.task-config.d.ts.map +1 -1
- package/dist/src/capabilities-task/o-capability.task.d.ts.map +1 -1
- package/dist/src/capabilities-task/o-capability.task.js +4 -0
- package/dist/src/errors/capability-errors.d.ts +71 -0
- package/dist/src/errors/capability-errors.d.ts.map +1 -0
- package/dist/src/errors/capability-errors.js +142 -0
- package/dist/src/errors/index.d.ts +5 -0
- package/dist/src/errors/index.d.ts.map +1 -0
- package/dist/src/errors/index.js +4 -0
- package/dist/src/formatters/index.d.ts +7 -0
- package/dist/src/formatters/index.d.ts.map +1 -0
- package/dist/src/formatters/index.js +6 -0
- package/dist/src/formatters/markdown-builder.d.ts +65 -0
- package/dist/src/formatters/markdown-builder.d.ts.map +1 -0
- package/dist/src/formatters/markdown-builder.js +120 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -0
- package/dist/src/interfaces/o-lane.config.d.ts +5 -2
- package/dist/src/interfaces/o-lane.config.d.ts.map +1 -1
- package/dist/src/o-lane.d.ts +8 -1
- package/dist/src/o-lane.d.ts.map +1 -1
- package/dist/src/o-lane.js +165 -23
- package/dist/src/o-lane.mixin.d.ts +17 -0
- package/dist/src/o-lane.mixin.d.ts.map +1 -0
- package/dist/src/o-lane.mixin.js +136 -0
- package/dist/src/o-lane.tool.d.ts +12 -19
- package/dist/src/o-lane.tool.d.ts.map +1 -1
- package/dist/src/o-lane.tool.js +11 -93
- package/dist/src/prompts/agent.prompt.d.ts +11 -0
- package/dist/src/prompts/agent.prompt.d.ts.map +1 -1
- package/dist/src/prompts/agent.prompt.js +34 -10
- package/dist/src/prompts/configure.prompt.d.ts +7 -0
- package/dist/src/prompts/configure.prompt.d.ts.map +1 -1
- package/dist/src/prompts/configure.prompt.js +8 -1
- package/dist/src/prompts/custom.prompt.d.ts +7 -0
- package/dist/src/prompts/custom.prompt.d.ts.map +1 -1
- package/dist/src/prompts/custom.prompt.js +77 -0
- package/dist/src/storage/index.d.ts +8 -0
- package/dist/src/storage/index.d.ts.map +1 -0
- package/dist/src/storage/index.js +12 -0
- package/dist/src/storage/interfaces/prompt-storage.interface.d.ts +102 -0
- package/dist/src/storage/interfaces/prompt-storage.interface.d.ts.map +1 -0
- package/dist/src/storage/interfaces/prompt-storage.interface.js +1 -0
- package/dist/src/storage/methods/prompt-storage.methods.d.ts +9 -0
- package/dist/src/storage/methods/prompt-storage.methods.d.ts.map +1 -0
- package/dist/src/storage/methods/prompt-storage.methods.js +338 -0
- package/dist/src/storage/prompt-loader.d.ts +40 -0
- package/dist/src/storage/prompt-loader.d.ts.map +1 -0
- package/dist/src/storage/prompt-loader.js +126 -0
- package/dist/src/storage/prompt-schema.d.ts +42 -0
- package/dist/src/storage/prompt-schema.d.ts.map +1 -0
- package/dist/src/storage/prompt-schema.js +29 -0
- package/dist/src/storage/prompt-seeder.d.ts +42 -0
- package/dist/src/storage/prompt-seeder.d.ts.map +1 -0
- package/dist/src/storage/prompt-seeder.js +141 -0
- package/dist/src/storage/prompt-storage-provider.tool.d.ts +99 -0
- package/dist/src/storage/prompt-storage-provider.tool.d.ts.map +1 -0
- package/dist/src/storage/prompt-storage-provider.tool.js +320 -0
- package/dist/test/prompt-seeder.spec.d.ts +2 -0
- package/dist/test/prompt-seeder.spec.d.ts.map +1 -0
- package/dist/test/prompt-seeder.spec.js +254 -0
- package/dist/test/prompt-storage-provider.spec.d.ts +2 -0
- package/dist/test/prompt-storage-provider.spec.d.ts.map +1 -0
- package/dist/test/prompt-storage-provider.spec.js +456 -0
- package/package.json +10 -7
- package/dist/test/ai.spec.d.ts +0 -2
- package/dist/test/ai.spec.d.ts.map +0 -1
- package/dist/test/ai.spec.js +0 -19
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import 'dotenv/config';
|
|
2
|
+
import { describe, it, before, after } from 'mocha';
|
|
3
|
+
import { expect } from 'chai';
|
|
4
|
+
import { PromptStorageProvider } from '../src/storage/prompt-storage-provider.tool.js';
|
|
5
|
+
import { PromptSeeder } from '../src/storage/prompt-seeder.js';
|
|
6
|
+
import { PromptLoader } from '../src/storage/prompt-loader.js';
|
|
7
|
+
import { PROMPT_KEYS, PROMPT_IDS, } from '../src/storage/prompt-schema.js';
|
|
8
|
+
import { AGENT_PROMPT } from '../src/prompts/agent.prompt.js';
|
|
9
|
+
import { CONFIGURE_INSTRUCTIONS } from '../src/prompts/configure.prompt.js';
|
|
10
|
+
import { TestEnvironment, assertSuccess, assertDefined, } from '@olane/o-test';
|
|
11
|
+
describe('Prompt Seeding and Loading', () => {
|
|
12
|
+
const env = new TestEnvironment();
|
|
13
|
+
let storage;
|
|
14
|
+
let seeder;
|
|
15
|
+
let loader;
|
|
16
|
+
before(async () => {
|
|
17
|
+
storage = await env.createNode(PromptStorageProvider, {});
|
|
18
|
+
seeder = new PromptSeeder(storage);
|
|
19
|
+
loader = new PromptLoader(storage);
|
|
20
|
+
});
|
|
21
|
+
after(async () => {
|
|
22
|
+
await env.cleanup();
|
|
23
|
+
});
|
|
24
|
+
describe('PromptSeeder', () => {
|
|
25
|
+
it('should check if prompts are not seeded initially', async () => {
|
|
26
|
+
const isSeeded = await seeder.isSeeded();
|
|
27
|
+
expect(isSeeded).to.equal(false);
|
|
28
|
+
});
|
|
29
|
+
it('should seed all prompts successfully', async () => {
|
|
30
|
+
await seeder.seedAll();
|
|
31
|
+
// Verify all prompts are stored
|
|
32
|
+
const baseTemplateResponse = await storage.use(storage.address, {
|
|
33
|
+
method: 'has',
|
|
34
|
+
params: {
|
|
35
|
+
promptId: PROMPT_IDS.AGENT,
|
|
36
|
+
key: PROMPT_KEYS.BASE_TEMPLATE,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
assertSuccess(baseTemplateResponse);
|
|
40
|
+
expect(baseTemplateResponse.result?.data?.exists).to.equal(true);
|
|
41
|
+
const cycleResponse = await storage.use(storage.address, {
|
|
42
|
+
method: 'has',
|
|
43
|
+
params: {
|
|
44
|
+
promptId: PROMPT_IDS.AGENT,
|
|
45
|
+
key: PROMPT_KEYS.CYCLE_INSTRUCTIONS,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
assertSuccess(cycleResponse);
|
|
49
|
+
expect(cycleResponse.result?.data?.exists).to.equal(true);
|
|
50
|
+
const outputResponse = await storage.use(storage.address, {
|
|
51
|
+
method: 'has',
|
|
52
|
+
params: {
|
|
53
|
+
promptId: PROMPT_IDS.AGENT,
|
|
54
|
+
key: PROMPT_KEYS.OUTPUT_INSTRUCTIONS,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
assertSuccess(outputResponse);
|
|
58
|
+
expect(outputResponse.result?.data?.exists).to.equal(true);
|
|
59
|
+
const configureResponse = await storage.use(storage.address, {
|
|
60
|
+
method: 'has',
|
|
61
|
+
params: {
|
|
62
|
+
promptId: PROMPT_IDS.AGENT,
|
|
63
|
+
key: PROMPT_KEYS.CONFIGURE_INSTRUCTIONS,
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
assertSuccess(configureResponse);
|
|
67
|
+
expect(configureResponse.result?.data?.exists).to.equal(true);
|
|
68
|
+
});
|
|
69
|
+
it('should confirm prompts are seeded after seeding', async () => {
|
|
70
|
+
const isSeeded = await seeder.isSeeded();
|
|
71
|
+
expect(isSeeded).to.equal(true);
|
|
72
|
+
});
|
|
73
|
+
it('should store prompts with correct metadata', async () => {
|
|
74
|
+
const response = await storage.use(storage.address, {
|
|
75
|
+
method: 'get',
|
|
76
|
+
params: {
|
|
77
|
+
promptId: PROMPT_IDS.AGENT,
|
|
78
|
+
key: PROMPT_KEYS.BASE_TEMPLATE,
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
assertSuccess(response);
|
|
82
|
+
const template = response.result?.data?.value;
|
|
83
|
+
assertDefined(template, 'template');
|
|
84
|
+
expect(template.content).to.exist;
|
|
85
|
+
expect(template.metadata).to.exist;
|
|
86
|
+
expect(template.metadata.version).to.equal('1.0.0');
|
|
87
|
+
expect(template.metadata.source).to.equal('custom.prompt.ts');
|
|
88
|
+
});
|
|
89
|
+
it('should store base template with placeholders', async () => {
|
|
90
|
+
const response = await storage.use(storage.address, {
|
|
91
|
+
method: 'get',
|
|
92
|
+
params: {
|
|
93
|
+
promptId: PROMPT_IDS.AGENT,
|
|
94
|
+
key: PROMPT_KEYS.BASE_TEMPLATE,
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
assertSuccess(response);
|
|
98
|
+
const template = response.result?.data?.value;
|
|
99
|
+
assertDefined(template, 'template');
|
|
100
|
+
expect(template.content).to.include('{{intent}}');
|
|
101
|
+
expect(template.content).to.include('{{context}}');
|
|
102
|
+
expect(template.content).to.include('{{agentHistory}}');
|
|
103
|
+
expect(template.content).to.include('{{cycleInstructions}}');
|
|
104
|
+
expect(template.content).to.include('{{outputInstructions}}');
|
|
105
|
+
expect(template.content).to.include('{{extraInstructions}}');
|
|
106
|
+
});
|
|
107
|
+
it('should store cycle instructions with step details', async () => {
|
|
108
|
+
const response = await storage.use(storage.address, {
|
|
109
|
+
method: 'get',
|
|
110
|
+
params: {
|
|
111
|
+
promptId: PROMPT_IDS.AGENT,
|
|
112
|
+
key: PROMPT_KEYS.CYCLE_INSTRUCTIONS,
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
assertSuccess(response);
|
|
116
|
+
const template = response.result?.data?.value;
|
|
117
|
+
assertDefined(template, 'template');
|
|
118
|
+
expect(template.content).to.include('Step 1 - Evaluate the intent');
|
|
119
|
+
expect(template.content).to.include('Step 2 - Search for tools and context');
|
|
120
|
+
expect(template.content).to.include('Step 3 - Filter Search Results');
|
|
121
|
+
expect(template.content).to.include('Step 4 - Configure the target tool address use');
|
|
122
|
+
expect(template.content).to.include('Step 5 - Use target tool address');
|
|
123
|
+
expect(template.content).to.include('Step 6 - Review the tool use results');
|
|
124
|
+
});
|
|
125
|
+
it('should store output instructions with return types', async () => {
|
|
126
|
+
const response = await storage.use(storage.address, {
|
|
127
|
+
method: 'get',
|
|
128
|
+
params: {
|
|
129
|
+
promptId: PROMPT_IDS.AGENT,
|
|
130
|
+
key: PROMPT_KEYS.OUTPUT_INSTRUCTIONS,
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
assertSuccess(response);
|
|
134
|
+
const template = response.result?.data?.value;
|
|
135
|
+
assertDefined(template, 'template');
|
|
136
|
+
expect(template.content).to.include('Complex Intent Results');
|
|
137
|
+
expect(template.content).to.include('Configure Response');
|
|
138
|
+
expect(template.content).to.include('Search Response');
|
|
139
|
+
expect(template.content).to.include('Stop Response');
|
|
140
|
+
expect(template.content).to.include('Error Response');
|
|
141
|
+
expect(template.content).to.include('Use Tool Response');
|
|
142
|
+
});
|
|
143
|
+
it('should clear all prompts', async () => {
|
|
144
|
+
await seeder.clearAll();
|
|
145
|
+
const isSeeded = await seeder.isSeeded();
|
|
146
|
+
expect(isSeeded).to.equal(false);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
describe('PromptLoader', () => {
|
|
150
|
+
before(async () => {
|
|
151
|
+
// Ensure prompts are seeded for loader tests
|
|
152
|
+
await seeder.seedAll();
|
|
153
|
+
});
|
|
154
|
+
it('should load configure instructions from storage', async () => {
|
|
155
|
+
const instructions = await loader.loadConfigureInstructions();
|
|
156
|
+
expect(instructions).to.exist;
|
|
157
|
+
expect(instructions).to.include('Configure Request Instructions');
|
|
158
|
+
expect(instructions).to.include('Step 1 - Validate the intent');
|
|
159
|
+
});
|
|
160
|
+
it('should generate agent prompt from storage', async () => {
|
|
161
|
+
const prompt = await loader.generateAgentPrompt('test intent', 'test context', 'test history', 'test extra');
|
|
162
|
+
expect(prompt).to.exist;
|
|
163
|
+
expect(prompt).to.include('test intent');
|
|
164
|
+
expect(prompt).to.include('test context');
|
|
165
|
+
expect(prompt).to.include('test history');
|
|
166
|
+
expect(prompt).to.include('test extra');
|
|
167
|
+
expect(prompt).to.include('Step 1 - Evaluate the intent');
|
|
168
|
+
expect(prompt).to.include('Stop Response');
|
|
169
|
+
});
|
|
170
|
+
it('should generate prompt identical to hardcoded version', async () => {
|
|
171
|
+
const intent = 'Get user information';
|
|
172
|
+
const context = 'User ID: 123';
|
|
173
|
+
const history = 'Previous cycle: searched for user';
|
|
174
|
+
const extra = 'Be concise';
|
|
175
|
+
const storagePrompt = await loader.generateAgentPrompt(intent, context, history, extra);
|
|
176
|
+
const hardcodedPrompt = AGENT_PROMPT(intent, context, history, extra);
|
|
177
|
+
expect(storagePrompt).to.equal(hardcodedPrompt);
|
|
178
|
+
});
|
|
179
|
+
it('should cache loaded templates', async () => {
|
|
180
|
+
// Clear cache first
|
|
181
|
+
loader.clearCache();
|
|
182
|
+
// First load - should hit storage
|
|
183
|
+
const prompt1 = await loader.generateAgentPrompt('test', 'test', 'test', 'test');
|
|
184
|
+
// Second load - should use cache
|
|
185
|
+
const prompt2 = await loader.generateAgentPrompt('test', 'test', 'test', 'test');
|
|
186
|
+
expect(prompt1).to.equal(prompt2);
|
|
187
|
+
});
|
|
188
|
+
it('should fallback to hardcoded prompts when storage unavailable', async () => {
|
|
189
|
+
const loaderWithoutStorage = new PromptLoader();
|
|
190
|
+
const prompt = await loaderWithoutStorage.generateAgentPrompt('test intent', 'test context', 'test history', 'test extra');
|
|
191
|
+
expect(prompt).to.exist;
|
|
192
|
+
expect(prompt).to.include('test intent');
|
|
193
|
+
expect(prompt).to.include('Step 1 - Evaluate the intent');
|
|
194
|
+
});
|
|
195
|
+
it('should fallback to hardcoded configure instructions when storage unavailable', async () => {
|
|
196
|
+
const loaderWithoutStorage = new PromptLoader();
|
|
197
|
+
const instructions = await loaderWithoutStorage.loadConfigureInstructions();
|
|
198
|
+
expect(instructions).to.equal(CONFIGURE_INSTRUCTIONS);
|
|
199
|
+
});
|
|
200
|
+
it('should allow disabling storage usage', async () => {
|
|
201
|
+
loader.setUseStorage(false);
|
|
202
|
+
const prompt = await loader.generateAgentPrompt('test', 'test', 'test', 'test');
|
|
203
|
+
expect(prompt).to.exist;
|
|
204
|
+
// Re-enable for other tests
|
|
205
|
+
loader.setUseStorage(true);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
describe('Integration', () => {
|
|
209
|
+
it('should handle complete seed-load-clear cycle', async () => {
|
|
210
|
+
// Clear first
|
|
211
|
+
await seeder.clearAll();
|
|
212
|
+
expect(await seeder.isSeeded()).to.equal(false);
|
|
213
|
+
// Seed
|
|
214
|
+
await seeder.seedAll();
|
|
215
|
+
expect(await seeder.isSeeded()).to.equal(true);
|
|
216
|
+
// Load and verify
|
|
217
|
+
loader.clearCache();
|
|
218
|
+
const prompt = await loader.generateAgentPrompt('test', 'test', 'test', 'test');
|
|
219
|
+
expect(prompt).to.include('test');
|
|
220
|
+
const instructions = await loader.loadConfigureInstructions();
|
|
221
|
+
expect(instructions).to.include('Configure Request Instructions');
|
|
222
|
+
// Clear again
|
|
223
|
+
await seeder.clearAll();
|
|
224
|
+
expect(await seeder.isSeeded()).to.equal(false);
|
|
225
|
+
});
|
|
226
|
+
it('should list all seeded prompts', async () => {
|
|
227
|
+
await seeder.seedAll();
|
|
228
|
+
const response = await storage.use(storage.address, {
|
|
229
|
+
method: 'get_prompt_keys',
|
|
230
|
+
params: {
|
|
231
|
+
promptId: PROMPT_IDS.AGENT,
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
assertSuccess(response);
|
|
235
|
+
expect(response.result?.data?.keys).to.include(PROMPT_KEYS.BASE_TEMPLATE);
|
|
236
|
+
expect(response.result?.data?.keys).to.include(PROMPT_KEYS.CYCLE_INSTRUCTIONS);
|
|
237
|
+
expect(response.result?.data?.keys).to.include(PROMPT_KEYS.OUTPUT_INSTRUCTIONS);
|
|
238
|
+
expect(response.result?.data?.keys).to.include(PROMPT_KEYS.CONFIGURE_INSTRUCTIONS);
|
|
239
|
+
expect(response.result?.data?.count).to.equal(4);
|
|
240
|
+
});
|
|
241
|
+
it('should get stats for seeded prompts', async () => {
|
|
242
|
+
const response = await storage.use(storage.address, {
|
|
243
|
+
method: 'get_prompt_stats',
|
|
244
|
+
params: {
|
|
245
|
+
promptId: PROMPT_IDS.AGENT,
|
|
246
|
+
},
|
|
247
|
+
});
|
|
248
|
+
assertSuccess(response);
|
|
249
|
+
expect(response.result?.data?.exists).to.equal(true);
|
|
250
|
+
expect(response.result?.data?.keyCount).to.equal(4);
|
|
251
|
+
expect(response.result?.data?.promptId).to.equal(PROMPT_IDS.AGENT);
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-storage-provider.spec.d.ts","sourceRoot":"","sources":["../../test/prompt-storage-provider.spec.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC"}
|