@vertesia/build-tools 1.0.0-dev.20260128.144200 → 1.0.0-dev.20260225.024852Z
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/README.md +39 -0
- package/lib/build-tools.js +54 -6
- package/lib/build-tools.js.map +1 -1
- package/lib/cjs/index.js +2 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/presets/index.js +2 -1
- package/lib/cjs/presets/index.js.map +1 -1
- package/lib/cjs/presets/skill.js +52 -4
- package/lib/cjs/presets/skill.js.map +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/presets/index.js +1 -1
- package/lib/esm/presets/index.js.map +1 -1
- package/lib/esm/presets/skill.js +48 -3
- package/lib/esm/presets/skill.js.map +1 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/presets/index.d.ts +1 -1
- package/lib/types/presets/index.d.ts.map +1 -1
- package/lib/types/presets/skill.d.ts +253 -31
- package/lib/types/presets/skill.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +1 -0
- package/src/presets/index.ts +1 -1
- package/src/presets/skill.ts +51 -3
package/README.md
CHANGED
|
@@ -136,9 +136,48 @@ This is the skill content in markdown.
|
|
|
136
136
|
related_tools?: string[]; // Optional: Related tool names
|
|
137
137
|
scripts?: string[]; // Optional: Script files in skill dir
|
|
138
138
|
widgets?: string[]; // Optional: Widget names in skill dir
|
|
139
|
+
isEnabled?: (context: any) => Promise<boolean>; // Optional: Runtime filter function
|
|
139
140
|
}
|
|
140
141
|
```
|
|
141
142
|
|
|
143
|
+
### Runtime Properties (`properties.ts`)
|
|
144
|
+
|
|
145
|
+
For properties that cannot be defined in YAML frontmatter (like functions), create a `properties.ts` file in your skill directory:
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
// my-skill/properties.ts
|
|
149
|
+
import type { ToolUseContext } from '@vertesia/tools-sdk';
|
|
150
|
+
|
|
151
|
+
export default {
|
|
152
|
+
// Function to check if skill is enabled
|
|
153
|
+
isEnabled: async (context: ToolUseContext): Promise<boolean> => {
|
|
154
|
+
return context.project?.settings?.myFeature === true;
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
// You can override any frontmatter property
|
|
158
|
+
description: 'Dynamically set description',
|
|
159
|
+
|
|
160
|
+
// Add any other SkillDefinition properties
|
|
161
|
+
};
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
**How it works:**
|
|
165
|
+
1. The `properties.ts` file must export a default object of type `Partial<SkillDefinition>`
|
|
166
|
+
2. Properties from `properties.ts` **override** those from frontmatter
|
|
167
|
+
3. During build, the SKILL.md transformer generates code that imports `./properties.js`
|
|
168
|
+
4. Rollup automatically transpiles `properties.ts` to `properties.js` (via TypeScript plugin)
|
|
169
|
+
5. Runtime validation ensures `isEnabled` (if present) is a function
|
|
170
|
+
6. Build fails with clear errors if validation fails
|
|
171
|
+
|
|
172
|
+
**Directory structure:**
|
|
173
|
+
```
|
|
174
|
+
my-skill/
|
|
175
|
+
├── SKILL.md # Declarative properties (frontmatter + markdown)
|
|
176
|
+
├── properties.ts # Runtime properties (functions, overrides)
|
|
177
|
+
├── helper.js # Script files (auto-discovered)
|
|
178
|
+
└── chart.tsx # Widget files (auto-discovered)
|
|
179
|
+
```
|
|
180
|
+
|
|
142
181
|
### Raw Transformer
|
|
143
182
|
|
|
144
183
|
Imports any file as a raw string.
|
package/lib/build-tools.js
CHANGED
|
@@ -455,6 +455,9 @@ const SkillFrontmatterSchema = z.object({
|
|
|
455
455
|
* Zod schema for skill definition
|
|
456
456
|
* This validates the structure of skill objects generated from markdown
|
|
457
457
|
* Matches the SkillDefinition interface from @vertesia/tools-sdk
|
|
458
|
+
*
|
|
459
|
+
* Note: The isEnabled property is not included in this schema because Zod cannot
|
|
460
|
+
* properly validate function signatures. It will be type-checked by TypeScript instead.
|
|
458
461
|
*/
|
|
459
462
|
const SkillDefinitionSchema = z.object({
|
|
460
463
|
name: z.string().min(1, 'Skill name is required'),
|
|
@@ -472,7 +475,16 @@ const SkillDefinitionSchema = z.object({
|
|
|
472
475
|
related_tools: z.array(z.string()).optional(),
|
|
473
476
|
scripts: z.array(z.string()).optional(),
|
|
474
477
|
widgets: z.array(z.string()).optional()
|
|
475
|
-
});
|
|
478
|
+
}).passthrough();
|
|
479
|
+
/**
|
|
480
|
+
* Schema for validating properties exported from properties.ts
|
|
481
|
+
* This is a partial schema - allows any subset of SkillDefinition fields
|
|
482
|
+
*
|
|
483
|
+
* Note: Function properties like isEnabled cannot be validated by Zod for their signatures.
|
|
484
|
+
* Zod will only check that they are functions, not their specific parameter/return types.
|
|
485
|
+
* Use TypeScript for proper type checking of function signatures.
|
|
486
|
+
*/
|
|
487
|
+
const SkillPropertiesSchema = SkillDefinitionSchema.partial().passthrough();
|
|
476
488
|
/**
|
|
477
489
|
* Build a SkillDefinition from frontmatter and markdown content.
|
|
478
490
|
* This mirrors the logic in @vertesia/tools-sdk parseSkillFile function.
|
|
@@ -562,6 +574,11 @@ function buildSkillDefinition(frontmatter, instructions, contentType, widgets, s
|
|
|
562
574
|
* - Files with ?skill suffix: ./my-skill.md?skill
|
|
563
575
|
* - SKILL.md files: ./my-skill/SKILL.md
|
|
564
576
|
*
|
|
577
|
+
* Runtime Properties:
|
|
578
|
+
* - Supports properties.ts file in skill directory for runtime properties (functions, overrides)
|
|
579
|
+
* - Properties from properties.ts override those from frontmatter
|
|
580
|
+
* - See README.md for detailed usage examples
|
|
581
|
+
*
|
|
565
582
|
* @example
|
|
566
583
|
* ```typescript
|
|
567
584
|
* import skill1 from './my-skill.md?skill';
|
|
@@ -579,8 +596,8 @@ const skillTransformer = {
|
|
|
579
596
|
if (!frontmatterValidation.success) {
|
|
580
597
|
const errors = frontmatterValidation.error.errors
|
|
581
598
|
.map((err) => {
|
|
582
|
-
const
|
|
583
|
-
return ` - ${
|
|
599
|
+
const pathStr = err.path.length > 0 ? err.path.join('.') : 'frontmatter';
|
|
600
|
+
return ` - ${pathStr}: ${err.message}`;
|
|
584
601
|
})
|
|
585
602
|
.join('\n');
|
|
586
603
|
throw new Error(`Invalid frontmatter in ${filePath}:\n${errors}`);
|
|
@@ -591,6 +608,32 @@ const skillTransformer = {
|
|
|
591
608
|
const assets = discoverSkillAssets(filePath);
|
|
592
609
|
// Build skill definition using the same logic as parseSkillFile in tools-sdk
|
|
593
610
|
const skillData = buildSkillDefinition(frontmatter, markdown, content_type, assets.widgets, assets.scripts);
|
|
611
|
+
// Check if properties.ts exists in the skill directory
|
|
612
|
+
const skillDir = path.dirname(filePath);
|
|
613
|
+
const propertiesPath = path.join(skillDir, 'properties.ts');
|
|
614
|
+
const hasProperties = existsSync(propertiesPath);
|
|
615
|
+
// If properties.ts exists, generate custom code with import and merge
|
|
616
|
+
// Rollup will handle transpiling properties.ts to properties.js
|
|
617
|
+
if (hasProperties) {
|
|
618
|
+
const skillDataJson = JSON.stringify(skillData, null, 2);
|
|
619
|
+
const code = `import properties from './properties.js';
|
|
620
|
+
|
|
621
|
+
// Runtime validation for function properties
|
|
622
|
+
if ('isEnabled' in properties && typeof properties.isEnabled !== 'function') {
|
|
623
|
+
throw new Error('properties.isEnabled must be a function, got ' + typeof properties.isEnabled);
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
const skill = ${skillDataJson};
|
|
627
|
+
|
|
628
|
+
export default { ...skill, ...properties };
|
|
629
|
+
`;
|
|
630
|
+
return {
|
|
631
|
+
data: skillData,
|
|
632
|
+
assets: assets.assetFiles,
|
|
633
|
+
widgets: assets.widgetMetadata,
|
|
634
|
+
code
|
|
635
|
+
};
|
|
636
|
+
}
|
|
594
637
|
return {
|
|
595
638
|
data: skillData,
|
|
596
639
|
assets: assets.assetFiles,
|
|
@@ -760,6 +803,7 @@ var PrincipalType;
|
|
|
760
803
|
PrincipalType["ApiKey"] = "apikey";
|
|
761
804
|
PrincipalType["ServiceAccount"] = "service_account";
|
|
762
805
|
PrincipalType["Agent"] = "agent";
|
|
806
|
+
PrincipalType["Schedule"] = "schedule";
|
|
763
807
|
})(PrincipalType || (PrincipalType = {}));
|
|
764
808
|
|
|
765
809
|
var InteractionStatus;
|
|
@@ -1165,6 +1209,8 @@ var SupportedIntegrations;
|
|
|
1165
1209
|
SupportedIntegrations["aws"] = "aws";
|
|
1166
1210
|
SupportedIntegrations["magic_pdf"] = "magic_pdf";
|
|
1167
1211
|
SupportedIntegrations["serper"] = "serper";
|
|
1212
|
+
SupportedIntegrations["exa"] = "exa";
|
|
1213
|
+
SupportedIntegrations["linkup"] = "linkup";
|
|
1168
1214
|
SupportedIntegrations["resend"] = "resend";
|
|
1169
1215
|
SupportedIntegrations["ask_user_webhook"] = "ask_user_webhook";
|
|
1170
1216
|
})(SupportedIntegrations || (SupportedIntegrations = {}));
|
|
@@ -1354,8 +1400,8 @@ var MarkdownRenditionFormat;
|
|
|
1354
1400
|
'application/pdf': [ImageRenditionFormat.jpeg, ImageRenditionFormat.png, ImageRenditionFormat.webp],
|
|
1355
1401
|
// Markdown can generate: pdf, docx (NOT jpeg/png)
|
|
1356
1402
|
'text/markdown': [MarkdownRenditionFormat.pdf, MarkdownRenditionFormat.docx],
|
|
1357
|
-
//
|
|
1358
|
-
'text
|
|
1403
|
+
// Any text/* can generate: docx (editable export)
|
|
1404
|
+
'text/*': [MarkdownRenditionFormat.docx],
|
|
1359
1405
|
// Office documents can generate: pdf
|
|
1360
1406
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.document': [MarkdownRenditionFormat.pdf],
|
|
1361
1407
|
'application/msword': [MarkdownRenditionFormat.pdf],
|
|
@@ -1398,6 +1444,7 @@ var TaskType;
|
|
|
1398
1444
|
TaskType["ACTIVITY"] = "activity";
|
|
1399
1445
|
TaskType["CHILD_WORKFLOW"] = "childWorkflow";
|
|
1400
1446
|
TaskType["SIGNAL"] = "signal";
|
|
1447
|
+
TaskType["TIMER"] = "timer";
|
|
1401
1448
|
})(TaskType || (TaskType = {}));
|
|
1402
1449
|
var WorkflowExecutionStatus;
|
|
1403
1450
|
(function (WorkflowExecutionStatus) {
|
|
@@ -1523,6 +1570,7 @@ var AccountType;
|
|
|
1523
1570
|
var ApiVersions;
|
|
1524
1571
|
(function (ApiVersions) {
|
|
1525
1572
|
ApiVersions[ApiVersions["COMPLETION_RESULT_V1"] = 20250925] = "COMPLETION_RESULT_V1";
|
|
1573
|
+
ApiVersions[ApiVersions["DOWNLOAD_URL_NO_MIME_TYPE_V1"] = 20260210] = "DOWNLOAD_URL_NO_MIME_TYPE_V1";
|
|
1526
1574
|
})(ApiVersions || (ApiVersions = {}));
|
|
1527
1575
|
|
|
1528
1576
|
/**
|
|
@@ -1746,5 +1794,5 @@ const promptTransformer = {
|
|
|
1746
1794
|
}
|
|
1747
1795
|
};
|
|
1748
1796
|
|
|
1749
|
-
export { PromptDefinitionSchema, PromptRole, SkillDefinitionSchema, TemplateType, parseFrontmatter, promptTransformer, rawTransformer, skillCollectionTransformer, skillTransformer, vertesiaImportPlugin };
|
|
1797
|
+
export { PromptDefinitionSchema, PromptRole, SkillDefinitionSchema, SkillPropertiesSchema, TemplateType, parseFrontmatter, promptTransformer, rawTransformer, skillCollectionTransformer, skillTransformer, vertesiaImportPlugin };
|
|
1750
1798
|
//# sourceMappingURL=build-tools.js.map
|