@quilltap/plugin-utils 1.6.2 → 1.7.1
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 +43 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +79 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +77 -1
- package/dist/index.mjs.map +1 -1
- package/dist/system-prompts/index.d.mts +65 -0
- package/dist/system-prompts/index.d.ts +65 -0
- package/dist/system-prompts/index.js +106 -0
- package/dist/system-prompts/index.js.map +1 -0
- package/dist/system-prompts/index.mjs +78 -0
- package/dist/system-prompts/index.mjs.map +1 -0
- package/package.json +8 -3
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/system-prompts/index.ts
|
|
21
|
+
var system_prompts_exports = {};
|
|
22
|
+
__export(system_prompts_exports, {
|
|
23
|
+
createSystemPromptPlugin: () => createSystemPromptPlugin,
|
|
24
|
+
validateSystemPromptPlugin: () => validateSystemPromptPlugin
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(system_prompts_exports);
|
|
27
|
+
|
|
28
|
+
// src/system-prompts/builder.ts
|
|
29
|
+
function createSystemPromptPlugin(options) {
|
|
30
|
+
const { metadata, prompts, initialize } = options;
|
|
31
|
+
if (prompts.length === 0) {
|
|
32
|
+
throw new Error("At least one system prompt is required");
|
|
33
|
+
}
|
|
34
|
+
const names = /* @__PURE__ */ new Set();
|
|
35
|
+
for (const prompt of prompts) {
|
|
36
|
+
if (!prompt.name || prompt.name.trim() === "") {
|
|
37
|
+
throw new Error("Prompt name is required");
|
|
38
|
+
}
|
|
39
|
+
if (!prompt.content || prompt.content.trim() === "") {
|
|
40
|
+
throw new Error(`Prompt "${prompt.name}" requires content`);
|
|
41
|
+
}
|
|
42
|
+
if (!prompt.modelHint || prompt.modelHint.trim() === "") {
|
|
43
|
+
throw new Error(`Prompt "${prompt.name}" requires a modelHint`);
|
|
44
|
+
}
|
|
45
|
+
if (!prompt.category || prompt.category.trim() === "") {
|
|
46
|
+
throw new Error(`Prompt "${prompt.name}" requires a category`);
|
|
47
|
+
}
|
|
48
|
+
if (names.has(prompt.name)) {
|
|
49
|
+
throw new Error(`Duplicate prompt name: "${prompt.name}"`);
|
|
50
|
+
}
|
|
51
|
+
names.add(prompt.name);
|
|
52
|
+
}
|
|
53
|
+
const plugin = {
|
|
54
|
+
metadata,
|
|
55
|
+
prompts
|
|
56
|
+
};
|
|
57
|
+
if (initialize) {
|
|
58
|
+
plugin.initialize = async () => {
|
|
59
|
+
await initialize();
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return plugin;
|
|
63
|
+
}
|
|
64
|
+
function validateSystemPromptPlugin(plugin) {
|
|
65
|
+
if (!plugin.metadata) {
|
|
66
|
+
throw new Error("Plugin metadata is required");
|
|
67
|
+
}
|
|
68
|
+
if (!plugin.metadata.pluginId || plugin.metadata.pluginId.trim() === "") {
|
|
69
|
+
throw new Error("Plugin metadata.pluginId is required");
|
|
70
|
+
}
|
|
71
|
+
if (!/^[a-z0-9-]+$/.test(plugin.metadata.pluginId)) {
|
|
72
|
+
throw new Error("Plugin pluginId must be lowercase alphanumeric with hyphens only");
|
|
73
|
+
}
|
|
74
|
+
if (!plugin.metadata.displayName || plugin.metadata.displayName.trim() === "") {
|
|
75
|
+
throw new Error("Plugin metadata.displayName is required");
|
|
76
|
+
}
|
|
77
|
+
if (!plugin.prompts || !Array.isArray(plugin.prompts) || plugin.prompts.length === 0) {
|
|
78
|
+
throw new Error("Plugin must have at least one prompt");
|
|
79
|
+
}
|
|
80
|
+
const names = /* @__PURE__ */ new Set();
|
|
81
|
+
for (const prompt of plugin.prompts) {
|
|
82
|
+
if (!prompt.name || prompt.name.trim() === "") {
|
|
83
|
+
throw new Error("Prompt name is required");
|
|
84
|
+
}
|
|
85
|
+
if (!prompt.content || prompt.content.trim() === "") {
|
|
86
|
+
throw new Error(`Prompt "${prompt.name}" requires content`);
|
|
87
|
+
}
|
|
88
|
+
if (!prompt.modelHint || prompt.modelHint.trim() === "") {
|
|
89
|
+
throw new Error(`Prompt "${prompt.name}" requires a modelHint`);
|
|
90
|
+
}
|
|
91
|
+
if (!prompt.category || prompt.category.trim() === "") {
|
|
92
|
+
throw new Error(`Prompt "${prompt.name}" requires a category`);
|
|
93
|
+
}
|
|
94
|
+
if (names.has(prompt.name)) {
|
|
95
|
+
throw new Error(`Duplicate prompt name: "${prompt.name}"`);
|
|
96
|
+
}
|
|
97
|
+
names.add(prompt.name);
|
|
98
|
+
}
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
+
0 && (module.exports = {
|
|
103
|
+
createSystemPromptPlugin,
|
|
104
|
+
validateSystemPromptPlugin
|
|
105
|
+
});
|
|
106
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/system-prompts/index.ts","../../src/system-prompts/builder.ts"],"sourcesContent":["/**\n * System Prompt Plugin utilities\n *\n * Provides helper functions for creating and validating system prompt plugins.\n *\n * @module @quilltap/plugin-utils/system-prompts\n */\n\nexport {\n // Builder functions\n createSystemPromptPlugin,\n\n // Validation utilities\n validateSystemPromptPlugin,\n} from './builder';\n\nexport type {\n // Builder option types\n CreateSystemPromptPluginOptions,\n} from './builder';\n\n// Re-export types from plugin-types for convenience\nexport type {\n SystemPromptData,\n SystemPromptMetadata,\n SystemPromptPlugin,\n SystemPromptPluginExport,\n} from '@quilltap/plugin-types';\n","/**\n * System Prompt Plugin Builder utilities\n *\n * Provides helper functions for creating and validating system prompt plugins.\n *\n * @module @quilltap/plugin-utils/system-prompts\n */\n\nimport type {\n SystemPromptData,\n SystemPromptMetadata,\n SystemPromptPlugin,\n} from '@quilltap/plugin-types';\n\n// ============================================================================\n// BUILDER OPTIONS\n// ============================================================================\n\n/**\n * Options for creating a system prompt plugin\n */\nexport interface CreateSystemPromptPluginOptions {\n /** Plugin metadata */\n metadata: SystemPromptMetadata;\n\n /**\n * One or more system prompts.\n * Each prompt must have a unique name within the plugin.\n */\n prompts: SystemPromptData[];\n\n /**\n * Optional initialization function.\n * Called when the plugin is loaded.\n */\n initialize?: () => void | Promise<void>;\n}\n\n// ============================================================================\n// BUILDER FUNCTIONS\n// ============================================================================\n\n/**\n * Creates a system prompt plugin.\n *\n * @param options - Plugin configuration options\n * @returns A valid SystemPromptPlugin instance\n *\n * @example\n * ```typescript\n * import { createSystemPromptPlugin } from '@quilltap/plugin-utils';\n *\n * export const plugin = createSystemPromptPlugin({\n * metadata: {\n * pluginId: 'my-prompts',\n * displayName: 'My Prompt Collection',\n * description: 'Custom system prompts for various models',\n * },\n * prompts: [\n * {\n * name: 'CLAUDE_CREATIVE',\n * content: '# Creative Writing Prompt\\n\\nYou are {{char}}...',\n * modelHint: 'CLAUDE',\n * category: 'CREATIVE',\n * },\n * ],\n * });\n * ```\n */\nexport function createSystemPromptPlugin(\n options: CreateSystemPromptPluginOptions\n): SystemPromptPlugin {\n const { metadata, prompts, initialize } = options;\n\n // Validate prompts\n if (prompts.length === 0) {\n throw new Error('At least one system prompt is required');\n }\n\n // Check for duplicate names\n const names = new Set<string>();\n for (const prompt of prompts) {\n if (!prompt.name || prompt.name.trim() === '') {\n throw new Error('Prompt name is required');\n }\n if (!prompt.content || prompt.content.trim() === '') {\n throw new Error(`Prompt \"${prompt.name}\" requires content`);\n }\n if (!prompt.modelHint || prompt.modelHint.trim() === '') {\n throw new Error(`Prompt \"${prompt.name}\" requires a modelHint`);\n }\n if (!prompt.category || prompt.category.trim() === '') {\n throw new Error(`Prompt \"${prompt.name}\" requires a category`);\n }\n if (names.has(prompt.name)) {\n throw new Error(`Duplicate prompt name: \"${prompt.name}\"`);\n }\n names.add(prompt.name);\n }\n\n // Create the plugin\n const plugin: SystemPromptPlugin = {\n metadata,\n prompts,\n };\n\n // Add initialize function if provided\n if (initialize) {\n plugin.initialize = async () => {\n await initialize();\n };\n }\n\n return plugin;\n}\n\n// ============================================================================\n// VALIDATION UTILITIES\n// ============================================================================\n\n/**\n * Validates a complete system prompt plugin\n *\n * @param plugin - The plugin to validate\n * @returns True if valid, throws Error if invalid\n */\nexport function validateSystemPromptPlugin(plugin: SystemPromptPlugin): boolean {\n // Validate metadata\n if (!plugin.metadata) {\n throw new Error('Plugin metadata is required');\n }\n\n if (!plugin.metadata.pluginId || plugin.metadata.pluginId.trim() === '') {\n throw new Error('Plugin metadata.pluginId is required');\n }\n\n if (!/^[a-z0-9-]+$/.test(plugin.metadata.pluginId)) {\n throw new Error('Plugin pluginId must be lowercase alphanumeric with hyphens only');\n }\n\n if (!plugin.metadata.displayName || plugin.metadata.displayName.trim() === '') {\n throw new Error('Plugin metadata.displayName is required');\n }\n\n // Validate prompts\n if (!plugin.prompts || !Array.isArray(plugin.prompts) || plugin.prompts.length === 0) {\n throw new Error('Plugin must have at least one prompt');\n }\n\n const names = new Set<string>();\n for (const prompt of plugin.prompts) {\n if (!prompt.name || prompt.name.trim() === '') {\n throw new Error('Prompt name is required');\n }\n if (!prompt.content || prompt.content.trim() === '') {\n throw new Error(`Prompt \"${prompt.name}\" requires content`);\n }\n if (!prompt.modelHint || prompt.modelHint.trim() === '') {\n throw new Error(`Prompt \"${prompt.name}\" requires a modelHint`);\n }\n if (!prompt.category || prompt.category.trim() === '') {\n throw new Error(`Prompt \"${prompt.name}\" requires a category`);\n }\n if (names.has(prompt.name)) {\n throw new Error(`Duplicate prompt name: \"${prompt.name}\"`);\n }\n names.add(prompt.name);\n }\n\n return true;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACqEO,SAAS,yBACd,SACoB;AACpB,QAAM,EAAE,UAAU,SAAS,WAAW,IAAI;AAG1C,MAAI,QAAQ,WAAW,GAAG;AACxB,UAAM,IAAI,MAAM,wCAAwC;AAAA,EAC1D;AAGA,QAAM,QAAQ,oBAAI,IAAY;AAC9B,aAAW,UAAU,SAAS;AAC5B,QAAI,CAAC,OAAO,QAAQ,OAAO,KAAK,KAAK,MAAM,IAAI;AAC7C,YAAM,IAAI,MAAM,yBAAyB;AAAA,IAC3C;AACA,QAAI,CAAC,OAAO,WAAW,OAAO,QAAQ,KAAK,MAAM,IAAI;AACnD,YAAM,IAAI,MAAM,WAAW,OAAO,IAAI,oBAAoB;AAAA,IAC5D;AACA,QAAI,CAAC,OAAO,aAAa,OAAO,UAAU,KAAK,MAAM,IAAI;AACvD,YAAM,IAAI,MAAM,WAAW,OAAO,IAAI,wBAAwB;AAAA,IAChE;AACA,QAAI,CAAC,OAAO,YAAY,OAAO,SAAS,KAAK,MAAM,IAAI;AACrD,YAAM,IAAI,MAAM,WAAW,OAAO,IAAI,uBAAuB;AAAA,IAC/D;AACA,QAAI,MAAM,IAAI,OAAO,IAAI,GAAG;AAC1B,YAAM,IAAI,MAAM,2BAA2B,OAAO,IAAI,GAAG;A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AO,SAAS,KAAK,MAAM,IAAI;AACrD,YAAM,IAAI,MAAM,WAAW,OAAO,IAAI,uBAAuB;AAAA,IAC/D;AACA,QAAI,MAAM,IAAI,OAAO,IAAI,GAAG;AAC1B,YAAM,IAAI,MAAM,2BAA2B,OAAO,IAAI,GAAG;AAAA,IAC3D;AACA,UAAM,IAAI,OAAO,IAAI;AAAA,EACvB;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// src/system-prompts/builder.ts
|
|
2
|
+
function createSystemPromptPlugin(options) {
|
|
3
|
+
const { metadata, prompts, initialize } = options;
|
|
4
|
+
if (prompts.length === 0) {
|
|
5
|
+
throw new Error("At least one system prompt is required");
|
|
6
|
+
}
|
|
7
|
+
const names = /* @__PURE__ */ new Set();
|
|
8
|
+
for (const prompt of prompts) {
|
|
9
|
+
if (!prompt.name || prompt.name.trim() === "") {
|
|
10
|
+
throw new Error("Prompt name is required");
|
|
11
|
+
}
|
|
12
|
+
if (!prompt.content || prompt.content.trim() === "") {
|
|
13
|
+
throw new Error(`Prompt "${prompt.name}" requires content`);
|
|
14
|
+
}
|
|
15
|
+
if (!prompt.modelHint || prompt.modelHint.trim() === "") {
|
|
16
|
+
throw new Error(`Prompt "${prompt.name}" requires a modelHint`);
|
|
17
|
+
}
|
|
18
|
+
if (!prompt.category || prompt.category.trim() === "") {
|
|
19
|
+
throw new Error(`Prompt "${prompt.name}" requires a category`);
|
|
20
|
+
}
|
|
21
|
+
if (names.has(prompt.name)) {
|
|
22
|
+
throw new Error(`Duplicate prompt name: "${prompt.name}"`);
|
|
23
|
+
}
|
|
24
|
+
names.add(prompt.name);
|
|
25
|
+
}
|
|
26
|
+
const plugin = {
|
|
27
|
+
metadata,
|
|
28
|
+
prompts
|
|
29
|
+
};
|
|
30
|
+
if (initialize) {
|
|
31
|
+
plugin.initialize = async () => {
|
|
32
|
+
await initialize();
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return plugin;
|
|
36
|
+
}
|
|
37
|
+
function validateSystemPromptPlugin(plugin) {
|
|
38
|
+
if (!plugin.metadata) {
|
|
39
|
+
throw new Error("Plugin metadata is required");
|
|
40
|
+
}
|
|
41
|
+
if (!plugin.metadata.pluginId || plugin.metadata.pluginId.trim() === "") {
|
|
42
|
+
throw new Error("Plugin metadata.pluginId is required");
|
|
43
|
+
}
|
|
44
|
+
if (!/^[a-z0-9-]+$/.test(plugin.metadata.pluginId)) {
|
|
45
|
+
throw new Error("Plugin pluginId must be lowercase alphanumeric with hyphens only");
|
|
46
|
+
}
|
|
47
|
+
if (!plugin.metadata.displayName || plugin.metadata.displayName.trim() === "") {
|
|
48
|
+
throw new Error("Plugin metadata.displayName is required");
|
|
49
|
+
}
|
|
50
|
+
if (!plugin.prompts || !Array.isArray(plugin.prompts) || plugin.prompts.length === 0) {
|
|
51
|
+
throw new Error("Plugin must have at least one prompt");
|
|
52
|
+
}
|
|
53
|
+
const names = /* @__PURE__ */ new Set();
|
|
54
|
+
for (const prompt of plugin.prompts) {
|
|
55
|
+
if (!prompt.name || prompt.name.trim() === "") {
|
|
56
|
+
throw new Error("Prompt name is required");
|
|
57
|
+
}
|
|
58
|
+
if (!prompt.content || prompt.content.trim() === "") {
|
|
59
|
+
throw new Error(`Prompt "${prompt.name}" requires content`);
|
|
60
|
+
}
|
|
61
|
+
if (!prompt.modelHint || prompt.modelHint.trim() === "") {
|
|
62
|
+
throw new Error(`Prompt "${prompt.name}" requires a modelHint`);
|
|
63
|
+
}
|
|
64
|
+
if (!prompt.category || prompt.category.trim() === "") {
|
|
65
|
+
throw new Error(`Prompt "${prompt.name}" requires a category`);
|
|
66
|
+
}
|
|
67
|
+
if (names.has(prompt.name)) {
|
|
68
|
+
throw new Error(`Duplicate prompt name: "${prompt.name}"`);
|
|
69
|
+
}
|
|
70
|
+
names.add(prompt.name);
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
export {
|
|
75
|
+
createSystemPromptPlugin,
|
|
76
|
+
validateSystemPromptPlugin
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/system-prompts/builder.ts"],"sourcesContent":["/**\n * System Prompt Plugin Builder utilities\n *\n * Provides helper functions for creating and validating system prompt plugins.\n *\n * @module @quilltap/plugin-utils/system-prompts\n */\n\nimport type {\n SystemPromptData,\n SystemPromptMetadata,\n SystemPromptPlugin,\n} from '@quilltap/plugin-types';\n\n// ============================================================================\n// BUILDER OPTIONS\n// ============================================================================\n\n/**\n * Options for creating a system prompt plugin\n */\nexport interface CreateSystemPromptPluginOptions {\n /** Plugin metadata */\n metadata: SystemPromptMetadata;\n\n /**\n * One or more system prompts.\n * Each prompt must have a unique name within the plugin.\n */\n prompts: SystemPromptData[];\n\n /**\n * Optional initialization function.\n * Called when the plugin is loaded.\n */\n initialize?: () => void | Promise<void>;\n}\n\n// ============================================================================\n// BUILDER FUNCTIONS\n// ============================================================================\n\n/**\n * Creates a system prompt plugin.\n *\n * @param options - Plugin configuration options\n * @returns A valid SystemPromptPlugin instance\n *\n * @example\n * ```typescript\n * import { createSystemPromptPlugin } from '@quilltap/plugin-utils';\n *\n * export const plugin = createSystemPromptPlugin({\n * metadata: {\n * pluginId: 'my-prompts',\n * displayName: 'My Prompt Collection',\n * description: 'Custom system prompts for various models',\n * },\n * prompts: [\n * {\n * name: 'CLAUDE_CREATIVE',\n * content: '# Creative Writing Prompt\\n\\nYou are {{char}}...',\n * modelHint: 'CLAUDE',\n * category: 'CREATIVE',\n * },\n * ],\n * });\n * ```\n */\nexport function createSystemPromptPlugin(\n options: CreateSystemPromptPluginOptions\n): SystemPromptPlugin {\n const { metadata, prompts, initialize } = options;\n\n // Validate prompts\n if (prompts.length === 0) {\n throw new Error('At least one system prompt is required');\n }\n\n // Check for duplicate names\n const names = new Set<string>();\n for (const prompt of prompts) {\n if (!prompt.name || prompt.name.trim() === '') {\n throw new Error('Prompt name is required');\n }\n if (!prompt.content || prompt.content.trim() === '') {\n throw new Error(`Prompt \"${prompt.name}\" requires content`);\n }\n if (!prompt.modelHint || prompt.modelHint.trim() === '') {\n throw new Error(`Prompt \"${prompt.name}\" requires a modelHint`);\n }\n if (!prompt.category || prompt.category.trim() === '') {\n throw new Error(`Prompt \"${prompt.name}\" requires a category`);\n }\n if (names.has(prompt.name)) {\n throw new Error(`Duplicate prompt name: \"${prompt.name}\"`);\n }\n names.add(prompt.name);\n }\n\n // Create the plugin\n const plugin: SystemPromptPlugin = {\n metadata,\n prompts,\n };\n\n // Add initialize function if provided\n if (initialize) {\n plugin.initialize = async () => {\n await initialize();\n };\n }\n\n return plugin;\n}\n\n// ============================================================================\n// VALIDATION UTILITIES\n// ============================================================================\n\n/**\n * Validates a complete system prompt plugin\n *\n * @param plugin - The plugin to validate\n * @returns True if valid, throws Error if invalid\n */\nexport function validateSystemPromptPlugin(plugin: SystemPromptPlugin): boolean {\n // Validate metadata\n if (!plugin.metadata) {\n throw new Error('Plugin metadata is required');\n }\n\n if (!plugin.metadata.pluginId || plugin.metadata.pluginId.trim() === '') {\n throw new Error('Plugin metadata.pluginId is required');\n }\n\n if (!/^[a-z0-9-]+$/.test(plugin.metadata.pluginId)) {\n throw new Error('Plugin pluginId must be lowercase alphanumeric with hyphens only');\n }\n\n if (!plugin.metadata.displayName || plugin.metadata.displayName.trim() === '') {\n throw new Error('Plugin metadata.displayName is required');\n }\n\n // Validate prompts\n if (!plugin.prompts || !Array.isArray(plugin.prompts) || plugin.prompts.length === 0) {\n throw new Error('Plugin must have at least one prompt');\n }\n\n const names = new Set<string>();\n for (const prompt of plugin.prompts) {\n if (!prompt.name || prompt.name.trim() === '') {\n throw new Error('Prompt name is required');\n }\n if (!prompt.content || prompt.content.trim() === '') {\n throw new Error(`Prompt \"${prompt.name}\" requires content`);\n }\n if (!prompt.modelHint || prompt.modelHint.trim() === '') {\n throw new Error(`Prompt \"${prompt.name}\" requires a modelHint`);\n }\n if (!prompt.category || prompt.category.trim() === '') {\n throw new Error(`Prompt \"${prompt.name}\" requires a category`);\n }\n if (names.has(prompt.name)) {\n throw new Error(`Duplicate prompt name: \"${prompt.name}\"`);\n }\n names.add(prompt.name);\n }\n\n return true;\n}\n"],"mappings":";AAqEO,SAAS,yBACd,SACoB;AACpB,QAAM,EAAE,UAAU,SAAS,WAAW,IAAI;AAG1C,MAAI,QAAQ,WAAW,GAAG;AACxB,UAAM,IAAI,MAAM,wCAAwC;AAAA,EAC1D;AAGA,QAAM,QAAQ,oBAAI,IAAY;AAC9B,aAAW,UAAU,SAAS;AAC5B,QAAI,CAAC,OAAO,QAAQ,OAAO,KAAK,KAAK,MAAM,IAAI;AAC7C,YAAM,IAAI,MAAM,yBAAyB;AAAA,IAC3C;AACA,QAAI,CAAC,OAAO,WAAW,OAAO,QAAQ,KAAK,MAAM,IAAI;AACnD,YAAM,IAAI,MAAM,WAAW,OAAO,IAAI,oBAAoB;AAAA,IAC5D;AACA,QAAI,CAAC,OAAO,aAAa,OAAO,UAAU,KAAK,MAAM,IAAI;AACvD,YAAM,IAAI,MAAM,WAAW,OAAO,IAAI,wBAAwB;AAAA,IAChE;AACA,QAAI,CAAC,OAAO,YAAY,OAAO,SAAS,KAAK,MAAM,IAAI;AACrD,YAAM,IAAI,MAAM,WAAW,OAAO,IAAI,uBAAuB;AAAA,IAC/D;AACA,QAAI,MAAM,IAAI,OAAO,IAAI,GAAG;AAC1B,YAAM,IAAI,MAAM,2BAA2B,OAAO,IAAI,GAAG;AAAA,IAC3D;AACA,UAAM,IAAI,OAAO,IAAI;AAAA,EACvB;AAGA,QAAM,SAA6B;AAAA,IACjC;AAAA,IACA;AAAA,EACF;AAGA,MAAI,YAAY;AACd,WAAO,aAAa,YAAY;AAC9B,YAAM,WAAW;AAAA,IACnB;AAAA,EACF;AAEA,SAAO;AACT;AAYO,SAAS,2BAA2B,QAAqC;AAE9E,MAAI,CAAC,OAAO,UAAU;AACpB,UAAM,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GED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quilltap/plugin-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "Utility functions for Quilltap plugin development",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -31,6 +31,11 @@
|
|
|
31
31
|
"import": "./dist/roleplay-templates/index.mjs",
|
|
32
32
|
"require": "./dist/roleplay-templates/index.js"
|
|
33
33
|
},
|
|
34
|
+
"./system-prompts": {
|
|
35
|
+
"types": "./dist/system-prompts/index.d.ts",
|
|
36
|
+
"import": "./dist/system-prompts/index.mjs",
|
|
37
|
+
"require": "./dist/system-prompts/index.js"
|
|
38
|
+
},
|
|
34
39
|
"./host-rewrite": {
|
|
35
40
|
"types": "./dist/host-rewrite.d.ts",
|
|
36
41
|
"import": "./dist/host-rewrite.mjs",
|
|
@@ -49,7 +54,7 @@
|
|
|
49
54
|
"typecheck": "tsc --noEmit"
|
|
50
55
|
},
|
|
51
56
|
"dependencies": {
|
|
52
|
-
"@quilltap/plugin-types": "^1.
|
|
57
|
+
"@quilltap/plugin-types": "^1.18.0"
|
|
53
58
|
},
|
|
54
59
|
"peerDependencies": {
|
|
55
60
|
"openai": "^4.0.0 || ^5.0.0 || ^6.0.0"
|
|
@@ -63,7 +68,7 @@
|
|
|
63
68
|
}
|
|
64
69
|
},
|
|
65
70
|
"devDependencies": {
|
|
66
|
-
"openai": "^6.
|
|
71
|
+
"openai": "^6.33.0",
|
|
67
72
|
"tsup": "^8.5.1",
|
|
68
73
|
"typescript": "^5.9.3"
|
|
69
74
|
},
|