@goreal-ai/echo-pdk 0.8.1 → 0.10.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/evaluator/evaluator.d.ts.map +1 -1
- package/dist/evaluator/evaluator.js +8 -0
- package/dist/evaluator/evaluator.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +91 -3
- package/dist/index.js.map +1 -1
- package/dist/parser/ast.d.ts +11 -1
- package/dist/parser/ast.d.ts.map +1 -1
- package/dist/parser/ast.js +38 -0
- package/dist/parser/ast.js.map +1 -1
- package/dist/parser/lexer.d.ts +16 -0
- package/dist/parser/lexer.d.ts.map +1 -1
- package/dist/parser/lexer.js +34 -0
- package/dist/parser/lexer.js.map +1 -1
- package/dist/parser/parser.d.ts.map +1 -1
- package/dist/parser/parser.js +175 -3
- package/dist/parser/parser.js.map +1 -1
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +20 -1
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/google.d.ts +20 -0
- package/dist/providers/google.d.ts.map +1 -0
- package/dist/providers/google.js +152 -0
- package/dist/providers/google.js.map +1 -0
- package/dist/providers/index.d.ts +2 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +1 -0
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/openai.d.ts.map +1 -1
- package/dist/providers/openai.js +15 -1
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/registry.d.ts.map +1 -1
- package/dist/providers/registry.js +3 -0
- package/dist/providers/registry.js.map +1 -1
- package/dist/providers/run-prompt.d.ts +3 -0
- package/dist/providers/run-prompt.d.ts.map +1 -1
- package/dist/providers/run-prompt.js +20 -9
- package/dist/providers/run-prompt.js.map +1 -1
- package/dist/providers/types.d.ts +17 -2
- package/dist/providers/types.d.ts.map +1 -1
- package/dist/renderer/renderer.d.ts +14 -1
- package/dist/renderer/renderer.d.ts.map +1 -1
- package/dist/renderer/renderer.js +116 -0
- package/dist/renderer/renderer.js.map +1 -1
- package/dist/types.d.ts +102 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/scripts/bundle-for-graaljs.mjs +39 -1
- package/scripts/stubs/fs-promises.mjs +27 -0
- package/scripts/stubs/fs.mjs +18 -0
- package/scripts/stubs/path.mjs +33 -0
|
@@ -30,9 +30,12 @@ async function bundle() {
|
|
|
30
30
|
'process.env': '{}',
|
|
31
31
|
'process': '{"env":{}}',
|
|
32
32
|
},
|
|
33
|
-
// Stub out
|
|
33
|
+
// Stub out Node.js built-ins not available in GraalJS
|
|
34
34
|
alias: {
|
|
35
35
|
'crypto': join(__dirname, 'stubs', 'crypto.mjs'),
|
|
36
|
+
'fs/promises': join(__dirname, 'stubs', 'fs-promises.mjs'),
|
|
37
|
+
'fs': join(__dirname, 'stubs', 'fs.mjs'),
|
|
38
|
+
'path': join(__dirname, 'stubs', 'path.mjs'),
|
|
36
39
|
},
|
|
37
40
|
});
|
|
38
41
|
|
|
@@ -142,6 +145,8 @@ var echoPdk = {
|
|
|
142
145
|
}
|
|
143
146
|
} else if (node.type === 'section') {
|
|
144
147
|
visit(node.body);
|
|
148
|
+
} else if (node.type === 'role') {
|
|
149
|
+
visit(node.body);
|
|
145
150
|
}
|
|
146
151
|
}
|
|
147
152
|
}
|
|
@@ -205,6 +210,39 @@ var echoPdk = {
|
|
|
205
210
|
*/
|
|
206
211
|
runPrompt: function(options) {
|
|
207
212
|
return EchoPDK.runPrompt(options);
|
|
213
|
+
},
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Render a template to structured messages, tool definitions, and meta config (async).
|
|
217
|
+
* Returns { messages: [{ role, content }], tools: [{ type, function }], meta: {} }.
|
|
218
|
+
* @param {string} template - The Echo DSL template with [#ROLE] and [#TOOL] blocks
|
|
219
|
+
* @param {Object} context - Variables to substitute
|
|
220
|
+
* @param {Object} [config] - Optional configuration (may include metaTemplate)
|
|
221
|
+
* @returns {Promise<Object>} - { messages, tools, meta }
|
|
222
|
+
*/
|
|
223
|
+
renderMessages: function(template, context, config) {
|
|
224
|
+
var metaTemplate = config && config.metaTemplate;
|
|
225
|
+
var echoConfig = {};
|
|
226
|
+
if (config) {
|
|
227
|
+
Object.keys(config).forEach(function(k) {
|
|
228
|
+
if (k !== 'metaTemplate') echoConfig[k] = config[k];
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
var echo = EchoPDK.createEcho(echoConfig);
|
|
232
|
+
var options = metaTemplate ? { metaTemplate: metaTemplate } : undefined;
|
|
233
|
+
return echo.renderMessages(template, context || {}, options).then(function(result) {
|
|
234
|
+
// Simplify content blocks to plain strings for Java interop
|
|
235
|
+
return {
|
|
236
|
+
messages: result.messages.map(function(m) {
|
|
237
|
+
var text = m.content.map(function(b) {
|
|
238
|
+
return b.type === 'text' ? b.text : '';
|
|
239
|
+
}).join('');
|
|
240
|
+
return { role: m.role, content: text };
|
|
241
|
+
}),
|
|
242
|
+
tools: result.tools,
|
|
243
|
+
meta: result.meta || {}
|
|
244
|
+
};
|
|
245
|
+
});
|
|
208
246
|
}
|
|
209
247
|
};
|
|
210
248
|
`;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* fs/promises stub for GraalJS bundle.
|
|
3
|
+
* File system operations are only used by the CLI eval runner (loader.ts, dataset.ts, runner.ts).
|
|
4
|
+
* In Java, datasets and eval runs are managed via the database, not the filesystem.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export async function readFile() {
|
|
8
|
+
throw new Error('fs/promises.readFile is not available in GraalJS');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function writeFile() {
|
|
12
|
+
throw new Error('fs/promises.writeFile is not available in GraalJS');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export async function readdir() {
|
|
16
|
+
throw new Error('fs/promises.readdir is not available in GraalJS');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function stat() {
|
|
20
|
+
throw new Error('fs/promises.stat is not available in GraalJS');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export async function mkdir() {
|
|
24
|
+
throw new Error('fs/promises.mkdir is not available in GraalJS');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default { readFile, writeFile, readdir, stat, mkdir };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* fs stub for GraalJS bundle.
|
|
3
|
+
* File system operations are not available in the GraalJS runtime.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export function readFileSync() {
|
|
7
|
+
throw new Error('fs.readFileSync is not available in GraalJS');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function writeFileSync() {
|
|
11
|
+
throw new Error('fs.writeFileSync is not available in GraalJS');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function existsSync() {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default { readFileSync, writeFileSync, existsSync };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* path stub for GraalJS bundle.
|
|
3
|
+
* Path operations are only used by the CLI eval runner (dataset.ts, runner.ts).
|
|
4
|
+
* In Java, file paths are managed by the JVM, not JavaScript.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export function join(...parts) {
|
|
8
|
+
return parts.filter(Boolean).join('/');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function resolve(...parts) {
|
|
12
|
+
return parts.filter(Boolean).join('/');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function dirname(p) {
|
|
16
|
+
const i = p.lastIndexOf('/');
|
|
17
|
+
return i >= 0 ? p.substring(0, i) : '.';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function basename(p, ext) {
|
|
21
|
+
let base = p.substring(p.lastIndexOf('/') + 1);
|
|
22
|
+
if (ext && base.endsWith(ext)) {
|
|
23
|
+
base = base.substring(0, base.length - ext.length);
|
|
24
|
+
}
|
|
25
|
+
return base;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function extname(p) {
|
|
29
|
+
const i = p.lastIndexOf('.');
|
|
30
|
+
return i >= 0 ? p.substring(i) : '';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default { join, resolve, dirname, basename, extname };
|