@olane/o-lane 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/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,338 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Method definitions for prompt-specific storage operations
|
|
3
|
+
* Extends standard storage with promptId namespace isolation
|
|
4
|
+
*/
|
|
5
|
+
export const PROMPT_STORAGE_METHODS = {
|
|
6
|
+
put: {
|
|
7
|
+
name: 'put',
|
|
8
|
+
description: 'Store data in a prompt-specific namespace. Data is isolated per promptId.',
|
|
9
|
+
dependencies: [],
|
|
10
|
+
parameters: [
|
|
11
|
+
{
|
|
12
|
+
name: 'promptId',
|
|
13
|
+
type: 'string',
|
|
14
|
+
value: 'string',
|
|
15
|
+
description: 'Unique prompt/conversation identifier for namespace isolation',
|
|
16
|
+
required: true,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'key',
|
|
20
|
+
type: 'string',
|
|
21
|
+
value: 'string',
|
|
22
|
+
description: 'Key to store the data under within the prompt namespace',
|
|
23
|
+
required: true,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'value',
|
|
27
|
+
type: 'string',
|
|
28
|
+
value: 'string',
|
|
29
|
+
description: 'The data to store',
|
|
30
|
+
required: true,
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
examples: [
|
|
34
|
+
{
|
|
35
|
+
description: 'Store user preference in a conversation',
|
|
36
|
+
intent: 'Store the user name Alice for conversation 123',
|
|
37
|
+
params: {
|
|
38
|
+
promptId: 'conversation-123',
|
|
39
|
+
key: 'user_name',
|
|
40
|
+
value: 'Alice',
|
|
41
|
+
},
|
|
42
|
+
expectedResult: {
|
|
43
|
+
success: true,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
performance: {
|
|
48
|
+
estimatedDuration: 10,
|
|
49
|
+
maxDuration: 1000,
|
|
50
|
+
idempotent: true,
|
|
51
|
+
cacheable: false,
|
|
52
|
+
},
|
|
53
|
+
approvalMetadata: {
|
|
54
|
+
riskLevel: 'low',
|
|
55
|
+
category: 'write',
|
|
56
|
+
description: 'Store data in isolated prompt namespace',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
get: {
|
|
60
|
+
name: 'get',
|
|
61
|
+
description: 'Retrieve data from a prompt-specific namespace. Returns null if key not found.',
|
|
62
|
+
dependencies: [],
|
|
63
|
+
parameters: [
|
|
64
|
+
{
|
|
65
|
+
name: 'promptId',
|
|
66
|
+
type: 'string',
|
|
67
|
+
value: 'string',
|
|
68
|
+
description: 'Unique prompt/conversation identifier',
|
|
69
|
+
required: true,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'key',
|
|
73
|
+
type: 'string',
|
|
74
|
+
value: 'string',
|
|
75
|
+
description: 'The key to retrieve from the prompt namespace',
|
|
76
|
+
required: true,
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
examples: [
|
|
80
|
+
{
|
|
81
|
+
description: 'Retrieve stored user preference',
|
|
82
|
+
intent: 'Get the user name from conversation 123',
|
|
83
|
+
params: {
|
|
84
|
+
promptId: 'conversation-123',
|
|
85
|
+
key: 'user_name',
|
|
86
|
+
},
|
|
87
|
+
expectedResult: {
|
|
88
|
+
value: 'Alice',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
performance: {
|
|
93
|
+
estimatedDuration: 5,
|
|
94
|
+
maxDuration: 500,
|
|
95
|
+
idempotent: true,
|
|
96
|
+
cacheable: true,
|
|
97
|
+
},
|
|
98
|
+
approvalMetadata: {
|
|
99
|
+
riskLevel: 'low',
|
|
100
|
+
category: 'read',
|
|
101
|
+
description: 'Read data from isolated prompt namespace',
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
delete: {
|
|
105
|
+
name: 'delete',
|
|
106
|
+
description: 'Delete a specific key from a prompt namespace.',
|
|
107
|
+
dependencies: [],
|
|
108
|
+
parameters: [
|
|
109
|
+
{
|
|
110
|
+
name: 'promptId',
|
|
111
|
+
type: 'string',
|
|
112
|
+
value: 'string',
|
|
113
|
+
description: 'Unique prompt/conversation identifier',
|
|
114
|
+
required: true,
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: 'key',
|
|
118
|
+
type: 'string',
|
|
119
|
+
value: 'string',
|
|
120
|
+
description: 'The key to delete from the prompt namespace',
|
|
121
|
+
required: true,
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
examples: [
|
|
125
|
+
{
|
|
126
|
+
description: 'Delete a stored value',
|
|
127
|
+
intent: 'Delete the user name from conversation 123',
|
|
128
|
+
params: {
|
|
129
|
+
promptId: 'conversation-123',
|
|
130
|
+
key: 'user_name',
|
|
131
|
+
},
|
|
132
|
+
expectedResult: {
|
|
133
|
+
success: true,
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
performance: {
|
|
138
|
+
estimatedDuration: 10,
|
|
139
|
+
maxDuration: 1000,
|
|
140
|
+
idempotent: true,
|
|
141
|
+
cacheable: false,
|
|
142
|
+
},
|
|
143
|
+
approvalMetadata: {
|
|
144
|
+
riskLevel: 'low',
|
|
145
|
+
category: 'write',
|
|
146
|
+
description: 'Delete data from isolated prompt namespace',
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
has: {
|
|
150
|
+
name: 'has',
|
|
151
|
+
description: 'Check if a key exists in a prompt namespace.',
|
|
152
|
+
dependencies: [],
|
|
153
|
+
parameters: [
|
|
154
|
+
{
|
|
155
|
+
name: 'promptId',
|
|
156
|
+
type: 'string',
|
|
157
|
+
value: 'string',
|
|
158
|
+
description: 'Unique prompt/conversation identifier',
|
|
159
|
+
required: true,
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: 'key',
|
|
163
|
+
type: 'string',
|
|
164
|
+
value: 'string',
|
|
165
|
+
description: 'The key to check in the prompt namespace',
|
|
166
|
+
required: true,
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
examples: [
|
|
170
|
+
{
|
|
171
|
+
description: 'Check if a key exists',
|
|
172
|
+
intent: 'Check if user name exists in conversation 123',
|
|
173
|
+
params: {
|
|
174
|
+
promptId: 'conversation-123',
|
|
175
|
+
key: 'user_name',
|
|
176
|
+
},
|
|
177
|
+
expectedResult: {
|
|
178
|
+
success: true,
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
performance: {
|
|
183
|
+
estimatedDuration: 5,
|
|
184
|
+
maxDuration: 500,
|
|
185
|
+
idempotent: true,
|
|
186
|
+
cacheable: true,
|
|
187
|
+
},
|
|
188
|
+
approvalMetadata: {
|
|
189
|
+
riskLevel: 'low',
|
|
190
|
+
category: 'read',
|
|
191
|
+
description: 'Check key existence in isolated prompt namespace',
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
list_prompts: {
|
|
195
|
+
name: 'list_prompts',
|
|
196
|
+
description: 'List all prompt IDs that have active storage. Returns an array of prompt identifiers.',
|
|
197
|
+
dependencies: [],
|
|
198
|
+
parameters: [],
|
|
199
|
+
examples: [
|
|
200
|
+
{
|
|
201
|
+
description: 'List all prompts with storage',
|
|
202
|
+
intent: 'Show all conversations that have stored data',
|
|
203
|
+
params: {},
|
|
204
|
+
expectedResult: {
|
|
205
|
+
promptIds: ['conversation-123', 'conversation-456'],
|
|
206
|
+
count: 2,
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
],
|
|
210
|
+
performance: {
|
|
211
|
+
estimatedDuration: 10,
|
|
212
|
+
maxDuration: 1000,
|
|
213
|
+
idempotent: true,
|
|
214
|
+
cacheable: true,
|
|
215
|
+
},
|
|
216
|
+
approvalMetadata: {
|
|
217
|
+
riskLevel: 'low',
|
|
218
|
+
category: 'read',
|
|
219
|
+
description: 'List all prompt namespaces',
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
clear_prompt: {
|
|
223
|
+
name: 'clear_prompt',
|
|
224
|
+
description: 'Clear all data for a specific prompt namespace. This removes all keys and values.',
|
|
225
|
+
dependencies: [],
|
|
226
|
+
parameters: [
|
|
227
|
+
{
|
|
228
|
+
name: 'promptId',
|
|
229
|
+
type: 'string',
|
|
230
|
+
value: 'string',
|
|
231
|
+
description: 'Unique prompt/conversation identifier to clear',
|
|
232
|
+
required: true,
|
|
233
|
+
},
|
|
234
|
+
],
|
|
235
|
+
examples: [
|
|
236
|
+
{
|
|
237
|
+
description: 'Clear all data for a conversation',
|
|
238
|
+
intent: 'Delete all stored data for conversation 123',
|
|
239
|
+
params: {
|
|
240
|
+
promptId: 'conversation-123',
|
|
241
|
+
},
|
|
242
|
+
expectedResult: {
|
|
243
|
+
success: true,
|
|
244
|
+
keysDeleted: 5,
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
performance: {
|
|
249
|
+
estimatedDuration: 20,
|
|
250
|
+
maxDuration: 2000,
|
|
251
|
+
idempotent: true,
|
|
252
|
+
cacheable: false,
|
|
253
|
+
},
|
|
254
|
+
approvalMetadata: {
|
|
255
|
+
riskLevel: 'medium',
|
|
256
|
+
category: 'write',
|
|
257
|
+
description: 'Clear entire prompt namespace',
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
get_prompt_keys: {
|
|
261
|
+
name: 'get_prompt_keys',
|
|
262
|
+
description: 'Get all keys stored in a specific prompt namespace. Returns an array of key names.',
|
|
263
|
+
dependencies: [],
|
|
264
|
+
parameters: [
|
|
265
|
+
{
|
|
266
|
+
name: 'promptId',
|
|
267
|
+
type: 'string',
|
|
268
|
+
value: 'string',
|
|
269
|
+
description: 'Unique prompt/conversation identifier',
|
|
270
|
+
required: true,
|
|
271
|
+
},
|
|
272
|
+
],
|
|
273
|
+
examples: [
|
|
274
|
+
{
|
|
275
|
+
description: 'Get all keys for a conversation',
|
|
276
|
+
intent: 'List all data keys stored for conversation 123',
|
|
277
|
+
params: {
|
|
278
|
+
promptId: 'conversation-123',
|
|
279
|
+
},
|
|
280
|
+
expectedResult: {
|
|
281
|
+
keys: ['user_name', 'user_email', 'preferences'],
|
|
282
|
+
count: 3,
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
],
|
|
286
|
+
performance: {
|
|
287
|
+
estimatedDuration: 10,
|
|
288
|
+
maxDuration: 1000,
|
|
289
|
+
idempotent: true,
|
|
290
|
+
cacheable: true,
|
|
291
|
+
},
|
|
292
|
+
approvalMetadata: {
|
|
293
|
+
riskLevel: 'low',
|
|
294
|
+
category: 'read',
|
|
295
|
+
description: 'List keys in prompt namespace',
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
get_prompt_stats: {
|
|
299
|
+
name: 'get_prompt_stats',
|
|
300
|
+
description: 'Get statistics for a specific prompt namespace including key count and last accessed time.',
|
|
301
|
+
dependencies: [],
|
|
302
|
+
parameters: [
|
|
303
|
+
{
|
|
304
|
+
name: 'promptId',
|
|
305
|
+
type: 'string',
|
|
306
|
+
value: 'string',
|
|
307
|
+
description: 'Unique prompt/conversation identifier',
|
|
308
|
+
required: true,
|
|
309
|
+
},
|
|
310
|
+
],
|
|
311
|
+
examples: [
|
|
312
|
+
{
|
|
313
|
+
description: 'Get stats for a conversation',
|
|
314
|
+
intent: 'Show storage statistics for conversation 123',
|
|
315
|
+
params: {
|
|
316
|
+
promptId: 'conversation-123',
|
|
317
|
+
},
|
|
318
|
+
expectedResult: {
|
|
319
|
+
promptId: 'conversation-123',
|
|
320
|
+
keyCount: 3,
|
|
321
|
+
lastAccessed: 1638360000000,
|
|
322
|
+
exists: true,
|
|
323
|
+
},
|
|
324
|
+
},
|
|
325
|
+
],
|
|
326
|
+
performance: {
|
|
327
|
+
estimatedDuration: 10,
|
|
328
|
+
maxDuration: 1000,
|
|
329
|
+
idempotent: true,
|
|
330
|
+
cacheable: true,
|
|
331
|
+
},
|
|
332
|
+
approvalMetadata: {
|
|
333
|
+
riskLevel: 'low',
|
|
334
|
+
category: 'read',
|
|
335
|
+
description: 'Get prompt namespace statistics',
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt Loader
|
|
3
|
+
*
|
|
4
|
+
* Loads and compiles prompts from PromptStorageProvider with fallback to hardcoded versions
|
|
5
|
+
*/
|
|
6
|
+
import { PromptStorageProvider } from './prompt-storage-provider.tool.js';
|
|
7
|
+
/**
|
|
8
|
+
* Loads prompts from storage and compiles them into final prompt strings
|
|
9
|
+
*/
|
|
10
|
+
export declare class PromptLoader {
|
|
11
|
+
private storage?;
|
|
12
|
+
private cache;
|
|
13
|
+
private useStorage;
|
|
14
|
+
constructor(storage?: PromptStorageProvider | undefined);
|
|
15
|
+
/**
|
|
16
|
+
* Generate agent prompt (equivalent to AGENT_PROMPT function)
|
|
17
|
+
*/
|
|
18
|
+
generateAgentPrompt(intent: string, context: string, agentHistory: string, extraInstructions: string): Promise<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Generate custom agent prompt (equivalent to CUSTOM_AGENT_PROMPT function)
|
|
21
|
+
*/
|
|
22
|
+
generateCustomAgentPrompt(intent: string, context: string, agentHistory: string, cycleInstructions: string, outputInstructions: string, extraInstructions: string): Promise<string>;
|
|
23
|
+
/**
|
|
24
|
+
* Load configure instructions
|
|
25
|
+
*/
|
|
26
|
+
loadConfigureInstructions(): Promise<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Load a template from storage
|
|
29
|
+
*/
|
|
30
|
+
private loadTemplate;
|
|
31
|
+
/**
|
|
32
|
+
* Clear the template cache
|
|
33
|
+
*/
|
|
34
|
+
clearCache(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Enable or disable storage usage
|
|
37
|
+
*/
|
|
38
|
+
setUseStorage(use: boolean): void;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=prompt-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-loader.d.ts","sourceRoot":"","sources":["../../../src/storage/prompt-loader.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAU1E;;GAEG;AACH,qBAAa,YAAY;IAIX,OAAO,CAAC,OAAO,CAAC;IAH5B,OAAO,CAAC,KAAK,CAAgD;IAC7D,OAAO,CAAC,UAAU,CAAiB;gBAEf,OAAO,CAAC,mCAAuB;IAMnD;;OAEG;IACG,mBAAmB,CACvB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,iBAAiB,EAAE,MAAM,GACxB,OAAO,CAAC,MAAM,CAAC;IAiClB;;OAEG;IACG,yBAAyB,CAC7B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,iBAAiB,EAAE,MAAM,EACzB,kBAAkB,EAAE,MAAM,EAC1B,iBAAiB,EAAE,MAAM,GACxB,OAAO,CAAC,MAAM,CAAC;IA0ClB;;OAEG;IACG,yBAAyB,IAAI,OAAO,CAAC,MAAM,CAAC;IAqBlD;;OAEG;YACW,YAAY;IAgC1B;;OAEG;IACH,UAAU,IAAI,IAAI;IAIlB;;OAEG;IACH,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI;CAGlC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt Loader
|
|
3
|
+
*
|
|
4
|
+
* Loads and compiles prompts from PromptStorageProvider with fallback to hardcoded versions
|
|
5
|
+
*/
|
|
6
|
+
import { PROMPT_KEYS, PROMPT_IDS, } from './prompt-schema.js';
|
|
7
|
+
import { AGENT_PROMPT } from '../prompts/agent.prompt.js';
|
|
8
|
+
import { CUSTOM_AGENT_PROMPT } from '../prompts/custom.prompt.js';
|
|
9
|
+
import { CONFIGURE_INSTRUCTIONS } from '../prompts/configure.prompt.js';
|
|
10
|
+
/**
|
|
11
|
+
* Loads prompts from storage and compiles them into final prompt strings
|
|
12
|
+
*/
|
|
13
|
+
export class PromptLoader {
|
|
14
|
+
constructor(storage) {
|
|
15
|
+
this.storage = storage;
|
|
16
|
+
this.cache = new Map();
|
|
17
|
+
this.useStorage = true;
|
|
18
|
+
if (!storage) {
|
|
19
|
+
this.useStorage = false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Generate agent prompt (equivalent to AGENT_PROMPT function)
|
|
24
|
+
*/
|
|
25
|
+
async generateAgentPrompt(intent, context, agentHistory, extraInstructions) {
|
|
26
|
+
if (!this.useStorage || !this.storage) {
|
|
27
|
+
// Fallback to hardcoded version
|
|
28
|
+
return AGENT_PROMPT(intent, context, agentHistory, extraInstructions);
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
// Load templates from storage
|
|
32
|
+
const cycleInstructions = await this.loadTemplate(PROMPT_IDS.AGENT, PROMPT_KEYS.CYCLE_INSTRUCTIONS);
|
|
33
|
+
const outputInstructions = await this.loadTemplate(PROMPT_IDS.AGENT, PROMPT_KEYS.OUTPUT_INSTRUCTIONS);
|
|
34
|
+
// Compile using custom agent prompt
|
|
35
|
+
return await this.generateCustomAgentPrompt(intent, context, agentHistory, cycleInstructions, outputInstructions, extraInstructions);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
// Fallback to hardcoded version on error
|
|
39
|
+
console.warn('Failed to load prompts from storage, using fallback', error);
|
|
40
|
+
return AGENT_PROMPT(intent, context, agentHistory, extraInstructions);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Generate custom agent prompt (equivalent to CUSTOM_AGENT_PROMPT function)
|
|
45
|
+
*/
|
|
46
|
+
async generateCustomAgentPrompt(intent, context, agentHistory, cycleInstructions, outputInstructions, extraInstructions) {
|
|
47
|
+
if (!this.useStorage || !this.storage) {
|
|
48
|
+
// Fallback to hardcoded version
|
|
49
|
+
return CUSTOM_AGENT_PROMPT(intent, context, agentHistory, cycleInstructions, outputInstructions, extraInstructions);
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
// Load base template from storage
|
|
53
|
+
const baseTemplate = await this.loadTemplate(PROMPT_IDS.AGENT, PROMPT_KEYS.BASE_TEMPLATE);
|
|
54
|
+
// Replace placeholders with actual values
|
|
55
|
+
return baseTemplate
|
|
56
|
+
.replace('{{intent}}', intent)
|
|
57
|
+
.replace('{{context}}', context)
|
|
58
|
+
.replace('{{agentHistory}}', agentHistory)
|
|
59
|
+
.replace('{{cycleInstructions}}', cycleInstructions)
|
|
60
|
+
.replace('{{outputInstructions}}', outputInstructions)
|
|
61
|
+
.replace('{{extraInstructions}}', extraInstructions);
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
// Fallback to hardcoded version on error
|
|
65
|
+
console.warn('Failed to load base template from storage, using fallback', error);
|
|
66
|
+
return CUSTOM_AGENT_PROMPT(intent, context, agentHistory, cycleInstructions, outputInstructions, extraInstructions);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Load configure instructions
|
|
71
|
+
*/
|
|
72
|
+
async loadConfigureInstructions() {
|
|
73
|
+
if (!this.useStorage || !this.storage) {
|
|
74
|
+
// Fallback to hardcoded version
|
|
75
|
+
return CONFIGURE_INSTRUCTIONS;
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
return await this.loadTemplate(PROMPT_IDS.AGENT, PROMPT_KEYS.CONFIGURE_INSTRUCTIONS);
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
// Fallback to hardcoded version on error
|
|
82
|
+
console.warn('Failed to load configure instructions from storage, using fallback', error);
|
|
83
|
+
return CONFIGURE_INSTRUCTIONS;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Load a template from storage
|
|
88
|
+
*/
|
|
89
|
+
async loadTemplate(promptId, key) {
|
|
90
|
+
// Check cache first
|
|
91
|
+
const cacheKey = `${promptId}:${key}`;
|
|
92
|
+
if (this.cache.has(cacheKey)) {
|
|
93
|
+
return this.cache.get(cacheKey).content;
|
|
94
|
+
}
|
|
95
|
+
if (!this.storage) {
|
|
96
|
+
throw new Error('Storage not available');
|
|
97
|
+
}
|
|
98
|
+
// Load from storage
|
|
99
|
+
const response = await this.storage.use(this.storage.address, {
|
|
100
|
+
method: 'get',
|
|
101
|
+
params: { promptId, key },
|
|
102
|
+
});
|
|
103
|
+
if (!response.result.success) {
|
|
104
|
+
throw new Error(`Failed to load template: ${response.result.error}`);
|
|
105
|
+
}
|
|
106
|
+
const template = response.result?.data?.value;
|
|
107
|
+
if (!template || !template.content) {
|
|
108
|
+
throw new Error(`Template not found: ${promptId}/${key}`);
|
|
109
|
+
}
|
|
110
|
+
// Cache for future use
|
|
111
|
+
this.cache.set(cacheKey, template);
|
|
112
|
+
return template.content;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Clear the template cache
|
|
116
|
+
*/
|
|
117
|
+
clearCache() {
|
|
118
|
+
this.cache.clear();
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Enable or disable storage usage
|
|
122
|
+
*/
|
|
123
|
+
setUseStorage(use) {
|
|
124
|
+
this.useStorage = use && !!this.storage;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt Storage Schema
|
|
3
|
+
*
|
|
4
|
+
* Defines the structure for storing prompt templates in PromptStorageProvider
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Prompt storage keys for the 'agent' promptId namespace
|
|
8
|
+
*/
|
|
9
|
+
export declare const PROMPT_KEYS: {
|
|
10
|
+
readonly BASE_TEMPLATE: "base_template";
|
|
11
|
+
readonly CYCLE_INSTRUCTIONS: "cycle_instructions";
|
|
12
|
+
readonly OUTPUT_INSTRUCTIONS: "output_instructions";
|
|
13
|
+
readonly CONFIGURE_INSTRUCTIONS: "configure_instructions";
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Prompt namespace IDs
|
|
17
|
+
*/
|
|
18
|
+
export declare const PROMPT_IDS: {
|
|
19
|
+
readonly AGENT: "agent";
|
|
20
|
+
readonly CUSTOM: "custom";
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Version tracking for prompt templates
|
|
24
|
+
*/
|
|
25
|
+
export declare const PROMPT_VERSION = "1.0.0";
|
|
26
|
+
/**
|
|
27
|
+
* Interface for prompt template metadata
|
|
28
|
+
*/
|
|
29
|
+
export interface PromptTemplateMetadata {
|
|
30
|
+
version: string;
|
|
31
|
+
description: string;
|
|
32
|
+
lastModified: number;
|
|
33
|
+
source: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Type for stored prompt data
|
|
37
|
+
*/
|
|
38
|
+
export interface StoredPromptTemplate {
|
|
39
|
+
content: string;
|
|
40
|
+
metadata: PromptTemplateMetadata;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=prompt-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-schema.d.ts","sourceRoot":"","sources":["../../../src/storage/prompt-schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;CAYd,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,UAAU;;;CAGb,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,cAAc,UAAU,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,sBAAsB,CAAC;CAClC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt Storage Schema
|
|
3
|
+
*
|
|
4
|
+
* Defines the structure for storing prompt templates in PromptStorageProvider
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Prompt storage keys for the 'agent' promptId namespace
|
|
8
|
+
*/
|
|
9
|
+
export const PROMPT_KEYS = {
|
|
10
|
+
// Base template structure (from custom.prompt.ts)
|
|
11
|
+
BASE_TEMPLATE: 'base_template',
|
|
12
|
+
// Cycle instructions for agent workflow (from agent.prompt.ts lines 13-68)
|
|
13
|
+
CYCLE_INSTRUCTIONS: 'cycle_instructions',
|
|
14
|
+
// Output/return format instructions (from agent.prompt.ts lines 70-145)
|
|
15
|
+
OUTPUT_INSTRUCTIONS: 'output_instructions',
|
|
16
|
+
// Configure-specific instructions (from configure.prompt.ts)
|
|
17
|
+
CONFIGURE_INSTRUCTIONS: 'configure_instructions',
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Prompt namespace IDs
|
|
21
|
+
*/
|
|
22
|
+
export const PROMPT_IDS = {
|
|
23
|
+
AGENT: 'agent',
|
|
24
|
+
CUSTOM: 'custom',
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Version tracking for prompt templates
|
|
28
|
+
*/
|
|
29
|
+
export const PROMPT_VERSION = '1.0.0';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt Seeder
|
|
3
|
+
*
|
|
4
|
+
* Seeds the PromptStorageProvider with prompt templates from prompts/ folder
|
|
5
|
+
*/
|
|
6
|
+
import { PromptStorageProvider } from './prompt-storage-provider.tool.js';
|
|
7
|
+
/**
|
|
8
|
+
* Seeds the prompt storage with default prompt templates
|
|
9
|
+
*/
|
|
10
|
+
export declare class PromptSeeder {
|
|
11
|
+
private storage;
|
|
12
|
+
constructor(storage: PromptStorageProvider);
|
|
13
|
+
/**
|
|
14
|
+
* Seed all default prompts into storage
|
|
15
|
+
*/
|
|
16
|
+
seedAll(): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Seed the base template from custom.prompt.ts
|
|
19
|
+
*/
|
|
20
|
+
private seedBaseTemplate;
|
|
21
|
+
/**
|
|
22
|
+
* Seed cycle instructions from agent.prompt.ts
|
|
23
|
+
*/
|
|
24
|
+
private seedCycleInstructions;
|
|
25
|
+
/**
|
|
26
|
+
* Seed output instructions from agent.prompt.ts
|
|
27
|
+
*/
|
|
28
|
+
private seedOutputInstructions;
|
|
29
|
+
/**
|
|
30
|
+
* Seed configure instructions from configure.prompt.ts
|
|
31
|
+
*/
|
|
32
|
+
private seedConfigureInstructions;
|
|
33
|
+
/**
|
|
34
|
+
* Check if prompts are already seeded
|
|
35
|
+
*/
|
|
36
|
+
isSeeded(): Promise<boolean>;
|
|
37
|
+
/**
|
|
38
|
+
* Clear all seeded prompts
|
|
39
|
+
*/
|
|
40
|
+
clearAll(): Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=prompt-seeder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-seeder.d.ts","sourceRoot":"","sources":["../../../src/storage/prompt-seeder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAc1E;;GAEG;AACH,qBAAa,YAAY;IACX,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,qBAAqB;IAElD;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAO9B;;OAEG;YACW,gBAAgB;IAqB9B;;OAEG;YACW,qBAAqB;IAqBnC;;OAEG;YACW,sBAAsB;IAqBpC;;OAEG;YACW,yBAAyB;IAqBvC;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC;IAgBlC;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAQhC"}
|