@vertesia/build-tools 0.80.0 → 0.80.2
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/lib/build-tools.js +1122 -8
- package/lib/build-tools.js.map +1 -1
- package/lib/cjs/index.js +6 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/plugin.js +14 -6
- package/lib/cjs/plugin.js.map +1 -1
- package/lib/cjs/presets/index.js +8 -1
- package/lib/cjs/presets/index.js.map +1 -1
- package/lib/cjs/presets/prompt.js +185 -0
- package/lib/cjs/presets/prompt.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/esm/index.js +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/plugin.js +14 -6
- package/lib/esm/plugin.js.map +1 -1
- package/lib/esm/presets/index.js +2 -0
- package/lib/esm/presets/index.js.map +1 -1
- package/lib/esm/presets/prompt.js +181 -0
- package/lib/esm/presets/prompt.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/types/index.d.ts +1 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/plugin.d.ts.map +1 -1
- package/lib/types/presets/index.d.ts +2 -0
- package/lib/types/presets/index.d.ts.map +1 -1
- package/lib/types/presets/prompt.d.ts +63 -0
- package/lib/types/presets/prompt.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/types.d.ts +2 -0
- package/lib/types/types.d.ts.map +1 -1
- package/package.json +4 -2
- package/src/index.ts +8 -1
- package/src/plugin.ts +14 -6
- package/src/presets/index.ts +2 -0
- package/src/presets/prompt.ts +227 -0
- package/src/presets/skill-collection.ts +86 -0
- package/src/types.ts +3 -0
package/lib/build-tools.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { copyFileSync, mkdirSync, readFileSync, readdirSync, statSync } from 'node:fs';
|
|
1
|
+
import { copyFileSync, mkdirSync, readFileSync, readdirSync, statSync, existsSync } from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { rollup } from 'rollup';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import matter from 'gray-matter';
|
|
6
|
+
import path$1 from 'path';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Utilities for copying asset files during build
|
|
@@ -158,7 +159,13 @@ function vertesiaImportPlugin(config) {
|
|
|
158
159
|
// Handle relative imports
|
|
159
160
|
if (source.startsWith('.') && importer) {
|
|
160
161
|
const cleanSource = source.replace(transformer.pattern, '');
|
|
161
|
-
|
|
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);
|
|
162
169
|
// Return with the pattern suffix to identify it in load
|
|
163
170
|
const suffix = source.match(transformer.pattern)?.[0] || '';
|
|
164
171
|
return resolved + suffix;
|
|
@@ -190,8 +197,10 @@ function vertesiaImportPlugin(config) {
|
|
|
190
197
|
return null; // Not for us
|
|
191
198
|
}
|
|
192
199
|
try {
|
|
193
|
-
// Read file content
|
|
194
|
-
const content =
|
|
200
|
+
// Read file content (skip for virtual transforms)
|
|
201
|
+
const content = matchedTransformer.virtual
|
|
202
|
+
? ''
|
|
203
|
+
: readFileSync(cleanId, 'utf-8');
|
|
195
204
|
// Transform the content
|
|
196
205
|
const result = await matchedTransformer.transform(content, cleanId);
|
|
197
206
|
// Collect assets if any
|
|
@@ -213,13 +222,13 @@ function vertesiaImportPlugin(config) {
|
|
|
213
222
|
}
|
|
214
223
|
}
|
|
215
224
|
// Generate code
|
|
225
|
+
const imports = result.imports ? result.imports.join('\n') + '\n\n' : '';
|
|
216
226
|
if (result.code) {
|
|
217
|
-
// Custom code provided
|
|
218
|
-
return result.code;
|
|
227
|
+
// Custom code provided - prepend imports
|
|
228
|
+
return imports + result.code;
|
|
219
229
|
}
|
|
220
230
|
else {
|
|
221
231
|
// Default: export data (escape if string, otherwise stringify as JSON)
|
|
222
|
-
const imports = result.imports ? result.imports.join('\n') + '\n\n' : '';
|
|
223
232
|
const dataJson = JSON.stringify(result.data, null, 2);
|
|
224
233
|
return `${imports}export default ${dataJson};`;
|
|
225
234
|
}
|
|
@@ -590,6 +599,81 @@ const skillTransformer = {
|
|
|
590
599
|
}
|
|
591
600
|
};
|
|
592
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
|
+
|
|
593
677
|
/**
|
|
594
678
|
* Raw transformer preset for importing file content as strings
|
|
595
679
|
*/
|
|
@@ -612,5 +696,1035 @@ const rawTransformer = {
|
|
|
612
696
|
}
|
|
613
697
|
};
|
|
614
698
|
|
|
615
|
-
|
|
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 };
|
|
616
1730
|
//# sourceMappingURL=build-tools.js.map
|