openpets 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data/api.json +3172 -0
- package/dist/src/core/ai-client-base/index.d.ts +47 -0
- package/dist/src/core/ai-client-base/index.d.ts.map +1 -0
- package/dist/src/core/ai-client-base/index.js +168 -0
- package/dist/src/core/ai-client-base/index.js.map +1 -0
- package/dist/src/core/browser.d.ts +10 -0
- package/dist/src/core/browser.d.ts.map +1 -0
- package/{browser.ts → dist/src/core/browser.js} +4 -4
- package/dist/src/core/browser.js.map +1 -0
- package/dist/src/core/build-pet.d.ts +2 -0
- package/dist/src/core/build-pet.d.ts.map +1 -0
- package/dist/src/core/build-pet.js +364 -0
- package/dist/src/core/build-pet.js.map +1 -0
- package/dist/src/core/cli.d.ts +3 -0
- package/dist/src/core/cli.d.ts.map +1 -0
- package/dist/src/core/cli.js +244 -0
- package/dist/src/core/cli.js.map +1 -0
- package/dist/src/core/config-manager.d.ts +13 -0
- package/dist/src/core/config-manager.d.ts.map +1 -0
- package/dist/src/core/config-manager.js +59 -0
- package/dist/src/core/config-manager.js.map +1 -0
- package/dist/src/core/deploy-pet.d.ts +2 -0
- package/dist/src/core/deploy-pet.d.ts.map +1 -0
- package/dist/src/core/deploy-pet.js +66 -0
- package/dist/src/core/deploy-pet.js.map +1 -0
- package/dist/src/core/index.d.ts +11 -0
- package/dist/src/core/index.d.ts.map +1 -0
- package/dist/src/core/index.js +11 -0
- package/dist/src/core/index.js.map +1 -0
- package/dist/src/core/local-cache.d.ts +69 -0
- package/dist/src/core/local-cache.d.ts.map +1 -0
- package/dist/src/core/local-cache.js +212 -0
- package/dist/src/core/local-cache.js.map +1 -0
- package/dist/src/core/logger.d.ts.map +1 -0
- package/{logger.js → dist/src/core/logger.js} +8 -9
- package/dist/src/core/logger.js.map +1 -0
- package/dist/src/core/mcp-factory.d.ts +12 -0
- package/dist/src/core/mcp-factory.d.ts.map +1 -0
- package/dist/src/core/mcp-factory.js +143 -0
- package/dist/src/core/mcp-factory.js.map +1 -0
- package/dist/src/core/mcp-server.d.ts +3 -0
- package/dist/src/core/mcp-server.d.ts.map +1 -0
- package/dist/src/core/mcp-server.js +55 -0
- package/dist/src/core/mcp-server.js.map +1 -0
- package/dist/src/core/migrate-plugin.d.ts +15 -0
- package/dist/src/core/migrate-plugin.d.ts.map +1 -0
- package/dist/src/core/migrate-plugin.js +181 -0
- package/dist/src/core/migrate-plugin.js.map +1 -0
- package/dist/src/core/pets-registry.d.ts +47 -0
- package/dist/src/core/pets-registry.d.ts.map +1 -0
- package/dist/src/core/pets-registry.js +109 -0
- package/dist/src/core/pets-registry.js.map +1 -0
- package/dist/src/core/plugin-factory.d.ts +58 -0
- package/dist/src/core/plugin-factory.d.ts.map +1 -0
- package/dist/src/core/plugin-factory.js +212 -0
- package/dist/src/core/plugin-factory.js.map +1 -0
- package/dist/src/core/prompt-utils.d.ts +14 -0
- package/dist/src/core/prompt-utils.d.ts.map +1 -0
- package/dist/src/core/prompt-utils.js +106 -0
- package/dist/src/core/prompt-utils.js.map +1 -0
- package/dist/src/core/schema-helpers.d.ts +33 -0
- package/dist/src/core/schema-helpers.d.ts.map +1 -0
- package/dist/src/core/schema-helpers.js +46 -0
- package/dist/src/core/schema-helpers.js.map +1 -0
- package/dist/src/core/search-pets.d.ts +29 -0
- package/dist/src/core/search-pets.d.ts.map +1 -0
- package/dist/src/core/search-pets.js +196 -0
- package/dist/src/core/search-pets.js.map +1 -0
- package/dist/src/core/types.d.ts +63 -0
- package/dist/src/core/types.d.ts.map +1 -0
- package/dist/src/core/types.js +2 -0
- package/dist/src/core/types.js.map +1 -0
- package/dist/src/core/validate-pet.d.ts +40 -0
- package/dist/src/core/validate-pet.d.ts.map +1 -0
- package/dist/src/core/validate-pet.js +650 -0
- package/dist/src/core/validate-pet.js.map +1 -0
- package/package.json +7 -11
- package/ai-client-base/index.ts +0 -117
- package/build-pet.ts +0 -429
- package/cli.ts +0 -179
- package/config-manager.ts +0 -82
- package/deploy-pet.ts +0 -91
- package/index.ts +0 -10
- package/local-cache.ts +0 -280
- package/logger.ts +0 -143
- package/mcp-factory.ts +0 -180
- package/mcp-server.ts +0 -69
- package/migrate-plugin.ts +0 -220
- package/pets-registry.ts +0 -160
- package/plugin-factory.ts +0 -309
- package/prompt-utils.ts +0 -130
- package/schema-helpers.ts +0 -59
- package/search-pets.ts +0 -267
- package/types.ts +0 -68
- package/validate-pet.ts +0 -594
- /package/{logger.d.ts → dist/src/core/logger.d.ts} +0 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync, existsSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
export class PluginMigrator {
|
|
4
|
+
migratePlugin(pluginPath) {
|
|
5
|
+
const indexPath = join(pluginPath, 'index.ts');
|
|
6
|
+
const changes = [];
|
|
7
|
+
const errors = [];
|
|
8
|
+
if (!existsSync(indexPath)) {
|
|
9
|
+
return {
|
|
10
|
+
success: false,
|
|
11
|
+
changes,
|
|
12
|
+
errors: ['index.ts not found']
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
let code = readFileSync(indexPath, 'utf-8');
|
|
17
|
+
const original = code;
|
|
18
|
+
code = this.addImports(code, changes);
|
|
19
|
+
code = this.convertInputSchemaToToolBuilder(code, changes);
|
|
20
|
+
if (code !== original) {
|
|
21
|
+
writeFileSync(indexPath, code, 'utf-8');
|
|
22
|
+
return { success: true, changes, errors };
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return { success: true, changes: ['No changes needed'], errors };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
errors.push(`Migration failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
30
|
+
return { success: false, changes, errors };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
addImports(code, changes) {
|
|
34
|
+
const hasToolImport = /import\s+{\s*tool\s*}\s+from\s+['"]@opencode-ai\/plugin['"]/.test(code);
|
|
35
|
+
const hasZodImport = /import.*from\s+['"]zod['"]/.test(code);
|
|
36
|
+
const hasPluginImport = /import.*from\s+['"]@opencode-ai\/plugin['"]/.test(code);
|
|
37
|
+
if (!hasPluginImport) {
|
|
38
|
+
code = `import type { Plugin } from "@opencode-ai/plugin"\n${code}`;
|
|
39
|
+
changes.push('Added Plugin type import');
|
|
40
|
+
}
|
|
41
|
+
if (!hasToolImport) {
|
|
42
|
+
if (hasPluginImport) {
|
|
43
|
+
code = code.replace(/import\s+(type\s+)?\{([^}]+)\}\s+from\s+['"]@opencode-ai\/plugin['"]/, (match, typeKeyword, imports) => {
|
|
44
|
+
if (typeKeyword) {
|
|
45
|
+
return match.replace('}', ', tool }').replace('type ', '');
|
|
46
|
+
}
|
|
47
|
+
const cleanImports = imports.split(',').map((s) => s.trim()).filter(Boolean);
|
|
48
|
+
if (!cleanImports.includes('tool')) {
|
|
49
|
+
cleanImports.push('tool');
|
|
50
|
+
}
|
|
51
|
+
return `import { ${cleanImports.join(', ')} } from "@opencode-ai/plugin"`;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
code = `import { tool } from "@opencode-ai/plugin"\n${code}`;
|
|
56
|
+
}
|
|
57
|
+
changes.push('Added tool import from @opencode-ai/plugin');
|
|
58
|
+
}
|
|
59
|
+
if (!hasZodImport) {
|
|
60
|
+
const pluginImportIndex = code.indexOf('import');
|
|
61
|
+
const firstNewline = code.indexOf('\n', pluginImportIndex);
|
|
62
|
+
code = code.slice(0, firstNewline + 1) + `import { z } from "zod"\n` + code.slice(firstNewline + 1);
|
|
63
|
+
changes.push('Added Zod import');
|
|
64
|
+
}
|
|
65
|
+
return code;
|
|
66
|
+
}
|
|
67
|
+
convertInputSchemaToToolBuilder(code, changes) {
|
|
68
|
+
const toolPattern = /"([^"]+)":\s*{\s*description:\s*"([^"]+)",\s*inputSchema:\s*(\{[\s\S]*?\}),\s*async\s+execute\s*\(([^)]*)\)\s*(\{[\s\S]*?\n\s*\})\s*\}/g;
|
|
69
|
+
let matchCount = 0;
|
|
70
|
+
code = code.replace(toolPattern, (match, toolName, description, inputSchemaStr, argsParam, executeBody) => {
|
|
71
|
+
matchCount++;
|
|
72
|
+
try {
|
|
73
|
+
const inputSchema = this.parseInputSchema(inputSchemaStr);
|
|
74
|
+
const zodArgs = this.convertToZodSchema(inputSchema);
|
|
75
|
+
const converted = `"${toolName}": tool({
|
|
76
|
+
description: "${description}",
|
|
77
|
+
args: ${zodArgs},
|
|
78
|
+
async execute(${argsParam}) ${executeBody}
|
|
79
|
+
})`;
|
|
80
|
+
return converted;
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
console.warn(`Failed to convert tool "${toolName}": ${error}`);
|
|
84
|
+
return match;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
if (matchCount > 0) {
|
|
88
|
+
changes.push(`Converted ${matchCount} tool(s) from inputSchema to tool() builder`);
|
|
89
|
+
}
|
|
90
|
+
return code;
|
|
91
|
+
}
|
|
92
|
+
parseInputSchema(schemaStr) {
|
|
93
|
+
const cleaned = schemaStr
|
|
94
|
+
.replace(/\/\/.*$/gm, '')
|
|
95
|
+
.replace(/\/\*[\s\S]*?\*\//g, '')
|
|
96
|
+
.trim();
|
|
97
|
+
try {
|
|
98
|
+
const jsonStr = cleaned
|
|
99
|
+
.replace(/(\w+):/g, '"$1":')
|
|
100
|
+
.replace(/'/g, '"');
|
|
101
|
+
return JSON.parse(jsonStr);
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
return eval(`(${cleaned})`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
convertToZodSchema(inputSchema) {
|
|
108
|
+
if (!inputSchema.properties) {
|
|
109
|
+
return '{}';
|
|
110
|
+
}
|
|
111
|
+
const required = new Set(inputSchema.required || []);
|
|
112
|
+
const properties = inputSchema.properties;
|
|
113
|
+
const zodFields = [];
|
|
114
|
+
for (const [key, propDef] of Object.entries(properties)) {
|
|
115
|
+
const isRequired = required.has(key);
|
|
116
|
+
let zodType = this.getZodType(propDef, isRequired);
|
|
117
|
+
const description = propDef.description;
|
|
118
|
+
if (description) {
|
|
119
|
+
zodType += `.describe("${description.replace(/"/g, '\\"')}")`;
|
|
120
|
+
}
|
|
121
|
+
zodFields.push(`${key}: ${zodType}`);
|
|
122
|
+
}
|
|
123
|
+
return `{\n ${zodFields.join(',\n ')}\n }`;
|
|
124
|
+
}
|
|
125
|
+
getZodType(propDef, isRequired) {
|
|
126
|
+
let zodType;
|
|
127
|
+
switch (propDef.type) {
|
|
128
|
+
case 'string':
|
|
129
|
+
if (propDef.enum && Array.isArray(propDef.enum)) {
|
|
130
|
+
zodType = `z.enum([${propDef.enum.map((v) => `"${v}"`).join(', ')}])`;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
zodType = 'z.string()';
|
|
134
|
+
}
|
|
135
|
+
break;
|
|
136
|
+
case 'number':
|
|
137
|
+
zodType = 'z.number()';
|
|
138
|
+
break;
|
|
139
|
+
case 'boolean':
|
|
140
|
+
zodType = 'z.boolean()';
|
|
141
|
+
break;
|
|
142
|
+
case 'array':
|
|
143
|
+
if (propDef.items) {
|
|
144
|
+
const itemType = this.getZodType(propDef.items, true);
|
|
145
|
+
zodType = `z.array(${itemType})`;
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
zodType = 'z.array(z.any())';
|
|
149
|
+
}
|
|
150
|
+
break;
|
|
151
|
+
case 'object':
|
|
152
|
+
if (propDef.additionalProperties) {
|
|
153
|
+
const valueType = this.getZodType(propDef.additionalProperties, true);
|
|
154
|
+
zodType = `z.record(${valueType})`;
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
zodType = 'z.object({})';
|
|
158
|
+
}
|
|
159
|
+
break;
|
|
160
|
+
default:
|
|
161
|
+
zodType = 'z.any()';
|
|
162
|
+
}
|
|
163
|
+
if (!isRequired) {
|
|
164
|
+
zodType += '.optional()';
|
|
165
|
+
}
|
|
166
|
+
return zodType;
|
|
167
|
+
}
|
|
168
|
+
printMigrationResult(pluginName, result) {
|
|
169
|
+
const status = result.success ? '✅' : '❌';
|
|
170
|
+
console.log(`\n${status} ${pluginName}`);
|
|
171
|
+
if (result.changes.length > 0) {
|
|
172
|
+
console.log(' Changes:');
|
|
173
|
+
result.changes.forEach(change => console.log(` • ${change}`));
|
|
174
|
+
}
|
|
175
|
+
if (result.errors.length > 0) {
|
|
176
|
+
console.log(' Errors:');
|
|
177
|
+
result.errors.forEach(error => console.log(` ❌ ${error}`));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=migrate-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-plugin.js","sourceRoot":"","sources":["../../../migrate-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAQ3B,MAAM,OAAO,cAAc;IACzB,aAAa,CAAC,UAAkB;QAC9B,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAA;QAC9C,MAAM,OAAO,GAAa,EAAE,CAAA;QAC5B,MAAM,MAAM,GAAa,EAAE,CAAA;QAE3B,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3B,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,OAAO;gBACP,MAAM,EAAE,CAAC,oBAAoB,CAAC;aAC/B,CAAA;QACH,CAAC;QAED,IAAI,CAAC;YACH,IAAI,IAAI,GAAG,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;YAC3C,MAAM,QAAQ,GAAG,IAAI,CAAA;YAErB,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,I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EAAE,CAAC,CAAA;QAExC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9B,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;YACzB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC,CAAA;QAClE,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;YACxB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,KAAK,EAAE,CAAC,CAAC,CAAA;QAC/D,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export interface PetMetadata {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
version: string;
|
|
6
|
+
keywords: string[];
|
|
7
|
+
author?: string;
|
|
8
|
+
repository?: {
|
|
9
|
+
type: string;
|
|
10
|
+
url: string;
|
|
11
|
+
directory?: string;
|
|
12
|
+
};
|
|
13
|
+
queries?: string[];
|
|
14
|
+
scenarios?: Record<string, string[]>;
|
|
15
|
+
envVariables?: {
|
|
16
|
+
required?: Array<{
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
provider?: string;
|
|
20
|
+
}>;
|
|
21
|
+
optional?: Array<{
|
|
22
|
+
name: string;
|
|
23
|
+
description: string;
|
|
24
|
+
provider?: string;
|
|
25
|
+
}>;
|
|
26
|
+
};
|
|
27
|
+
utils?: {
|
|
28
|
+
dependencies?: string[];
|
|
29
|
+
paths?: string[];
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export declare class PetsRegistry {
|
|
33
|
+
private pets;
|
|
34
|
+
private petsDir;
|
|
35
|
+
constructor(petsDir?: string);
|
|
36
|
+
private loadPets;
|
|
37
|
+
getAllPets(): PetMetadata[];
|
|
38
|
+
getPet(id: string): PetMetadata | undefined;
|
|
39
|
+
searchPets(query: string): PetMetadata[];
|
|
40
|
+
getPetsByCategory(keywords: string[]): PetMetadata[];
|
|
41
|
+
reload(): void;
|
|
42
|
+
}
|
|
43
|
+
export declare function getPetsRegistry(petsDir?: string): PetsRegistry;
|
|
44
|
+
export declare function searchPetsInRegistry(query: string, petsDir?: string): PetMetadata[];
|
|
45
|
+
export declare function getAllPetsFromRegistry(petsDir?: string): PetMetadata[];
|
|
46
|
+
export declare function getPetFromRegistry(id: string, petsDir?: string): PetMetadata | undefined;
|
|
47
|
+
//# sourceMappingURL=pets-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pets-registry.d.ts","sourceRoot":"","sources":["../../../pets-registry.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE;QACX,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,EAAE,MAAM,CAAA;QACX,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,CAAA;IACD,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;IACpC,YAAY,CAAC,EAAE;QACb,QAAQ,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;QAC1E,QAAQ,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAC3E,CAAA;IACD,KAAK,CAAC,EAAE;QACN,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;QACvB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;KACjB,CAAA;CACF;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,IAAI,CAAsC;IAClD,OAAO,CAAC,OAAO,CAAQ;gBAEX,OAAO,CAAC,EAAE,MAAM;IAK5B,OAAO,CAAC,QAAQ;IAmDhB,UAAU,IAAI,WAAW,EAAE;IAI3B,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAI3C,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,EAAE;IAyBxC,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE;IAQpD,MAAM,IAAI,IAAI;CAIf;AAID,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,YAAY,CAK9D;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,EAAE,CAGnF;AAED,wBAAgB,sBAAsB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,EAAE,CAGtE;AAED,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAGxF"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { readdirSync, existsSync, readFileSync } from "fs";
|
|
2
|
+
import { join, resolve } from "path";
|
|
3
|
+
import { createLogger } from "./logger";
|
|
4
|
+
const logger = createLogger("pets-registry");
|
|
5
|
+
export class PetsRegistry {
|
|
6
|
+
pets = new Map();
|
|
7
|
+
petsDir;
|
|
8
|
+
constructor(petsDir) {
|
|
9
|
+
this.petsDir = petsDir || resolve(__dirname, "../../pets");
|
|
10
|
+
this.loadPets();
|
|
11
|
+
}
|
|
12
|
+
loadPets() {
|
|
13
|
+
try {
|
|
14
|
+
if (!existsSync(this.petsDir)) {
|
|
15
|
+
logger.warn(`Pets directory not found: ${this.petsDir}`);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const entries = readdirSync(this.petsDir, { withFileTypes: true });
|
|
19
|
+
for (const entry of entries) {
|
|
20
|
+
if (!entry.isDirectory() || entry.name.startsWith('.') || entry.name === 'node_modules') {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const petDir = join(this.petsDir, entry.name);
|
|
24
|
+
const packageJsonPath = join(petDir, 'package.json');
|
|
25
|
+
if (!existsSync(packageJsonPath)) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
|
30
|
+
const metadata = {
|
|
31
|
+
id: entry.name,
|
|
32
|
+
name: packageJson.name || entry.name,
|
|
33
|
+
description: packageJson.description || '',
|
|
34
|
+
version: packageJson.version || '1.0.0',
|
|
35
|
+
keywords: packageJson.keywords || [],
|
|
36
|
+
author: packageJson.author,
|
|
37
|
+
repository: packageJson.repository,
|
|
38
|
+
queries: packageJson.queries,
|
|
39
|
+
scenarios: packageJson.scenarios,
|
|
40
|
+
envVariables: packageJson.envVariables,
|
|
41
|
+
utils: packageJson.utils
|
|
42
|
+
};
|
|
43
|
+
this.pets.set(entry.name, metadata);
|
|
44
|
+
logger.debug(`Loaded pet: ${entry.name}`);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
logger.error(`Failed to load pet ${entry.name}: ${error.message}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
logger.info(`Loaded ${this.pets.size} pets`);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
logger.error(`Failed to load pets: ${error.message}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
getAllPets() {
|
|
57
|
+
return Array.from(this.pets.values());
|
|
58
|
+
}
|
|
59
|
+
getPet(id) {
|
|
60
|
+
return this.pets.get(id);
|
|
61
|
+
}
|
|
62
|
+
searchPets(query) {
|
|
63
|
+
if (!query || query.trim() === '') {
|
|
64
|
+
return this.getAllPets();
|
|
65
|
+
}
|
|
66
|
+
const normalizedQuery = query.toLowerCase().trim();
|
|
67
|
+
const results = [];
|
|
68
|
+
for (const pet of this.pets.values()) {
|
|
69
|
+
const searchableText = [
|
|
70
|
+
pet.id,
|
|
71
|
+
pet.name,
|
|
72
|
+
pet.description,
|
|
73
|
+
...(pet.keywords || []),
|
|
74
|
+
pet.author || '',
|
|
75
|
+
].join(' ').toLowerCase();
|
|
76
|
+
if (searchableText.includes(normalizedQuery)) {
|
|
77
|
+
results.push(pet);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return results;
|
|
81
|
+
}
|
|
82
|
+
getPetsByCategory(keywords) {
|
|
83
|
+
return this.getAllPets().filter(pet => keywords.some(keyword => pet.keywords?.some(k => k.toLowerCase().includes(keyword.toLowerCase()))));
|
|
84
|
+
}
|
|
85
|
+
reload() {
|
|
86
|
+
this.pets.clear();
|
|
87
|
+
this.loadPets();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
let defaultRegistry = null;
|
|
91
|
+
export function getPetsRegistry(petsDir) {
|
|
92
|
+
if (!defaultRegistry) {
|
|
93
|
+
defaultRegistry = new PetsRegistry(petsDir);
|
|
94
|
+
}
|
|
95
|
+
return defaultRegistry;
|
|
96
|
+
}
|
|
97
|
+
export function searchPetsInRegistry(query, petsDir) {
|
|
98
|
+
const registry = getPetsRegistry(petsDir);
|
|
99
|
+
return registry.searchPets(query);
|
|
100
|
+
}
|
|
101
|
+
export function getAllPetsFromRegistry(petsDir) {
|
|
102
|
+
const registry = getPetsRegistry(petsDir);
|
|
103
|
+
return registry.getAllPets();
|
|
104
|
+
}
|
|
105
|
+
export function getPetFromRegistry(id, petsDir) {
|
|
106
|
+
const registry = getPetsRegistry(petsDir);
|
|
107
|
+
return registry.getPet(id);
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=pets-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pets-registry.js","sourceRoot":"","sources":["../../../pets-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAA;AAC1D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAEvC,MAAM,MAAM,GAAG,YAAY,CAAC,eAAe,CAAC,CAAA;AA0B5C,MAAM,OAAO,YAAY;IACf,IAAI,GAA6B,IAAI,GAAG,EAAE,CAAA;IAC1C,OAAO,CAAQ;IAEvB,YAAY,OAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,OAAO,CAAC,SAAS,EAAE,YAAY,CAAC,CAAA;QAC1D,IAAI,CAAC,QAAQ,EAAE,CAAA;IACjB,CAAC;IAEO,QAAQ;QACd,IAAI,CAAC;YACH,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC9B,MAAM,CAAC,IAAI,CAAC,6BAA6B,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;gBACxD,OAAM;YACR,CAAC;YAED,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;YAElE,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;gBAC5B,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC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ugin";
|
|
2
|
+
import type * as z from "zod";
|
|
3
|
+
import * as zodRuntime from "zod";
|
|
4
|
+
export { tool };
|
|
5
|
+
export { zodRuntime as z };
|
|
6
|
+
export interface ToolDefinition<T extends Record<string, any> = any> {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
schema: z.ZodType<any, any, any>;
|
|
10
|
+
execute: (args: T, context?: any) => Promise<string>;
|
|
11
|
+
}
|
|
12
|
+
export interface ProviderSpec {
|
|
13
|
+
name: string;
|
|
14
|
+
displayName: string;
|
|
15
|
+
envVars: {
|
|
16
|
+
required: Array<{
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
example?: string;
|
|
20
|
+
}>;
|
|
21
|
+
};
|
|
22
|
+
capabilities: string[];
|
|
23
|
+
comingSoon?: string[];
|
|
24
|
+
credentialsUrl?: string;
|
|
25
|
+
credentialsDocUrl?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ProviderValidationResult {
|
|
28
|
+
provider: string;
|
|
29
|
+
configured: boolean;
|
|
30
|
+
missingVars: string[];
|
|
31
|
+
spec?: ProviderSpec;
|
|
32
|
+
}
|
|
33
|
+
export interface ProviderValidationReport {
|
|
34
|
+
hasRequiredProvider: boolean;
|
|
35
|
+
requiredResults: ProviderValidationResult[];
|
|
36
|
+
optionalResults: ProviderValidationResult[];
|
|
37
|
+
errors: string[];
|
|
38
|
+
}
|
|
39
|
+
export type ToolRecord = Record<string, {
|
|
40
|
+
description: string;
|
|
41
|
+
args: z.ZodObject<any>;
|
|
42
|
+
execute: (args: any, context?: any) => Promise<string>;
|
|
43
|
+
}>;
|
|
44
|
+
export declare function createPlugin(tools: ToolDefinition[]): {
|
|
45
|
+
tool: ToolRecord;
|
|
46
|
+
};
|
|
47
|
+
export declare function createSingleTool<T extends Record<string, any>>(definition: Omit<ToolDefinition<T>, 'name'>): {
|
|
48
|
+
description: string;
|
|
49
|
+
args: z.ZodObject<any>;
|
|
50
|
+
execute: (args: T, context?: any) => Promise<string>;
|
|
51
|
+
};
|
|
52
|
+
export declare function validateProviders(packageJson: any, pluginDir: string): ProviderValidationReport;
|
|
53
|
+
export interface EnvConfig {
|
|
54
|
+
[key: string]: string;
|
|
55
|
+
}
|
|
56
|
+
export declare function loadEnv(petId?: string): EnvConfig;
|
|
57
|
+
export declare function getEnv(key: string, petId?: string): string | undefined;
|
|
58
|
+
//# sourceMappingURL=plugin-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-factory.d.ts","sourceRoot":"","sources":["../../../plugin-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAK1C,OAAO,KAAK,KAAK,CAAC,MAAM,KAAK,CAAA;AAC7B,OAAO,KAAK,UAAU,MAAM,KAAK,CAAA;AAqCjC,OAAO,EAAE,IAAI,EAAE,CAAA;AACf,OAAO,EAAE,UAAU,IAAI,CAAC,EAAE,CAAA;AAI1B,MAAM,WAAW,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG;IACjE,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;IAChC,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;CACrD;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE;QACP,QAAQ,EAAE,KAAK,CAAC;YACd,IAAI,EAAE,MAAM,CAAA;YACZ,WAAW,EAAE,MAAM,CAAA;YACnB,OAAO,CAAC,EAAE,MAAM,CAAA;SACjB,CAAC,CAAA;KACH,CAAA;IACD,YAAY,EA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wBAAgB,iBAAiB,CAAC,WAAW,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,GAAG,wBAAwB,CAkD/F;AAED,MAAM,WAAW,SAAS;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CACtB;AAED,wBAAgB,OAAO,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CA8CjD;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGtE"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { tool } from "@opencode-ai/plugin";
|
|
2
|
+
import { readFileSync, existsSync } from "fs";
|
|
3
|
+
import { resolve } from "path";
|
|
4
|
+
import { createLogger } from "./logger";
|
|
5
|
+
import { config } from "dotenv";
|
|
6
|
+
import * as zodRuntime from "zod";
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// CRITICAL: SCHEMA FORMAT REQUIREMENTS
|
|
9
|
+
// ============================================================================
|
|
10
|
+
//
|
|
11
|
+
// 1. ALWAYS use tool.schema for the Zod instance (not direct "zod" import)
|
|
12
|
+
// This ensures the same Zod version as OpenCode
|
|
13
|
+
//
|
|
14
|
+
// 2. SIMPLE TYPES ONLY - Do NOT use nested schemas
|
|
15
|
+
// ✅ ALLOWED:
|
|
16
|
+
// - z.string()
|
|
17
|
+
// - z.number()
|
|
18
|
+
// - z.boolean()
|
|
19
|
+
// - z.array(z.string())
|
|
20
|
+
// - z.array(z.number())
|
|
21
|
+
// - z.object({ field: z.string() })
|
|
22
|
+
//
|
|
23
|
+
// ❌ NOT ALLOWED (will cause runtime errors):
|
|
24
|
+
// - z.array(z.object({...})) // Nested object in array
|
|
25
|
+
// - z.object({ nested: z.object({...}) }) // Nested object in object
|
|
26
|
+
// - z.record(z.string()) // Record with any nested type
|
|
27
|
+
// - z.union([z.object({...}), ...]) // Union with nested types
|
|
28
|
+
//
|
|
29
|
+
// 3. WORKAROUND for complex data structures:
|
|
30
|
+
// Use z.string() with JSON serialization
|
|
31
|
+
// Example:
|
|
32
|
+
// schema: z.object({
|
|
33
|
+
// dataJson: z.string().describe("JSON string of data array")
|
|
34
|
+
// }),
|
|
35
|
+
// execute(args) {
|
|
36
|
+
// const data = JSON.parse(args.dataJson)
|
|
37
|
+
// // ... process data
|
|
38
|
+
// }
|
|
39
|
+
//
|
|
40
|
+
// ============================================================================
|
|
41
|
+
export { tool };
|
|
42
|
+
export { zodRuntime as z };
|
|
43
|
+
const logger = createLogger("plugin-factory");
|
|
44
|
+
export function createPlugin(tools) {
|
|
45
|
+
const toolRecord = {};
|
|
46
|
+
for (const toolDef of tools) {
|
|
47
|
+
const schema = toolDef.schema;
|
|
48
|
+
toolRecord[toolDef.name] = tool({
|
|
49
|
+
description: toolDef.description,
|
|
50
|
+
args: schema.shape || schema,
|
|
51
|
+
execute: toolDef.execute
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return { tool: toolRecord };
|
|
55
|
+
}
|
|
56
|
+
export function createSingleTool(definition) {
|
|
57
|
+
const schema = definition.schema;
|
|
58
|
+
return tool({
|
|
59
|
+
description: definition.description,
|
|
60
|
+
args: schema.shape || schema,
|
|
61
|
+
execute: definition.execute
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
function loadProviderSpec(providerPath, pluginDir) {
|
|
65
|
+
try {
|
|
66
|
+
let packagePath;
|
|
67
|
+
if (providerPath.startsWith('openpets/')) {
|
|
68
|
+
const petName = providerPath.replace('openpets/', '');
|
|
69
|
+
packagePath = resolve(pluginDir, `../${petName}/package.json`);
|
|
70
|
+
}
|
|
71
|
+
else if (providerPath.startsWith('@/utils/')) {
|
|
72
|
+
const normalizedPath = providerPath.replace('@/utils/', '');
|
|
73
|
+
packagePath = resolve(pluginDir, `../../src/utils/${normalizedPath}/package.json`);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
logger.debug(`Unknown provider path format: ${providerPath}`);
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
const packageJson = JSON.parse(readFileSync(packagePath, 'utf-8'));
|
|
80
|
+
if (packageJson.provider) {
|
|
81
|
+
return packageJson.provider;
|
|
82
|
+
}
|
|
83
|
+
if (packageJson.envVariables?.required) {
|
|
84
|
+
return {
|
|
85
|
+
name: packageJson.name || providerPath,
|
|
86
|
+
displayName: packageJson.description?.split('-')[0]?.trim() || providerPath,
|
|
87
|
+
envVars: {
|
|
88
|
+
required: packageJson.envVariables.required.map((env) => ({
|
|
89
|
+
name: env.name,
|
|
90
|
+
description: env.description,
|
|
91
|
+
example: env.example
|
|
92
|
+
}))
|
|
93
|
+
},
|
|
94
|
+
capabilities: packageJson.keywords?.filter((k) => k !== 'opencode' && k !== 'plugin') || []
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
logger.debug(`Could not load provider spec for ${providerPath}: ${error.message}`);
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function validateProvider(providerPath, pluginDir) {
|
|
105
|
+
const spec = loadProviderSpec(providerPath, pluginDir);
|
|
106
|
+
if (!spec) {
|
|
107
|
+
return {
|
|
108
|
+
provider: providerPath,
|
|
109
|
+
configured: false,
|
|
110
|
+
missingVars: [],
|
|
111
|
+
spec: undefined
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
const missingVars = [];
|
|
115
|
+
for (const envVar of spec.envVars.required) {
|
|
116
|
+
if (!process.env[envVar.name]) {
|
|
117
|
+
missingVars.push(envVar.name);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
provider: providerPath,
|
|
122
|
+
configured: missingVars.length === 0,
|
|
123
|
+
missingVars,
|
|
124
|
+
spec
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
export function validateProviders(packageJson, pluginDir) {
|
|
128
|
+
const errors = [];
|
|
129
|
+
const requiredResults = [];
|
|
130
|
+
const optionalResults = [];
|
|
131
|
+
if (!packageJson.providers) {
|
|
132
|
+
return { hasRequiredProvider: true, requiredResults, optionalResults, errors };
|
|
133
|
+
}
|
|
134
|
+
const anyProviders = packageJson.providers.any || [];
|
|
135
|
+
const requiredProviders = packageJson.providers.required || [];
|
|
136
|
+
const optionalProviders = packageJson.providers.optional || [];
|
|
137
|
+
const allProviders = [...anyProviders, ...requiredProviders];
|
|
138
|
+
for (const providerPath of allProviders) {
|
|
139
|
+
const result = validateProvider(providerPath, pluginDir);
|
|
140
|
+
requiredResults.push(result);
|
|
141
|
+
}
|
|
142
|
+
for (const providerPath of optionalProviders) {
|
|
143
|
+
const result = validateProvider(providerPath, pluginDir);
|
|
144
|
+
optionalResults.push(result);
|
|
145
|
+
}
|
|
146
|
+
const hasRequiredProvider = requiredResults.length === 0 || requiredResults.some(r => r.configured);
|
|
147
|
+
if (!hasRequiredProvider && requiredResults.length > 0) {
|
|
148
|
+
const providerNames = requiredResults
|
|
149
|
+
.map(r => r.spec?.displayName || r.provider)
|
|
150
|
+
.join(', ');
|
|
151
|
+
errors.push(`At least one provider must be configured. Available providers: ${providerNames}`);
|
|
152
|
+
errors.push(`\nConfigure any one of the following:\n`);
|
|
153
|
+
for (const result of requiredResults) {
|
|
154
|
+
if (result.spec) {
|
|
155
|
+
errors.push(`${result.spec.displayName}:`);
|
|
156
|
+
for (const envVar of result.spec.envVars.required) {
|
|
157
|
+
errors.push(` - ${envVar.name}: ${envVar.description}`);
|
|
158
|
+
if (envVar.example) {
|
|
159
|
+
errors.push(` Example: ${envVar.example}`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
errors.push('');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return { hasRequiredProvider, requiredResults, optionalResults, errors };
|
|
167
|
+
}
|
|
168
|
+
export function loadEnv(petId) {
|
|
169
|
+
const envVars = {};
|
|
170
|
+
try {
|
|
171
|
+
const projectRoot = resolve(process.cwd());
|
|
172
|
+
const dotenvPath = resolve(projectRoot, '.env');
|
|
173
|
+
const petsConfigPath = resolve(projectRoot, '.pets', 'config.json');
|
|
174
|
+
logger.debug(`Loading env vars for pet: ${petId || 'global'}`);
|
|
175
|
+
if (petId && existsSync(petsConfigPath)) {
|
|
176
|
+
try {
|
|
177
|
+
const petsConfig = JSON.parse(readFileSync(petsConfigPath, 'utf-8'));
|
|
178
|
+
const petEnvConfig = petsConfig.envConfig?.[petId] || {};
|
|
179
|
+
for (const [key, value] of Object.entries(petEnvConfig)) {
|
|
180
|
+
if (typeof value === 'string' && value.length > 0) {
|
|
181
|
+
envVars[key] = value;
|
|
182
|
+
logger.debug(`Loaded from .pets/config.json: ${key}`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
logger.debug(`Failed to load pet config: ${error.message}`);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (existsSync(dotenvPath)) {
|
|
191
|
+
const dotenvResult = config({ path: dotenvPath });
|
|
192
|
+
if (dotenvResult.parsed) {
|
|
193
|
+
for (const [key, value] of Object.entries(dotenvResult.parsed)) {
|
|
194
|
+
if (value && value.length > 0) {
|
|
195
|
+
envVars[key] = value;
|
|
196
|
+
logger.debug(`Loaded from .env (overriding if exists): ${key}`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
logger.info(`Loaded ${Object.keys(envVars).length} environment variables from project config`);
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
logger.error(`Error loading environment variables: ${error.message}`);
|
|
205
|
+
}
|
|
206
|
+
return envVars;
|
|
207
|
+
}
|
|
208
|
+
export function getEnv(key, petId) {
|
|
209
|
+
const envVars = loadEnv(petId);
|
|
210
|
+
return envVars[key];
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=plugin-factory.js.map
|
|
@@ -0,0 +1 @@
|
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