@vertesia/build-tools 0.24.0-dev.202601221707
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/LICENSE +13 -0
- package/README.md +334 -0
- package/lib/build-tools.js +1730 -0
- package/lib/build-tools.js.map +1 -0
- package/lib/cjs/index.js +39 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/parsers/frontmatter.js +25 -0
- package/lib/cjs/parsers/frontmatter.js.map +1 -0
- package/lib/cjs/plugin.js +150 -0
- package/lib/cjs/plugin.js.map +1 -0
- package/lib/cjs/presets/index.js +19 -0
- package/lib/cjs/presets/index.js.map +1 -0
- package/lib/cjs/presets/prompt.js +185 -0
- package/lib/cjs/presets/prompt.js.map +1 -0
- package/lib/cjs/presets/raw.js +25 -0
- package/lib/cjs/presets/raw.js.map +1 -0
- package/lib/cjs/presets/skill-collection.js +83 -0
- package/lib/cjs/presets/skill-collection.js.map +1 -0
- package/lib/cjs/presets/skill.js +224 -0
- package/lib/cjs/presets/skill.js.map +1 -0
- package/lib/cjs/types.js +6 -0
- package/lib/cjs/types.js.map +1 -0
- package/lib/cjs/utils/asset-copy.js +61 -0
- package/lib/cjs/utils/asset-copy.js.map +1 -0
- package/lib/cjs/utils/asset-discovery.js +100 -0
- package/lib/cjs/utils/asset-discovery.js.map +1 -0
- package/lib/cjs/utils/widget-compiler.js +115 -0
- package/lib/cjs/utils/widget-compiler.js.map +1 -0
- package/lib/esm/index.js +26 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/parsers/frontmatter.js +19 -0
- package/lib/esm/parsers/frontmatter.js.map +1 -0
- package/lib/esm/plugin.js +144 -0
- package/lib/esm/plugin.js.map +1 -0
- package/lib/esm/presets/index.js +8 -0
- package/lib/esm/presets/index.js.map +1 -0
- package/lib/esm/presets/prompt.js +181 -0
- package/lib/esm/presets/prompt.js.map +1 -0
- package/lib/esm/presets/raw.js +22 -0
- package/lib/esm/presets/raw.js.map +1 -0
- package/lib/esm/presets/skill-collection.js +77 -0
- package/lib/esm/presets/skill-collection.js.map +1 -0
- package/lib/esm/presets/skill.js +221 -0
- package/lib/esm/presets/skill.js.map +1 -0
- package/lib/esm/types.js +5 -0
- package/lib/esm/types.js.map +1 -0
- package/lib/esm/utils/asset-copy.js +54 -0
- package/lib/esm/utils/asset-copy.js.map +1 -0
- package/lib/esm/utils/asset-discovery.js +94 -0
- package/lib/esm/utils/asset-discovery.js.map +1 -0
- package/lib/esm/utils/widget-compiler.js +76 -0
- package/lib/esm/utils/widget-compiler.js.map +1 -0
- package/lib/types/index.d.ts +24 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/parsers/frontmatter.d.ts +19 -0
- package/lib/types/parsers/frontmatter.d.ts.map +1 -0
- package/lib/types/plugin.d.ts +10 -0
- package/lib/types/plugin.d.ts.map +1 -0
- package/lib/types/presets/index.d.ts +8 -0
- package/lib/types/presets/index.d.ts.map +1 -0
- package/lib/types/presets/prompt.d.ts +63 -0
- package/lib/types/presets/prompt.d.ts.map +1 -0
- package/lib/types/presets/raw.d.ts +16 -0
- package/lib/types/presets/raw.d.ts.map +1 -0
- package/lib/types/presets/skill-collection.d.ts +26 -0
- package/lib/types/presets/skill-collection.d.ts.map +1 -0
- package/lib/types/presets/skill.d.ts +139 -0
- package/lib/types/presets/skill.d.ts.map +1 -0
- package/lib/types/types.d.ts +115 -0
- package/lib/types/types.d.ts.map +1 -0
- package/lib/types/utils/asset-copy.d.ts +20 -0
- package/lib/types/utils/asset-copy.d.ts.map +1 -0
- package/lib/types/utils/asset-discovery.d.ts +38 -0
- package/lib/types/utils/asset-discovery.d.ts.map +1 -0
- package/lib/types/utils/widget-compiler.d.ts +15 -0
- package/lib/types/utils/widget-compiler.d.ts.map +1 -0
- package/package.json +69 -0
- package/src/index.ts +52 -0
- package/src/parsers/frontmatter.ts +32 -0
- package/src/plugin.ts +166 -0
- package/src/presets/index.ts +8 -0
- package/src/presets/prompt.ts +227 -0
- package/src/presets/raw.ts +24 -0
- package/src/presets/skill-collection.ts +86 -0
- package/src/presets/skill.ts +271 -0
- package/src/types.ts +140 -0
- package/src/utils/asset-copy.ts +63 -0
- package/src/utils/asset-discovery.ts +138 -0
- package/src/utils/widget-compiler.ts +98 -0
|
@@ -0,0 +1,1730 @@
|
|
|
1
|
+
import { copyFileSync, mkdirSync, readFileSync, readdirSync, statSync, existsSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { rollup } from 'rollup';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import matter from 'gray-matter';
|
|
6
|
+
import path$1 from 'path';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Utilities for copying asset files during build
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Ensure a directory exists, creating it recursively if needed
|
|
13
|
+
*/
|
|
14
|
+
function ensureDirectory(dirPath) {
|
|
15
|
+
try {
|
|
16
|
+
mkdirSync(dirPath, { recursive: true });
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
// Ignore if directory already exists
|
|
20
|
+
if (error.code !== 'EEXIST') {
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Copy an asset file to its destination
|
|
27
|
+
*
|
|
28
|
+
* @param asset - Asset file information
|
|
29
|
+
* @param assetsRoot - Root directory for assets
|
|
30
|
+
*/
|
|
31
|
+
function copyAssetFile(asset, assetsRoot) {
|
|
32
|
+
const destPath = path.join(assetsRoot, asset.destPath);
|
|
33
|
+
const destDir = path.dirname(destPath);
|
|
34
|
+
// Ensure destination directory exists
|
|
35
|
+
ensureDirectory(destDir);
|
|
36
|
+
// Copy file
|
|
37
|
+
try {
|
|
38
|
+
copyFileSync(asset.sourcePath, destPath);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
throw new Error(`Failed to copy asset from ${asset.sourcePath} to ${destPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Copy multiple asset files
|
|
46
|
+
*
|
|
47
|
+
* @param assets - Array of asset files to copy
|
|
48
|
+
* @param assetsRoot - Root directory for assets
|
|
49
|
+
* @returns Number of files copied
|
|
50
|
+
*/
|
|
51
|
+
function copyAssets(assets, assetsRoot) {
|
|
52
|
+
let copied = 0;
|
|
53
|
+
for (const asset of assets) {
|
|
54
|
+
copyAssetFile(asset, assetsRoot);
|
|
55
|
+
copied++;
|
|
56
|
+
}
|
|
57
|
+
return copied;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Widget compilation utility using Rollup
|
|
62
|
+
*/
|
|
63
|
+
/**
|
|
64
|
+
* Default external dependencies for widgets
|
|
65
|
+
*/
|
|
66
|
+
const DEFAULT_EXTERNALS = [
|
|
67
|
+
'react',
|
|
68
|
+
'react-dom',
|
|
69
|
+
'react/jsx-runtime',
|
|
70
|
+
'react/jsx-dev-runtime',
|
|
71
|
+
'react-dom/client'
|
|
72
|
+
];
|
|
73
|
+
/**
|
|
74
|
+
* Compile widgets using Rollup
|
|
75
|
+
*
|
|
76
|
+
* @param widgets - Array of widget metadata to compile
|
|
77
|
+
* @param outputDir - Directory to write compiled widgets
|
|
78
|
+
* @param config - Widget compilation configuration
|
|
79
|
+
* @returns Number of widgets compiled
|
|
80
|
+
*/
|
|
81
|
+
async function compileWidgets(widgets, outputDir, config = {}) {
|
|
82
|
+
if (widgets.length === 0) {
|
|
83
|
+
return 0;
|
|
84
|
+
}
|
|
85
|
+
const { external = DEFAULT_EXTERNALS, tsconfig = './tsconfig.json', typescript: typescriptOptions = {}, minify = false } = config;
|
|
86
|
+
// Build each widget separately to get individual bundles
|
|
87
|
+
const buildPromises = widgets.map(async (widget) => {
|
|
88
|
+
// Dynamically import plugins - use any to bypass TypeScript module resolution issues
|
|
89
|
+
const typescript = (await import('@rollup/plugin-typescript')).default;
|
|
90
|
+
const nodeResolve = (await import('@rollup/plugin-node-resolve')).default;
|
|
91
|
+
const commonjs = (await import('@rollup/plugin-commonjs')).default;
|
|
92
|
+
const plugins = [
|
|
93
|
+
typescript({
|
|
94
|
+
tsconfig,
|
|
95
|
+
declaration: false,
|
|
96
|
+
sourceMap: true,
|
|
97
|
+
...typescriptOptions
|
|
98
|
+
}),
|
|
99
|
+
nodeResolve({
|
|
100
|
+
browser: true,
|
|
101
|
+
preferBuiltins: false,
|
|
102
|
+
extensions: ['.tsx', '.ts', '.jsx', '.js']
|
|
103
|
+
}),
|
|
104
|
+
commonjs()
|
|
105
|
+
];
|
|
106
|
+
// Add minification if requested
|
|
107
|
+
if (minify) {
|
|
108
|
+
const { terser } = await import('rollup-plugin-terser');
|
|
109
|
+
plugins.push(terser({
|
|
110
|
+
compress: {
|
|
111
|
+
drop_console: false
|
|
112
|
+
}
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
115
|
+
const rollupConfig = {
|
|
116
|
+
input: widget.path,
|
|
117
|
+
output: {
|
|
118
|
+
file: path.join(outputDir, `${widget.name}.js`),
|
|
119
|
+
format: 'es',
|
|
120
|
+
sourcemap: true,
|
|
121
|
+
inlineDynamicImports: true
|
|
122
|
+
},
|
|
123
|
+
external,
|
|
124
|
+
plugins
|
|
125
|
+
};
|
|
126
|
+
const bundle = await rollup(rollupConfig);
|
|
127
|
+
await bundle.write(rollupConfig.output);
|
|
128
|
+
await bundle.close();
|
|
129
|
+
});
|
|
130
|
+
await Promise.all(buildPromises);
|
|
131
|
+
return widgets.length;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Core Rollup plugin implementation for transforming imports
|
|
136
|
+
*/
|
|
137
|
+
/**
|
|
138
|
+
* Creates a Rollup plugin that transforms imports based on configured rules
|
|
139
|
+
*/
|
|
140
|
+
function vertesiaImportPlugin(config) {
|
|
141
|
+
const { transformers, assetsDir = './dist', widgetConfig } = config;
|
|
142
|
+
if (!transformers || transformers.length === 0) {
|
|
143
|
+
throw new Error('vertesiaImportPlugin: At least one transformer must be configured');
|
|
144
|
+
}
|
|
145
|
+
// Track assets to copy and widgets to compile
|
|
146
|
+
const assetsToProcess = [];
|
|
147
|
+
const widgetsToCompile = [];
|
|
148
|
+
const shouldCopyAssets = assetsDir !== false;
|
|
149
|
+
const shouldCompileWidgets = widgetConfig !== undefined && assetsDir !== false;
|
|
150
|
+
return {
|
|
151
|
+
name: 'vertesia-import-plugin',
|
|
152
|
+
/**
|
|
153
|
+
* Resolve import IDs to handle pattern-based imports
|
|
154
|
+
*/
|
|
155
|
+
resolveId(source, importer) {
|
|
156
|
+
// Check if any transformer pattern matches
|
|
157
|
+
for (const transformer of transformers) {
|
|
158
|
+
if (transformer.pattern.test(source)) {
|
|
159
|
+
// Handle relative imports
|
|
160
|
+
if (source.startsWith('.') && importer) {
|
|
161
|
+
const cleanSource = source.replace(transformer.pattern, '');
|
|
162
|
+
// Strip query parameters from importer to get the file path
|
|
163
|
+
const cleanImporter = importer.indexOf('?') >= 0
|
|
164
|
+
? importer.substring(0, importer.indexOf('?'))
|
|
165
|
+
: importer;
|
|
166
|
+
// Always use dirname to get the directory containing the importer
|
|
167
|
+
const baseDir = path.dirname(cleanImporter);
|
|
168
|
+
const resolved = path.resolve(baseDir, cleanSource);
|
|
169
|
+
// Return with the pattern suffix to identify it in load
|
|
170
|
+
const suffix = source.match(transformer.pattern)?.[0] || '';
|
|
171
|
+
return resolved + suffix;
|
|
172
|
+
}
|
|
173
|
+
return source;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return null; // Let other plugins handle it
|
|
177
|
+
},
|
|
178
|
+
/**
|
|
179
|
+
* Load and transform the file content
|
|
180
|
+
*/
|
|
181
|
+
async load(id) {
|
|
182
|
+
// Find matching transformer
|
|
183
|
+
let matchedTransformer;
|
|
184
|
+
let cleanId = id;
|
|
185
|
+
for (const transformer of transformers) {
|
|
186
|
+
if (transformer.pattern.test(id)) {
|
|
187
|
+
matchedTransformer = transformer;
|
|
188
|
+
// Remove query parameters to get actual file path
|
|
189
|
+
// For example: '/path/file.md?skill' -> '/path/file.md'
|
|
190
|
+
// '/path/file.html?raw' -> '/path/file.html'
|
|
191
|
+
const queryIndex = id.indexOf('?');
|
|
192
|
+
cleanId = queryIndex >= 0 ? id.substring(0, queryIndex) : id;
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (!matchedTransformer) {
|
|
197
|
+
return null; // Not for us
|
|
198
|
+
}
|
|
199
|
+
try {
|
|
200
|
+
// Read file content (skip for virtual transforms)
|
|
201
|
+
const content = matchedTransformer.virtual
|
|
202
|
+
? ''
|
|
203
|
+
: readFileSync(cleanId, 'utf-8');
|
|
204
|
+
// Transform the content
|
|
205
|
+
const result = await matchedTransformer.transform(content, cleanId);
|
|
206
|
+
// Collect assets if any
|
|
207
|
+
if (result.assets && shouldCopyAssets) {
|
|
208
|
+
assetsToProcess.push(...result.assets);
|
|
209
|
+
}
|
|
210
|
+
// Collect widgets if any
|
|
211
|
+
if (result.widgets && shouldCompileWidgets) {
|
|
212
|
+
widgetsToCompile.push(...result.widgets);
|
|
213
|
+
}
|
|
214
|
+
// Validate if schema provided
|
|
215
|
+
if (matchedTransformer.schema) {
|
|
216
|
+
const validation = matchedTransformer.schema.safeParse(result.data);
|
|
217
|
+
if (!validation.success) {
|
|
218
|
+
const errors = validation.error.errors
|
|
219
|
+
.map((err) => ` - ${err.path.join('.')}: ${err.message}`)
|
|
220
|
+
.join('\n');
|
|
221
|
+
throw new Error(`Validation failed for ${id}:\n${errors}`);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
// Generate code
|
|
225
|
+
const imports = result.imports ? result.imports.join('\n') + '\n\n' : '';
|
|
226
|
+
if (result.code) {
|
|
227
|
+
// Custom code provided - prepend imports
|
|
228
|
+
return imports + result.code;
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
// Default: export data (escape if string, otherwise stringify as JSON)
|
|
232
|
+
const dataJson = JSON.stringify(result.data, null, 2);
|
|
233
|
+
return `${imports}export default ${dataJson};`;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
238
|
+
this.error(`Failed to transform ${id}: ${message}`);
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
/**
|
|
242
|
+
* Copy assets and compile widgets after all modules are loaded
|
|
243
|
+
*/
|
|
244
|
+
async buildEnd() {
|
|
245
|
+
// Copy script assets
|
|
246
|
+
if (shouldCopyAssets && assetsToProcess.length > 0) {
|
|
247
|
+
try {
|
|
248
|
+
const copied = copyAssets(assetsToProcess, assetsDir);
|
|
249
|
+
console.log(`Copied ${copied} asset file(s) to ${assetsDir}`);
|
|
250
|
+
}
|
|
251
|
+
catch (error) {
|
|
252
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
253
|
+
this.warn(`Failed to copy assets: ${message}`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
// Compile widgets
|
|
257
|
+
if (shouldCompileWidgets && widgetsToCompile.length > 0) {
|
|
258
|
+
try {
|
|
259
|
+
const widgetsDir = config.widgetsDir || 'widgets';
|
|
260
|
+
const outputDir = path.join(assetsDir, widgetsDir);
|
|
261
|
+
console.log(`Compiling ${widgetsToCompile.length} widget(s)...`);
|
|
262
|
+
const compiled = await compileWidgets(widgetsToCompile, outputDir, widgetConfig);
|
|
263
|
+
console.log(`Compiled ${compiled} widget(s) to ${outputDir}`);
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
267
|
+
this.error(`Failed to compile widgets: ${message}`);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Frontmatter parser utility using gray-matter
|
|
276
|
+
*/
|
|
277
|
+
/**
|
|
278
|
+
* Parse YAML frontmatter from markdown content
|
|
279
|
+
*
|
|
280
|
+
* @param content - Raw markdown content with optional frontmatter
|
|
281
|
+
* @returns Parsed frontmatter and content
|
|
282
|
+
*/
|
|
283
|
+
function parseFrontmatter(content) {
|
|
284
|
+
const result = matter(content);
|
|
285
|
+
return {
|
|
286
|
+
frontmatter: result.data,
|
|
287
|
+
content: result.content,
|
|
288
|
+
original: content
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Utilities for discovering asset files (scripts, widgets) in skill directories
|
|
294
|
+
*/
|
|
295
|
+
/**
|
|
296
|
+
* Check if a file exists and is a regular file
|
|
297
|
+
*/
|
|
298
|
+
function isFile(filePath) {
|
|
299
|
+
try {
|
|
300
|
+
return statSync(filePath).isFile();
|
|
301
|
+
}
|
|
302
|
+
catch {
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Get all files in a directory (non-recursive)
|
|
308
|
+
*/
|
|
309
|
+
function getFilesInDirectory(dirPath) {
|
|
310
|
+
try {
|
|
311
|
+
return readdirSync(dirPath).filter(file => {
|
|
312
|
+
const fullPath = path.join(dirPath, file);
|
|
313
|
+
return isFile(fullPath);
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
catch {
|
|
317
|
+
return [];
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Check if a file is a script file (.js or .py)
|
|
322
|
+
*/
|
|
323
|
+
function isScriptFile(fileName) {
|
|
324
|
+
return /\.(js|py)$/.test(fileName);
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Check if a file is a widget file (.tsx)
|
|
328
|
+
*/
|
|
329
|
+
function isWidgetFile(fileName) {
|
|
330
|
+
return /\.tsx$/.test(fileName);
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Extract widget name from .tsx file (remove extension)
|
|
334
|
+
*/
|
|
335
|
+
function getWidgetName(fileName) {
|
|
336
|
+
return fileName.replace(/\.tsx$/, '');
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Discover assets (scripts and widgets) in a skill directory
|
|
340
|
+
*
|
|
341
|
+
* @param skillFilePath - Absolute path to the skill.md file
|
|
342
|
+
* @param options - Asset discovery options
|
|
343
|
+
* @returns Discovered assets and metadata
|
|
344
|
+
*/
|
|
345
|
+
function discoverSkillAssets(skillFilePath, options = {}) {
|
|
346
|
+
const skillDir = path.dirname(skillFilePath);
|
|
347
|
+
const files = getFilesInDirectory(skillDir);
|
|
348
|
+
const scripts = [];
|
|
349
|
+
const widgets = [];
|
|
350
|
+
const widgetMetadata = [];
|
|
351
|
+
const assetFiles = [];
|
|
352
|
+
const scriptsDir = options.scriptsDir || 'scripts';
|
|
353
|
+
for (const file of files) {
|
|
354
|
+
const fullPath = path.join(skillDir, file);
|
|
355
|
+
if (isScriptFile(file)) {
|
|
356
|
+
// Script file (.js or .py)
|
|
357
|
+
scripts.push(file);
|
|
358
|
+
assetFiles.push({
|
|
359
|
+
sourcePath: fullPath,
|
|
360
|
+
destPath: path.join(scriptsDir, file),
|
|
361
|
+
type: 'script'
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
else if (isWidgetFile(file)) {
|
|
365
|
+
// Widget file (.tsx)
|
|
366
|
+
const widgetName = getWidgetName(file);
|
|
367
|
+
widgets.push(widgetName);
|
|
368
|
+
widgetMetadata.push({
|
|
369
|
+
name: widgetName,
|
|
370
|
+
path: fullPath
|
|
371
|
+
});
|
|
372
|
+
// Note: We don't add widget .tsx files to assetFiles
|
|
373
|
+
// Widgets are compiled by the plugin if widgetConfig is provided
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return {
|
|
377
|
+
scripts,
|
|
378
|
+
widgets,
|
|
379
|
+
widgetMetadata,
|
|
380
|
+
assetFiles
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Skill transformer preset for markdown files with frontmatter
|
|
386
|
+
*/
|
|
387
|
+
/**
|
|
388
|
+
* Context triggers for auto-injection of skills (for frontmatter validation)
|
|
389
|
+
*/
|
|
390
|
+
const SkillContextTriggersFrontmatterSchema = z.object({
|
|
391
|
+
keywords: z.array(z.string()).optional(),
|
|
392
|
+
tool_names: z.array(z.string()).optional(),
|
|
393
|
+
data_patterns: z.array(z.string()).optional()
|
|
394
|
+
}).strict();
|
|
395
|
+
/**
|
|
396
|
+
* Context triggers for auto-injection of skills (for output validation)
|
|
397
|
+
*/
|
|
398
|
+
const SkillContextTriggersSchema = z.object({
|
|
399
|
+
keywords: z.array(z.string()).optional(),
|
|
400
|
+
tool_names: z.array(z.string()).optional(),
|
|
401
|
+
data_patterns: z.array(z.string()).optional()
|
|
402
|
+
}).optional();
|
|
403
|
+
/**
|
|
404
|
+
* Execution configuration for skills that need code execution (for frontmatter validation)
|
|
405
|
+
*/
|
|
406
|
+
const SkillExecutionFrontmatterSchema = z.object({
|
|
407
|
+
language: z.string(),
|
|
408
|
+
packages: z.array(z.string()).optional(),
|
|
409
|
+
system_packages: z.array(z.string()).optional(),
|
|
410
|
+
template: z.string().optional()
|
|
411
|
+
}).strict();
|
|
412
|
+
/**
|
|
413
|
+
* Execution configuration for skills that need code execution (for output validation)
|
|
414
|
+
*/
|
|
415
|
+
const SkillExecutionSchema = z.object({
|
|
416
|
+
language: z.string(),
|
|
417
|
+
packages: z.array(z.string()).optional(),
|
|
418
|
+
system_packages: z.array(z.string()).optional(),
|
|
419
|
+
template: z.string().optional()
|
|
420
|
+
}).optional();
|
|
421
|
+
/**
|
|
422
|
+
* Zod schema for skill frontmatter validation
|
|
423
|
+
* This validates the YAML frontmatter before transformation
|
|
424
|
+
* Supports both flat and nested structures
|
|
425
|
+
*/
|
|
426
|
+
const SkillFrontmatterSchema = z.object({
|
|
427
|
+
// Required fields
|
|
428
|
+
name: z.string().min(1, 'Skill name is required'),
|
|
429
|
+
description: z.string().min(1, 'Skill description is required'),
|
|
430
|
+
// Optional fields
|
|
431
|
+
title: z.string().optional(),
|
|
432
|
+
content_type: z.enum(['md', 'jst']).optional(),
|
|
433
|
+
// Flat structure fields (legacy)
|
|
434
|
+
keywords: z.array(z.string()).optional(),
|
|
435
|
+
tools: z.array(z.string()).optional(),
|
|
436
|
+
data_patterns: z.array(z.string()).optional(),
|
|
437
|
+
language: z.string().optional(),
|
|
438
|
+
packages: z.array(z.string()).optional(),
|
|
439
|
+
system_packages: z.array(z.string()).optional(),
|
|
440
|
+
// Nested structure fields
|
|
441
|
+
context_triggers: SkillContextTriggersFrontmatterSchema.optional(),
|
|
442
|
+
execution: SkillExecutionFrontmatterSchema.optional(),
|
|
443
|
+
related_tools: z.array(z.string()).optional(),
|
|
444
|
+
input_schema: z.object({
|
|
445
|
+
type: z.literal('object'),
|
|
446
|
+
properties: z.record(z.any()).optional(),
|
|
447
|
+
required: z.array(z.string()).optional()
|
|
448
|
+
}).optional(),
|
|
449
|
+
// Asset fields (auto-discovered but can be overridden)
|
|
450
|
+
scripts: z.array(z.string()).optional(),
|
|
451
|
+
widgets: z.array(z.string()).optional()
|
|
452
|
+
}).strict();
|
|
453
|
+
/**
|
|
454
|
+
* MUST be kept in sync with @vertesia/tools-sdk SkillDefinition
|
|
455
|
+
* Zod schema for skill definition
|
|
456
|
+
* This validates the structure of skill objects generated from markdown
|
|
457
|
+
* Matches the SkillDefinition interface from @vertesia/tools-sdk
|
|
458
|
+
*/
|
|
459
|
+
const SkillDefinitionSchema = z.object({
|
|
460
|
+
name: z.string().min(1, 'Skill name is required'),
|
|
461
|
+
title: z.string().optional(),
|
|
462
|
+
description: z.string().min(1, 'Skill description is required'),
|
|
463
|
+
instructions: z.string(),
|
|
464
|
+
content_type: z.enum(['md', 'jst']),
|
|
465
|
+
input_schema: z.object({
|
|
466
|
+
type: z.literal('object'),
|
|
467
|
+
properties: z.record(z.any()).optional(),
|
|
468
|
+
required: z.array(z.string()).optional()
|
|
469
|
+
}).optional(),
|
|
470
|
+
context_triggers: SkillContextTriggersSchema,
|
|
471
|
+
execution: SkillExecutionSchema,
|
|
472
|
+
related_tools: z.array(z.string()).optional(),
|
|
473
|
+
scripts: z.array(z.string()).optional(),
|
|
474
|
+
widgets: z.array(z.string()).optional()
|
|
475
|
+
});
|
|
476
|
+
/**
|
|
477
|
+
* Build a SkillDefinition from frontmatter and markdown content.
|
|
478
|
+
* This mirrors the logic in @vertesia/tools-sdk parseSkillFile function.
|
|
479
|
+
*
|
|
480
|
+
* Supports two frontmatter structures:
|
|
481
|
+
*
|
|
482
|
+
* 1. Flat structure (matches parseSkillFile in tools-sdk):
|
|
483
|
+
* keywords: [...]
|
|
484
|
+
* tools: [...]
|
|
485
|
+
* language: python
|
|
486
|
+
* packages: [...]
|
|
487
|
+
*
|
|
488
|
+
* 2. Nested structure (for more explicit YAML):
|
|
489
|
+
* context_triggers:
|
|
490
|
+
* keywords: [...]
|
|
491
|
+
* tool_names: [...]
|
|
492
|
+
* execution:
|
|
493
|
+
* language: python
|
|
494
|
+
* packages: [...]
|
|
495
|
+
* related_tools: [...]
|
|
496
|
+
*
|
|
497
|
+
* @param frontmatter - Parsed frontmatter object
|
|
498
|
+
* @param instructions - Markdown content (body of the file)
|
|
499
|
+
* @param contentType - Content type ('md' or 'jst')
|
|
500
|
+
* @param widgets - Discovered widget names
|
|
501
|
+
* @param scripts - Discovered script names
|
|
502
|
+
* @returns Skill definition object
|
|
503
|
+
*/
|
|
504
|
+
function buildSkillDefinition(frontmatter, instructions, contentType, widgets, scripts) {
|
|
505
|
+
const skill = {
|
|
506
|
+
name: frontmatter.name,
|
|
507
|
+
title: frontmatter.title,
|
|
508
|
+
description: frontmatter.description,
|
|
509
|
+
instructions,
|
|
510
|
+
content_type: contentType,
|
|
511
|
+
widgets: widgets.length > 0 ? widgets : undefined,
|
|
512
|
+
scripts: scripts.length > 0 ? scripts : undefined,
|
|
513
|
+
};
|
|
514
|
+
// Build context triggers - support both flat and nested structure
|
|
515
|
+
// Nested: context_triggers: { keywords: [...], tool_names: [...] }
|
|
516
|
+
// Flat: keywords: [...], tools: [...]
|
|
517
|
+
const contextTriggers = frontmatter.context_triggers;
|
|
518
|
+
const hasNestedTriggers = contextTriggers && typeof contextTriggers === 'object';
|
|
519
|
+
const hasFlatTriggers = frontmatter.keywords || frontmatter.tools || frontmatter.data_patterns;
|
|
520
|
+
if (hasNestedTriggers || hasFlatTriggers) {
|
|
521
|
+
skill.context_triggers = {
|
|
522
|
+
keywords: hasNestedTriggers ? contextTriggers.keywords : frontmatter.keywords,
|
|
523
|
+
tool_names: hasNestedTriggers ? contextTriggers.tool_names : frontmatter.tools,
|
|
524
|
+
data_patterns: hasNestedTriggers ? contextTriggers.data_patterns : frontmatter.data_patterns,
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
// Build execution config - support both flat and nested structure
|
|
528
|
+
const execution = frontmatter.execution;
|
|
529
|
+
const hasNestedExecution = execution && typeof execution === 'object';
|
|
530
|
+
const hasFlatExecution = frontmatter.language;
|
|
531
|
+
if (hasNestedExecution || hasFlatExecution) {
|
|
532
|
+
skill.execution = {
|
|
533
|
+
language: hasNestedExecution ? execution.language : frontmatter.language,
|
|
534
|
+
packages: hasNestedExecution ? execution.packages : frontmatter.packages,
|
|
535
|
+
system_packages: hasNestedExecution ? execution.system_packages : frontmatter.system_packages,
|
|
536
|
+
};
|
|
537
|
+
// Extract code template from instructions if present
|
|
538
|
+
const codeBlockMatch = instructions.match(/```(?:python|javascript|typescript|js|ts|py)\n([\s\S]*?)```/);
|
|
539
|
+
if (codeBlockMatch) {
|
|
540
|
+
skill.execution.template = codeBlockMatch[1].trim();
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
// Related tools - support both direct field and from tools field
|
|
544
|
+
if (frontmatter.related_tools) {
|
|
545
|
+
skill.related_tools = frontmatter.related_tools;
|
|
546
|
+
}
|
|
547
|
+
else if (frontmatter.tools && !hasNestedTriggers) {
|
|
548
|
+
// If tools is not part of context_triggers, use it as related_tools
|
|
549
|
+
skill.related_tools = frontmatter.tools;
|
|
550
|
+
}
|
|
551
|
+
// Input schema from frontmatter
|
|
552
|
+
if (frontmatter.input_schema) {
|
|
553
|
+
skill.input_schema = frontmatter.input_schema;
|
|
554
|
+
}
|
|
555
|
+
return skill;
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Skill transformer preset
|
|
559
|
+
* Transforms markdown files with ?skill suffix OR SKILL.md files into skill definition objects
|
|
560
|
+
*
|
|
561
|
+
* Matches:
|
|
562
|
+
* - Files with ?skill suffix: ./my-skill.md?skill
|
|
563
|
+
* - SKILL.md files: ./my-skill/SKILL.md
|
|
564
|
+
*
|
|
565
|
+
* @example
|
|
566
|
+
* ```typescript
|
|
567
|
+
* import skill1 from './my-skill.md?skill';
|
|
568
|
+
* import skill2 from './my-skill/SKILL.md';
|
|
569
|
+
* // Both are SkillDefinition objects
|
|
570
|
+
* ```
|
|
571
|
+
*/
|
|
572
|
+
const skillTransformer = {
|
|
573
|
+
pattern: /(\.md\?skill$|\/SKILL\.md$)/,
|
|
574
|
+
schema: SkillDefinitionSchema,
|
|
575
|
+
transform: (content, filePath) => {
|
|
576
|
+
const { frontmatter, content: markdown } = parseFrontmatter(content);
|
|
577
|
+
// Validate frontmatter first to catch unknown properties
|
|
578
|
+
const frontmatterValidation = SkillFrontmatterSchema.safeParse(frontmatter);
|
|
579
|
+
if (!frontmatterValidation.success) {
|
|
580
|
+
const errors = frontmatterValidation.error.errors
|
|
581
|
+
.map((err) => {
|
|
582
|
+
const path = err.path.length > 0 ? err.path.join('.') : 'frontmatter';
|
|
583
|
+
return ` - ${path}: ${err.message}`;
|
|
584
|
+
})
|
|
585
|
+
.join('\n');
|
|
586
|
+
throw new Error(`Invalid frontmatter in ${filePath}:\n${errors}`);
|
|
587
|
+
}
|
|
588
|
+
// Determine content type from frontmatter or file extension
|
|
589
|
+
const content_type = frontmatter.content_type || 'md';
|
|
590
|
+
// Discover assets (scripts and widgets) in the skill directory
|
|
591
|
+
const assets = discoverSkillAssets(filePath);
|
|
592
|
+
// Build skill definition using the same logic as parseSkillFile in tools-sdk
|
|
593
|
+
const skillData = buildSkillDefinition(frontmatter, markdown, content_type, assets.widgets, assets.scripts);
|
|
594
|
+
return {
|
|
595
|
+
data: skillData,
|
|
596
|
+
assets: assets.assetFiles,
|
|
597
|
+
widgets: assets.widgetMetadata
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* Skill collection transformer for directory-based skill imports
|
|
604
|
+
* Scans a directory for subdirectories containing SKILL.md files
|
|
605
|
+
*/
|
|
606
|
+
/**
|
|
607
|
+
* Skill collection transformer preset
|
|
608
|
+
* Transforms directory imports with ?skills suffix into an array of skill imports
|
|
609
|
+
*
|
|
610
|
+
* Matches:
|
|
611
|
+
* - ./all?skills (recommended - generates all.js in the directory)
|
|
612
|
+
* - ./_skills?skills (generates _skills.js in the directory)
|
|
613
|
+
* - Any path ending with a filename and ?skills
|
|
614
|
+
*
|
|
615
|
+
* NOTE: A filename before ?skills is REQUIRED to avoid naming conflicts.
|
|
616
|
+
* The filename becomes the output module name.
|
|
617
|
+
*
|
|
618
|
+
* @example
|
|
619
|
+
* ```typescript
|
|
620
|
+
* import skills from './all?skills';
|
|
621
|
+
* // Scans current directory for subdirectories with SKILL.md
|
|
622
|
+
* // Generates all.js containing array of all skills
|
|
623
|
+
* ```
|
|
624
|
+
*/
|
|
625
|
+
const skillCollectionTransformer = {
|
|
626
|
+
pattern: /\/[^/?]+\?skills$/,
|
|
627
|
+
virtual: true, // Indicates this doesn't transform a real file
|
|
628
|
+
transform: (_content, filePath) => {
|
|
629
|
+
// Remove ?skills suffix and the filename to get directory path
|
|
630
|
+
// Example: /path/code/all?skills -> /path/code/all -> /path/code/
|
|
631
|
+
const pathWithoutQuery = filePath.replace(/\?skills$/, '');
|
|
632
|
+
const dirPath = path.dirname(pathWithoutQuery);
|
|
633
|
+
if (!existsSync(dirPath)) {
|
|
634
|
+
throw new Error(`Directory not found: ${dirPath}`);
|
|
635
|
+
}
|
|
636
|
+
if (!statSync(dirPath).isDirectory()) {
|
|
637
|
+
throw new Error(`Not a directory: ${dirPath}`);
|
|
638
|
+
}
|
|
639
|
+
// Scan for subdirectories containing SKILL.md
|
|
640
|
+
const entries = readdirSync(dirPath);
|
|
641
|
+
const imports = [];
|
|
642
|
+
const names = [];
|
|
643
|
+
for (const entry of entries) {
|
|
644
|
+
const entryPath = path.join(dirPath, entry);
|
|
645
|
+
try {
|
|
646
|
+
if (statSync(entryPath).isDirectory()) {
|
|
647
|
+
const skillFile = path.join(entryPath, 'SKILL.md');
|
|
648
|
+
if (existsSync(skillFile)) {
|
|
649
|
+
// Generate unique identifier from directory name
|
|
650
|
+
const identifier = `Skill_${entry.replace(/[^a-zA-Z0-9_]/g, '_')}`;
|
|
651
|
+
imports.push(`import ${identifier} from './${entry}/SKILL.md';`);
|
|
652
|
+
names.push(identifier);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
catch (err) {
|
|
657
|
+
// Skip entries that can't be read
|
|
658
|
+
continue;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
if (names.length === 0) {
|
|
662
|
+
console.warn(`No SKILL.md files found in subdirectories of ${dirPath}`);
|
|
663
|
+
}
|
|
664
|
+
// Generate code that imports all skills and exports as array
|
|
665
|
+
const code = [
|
|
666
|
+
...imports,
|
|
667
|
+
'',
|
|
668
|
+
`export default [${names.join(', ')}];`
|
|
669
|
+
].join('\n');
|
|
670
|
+
return {
|
|
671
|
+
data: null, // Not used when custom code is provided
|
|
672
|
+
code
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
};
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* Raw transformer preset for importing file content as strings
|
|
679
|
+
*/
|
|
680
|
+
/**
|
|
681
|
+
* Raw transformer preset
|
|
682
|
+
* Transforms any file with ?raw suffix into a string export
|
|
683
|
+
*
|
|
684
|
+
* @example
|
|
685
|
+
* ```typescript
|
|
686
|
+
* import template from './template.html?raw';
|
|
687
|
+
* // template is a string containing the file content
|
|
688
|
+
* ```
|
|
689
|
+
*/
|
|
690
|
+
const rawTransformer = {
|
|
691
|
+
pattern: /\?raw$/,
|
|
692
|
+
transform: (content) => {
|
|
693
|
+
return {
|
|
694
|
+
data: content
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* @module access-control
|
|
701
|
+
* @description
|
|
702
|
+
* Access control interfaces
|
|
703
|
+
*/
|
|
704
|
+
var Permission;
|
|
705
|
+
(function (Permission) {
|
|
706
|
+
Permission["int_read"] = "interaction:read";
|
|
707
|
+
Permission["int_write"] = "interaction:write";
|
|
708
|
+
Permission["int_delete"] = "interaction:delete";
|
|
709
|
+
Permission["int_execute"] = "interaction:execute";
|
|
710
|
+
Permission["run_read"] = "run:read";
|
|
711
|
+
Permission["run_write"] = "run:write";
|
|
712
|
+
Permission["env_admin"] = "environment:admin";
|
|
713
|
+
Permission["project_admin"] = "project:admin";
|
|
714
|
+
Permission["project_integration_read"] = "project:integration_read";
|
|
715
|
+
Permission["project_settings_write"] = "project:settings_write";
|
|
716
|
+
Permission["api_key_create"] = "api_key:create";
|
|
717
|
+
Permission["api_key_read"] = "api_key:read";
|
|
718
|
+
Permission["api_key_update"] = "api_key:update";
|
|
719
|
+
Permission["api_key_delete"] = "api_key:delete";
|
|
720
|
+
Permission["account_read"] = "account:read";
|
|
721
|
+
Permission["account_write"] = "account:write";
|
|
722
|
+
Permission["account_admin"] = "account:admin";
|
|
723
|
+
Permission["manage_billing"] = "account:billing";
|
|
724
|
+
Permission["account_member"] = "account:member";
|
|
725
|
+
Permission["content_read"] = "content:read";
|
|
726
|
+
Permission["content_write"] = "content:write";
|
|
727
|
+
Permission["content_delete"] = "content:delete";
|
|
728
|
+
Permission["content_admin"] = "content:admin";
|
|
729
|
+
Permission["content_superadmin"] = "content:superadmin";
|
|
730
|
+
Permission["workflow_run"] = "workflow:run";
|
|
731
|
+
Permission["workflow_admin"] = "workflow:admin";
|
|
732
|
+
Permission["workflow_superadmin"] = "workflow:superadmin";
|
|
733
|
+
Permission["iam_impersonate"] = "iam:impersonate";
|
|
734
|
+
/** whether the user has access to Sutdio App. */
|
|
735
|
+
Permission["studio_access"] = "studio:access";
|
|
736
|
+
})(Permission || (Permission = {}));
|
|
737
|
+
var AccessControlResourceType;
|
|
738
|
+
(function (AccessControlResourceType) {
|
|
739
|
+
AccessControlResourceType["project"] = "project";
|
|
740
|
+
AccessControlResourceType["environment"] = "environment";
|
|
741
|
+
AccessControlResourceType["account"] = "account";
|
|
742
|
+
AccessControlResourceType["interaction"] = "interaction";
|
|
743
|
+
AccessControlResourceType["app"] = "application";
|
|
744
|
+
})(AccessControlResourceType || (AccessControlResourceType = {}));
|
|
745
|
+
var AccessControlPrincipalType;
|
|
746
|
+
(function (AccessControlPrincipalType) {
|
|
747
|
+
AccessControlPrincipalType["user"] = "user";
|
|
748
|
+
AccessControlPrincipalType["group"] = "group";
|
|
749
|
+
AccessControlPrincipalType["apikey"] = "apikey";
|
|
750
|
+
})(AccessControlPrincipalType || (AccessControlPrincipalType = {}));
|
|
751
|
+
|
|
752
|
+
var ApiKeyTypes;
|
|
753
|
+
(function (ApiKeyTypes) {
|
|
754
|
+
ApiKeyTypes["secret"] = "sk";
|
|
755
|
+
})(ApiKeyTypes || (ApiKeyTypes = {}));
|
|
756
|
+
var PrincipalType;
|
|
757
|
+
(function (PrincipalType) {
|
|
758
|
+
PrincipalType["User"] = "user";
|
|
759
|
+
PrincipalType["Group"] = "group";
|
|
760
|
+
PrincipalType["ApiKey"] = "apikey";
|
|
761
|
+
PrincipalType["ServiceAccount"] = "service_account";
|
|
762
|
+
PrincipalType["Agent"] = "agent";
|
|
763
|
+
})(PrincipalType || (PrincipalType = {}));
|
|
764
|
+
|
|
765
|
+
var InteractionStatus;
|
|
766
|
+
(function (InteractionStatus) {
|
|
767
|
+
InteractionStatus["draft"] = "draft";
|
|
768
|
+
InteractionStatus["published"] = "published";
|
|
769
|
+
InteractionStatus["archived"] = "archived";
|
|
770
|
+
})(InteractionStatus || (InteractionStatus = {}));
|
|
771
|
+
var ExecutionRunStatus;
|
|
772
|
+
(function (ExecutionRunStatus) {
|
|
773
|
+
ExecutionRunStatus["created"] = "created";
|
|
774
|
+
ExecutionRunStatus["processing"] = "processing";
|
|
775
|
+
ExecutionRunStatus["completed"] = "completed";
|
|
776
|
+
ExecutionRunStatus["failed"] = "failed";
|
|
777
|
+
})(ExecutionRunStatus || (ExecutionRunStatus = {}));
|
|
778
|
+
var RunDataStorageLevel;
|
|
779
|
+
(function (RunDataStorageLevel) {
|
|
780
|
+
RunDataStorageLevel["STANDARD"] = "STANDARD";
|
|
781
|
+
RunDataStorageLevel["RESTRICTED"] = "RESTRICTED";
|
|
782
|
+
RunDataStorageLevel["DEBUG"] = "DEBUG";
|
|
783
|
+
})(RunDataStorageLevel || (RunDataStorageLevel = {}));
|
|
784
|
+
var RunDataStorageDescription;
|
|
785
|
+
(function (RunDataStorageDescription) {
|
|
786
|
+
RunDataStorageDescription["STANDARD"] = "Run data is stored for both the model inputs and output.";
|
|
787
|
+
RunDataStorageDescription["RESTRICTED"] = "No run data is stored for the model inputs \u2014 only the model output.";
|
|
788
|
+
RunDataStorageDescription["DEBUG"] = "Run data is stored for the model inputs and output, schema, and final prompt.";
|
|
789
|
+
})(RunDataStorageDescription || (RunDataStorageDescription = {}));
|
|
790
|
+
({
|
|
791
|
+
[RunDataStorageLevel.STANDARD]: RunDataStorageDescription.STANDARD,
|
|
792
|
+
[RunDataStorageLevel.RESTRICTED]: RunDataStorageDescription.RESTRICTED,
|
|
793
|
+
[RunDataStorageLevel.DEBUG]: RunDataStorageDescription.DEBUG,
|
|
794
|
+
});
|
|
795
|
+
/**
|
|
796
|
+
* Defines the scope for agent search operations.
|
|
797
|
+
*/
|
|
798
|
+
var AgentSearchScope;
|
|
799
|
+
(function (AgentSearchScope) {
|
|
800
|
+
/**
|
|
801
|
+
* Search is scoped to a specific collection.
|
|
802
|
+
*/
|
|
803
|
+
AgentSearchScope["Collection"] = "collection";
|
|
804
|
+
})(AgentSearchScope || (AgentSearchScope = {}));
|
|
805
|
+
// ================= end async execution payloads ====================
|
|
806
|
+
var RunSourceTypes;
|
|
807
|
+
(function (RunSourceTypes) {
|
|
808
|
+
RunSourceTypes["api"] = "api";
|
|
809
|
+
RunSourceTypes["cli"] = "cli";
|
|
810
|
+
RunSourceTypes["ui"] = "ui";
|
|
811
|
+
RunSourceTypes["webhook"] = "webhook";
|
|
812
|
+
RunSourceTypes["test"] = "test-data";
|
|
813
|
+
RunSourceTypes["system"] = "system";
|
|
814
|
+
})(RunSourceTypes || (RunSourceTypes = {}));
|
|
815
|
+
var ConfigModes;
|
|
816
|
+
(function (ConfigModes) {
|
|
817
|
+
ConfigModes["RUN_AND_INTERACTION_CONFIG"] = "RUN_AND_INTERACTION_CONFIG";
|
|
818
|
+
ConfigModes["RUN_CONFIG_ONLY"] = "RUN_CONFIG_ONLY";
|
|
819
|
+
ConfigModes["INTERACTION_CONFIG_ONLY"] = "INTERACTION_CONFIG_ONLY";
|
|
820
|
+
})(ConfigModes || (ConfigModes = {}));
|
|
821
|
+
var ConfigModesDescription;
|
|
822
|
+
(function (ConfigModesDescription) {
|
|
823
|
+
ConfigModesDescription["RUN_AND_INTERACTION_CONFIG"] = "This run configuration is used. Undefined options are filled with interaction configuration.";
|
|
824
|
+
ConfigModesDescription["RUN_CONFIG_ONLY"] = "Only this run configuration is used. Undefined options remain undefined.";
|
|
825
|
+
ConfigModesDescription["INTERACTION_CONFIG_ONLY"] = "Only interaction configuration is used.";
|
|
826
|
+
})(ConfigModesDescription || (ConfigModesDescription = {}));
|
|
827
|
+
({
|
|
828
|
+
[ConfigModes.RUN_AND_INTERACTION_CONFIG]: ConfigModesDescription.RUN_AND_INTERACTION_CONFIG,
|
|
829
|
+
[ConfigModes.RUN_CONFIG_ONLY]: ConfigModesDescription.RUN_CONFIG_ONLY,
|
|
830
|
+
[ConfigModes.INTERACTION_CONFIG_ONLY]: ConfigModesDescription.INTERACTION_CONFIG_ONLY,
|
|
831
|
+
});
|
|
832
|
+
/**
|
|
833
|
+
* Source of the resolved model configuration
|
|
834
|
+
*/
|
|
835
|
+
var ModelSource;
|
|
836
|
+
(function (ModelSource) {
|
|
837
|
+
/** Model was explicitly provided in the execution config */
|
|
838
|
+
ModelSource["config"] = "config";
|
|
839
|
+
/** Model comes from the interaction definition */
|
|
840
|
+
ModelSource["interaction"] = "interaction";
|
|
841
|
+
/** Model comes from environment's default_model */
|
|
842
|
+
ModelSource["environmentDefault"] = "environmentDefault";
|
|
843
|
+
/** Model comes from project system interaction defaults */
|
|
844
|
+
ModelSource["projectSystemDefault"] = "projectSystemDefault";
|
|
845
|
+
/** Model comes from project base defaults */
|
|
846
|
+
ModelSource["projectBaseDefault"] = "projectBaseDefault";
|
|
847
|
+
/** Model comes from project modality-specific defaults */
|
|
848
|
+
ModelSource["projectModalityDefault"] = "projectModalityDefault";
|
|
849
|
+
/** Model comes from legacy project defaults */
|
|
850
|
+
ModelSource["projectLegacyDefault"] = "projectLegacyDefault";
|
|
851
|
+
})(ModelSource || (ModelSource = {}));
|
|
852
|
+
|
|
853
|
+
/**
|
|
854
|
+
* Data Platform Types
|
|
855
|
+
*
|
|
856
|
+
* Types for managing versioned analytical data stores with DuckDB + GCS storage.
|
|
857
|
+
* Supports AI-manageable schemas and multi-table atomic operations.
|
|
858
|
+
*/
|
|
859
|
+
// ============================================================================
|
|
860
|
+
// Column Types
|
|
861
|
+
// ============================================================================
|
|
862
|
+
/**
|
|
863
|
+
* Supported column data types for DuckDB tables.
|
|
864
|
+
*/
|
|
865
|
+
var DataColumnType;
|
|
866
|
+
(function (DataColumnType) {
|
|
867
|
+
DataColumnType["STRING"] = "STRING";
|
|
868
|
+
DataColumnType["INTEGER"] = "INTEGER";
|
|
869
|
+
DataColumnType["BIGINT"] = "BIGINT";
|
|
870
|
+
DataColumnType["FLOAT"] = "FLOAT";
|
|
871
|
+
DataColumnType["DOUBLE"] = "DOUBLE";
|
|
872
|
+
DataColumnType["DECIMAL"] = "DECIMAL";
|
|
873
|
+
DataColumnType["BOOLEAN"] = "BOOLEAN";
|
|
874
|
+
DataColumnType["DATE"] = "DATE";
|
|
875
|
+
DataColumnType["TIMESTAMP"] = "TIMESTAMP";
|
|
876
|
+
DataColumnType["JSON"] = "JSON";
|
|
877
|
+
})(DataColumnType || (DataColumnType = {}));
|
|
878
|
+
/**
|
|
879
|
+
* Semantic types that provide AI agents with context about column meaning.
|
|
880
|
+
*/
|
|
881
|
+
var SemanticColumnType;
|
|
882
|
+
(function (SemanticColumnType) {
|
|
883
|
+
SemanticColumnType["EMAIL"] = "email";
|
|
884
|
+
SemanticColumnType["PHONE"] = "phone";
|
|
885
|
+
SemanticColumnType["URL"] = "url";
|
|
886
|
+
SemanticColumnType["CURRENCY"] = "currency";
|
|
887
|
+
SemanticColumnType["PERCENTAGE"] = "percentage";
|
|
888
|
+
SemanticColumnType["PERSON_NAME"] = "person_name";
|
|
889
|
+
SemanticColumnType["ADDRESS"] = "address";
|
|
890
|
+
SemanticColumnType["COUNTRY"] = "country";
|
|
891
|
+
SemanticColumnType["DATE_ISO"] = "date_iso";
|
|
892
|
+
SemanticColumnType["IDENTIFIER"] = "identifier";
|
|
893
|
+
})(SemanticColumnType || (SemanticColumnType = {}));
|
|
894
|
+
/**
|
|
895
|
+
* Mapping from DataColumnType to DuckDB SQL types.
|
|
896
|
+
*/
|
|
897
|
+
({
|
|
898
|
+
[DataColumnType.STRING]: 'VARCHAR',
|
|
899
|
+
[DataColumnType.INTEGER]: 'INTEGER',
|
|
900
|
+
[DataColumnType.BIGINT]: 'BIGINT',
|
|
901
|
+
[DataColumnType.FLOAT]: 'FLOAT',
|
|
902
|
+
[DataColumnType.DOUBLE]: 'DOUBLE',
|
|
903
|
+
[DataColumnType.DECIMAL]: 'DECIMAL(18,4)',
|
|
904
|
+
[DataColumnType.BOOLEAN]: 'BOOLEAN',
|
|
905
|
+
[DataColumnType.DATE]: 'DATE',
|
|
906
|
+
[DataColumnType.TIMESTAMP]: 'TIMESTAMP',
|
|
907
|
+
[DataColumnType.JSON]: 'JSON',
|
|
908
|
+
});
|
|
909
|
+
// ============================================================================
|
|
910
|
+
// Data Store Types
|
|
911
|
+
// ============================================================================
|
|
912
|
+
/**
|
|
913
|
+
* Data store lifecycle status.
|
|
914
|
+
*/
|
|
915
|
+
var DataStoreStatus;
|
|
916
|
+
(function (DataStoreStatus) {
|
|
917
|
+
/** Store is being created */
|
|
918
|
+
DataStoreStatus["CREATING"] = "creating";
|
|
919
|
+
/** Store is active and usable */
|
|
920
|
+
DataStoreStatus["ACTIVE"] = "active";
|
|
921
|
+
/** Store encountered an error */
|
|
922
|
+
DataStoreStatus["ERROR"] = "error";
|
|
923
|
+
/** Store has been archived (soft deleted) */
|
|
924
|
+
DataStoreStatus["ARCHIVED"] = "archived";
|
|
925
|
+
})(DataStoreStatus || (DataStoreStatus = {}));
|
|
926
|
+
// ============================================================================
|
|
927
|
+
// Import Types
|
|
928
|
+
// ============================================================================
|
|
929
|
+
/**
|
|
930
|
+
* Import job status.
|
|
931
|
+
*/
|
|
932
|
+
var ImportStatus;
|
|
933
|
+
(function (ImportStatus) {
|
|
934
|
+
/** Job is queued */
|
|
935
|
+
ImportStatus["PENDING"] = "pending";
|
|
936
|
+
/** Job is running */
|
|
937
|
+
ImportStatus["PROCESSING"] = "processing";
|
|
938
|
+
/** Job completed successfully */
|
|
939
|
+
ImportStatus["COMPLETED"] = "completed";
|
|
940
|
+
/** Job failed */
|
|
941
|
+
ImportStatus["FAILED"] = "failed";
|
|
942
|
+
/** Job was rolled back */
|
|
943
|
+
ImportStatus["ROLLED_BACK"] = "rolled_back";
|
|
944
|
+
})(ImportStatus || (ImportStatus = {}));
|
|
945
|
+
// ============================================================================
|
|
946
|
+
// Dashboard Types
|
|
947
|
+
// ============================================================================
|
|
948
|
+
/**
|
|
949
|
+
* Dashboard lifecycle status.
|
|
950
|
+
*/
|
|
951
|
+
var DashboardStatus;
|
|
952
|
+
(function (DashboardStatus) {
|
|
953
|
+
/** Dashboard is active and usable */
|
|
954
|
+
DashboardStatus["ACTIVE"] = "active";
|
|
955
|
+
/** Dashboard has been archived (soft deleted) */
|
|
956
|
+
DashboardStatus["ARCHIVED"] = "archived";
|
|
957
|
+
})(DashboardStatus || (DashboardStatus = {}));
|
|
958
|
+
|
|
959
|
+
// ============== Provider details ===============
|
|
960
|
+
var Providers;
|
|
961
|
+
(function (Providers) {
|
|
962
|
+
Providers["openai"] = "openai";
|
|
963
|
+
Providers["openai_compatible"] = "openai_compatible";
|
|
964
|
+
Providers["azure_openai"] = "azure_openai";
|
|
965
|
+
Providers["azure_foundry"] = "azure_foundry";
|
|
966
|
+
Providers["huggingface_ie"] = "huggingface_ie";
|
|
967
|
+
Providers["replicate"] = "replicate";
|
|
968
|
+
Providers["bedrock"] = "bedrock";
|
|
969
|
+
Providers["vertexai"] = "vertexai";
|
|
970
|
+
Providers["togetherai"] = "togetherai";
|
|
971
|
+
Providers["mistralai"] = "mistralai";
|
|
972
|
+
Providers["groq"] = "groq";
|
|
973
|
+
Providers["watsonx"] = "watsonx";
|
|
974
|
+
Providers["xai"] = "xai";
|
|
975
|
+
})(Providers || (Providers = {}));
|
|
976
|
+
({
|
|
977
|
+
openai: {
|
|
978
|
+
id: Providers.openai},
|
|
979
|
+
azure_openai: {
|
|
980
|
+
id: Providers.azure_openai},
|
|
981
|
+
azure_foundry: {
|
|
982
|
+
id: Providers.azure_foundry},
|
|
983
|
+
huggingface_ie: {
|
|
984
|
+
id: Providers.huggingface_ie},
|
|
985
|
+
replicate: {
|
|
986
|
+
id: Providers.replicate},
|
|
987
|
+
bedrock: {
|
|
988
|
+
id: Providers.bedrock},
|
|
989
|
+
vertexai: {
|
|
990
|
+
id: Providers.vertexai},
|
|
991
|
+
togetherai: {
|
|
992
|
+
id: Providers.togetherai},
|
|
993
|
+
mistralai: {
|
|
994
|
+
id: Providers.mistralai},
|
|
995
|
+
groq: {
|
|
996
|
+
id: Providers.groq},
|
|
997
|
+
watsonx: {
|
|
998
|
+
id: Providers.watsonx},
|
|
999
|
+
xai: {
|
|
1000
|
+
id: Providers.xai},
|
|
1001
|
+
openai_compatible: {
|
|
1002
|
+
id: Providers.openai_compatible},
|
|
1003
|
+
});
|
|
1004
|
+
//Common names to share between different models
|
|
1005
|
+
var SharedOptions;
|
|
1006
|
+
(function (SharedOptions) {
|
|
1007
|
+
//Text
|
|
1008
|
+
SharedOptions["max_tokens"] = "max_tokens";
|
|
1009
|
+
SharedOptions["temperature"] = "temperature";
|
|
1010
|
+
SharedOptions["top_p"] = "top_p";
|
|
1011
|
+
SharedOptions["top_k"] = "top_k";
|
|
1012
|
+
SharedOptions["presence_penalty"] = "presence_penalty";
|
|
1013
|
+
SharedOptions["frequency_penalty"] = "frequency_penalty";
|
|
1014
|
+
SharedOptions["stop_sequence"] = "stop_sequence";
|
|
1015
|
+
//Image
|
|
1016
|
+
SharedOptions["seed"] = "seed";
|
|
1017
|
+
SharedOptions["number_of_images"] = "number_of_images";
|
|
1018
|
+
})(SharedOptions || (SharedOptions = {}));
|
|
1019
|
+
var OptionType;
|
|
1020
|
+
(function (OptionType) {
|
|
1021
|
+
OptionType["numeric"] = "numeric";
|
|
1022
|
+
OptionType["enum"] = "enum";
|
|
1023
|
+
OptionType["boolean"] = "boolean";
|
|
1024
|
+
OptionType["string_list"] = "string_list";
|
|
1025
|
+
})(OptionType || (OptionType = {}));
|
|
1026
|
+
// ============== Prompts ===============
|
|
1027
|
+
var PromptRole;
|
|
1028
|
+
(function (PromptRole) {
|
|
1029
|
+
PromptRole["safety"] = "safety";
|
|
1030
|
+
PromptRole["system"] = "system";
|
|
1031
|
+
PromptRole["user"] = "user";
|
|
1032
|
+
PromptRole["assistant"] = "assistant";
|
|
1033
|
+
PromptRole["negative"] = "negative";
|
|
1034
|
+
PromptRole["mask"] = "mask";
|
|
1035
|
+
/**
|
|
1036
|
+
* Used to send the response of a tool
|
|
1037
|
+
*/
|
|
1038
|
+
PromptRole["tool"] = "tool";
|
|
1039
|
+
})(PromptRole || (PromptRole = {}));
|
|
1040
|
+
/**
|
|
1041
|
+
* @deprecated This is deprecated. Use CompletionResult.type information instead.
|
|
1042
|
+
*/
|
|
1043
|
+
var Modalities;
|
|
1044
|
+
(function (Modalities) {
|
|
1045
|
+
Modalities["text"] = "text";
|
|
1046
|
+
Modalities["image"] = "image";
|
|
1047
|
+
})(Modalities || (Modalities = {}));
|
|
1048
|
+
var AIModelStatus;
|
|
1049
|
+
(function (AIModelStatus) {
|
|
1050
|
+
AIModelStatus["Available"] = "available";
|
|
1051
|
+
AIModelStatus["Pending"] = "pending";
|
|
1052
|
+
AIModelStatus["Stopped"] = "stopped";
|
|
1053
|
+
AIModelStatus["Unavailable"] = "unavailable";
|
|
1054
|
+
AIModelStatus["Unknown"] = "unknown";
|
|
1055
|
+
AIModelStatus["Legacy"] = "legacy";
|
|
1056
|
+
})(AIModelStatus || (AIModelStatus = {}));
|
|
1057
|
+
var ModelType;
|
|
1058
|
+
(function (ModelType) {
|
|
1059
|
+
ModelType["Classifier"] = "classifier";
|
|
1060
|
+
ModelType["Regressor"] = "regressor";
|
|
1061
|
+
ModelType["Clustering"] = "clustering";
|
|
1062
|
+
ModelType["AnomalyDetection"] = "anomaly-detection";
|
|
1063
|
+
ModelType["TimeSeries"] = "time-series";
|
|
1064
|
+
ModelType["Text"] = "text";
|
|
1065
|
+
ModelType["Image"] = "image";
|
|
1066
|
+
ModelType["Audio"] = "audio";
|
|
1067
|
+
ModelType["Video"] = "video";
|
|
1068
|
+
ModelType["Embedding"] = "embedding";
|
|
1069
|
+
ModelType["Chat"] = "chat";
|
|
1070
|
+
ModelType["Code"] = "code";
|
|
1071
|
+
ModelType["NLP"] = "nlp";
|
|
1072
|
+
ModelType["MultiModal"] = "multi-modal";
|
|
1073
|
+
ModelType["Test"] = "test";
|
|
1074
|
+
ModelType["Other"] = "other";
|
|
1075
|
+
ModelType["Unknown"] = "unknown";
|
|
1076
|
+
})(ModelType || (ModelType = {}));
|
|
1077
|
+
var TrainingJobStatus;
|
|
1078
|
+
(function (TrainingJobStatus) {
|
|
1079
|
+
TrainingJobStatus["running"] = "running";
|
|
1080
|
+
TrainingJobStatus["succeeded"] = "succeeded";
|
|
1081
|
+
TrainingJobStatus["failed"] = "failed";
|
|
1082
|
+
TrainingJobStatus["cancelled"] = "cancelled";
|
|
1083
|
+
})(TrainingJobStatus || (TrainingJobStatus = {}));
|
|
1084
|
+
|
|
1085
|
+
({
|
|
1086
|
+
options: [
|
|
1087
|
+
{
|
|
1088
|
+
name: SharedOptions.max_tokens, type: OptionType.numeric, min: 1,
|
|
1089
|
+
integer: true, step: 200, description: "The maximum number of tokens to generate"
|
|
1090
|
+
},
|
|
1091
|
+
{
|
|
1092
|
+
name: SharedOptions.temperature, type: OptionType.numeric, min: 0.0, default: 0.7,
|
|
1093
|
+
integer: false, step: 0.1, description: "A higher temperature biases toward less likely tokens, making the model more creative"
|
|
1094
|
+
},
|
|
1095
|
+
{
|
|
1096
|
+
name: SharedOptions.top_p, type: OptionType.numeric, min: 0, max: 1,
|
|
1097
|
+
integer: false, step: 0.1, description: "Limits token sampling to the cumulative probability of the top p tokens"
|
|
1098
|
+
},
|
|
1099
|
+
{
|
|
1100
|
+
name: SharedOptions.top_k, type: OptionType.numeric, min: 1,
|
|
1101
|
+
integer: true, step: 1, description: "Limits token sampling to the top k tokens"
|
|
1102
|
+
},
|
|
1103
|
+
{
|
|
1104
|
+
name: SharedOptions.presence_penalty, type: OptionType.numeric, min: -2, max: 2.0,
|
|
1105
|
+
integer: false, step: 0.1, description: "Penalise tokens if they appear at least once in the text"
|
|
1106
|
+
},
|
|
1107
|
+
{
|
|
1108
|
+
name: SharedOptions.frequency_penalty, type: OptionType.numeric, min: -2, max: 2.0,
|
|
1109
|
+
integer: false, step: 0.1, description: "Penalise tokens based on their frequency in the text"
|
|
1110
|
+
},
|
|
1111
|
+
{ name: SharedOptions.stop_sequence, type: OptionType.string_list, value: [], description: "The generation will halt if one of the stop sequences is output" },
|
|
1112
|
+
]
|
|
1113
|
+
});
|
|
1114
|
+
|
|
1115
|
+
var ImagenTaskType;
|
|
1116
|
+
(function (ImagenTaskType) {
|
|
1117
|
+
ImagenTaskType["TEXT_IMAGE"] = "TEXT_IMAGE";
|
|
1118
|
+
ImagenTaskType["EDIT_MODE_INPAINT_REMOVAL"] = "EDIT_MODE_INPAINT_REMOVAL";
|
|
1119
|
+
ImagenTaskType["EDIT_MODE_INPAINT_INSERTION"] = "EDIT_MODE_INPAINT_INSERTION";
|
|
1120
|
+
ImagenTaskType["EDIT_MODE_BGSWAP"] = "EDIT_MODE_BGSWAP";
|
|
1121
|
+
ImagenTaskType["EDIT_MODE_OUTPAINT"] = "EDIT_MODE_OUTPAINT";
|
|
1122
|
+
ImagenTaskType["CUSTOMIZATION_SUBJECT"] = "CUSTOMIZATION_SUBJECT";
|
|
1123
|
+
ImagenTaskType["CUSTOMIZATION_STYLE"] = "CUSTOMIZATION_STYLE";
|
|
1124
|
+
ImagenTaskType["CUSTOMIZATION_CONTROLLED"] = "CUSTOMIZATION_CONTROLLED";
|
|
1125
|
+
ImagenTaskType["CUSTOMIZATION_INSTRUCT"] = "CUSTOMIZATION_INSTRUCT";
|
|
1126
|
+
})(ImagenTaskType || (ImagenTaskType = {}));
|
|
1127
|
+
var ImagenMaskMode;
|
|
1128
|
+
(function (ImagenMaskMode) {
|
|
1129
|
+
ImagenMaskMode["MASK_MODE_USER_PROVIDED"] = "MASK_MODE_USER_PROVIDED";
|
|
1130
|
+
ImagenMaskMode["MASK_MODE_BACKGROUND"] = "MASK_MODE_BACKGROUND";
|
|
1131
|
+
ImagenMaskMode["MASK_MODE_FOREGROUND"] = "MASK_MODE_FOREGROUND";
|
|
1132
|
+
ImagenMaskMode["MASK_MODE_SEMANTIC"] = "MASK_MODE_SEMANTIC";
|
|
1133
|
+
})(ImagenMaskMode || (ImagenMaskMode = {}));
|
|
1134
|
+
var ThinkingLevel;
|
|
1135
|
+
(function (ThinkingLevel) {
|
|
1136
|
+
ThinkingLevel["HIGH"] = "HIGH";
|
|
1137
|
+
ThinkingLevel["LOW"] = "LOW";
|
|
1138
|
+
ThinkingLevel["THINKING_LEVEL_UNSPECIFIED"] = "THINKING_LEVEL_UNSPECIFIED";
|
|
1139
|
+
})(ThinkingLevel || (ThinkingLevel = {}));
|
|
1140
|
+
|
|
1141
|
+
// Virtual providers from studio
|
|
1142
|
+
var CustomProviders;
|
|
1143
|
+
(function (CustomProviders) {
|
|
1144
|
+
CustomProviders["virtual_lb"] = "virtual_lb";
|
|
1145
|
+
CustomProviders["virtual_mediator"] = "virtual_mediator";
|
|
1146
|
+
CustomProviders["test"] = "test";
|
|
1147
|
+
})(CustomProviders || (CustomProviders = {}));
|
|
1148
|
+
({
|
|
1149
|
+
...Providers,
|
|
1150
|
+
...CustomProviders
|
|
1151
|
+
});
|
|
1152
|
+
({
|
|
1153
|
+
virtual_lb: {
|
|
1154
|
+
id: CustomProviders.virtual_lb},
|
|
1155
|
+
virtual_mediator: {
|
|
1156
|
+
id: CustomProviders.virtual_mediator},
|
|
1157
|
+
test: {
|
|
1158
|
+
id: CustomProviders.test},
|
|
1159
|
+
});
|
|
1160
|
+
|
|
1161
|
+
var SupportedIntegrations;
|
|
1162
|
+
(function (SupportedIntegrations) {
|
|
1163
|
+
SupportedIntegrations["gladia"] = "gladia";
|
|
1164
|
+
SupportedIntegrations["github"] = "github";
|
|
1165
|
+
SupportedIntegrations["aws"] = "aws";
|
|
1166
|
+
SupportedIntegrations["magic_pdf"] = "magic_pdf";
|
|
1167
|
+
SupportedIntegrations["serper"] = "serper";
|
|
1168
|
+
SupportedIntegrations["resend"] = "resend";
|
|
1169
|
+
SupportedIntegrations["ask_user_webhook"] = "ask_user_webhook";
|
|
1170
|
+
})(SupportedIntegrations || (SupportedIntegrations = {}));
|
|
1171
|
+
|
|
1172
|
+
var MeterNames;
|
|
1173
|
+
(function (MeterNames) {
|
|
1174
|
+
MeterNames["analyzed_pages"] = "analyzed_pages";
|
|
1175
|
+
MeterNames["extracted_tables"] = "extracted_tables";
|
|
1176
|
+
MeterNames["analyzed_images"] = "analyzed_images";
|
|
1177
|
+
MeterNames["input_token_used"] = "input_token_used";
|
|
1178
|
+
MeterNames["output_token_used"] = "output_token_used";
|
|
1179
|
+
MeterNames["task_run"] = "task_run";
|
|
1180
|
+
})(MeterNames || (MeterNames = {}));
|
|
1181
|
+
|
|
1182
|
+
var ProjectRoles;
|
|
1183
|
+
(function (ProjectRoles) {
|
|
1184
|
+
ProjectRoles["owner"] = "owner";
|
|
1185
|
+
ProjectRoles["admin"] = "admin";
|
|
1186
|
+
ProjectRoles["manager"] = "manager";
|
|
1187
|
+
ProjectRoles["developer"] = "developer";
|
|
1188
|
+
ProjectRoles["application"] = "application";
|
|
1189
|
+
ProjectRoles["consumer"] = "consumer";
|
|
1190
|
+
ProjectRoles["executor"] = "executor";
|
|
1191
|
+
ProjectRoles["reader"] = "reader";
|
|
1192
|
+
ProjectRoles["billing"] = "billing";
|
|
1193
|
+
ProjectRoles["member"] = "member";
|
|
1194
|
+
ProjectRoles["app_member"] = "app_member";
|
|
1195
|
+
ProjectRoles["content_superadmin"] = "content_superadmin";
|
|
1196
|
+
})(ProjectRoles || (ProjectRoles = {}));
|
|
1197
|
+
var ResourceVisibility;
|
|
1198
|
+
(function (ResourceVisibility) {
|
|
1199
|
+
ResourceVisibility["public"] = "public";
|
|
1200
|
+
ResourceVisibility["account"] = "account";
|
|
1201
|
+
ResourceVisibility["project"] = "project";
|
|
1202
|
+
})(ResourceVisibility || (ResourceVisibility = {}));
|
|
1203
|
+
/**
|
|
1204
|
+
* System interaction category enum.
|
|
1205
|
+
* Categories group one or more system interactions for default model assignment.
|
|
1206
|
+
*/
|
|
1207
|
+
var SystemInteractionCategory;
|
|
1208
|
+
(function (SystemInteractionCategory) {
|
|
1209
|
+
SystemInteractionCategory["content_type"] = "content_type";
|
|
1210
|
+
SystemInteractionCategory["intake"] = "intake";
|
|
1211
|
+
SystemInteractionCategory["analysis"] = "analysis";
|
|
1212
|
+
SystemInteractionCategory["non_applicable"] = "non_applicable";
|
|
1213
|
+
})(SystemInteractionCategory || (SystemInteractionCategory = {}));
|
|
1214
|
+
/**
|
|
1215
|
+
* Map system interaction endpoints to categories.
|
|
1216
|
+
*/
|
|
1217
|
+
({
|
|
1218
|
+
"ExtractInformation": SystemInteractionCategory.intake,
|
|
1219
|
+
"SelectDocumentType": SystemInteractionCategory.intake,
|
|
1220
|
+
"GenerateMetadataModel": SystemInteractionCategory.content_type,
|
|
1221
|
+
"ChunkDocument": SystemInteractionCategory.intake,
|
|
1222
|
+
"IdentifyTextSections": SystemInteractionCategory.intake,
|
|
1223
|
+
"AnalyzeDocument": SystemInteractionCategory.analysis,
|
|
1224
|
+
"ReduceTextSections": SystemInteractionCategory.analysis,
|
|
1225
|
+
"GenericAgent": SystemInteractionCategory.non_applicable,
|
|
1226
|
+
"AdhocTaskAgent": SystemInteractionCategory.non_applicable,
|
|
1227
|
+
"Mediator": SystemInteractionCategory.non_applicable,
|
|
1228
|
+
"AnalyzeConversation": SystemInteractionCategory.analysis,
|
|
1229
|
+
"GetAgentConversationTopic": SystemInteractionCategory.analysis,
|
|
1230
|
+
});
|
|
1231
|
+
// export interface ProjectConfigurationEmbeddings {
|
|
1232
|
+
// environment: string;
|
|
1233
|
+
// max_tokens: number;
|
|
1234
|
+
// dimensions: number;
|
|
1235
|
+
// model?: string;
|
|
1236
|
+
// }
|
|
1237
|
+
var SupportedEmbeddingTypes;
|
|
1238
|
+
(function (SupportedEmbeddingTypes) {
|
|
1239
|
+
SupportedEmbeddingTypes["text"] = "text";
|
|
1240
|
+
SupportedEmbeddingTypes["image"] = "image";
|
|
1241
|
+
SupportedEmbeddingTypes["properties"] = "properties";
|
|
1242
|
+
})(SupportedEmbeddingTypes || (SupportedEmbeddingTypes = {}));
|
|
1243
|
+
var FullTextType;
|
|
1244
|
+
(function (FullTextType) {
|
|
1245
|
+
FullTextType["full_text"] = "full_text";
|
|
1246
|
+
})(FullTextType || (FullTextType = {}));
|
|
1247
|
+
({
|
|
1248
|
+
...SupportedEmbeddingTypes,
|
|
1249
|
+
...FullTextType
|
|
1250
|
+
});
|
|
1251
|
+
|
|
1252
|
+
var PromptStatus;
|
|
1253
|
+
(function (PromptStatus) {
|
|
1254
|
+
PromptStatus["draft"] = "draft";
|
|
1255
|
+
PromptStatus["published"] = "published";
|
|
1256
|
+
PromptStatus["archived"] = "archived";
|
|
1257
|
+
})(PromptStatus || (PromptStatus = {}));
|
|
1258
|
+
var PromptSegmentDefType;
|
|
1259
|
+
(function (PromptSegmentDefType) {
|
|
1260
|
+
PromptSegmentDefType["chat"] = "chat";
|
|
1261
|
+
PromptSegmentDefType["template"] = "template";
|
|
1262
|
+
})(PromptSegmentDefType || (PromptSegmentDefType = {}));
|
|
1263
|
+
var TemplateType;
|
|
1264
|
+
(function (TemplateType) {
|
|
1265
|
+
TemplateType["jst"] = "jst";
|
|
1266
|
+
TemplateType["handlebars"] = "handlebars";
|
|
1267
|
+
TemplateType["text"] = "text";
|
|
1268
|
+
})(TemplateType || (TemplateType = {}));
|
|
1269
|
+
|
|
1270
|
+
var ResolvableRefType;
|
|
1271
|
+
(function (ResolvableRefType) {
|
|
1272
|
+
ResolvableRefType["project"] = "Project";
|
|
1273
|
+
ResolvableRefType["projects"] = "Projects";
|
|
1274
|
+
ResolvableRefType["environment"] = "Environment";
|
|
1275
|
+
ResolvableRefType["user"] = "User";
|
|
1276
|
+
ResolvableRefType["account"] = "Account";
|
|
1277
|
+
ResolvableRefType["interaction"] = "Interaction";
|
|
1278
|
+
ResolvableRefType["userGroup"] = "UserGroup";
|
|
1279
|
+
})(ResolvableRefType || (ResolvableRefType = {}));
|
|
1280
|
+
|
|
1281
|
+
var CollectionStatus;
|
|
1282
|
+
(function (CollectionStatus) {
|
|
1283
|
+
CollectionStatus["active"] = "active";
|
|
1284
|
+
CollectionStatus["archived"] = "archived";
|
|
1285
|
+
})(CollectionStatus || (CollectionStatus = {}));
|
|
1286
|
+
|
|
1287
|
+
var ContentObjectApiHeaders;
|
|
1288
|
+
(function (ContentObjectApiHeaders) {
|
|
1289
|
+
ContentObjectApiHeaders["COLLECTION_ID"] = "x-collection-id";
|
|
1290
|
+
ContentObjectApiHeaders["PROCESSING_PRIORITY"] = "x-processing-priority";
|
|
1291
|
+
ContentObjectApiHeaders["CREATE_REVISION"] = "x-create-revision";
|
|
1292
|
+
ContentObjectApiHeaders["REVISION_LABEL"] = "x-revision-label";
|
|
1293
|
+
/** When set to 'true', prevents this update from triggering workflow rules */
|
|
1294
|
+
ContentObjectApiHeaders["SUPPRESS_WORKFLOWS"] = "x-suppress-workflows";
|
|
1295
|
+
})(ContentObjectApiHeaders || (ContentObjectApiHeaders = {}));
|
|
1296
|
+
/**
|
|
1297
|
+
* Headers for Data Store API calls.
|
|
1298
|
+
* Used for Cloud Run session affinity to route requests to the same instance.
|
|
1299
|
+
*/
|
|
1300
|
+
var DataStoreApiHeaders;
|
|
1301
|
+
(function (DataStoreApiHeaders) {
|
|
1302
|
+
/** Data store ID for session affinity - routes requests for same store to same instance */
|
|
1303
|
+
DataStoreApiHeaders["DATA_STORE_ID"] = "x-data-store-id";
|
|
1304
|
+
})(DataStoreApiHeaders || (DataStoreApiHeaders = {}));
|
|
1305
|
+
var ContentObjectStatus;
|
|
1306
|
+
(function (ContentObjectStatus) {
|
|
1307
|
+
ContentObjectStatus["created"] = "created";
|
|
1308
|
+
ContentObjectStatus["processing"] = "processing";
|
|
1309
|
+
ContentObjectStatus["ready"] = "ready";
|
|
1310
|
+
ContentObjectStatus["completed"] = "completed";
|
|
1311
|
+
ContentObjectStatus["failed"] = "failed";
|
|
1312
|
+
ContentObjectStatus["archived"] = "archived";
|
|
1313
|
+
})(ContentObjectStatus || (ContentObjectStatus = {}));
|
|
1314
|
+
var ContentNature;
|
|
1315
|
+
(function (ContentNature) {
|
|
1316
|
+
ContentNature["Video"] = "video";
|
|
1317
|
+
ContentNature["Image"] = "image";
|
|
1318
|
+
ContentNature["Audio"] = "audio";
|
|
1319
|
+
ContentNature["Document"] = "document";
|
|
1320
|
+
ContentNature["Code"] = "code";
|
|
1321
|
+
ContentNature["Other"] = "other";
|
|
1322
|
+
})(ContentNature || (ContentNature = {}));
|
|
1323
|
+
var WorkflowRuleInputType;
|
|
1324
|
+
(function (WorkflowRuleInputType) {
|
|
1325
|
+
WorkflowRuleInputType["single"] = "single";
|
|
1326
|
+
WorkflowRuleInputType["multiple"] = "multiple";
|
|
1327
|
+
WorkflowRuleInputType["none"] = "none";
|
|
1328
|
+
})(WorkflowRuleInputType || (WorkflowRuleInputType = {}));
|
|
1329
|
+
var ImageRenditionFormat;
|
|
1330
|
+
(function (ImageRenditionFormat) {
|
|
1331
|
+
ImageRenditionFormat["jpeg"] = "jpeg";
|
|
1332
|
+
ImageRenditionFormat["png"] = "png";
|
|
1333
|
+
ImageRenditionFormat["webp"] = "webp";
|
|
1334
|
+
})(ImageRenditionFormat || (ImageRenditionFormat = {}));
|
|
1335
|
+
var MarkdownRenditionFormat;
|
|
1336
|
+
(function (MarkdownRenditionFormat) {
|
|
1337
|
+
MarkdownRenditionFormat["docx"] = "docx";
|
|
1338
|
+
MarkdownRenditionFormat["pdf"] = "pdf";
|
|
1339
|
+
})(MarkdownRenditionFormat || (MarkdownRenditionFormat = {}));
|
|
1340
|
+
/**
|
|
1341
|
+
* Matrix of supported content type → format conversions.
|
|
1342
|
+
* This is the authoritative source of truth for what renditions can be generated.
|
|
1343
|
+
*
|
|
1344
|
+
* Key patterns:
|
|
1345
|
+
* - Exact MIME types (e.g., 'application/pdf')
|
|
1346
|
+
* - Wildcard patterns (e.g., 'image/*', 'video/*')
|
|
1347
|
+
*/
|
|
1348
|
+
({
|
|
1349
|
+
// Image formats can generate: jpeg, png, webp
|
|
1350
|
+
'image/*': [ImageRenditionFormat.jpeg, ImageRenditionFormat.png, ImageRenditionFormat.webp],
|
|
1351
|
+
// Video formats can generate: jpeg, png (thumbnails)
|
|
1352
|
+
'video/*': [ImageRenditionFormat.jpeg, ImageRenditionFormat.png],
|
|
1353
|
+
// PDF can generate: jpeg, png, webp (page images)
|
|
1354
|
+
'application/pdf': [ImageRenditionFormat.jpeg, ImageRenditionFormat.png, ImageRenditionFormat.webp],
|
|
1355
|
+
// Markdown can generate: pdf, docx (NOT jpeg/png)
|
|
1356
|
+
'text/markdown': [MarkdownRenditionFormat.pdf, MarkdownRenditionFormat.docx],
|
|
1357
|
+
// Plain text can generate: docx
|
|
1358
|
+
'text/plain': [MarkdownRenditionFormat.docx],
|
|
1359
|
+
// Office documents can generate: pdf
|
|
1360
|
+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document': [MarkdownRenditionFormat.pdf],
|
|
1361
|
+
'application/msword': [MarkdownRenditionFormat.pdf],
|
|
1362
|
+
'application/vnd.openxmlformats-officedocument.presentationml.presentation': [MarkdownRenditionFormat.pdf],
|
|
1363
|
+
'application/vnd.ms-powerpoint': [MarkdownRenditionFormat.pdf],
|
|
1364
|
+
});
|
|
1365
|
+
var ContentObjectProcessingPriority;
|
|
1366
|
+
(function (ContentObjectProcessingPriority) {
|
|
1367
|
+
ContentObjectProcessingPriority["normal"] = "normal";
|
|
1368
|
+
ContentObjectProcessingPriority["low"] = "low";
|
|
1369
|
+
})(ContentObjectProcessingPriority || (ContentObjectProcessingPriority = {}));
|
|
1370
|
+
|
|
1371
|
+
var ContentEventName;
|
|
1372
|
+
(function (ContentEventName) {
|
|
1373
|
+
ContentEventName["create"] = "create";
|
|
1374
|
+
ContentEventName["change_type"] = "change_type";
|
|
1375
|
+
ContentEventName["update"] = "update";
|
|
1376
|
+
ContentEventName["revision_created"] = "revision_created";
|
|
1377
|
+
ContentEventName["delete"] = "delete";
|
|
1378
|
+
ContentEventName["workflow_finished"] = "workflow_finished";
|
|
1379
|
+
ContentEventName["workflow_execution_request"] = "workflow_execution_request";
|
|
1380
|
+
ContentEventName["api_request"] = "api_request";
|
|
1381
|
+
})(ContentEventName || (ContentEventName = {}));
|
|
1382
|
+
var WorkflowExecutionStatus;
|
|
1383
|
+
(function (WorkflowExecutionStatus) {
|
|
1384
|
+
WorkflowExecutionStatus[WorkflowExecutionStatus["UNKNOWN"] = 0] = "UNKNOWN";
|
|
1385
|
+
WorkflowExecutionStatus[WorkflowExecutionStatus["RUNNING"] = 1] = "RUNNING";
|
|
1386
|
+
WorkflowExecutionStatus[WorkflowExecutionStatus["COMPLETED"] = 2] = "COMPLETED";
|
|
1387
|
+
WorkflowExecutionStatus[WorkflowExecutionStatus["FAILED"] = 3] = "FAILED";
|
|
1388
|
+
WorkflowExecutionStatus[WorkflowExecutionStatus["CANCELED"] = 4] = "CANCELED";
|
|
1389
|
+
WorkflowExecutionStatus[WorkflowExecutionStatus["TERMINATED"] = 5] = "TERMINATED";
|
|
1390
|
+
WorkflowExecutionStatus[WorkflowExecutionStatus["CONTINUED_AS_NEW"] = 6] = "CONTINUED_AS_NEW";
|
|
1391
|
+
WorkflowExecutionStatus[WorkflowExecutionStatus["TIMED_OUT"] = 7] = "TIMED_OUT";
|
|
1392
|
+
})(WorkflowExecutionStatus || (WorkflowExecutionStatus = {}));
|
|
1393
|
+
var AgentMessageType;
|
|
1394
|
+
(function (AgentMessageType) {
|
|
1395
|
+
AgentMessageType[AgentMessageType["SYSTEM"] = 0] = "SYSTEM";
|
|
1396
|
+
AgentMessageType[AgentMessageType["THOUGHT"] = 1] = "THOUGHT";
|
|
1397
|
+
AgentMessageType[AgentMessageType["PLAN"] = 2] = "PLAN";
|
|
1398
|
+
AgentMessageType[AgentMessageType["UPDATE"] = 3] = "UPDATE";
|
|
1399
|
+
AgentMessageType[AgentMessageType["COMPLETE"] = 4] = "COMPLETE";
|
|
1400
|
+
AgentMessageType[AgentMessageType["WARNING"] = 5] = "WARNING";
|
|
1401
|
+
AgentMessageType[AgentMessageType["ERROR"] = 6] = "ERROR";
|
|
1402
|
+
AgentMessageType[AgentMessageType["ANSWER"] = 7] = "ANSWER";
|
|
1403
|
+
AgentMessageType[AgentMessageType["QUESTION"] = 8] = "QUESTION";
|
|
1404
|
+
AgentMessageType[AgentMessageType["REQUEST_INPUT"] = 9] = "REQUEST_INPUT";
|
|
1405
|
+
AgentMessageType[AgentMessageType["IDLE"] = 10] = "IDLE";
|
|
1406
|
+
AgentMessageType[AgentMessageType["TERMINATED"] = 11] = "TERMINATED";
|
|
1407
|
+
AgentMessageType[AgentMessageType["STREAMING_CHUNK"] = 12] = "STREAMING_CHUNK";
|
|
1408
|
+
AgentMessageType[AgentMessageType["BATCH_PROGRESS"] = 13] = "BATCH_PROGRESS";
|
|
1409
|
+
})(AgentMessageType || (AgentMessageType = {}));
|
|
1410
|
+
// ============================================
|
|
1411
|
+
// CONVERTERS
|
|
1412
|
+
// ============================================
|
|
1413
|
+
/**
|
|
1414
|
+
* Map old string enum values to AgentMessageType
|
|
1415
|
+
*/
|
|
1416
|
+
({
|
|
1417
|
+
'system': AgentMessageType.SYSTEM,
|
|
1418
|
+
'thought': AgentMessageType.THOUGHT,
|
|
1419
|
+
'plan': AgentMessageType.PLAN,
|
|
1420
|
+
'update': AgentMessageType.UPDATE,
|
|
1421
|
+
'complete': AgentMessageType.COMPLETE,
|
|
1422
|
+
'warning': AgentMessageType.WARNING,
|
|
1423
|
+
'error': AgentMessageType.ERROR,
|
|
1424
|
+
'answer': AgentMessageType.ANSWER,
|
|
1425
|
+
'question': AgentMessageType.QUESTION,
|
|
1426
|
+
'request_input': AgentMessageType.REQUEST_INPUT,
|
|
1427
|
+
'idle': AgentMessageType.IDLE,
|
|
1428
|
+
'terminated': AgentMessageType.TERMINATED,
|
|
1429
|
+
'streaming_chunk': AgentMessageType.STREAMING_CHUNK,
|
|
1430
|
+
'batch_progress': AgentMessageType.BATCH_PROGRESS,
|
|
1431
|
+
});
|
|
1432
|
+
/**
|
|
1433
|
+
* Map integer values to AgentMessageType (primary format)
|
|
1434
|
+
*/
|
|
1435
|
+
({
|
|
1436
|
+
0: AgentMessageType.SYSTEM,
|
|
1437
|
+
1: AgentMessageType.THOUGHT,
|
|
1438
|
+
2: AgentMessageType.PLAN,
|
|
1439
|
+
3: AgentMessageType.UPDATE,
|
|
1440
|
+
4: AgentMessageType.COMPLETE,
|
|
1441
|
+
5: AgentMessageType.WARNING,
|
|
1442
|
+
6: AgentMessageType.ERROR,
|
|
1443
|
+
7: AgentMessageType.ANSWER,
|
|
1444
|
+
8: AgentMessageType.QUESTION,
|
|
1445
|
+
9: AgentMessageType.REQUEST_INPUT,
|
|
1446
|
+
10: AgentMessageType.IDLE,
|
|
1447
|
+
11: AgentMessageType.TERMINATED,
|
|
1448
|
+
12: AgentMessageType.STREAMING_CHUNK,
|
|
1449
|
+
13: AgentMessageType.BATCH_PROGRESS,
|
|
1450
|
+
});
|
|
1451
|
+
/**
|
|
1452
|
+
* Status of a file being processed for conversation use.
|
|
1453
|
+
*/
|
|
1454
|
+
var FileProcessingStatus;
|
|
1455
|
+
(function (FileProcessingStatus) {
|
|
1456
|
+
/** File is being uploaded to artifact storage */
|
|
1457
|
+
FileProcessingStatus["UPLOADING"] = "uploading";
|
|
1458
|
+
/** File uploaded, text extraction in progress */
|
|
1459
|
+
FileProcessingStatus["PROCESSING"] = "processing";
|
|
1460
|
+
/** File is ready for use in conversation */
|
|
1461
|
+
FileProcessingStatus["READY"] = "ready";
|
|
1462
|
+
/** File processing failed */
|
|
1463
|
+
FileProcessingStatus["ERROR"] = "error";
|
|
1464
|
+
})(FileProcessingStatus || (FileProcessingStatus = {}));
|
|
1465
|
+
|
|
1466
|
+
var TrainingSessionStatus;
|
|
1467
|
+
(function (TrainingSessionStatus) {
|
|
1468
|
+
TrainingSessionStatus["created"] = "created";
|
|
1469
|
+
TrainingSessionStatus["building"] = "building";
|
|
1470
|
+
TrainingSessionStatus["prepared"] = "prepared";
|
|
1471
|
+
TrainingSessionStatus["processing"] = "processing";
|
|
1472
|
+
TrainingSessionStatus["completed"] = "completed";
|
|
1473
|
+
TrainingSessionStatus["cancelled"] = "cancelled";
|
|
1474
|
+
TrainingSessionStatus["failed"] = "failed";
|
|
1475
|
+
})(TrainingSessionStatus || (TrainingSessionStatus = {}));
|
|
1476
|
+
|
|
1477
|
+
var TransientTokenType;
|
|
1478
|
+
(function (TransientTokenType) {
|
|
1479
|
+
TransientTokenType["userInvite"] = "user-invite";
|
|
1480
|
+
TransientTokenType["migration"] = "migration";
|
|
1481
|
+
})(TransientTokenType || (TransientTokenType = {}));
|
|
1482
|
+
|
|
1483
|
+
var Datacenters;
|
|
1484
|
+
(function (Datacenters) {
|
|
1485
|
+
Datacenters["aws"] = "aws";
|
|
1486
|
+
Datacenters["gcp"] = "gcp";
|
|
1487
|
+
Datacenters["azure"] = "azure";
|
|
1488
|
+
})(Datacenters || (Datacenters = {}));
|
|
1489
|
+
var BillingMethod;
|
|
1490
|
+
(function (BillingMethod) {
|
|
1491
|
+
BillingMethod["stripe"] = "stripe";
|
|
1492
|
+
BillingMethod["invoice"] = "invoice";
|
|
1493
|
+
})(BillingMethod || (BillingMethod = {}));
|
|
1494
|
+
var AccountType;
|
|
1495
|
+
(function (AccountType) {
|
|
1496
|
+
AccountType["vertesia"] = "vertesia";
|
|
1497
|
+
AccountType["partner"] = "partner";
|
|
1498
|
+
AccountType["free"] = "free";
|
|
1499
|
+
AccountType["customer"] = "customer";
|
|
1500
|
+
AccountType["unknown"] = "unknown";
|
|
1501
|
+
})(AccountType || (AccountType = {}));
|
|
1502
|
+
|
|
1503
|
+
var ApiVersions;
|
|
1504
|
+
(function (ApiVersions) {
|
|
1505
|
+
ApiVersions[ApiVersions["COMPLETION_RESULT_V1"] = 20250925] = "COMPLETION_RESULT_V1";
|
|
1506
|
+
})(ApiVersions || (ApiVersions = {}));
|
|
1507
|
+
|
|
1508
|
+
/**
|
|
1509
|
+
* Agent Observability Telemetry Types
|
|
1510
|
+
*
|
|
1511
|
+
* These types define the event-based model for agent observability.
|
|
1512
|
+
*/
|
|
1513
|
+
// ============================================================================
|
|
1514
|
+
// Enums
|
|
1515
|
+
// ============================================================================
|
|
1516
|
+
/**
|
|
1517
|
+
* Types of telemetry events
|
|
1518
|
+
*/
|
|
1519
|
+
var AgentEventType;
|
|
1520
|
+
(function (AgentEventType) {
|
|
1521
|
+
AgentEventType["AgentRunStarted"] = "agent_run_started";
|
|
1522
|
+
AgentEventType["AgentRunCompleted"] = "agent_run_completed";
|
|
1523
|
+
AgentEventType["LlmCall"] = "llm_call";
|
|
1524
|
+
AgentEventType["ToolCall"] = "tool_call";
|
|
1525
|
+
})(AgentEventType || (AgentEventType = {}));
|
|
1526
|
+
/**
|
|
1527
|
+
* Types of LLM calls in a conversation
|
|
1528
|
+
*/
|
|
1529
|
+
var LlmCallType;
|
|
1530
|
+
(function (LlmCallType) {
|
|
1531
|
+
/** Initial conversation start */
|
|
1532
|
+
LlmCallType["Start"] = "start";
|
|
1533
|
+
/** Resuming with tool results */
|
|
1534
|
+
LlmCallType["ResumeTools"] = "resume_tools";
|
|
1535
|
+
/** Resuming with user message */
|
|
1536
|
+
LlmCallType["ResumeUser"] = "resume_user";
|
|
1537
|
+
/** Checkpoint resume (after conversation summarization) */
|
|
1538
|
+
LlmCallType["Checkpoint"] = "checkpoint";
|
|
1539
|
+
/** Nested interaction call from within tools */
|
|
1540
|
+
LlmCallType["NestedInteraction"] = "nested_interaction";
|
|
1541
|
+
})(LlmCallType || (LlmCallType = {}));
|
|
1542
|
+
/**
|
|
1543
|
+
* Types of tools that can be called
|
|
1544
|
+
*/
|
|
1545
|
+
var TelemetryToolType;
|
|
1546
|
+
(function (TelemetryToolType) {
|
|
1547
|
+
/** Built-in tools (e.g., plan, search) */
|
|
1548
|
+
TelemetryToolType["Builtin"] = "builtin";
|
|
1549
|
+
/** Interaction-based tools */
|
|
1550
|
+
TelemetryToolType["Interaction"] = "interaction";
|
|
1551
|
+
/** Remote/MCP tools */
|
|
1552
|
+
TelemetryToolType["Remote"] = "remote";
|
|
1553
|
+
/** Skill tools */
|
|
1554
|
+
TelemetryToolType["Skill"] = "skill";
|
|
1555
|
+
})(TelemetryToolType || (TelemetryToolType = {}));
|
|
1556
|
+
|
|
1557
|
+
/**
|
|
1558
|
+
* Prompt transformer preset for template files with frontmatter
|
|
1559
|
+
* Supports .jst, .hbs, and plain text files
|
|
1560
|
+
*/
|
|
1561
|
+
/**
|
|
1562
|
+
* Zod schema for prompt frontmatter validation
|
|
1563
|
+
*/
|
|
1564
|
+
const PromptFrontmatterSchema = z.object({
|
|
1565
|
+
// Required fields
|
|
1566
|
+
role: z.nativeEnum(PromptRole, {
|
|
1567
|
+
errorMap: () => ({ message: 'Role must be one of: safety, system, user, assistant, negative' })
|
|
1568
|
+
}),
|
|
1569
|
+
// Optional fields
|
|
1570
|
+
content_type: z.nativeEnum(TemplateType).optional(),
|
|
1571
|
+
schema: z.string().optional(),
|
|
1572
|
+
name: z.string().optional(),
|
|
1573
|
+
externalId: z.string().optional(),
|
|
1574
|
+
}).strict();
|
|
1575
|
+
/**
|
|
1576
|
+
* MUST be kept in sync with @vertesia/common InCodePrompt
|
|
1577
|
+
* Zod schema for prompt definition
|
|
1578
|
+
*/
|
|
1579
|
+
const PromptDefinitionSchema = z.object({
|
|
1580
|
+
role: z.nativeEnum(PromptRole),
|
|
1581
|
+
content: z.string(),
|
|
1582
|
+
content_type: z.nativeEnum(TemplateType),
|
|
1583
|
+
schema: z.any().optional(),
|
|
1584
|
+
name: z.string().optional(),
|
|
1585
|
+
externalId: z.string().optional(),
|
|
1586
|
+
});
|
|
1587
|
+
/**
|
|
1588
|
+
* Normalize schema path for import
|
|
1589
|
+
* - Adds './' prefix if not a relative path
|
|
1590
|
+
* - Replaces .ts with .js
|
|
1591
|
+
* - Adds .js if no extension
|
|
1592
|
+
*
|
|
1593
|
+
* @param schemaPath - Original schema path from frontmatter
|
|
1594
|
+
* @returns Normalized path for ES module import
|
|
1595
|
+
*/
|
|
1596
|
+
function normalizeSchemaPath(schemaPath) {
|
|
1597
|
+
let normalized = schemaPath.trim();
|
|
1598
|
+
// Add './' prefix if not already a relative path
|
|
1599
|
+
if (!normalized.startsWith('.')) {
|
|
1600
|
+
normalized = './' + normalized;
|
|
1601
|
+
}
|
|
1602
|
+
// Get the extension
|
|
1603
|
+
const ext = path$1.extname(normalized);
|
|
1604
|
+
if (ext === '.ts') {
|
|
1605
|
+
// Replace .ts with .js
|
|
1606
|
+
normalized = normalized.slice(0, -3) + '.js';
|
|
1607
|
+
}
|
|
1608
|
+
else if (!ext) {
|
|
1609
|
+
// No extension, add .js
|
|
1610
|
+
normalized = normalized + '.js';
|
|
1611
|
+
}
|
|
1612
|
+
// If extension is already .js or something else, leave as is
|
|
1613
|
+
return normalized;
|
|
1614
|
+
}
|
|
1615
|
+
/**
|
|
1616
|
+
* Infer content type from file extension
|
|
1617
|
+
*
|
|
1618
|
+
* @param filePath - Path to the prompt file
|
|
1619
|
+
* @returns Inferred content type
|
|
1620
|
+
*/
|
|
1621
|
+
function inferContentType(filePath) {
|
|
1622
|
+
const ext = path$1.extname(filePath).toLowerCase();
|
|
1623
|
+
switch (ext) {
|
|
1624
|
+
case '.jst':
|
|
1625
|
+
return TemplateType.jst;
|
|
1626
|
+
case '.hbs':
|
|
1627
|
+
return TemplateType.handlebars;
|
|
1628
|
+
default:
|
|
1629
|
+
return TemplateType.text;
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
/**
|
|
1633
|
+
* Build a PromptDefinition from frontmatter and content
|
|
1634
|
+
*
|
|
1635
|
+
* @param frontmatter - Parsed frontmatter object
|
|
1636
|
+
* @param content - Prompt content (body of the file)
|
|
1637
|
+
* @param filePath - Path to the prompt file (for content type inference)
|
|
1638
|
+
* @returns Prompt definition object and optional imports
|
|
1639
|
+
*/
|
|
1640
|
+
function buildPromptDefinition(frontmatter, content, filePath) {
|
|
1641
|
+
// Determine content type from frontmatter or file extension
|
|
1642
|
+
const content_type = frontmatter.content_type || inferContentType(filePath);
|
|
1643
|
+
const prompt = {
|
|
1644
|
+
role: frontmatter.role,
|
|
1645
|
+
content,
|
|
1646
|
+
content_type,
|
|
1647
|
+
};
|
|
1648
|
+
// Add optional fields
|
|
1649
|
+
if (frontmatter.name) {
|
|
1650
|
+
prompt.name = frontmatter.name;
|
|
1651
|
+
}
|
|
1652
|
+
if (frontmatter.externalId) {
|
|
1653
|
+
prompt.externalId = frontmatter.externalId;
|
|
1654
|
+
}
|
|
1655
|
+
// Handle schema import if specified
|
|
1656
|
+
let imports;
|
|
1657
|
+
let schemaImportName;
|
|
1658
|
+
if (frontmatter.schema) {
|
|
1659
|
+
const normalizedPath = normalizeSchemaPath(frontmatter.schema);
|
|
1660
|
+
schemaImportName = '__promptSchema';
|
|
1661
|
+
imports = [`import ${schemaImportName} from '${normalizedPath}';`];
|
|
1662
|
+
}
|
|
1663
|
+
return { prompt, imports, schemaImportName };
|
|
1664
|
+
}
|
|
1665
|
+
/**
|
|
1666
|
+
* Prompt transformer preset
|
|
1667
|
+
* Transforms template files with ?prompt suffix into prompt definition objects
|
|
1668
|
+
*
|
|
1669
|
+
* Supported file types:
|
|
1670
|
+
* - .jst (JavaScript template literals) → content_type: 'jst'
|
|
1671
|
+
* - .hbs (Handlebars templates) → content_type: 'handlebars'
|
|
1672
|
+
* - .txt or other → content_type: 'text'
|
|
1673
|
+
*
|
|
1674
|
+
* @example
|
|
1675
|
+
* ```typescript
|
|
1676
|
+
* import PROMPT from './prompt.hbs?prompt';
|
|
1677
|
+
* // PROMPT is an InCodePrompt object
|
|
1678
|
+
* ```
|
|
1679
|
+
*/
|
|
1680
|
+
const promptTransformer = {
|
|
1681
|
+
pattern: /\?prompt$/,
|
|
1682
|
+
schema: PromptDefinitionSchema,
|
|
1683
|
+
transform: (content, filePath) => {
|
|
1684
|
+
const { frontmatter, content: promptContent } = parseFrontmatter(content);
|
|
1685
|
+
// Validate frontmatter
|
|
1686
|
+
const frontmatterValidation = PromptFrontmatterSchema.safeParse(frontmatter);
|
|
1687
|
+
if (!frontmatterValidation.success) {
|
|
1688
|
+
const errors = frontmatterValidation.error.errors
|
|
1689
|
+
.map((err) => {
|
|
1690
|
+
const path = err.path.length > 0 ? err.path.join('.') : 'frontmatter';
|
|
1691
|
+
return ` - ${path}: ${err.message}`;
|
|
1692
|
+
})
|
|
1693
|
+
.join('\n');
|
|
1694
|
+
throw new Error(`Invalid frontmatter in ${filePath}:\n${errors}`);
|
|
1695
|
+
}
|
|
1696
|
+
// Build prompt definition
|
|
1697
|
+
const { prompt, imports, schemaImportName } = buildPromptDefinition(frontmatter, promptContent, filePath);
|
|
1698
|
+
// If schema is specified, generate custom code with schema reference
|
|
1699
|
+
if (schemaImportName) {
|
|
1700
|
+
// Build the code manually to avoid JSON.stringify issues with schema reference
|
|
1701
|
+
const lines = [
|
|
1702
|
+
'export default {',
|
|
1703
|
+
` role: "${prompt.role}",`,
|
|
1704
|
+
` content: ${JSON.stringify(prompt.content)},`,
|
|
1705
|
+
` content_type: "${prompt.content_type}",`,
|
|
1706
|
+
` schema: ${schemaImportName}`,
|
|
1707
|
+
];
|
|
1708
|
+
if (prompt.name) {
|
|
1709
|
+
lines.splice(4, 0, ` name: ${JSON.stringify(prompt.name)},`);
|
|
1710
|
+
}
|
|
1711
|
+
if (prompt.externalId) {
|
|
1712
|
+
lines.splice(4, 0, ` externalId: ${JSON.stringify(prompt.externalId)},`);
|
|
1713
|
+
}
|
|
1714
|
+
lines.push('};');
|
|
1715
|
+
const code = lines.join('\n');
|
|
1716
|
+
return {
|
|
1717
|
+
data: prompt,
|
|
1718
|
+
imports,
|
|
1719
|
+
code,
|
|
1720
|
+
};
|
|
1721
|
+
}
|
|
1722
|
+
// Standard case without schema
|
|
1723
|
+
return {
|
|
1724
|
+
data: prompt,
|
|
1725
|
+
};
|
|
1726
|
+
}
|
|
1727
|
+
};
|
|
1728
|
+
|
|
1729
|
+
export { PromptDefinitionSchema, PromptRole, SkillDefinitionSchema, TemplateType, parseFrontmatter, promptTransformer, rawTransformer, skillCollectionTransformer, skillTransformer, vertesiaImportPlugin };
|
|
1730
|
+
//# sourceMappingURL=build-tools.js.map
|