@vertesia/create-plugin 0.80.0-dev.20251121 → 0.80.0

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.
Files changed (119) hide show
  1. package/README.md +123 -66
  2. package/lib/configuration.d.ts +63 -0
  3. package/lib/configuration.d.ts.map +1 -0
  4. package/lib/configuration.js +68 -0
  5. package/lib/configuration.js.map +1 -0
  6. package/lib/download-template.d.ts +5 -0
  7. package/lib/download-template.d.ts.map +1 -0
  8. package/lib/download-template.js +33 -0
  9. package/lib/download-template.js.map +1 -0
  10. package/lib/index.d.ts +9 -0
  11. package/lib/index.d.ts.map +1 -0
  12. package/lib/index.js +159 -0
  13. package/lib/index.js.map +1 -0
  14. package/lib/package-manager.d.ts +10 -0
  15. package/lib/package-manager.d.ts.map +1 -0
  16. package/lib/package-manager.js +74 -0
  17. package/lib/package-manager.js.map +1 -0
  18. package/lib/process-template.d.ts +25 -0
  19. package/lib/process-template.d.ts.map +1 -0
  20. package/lib/process-template.js +186 -0
  21. package/lib/process-template.js.map +1 -0
  22. package/lib/prompts.d.ts +6 -0
  23. package/lib/prompts.d.ts.map +1 -0
  24. package/lib/prompts.js +54 -0
  25. package/lib/prompts.js.map +1 -0
  26. package/lib/template-config.d.ts +87 -0
  27. package/lib/template-config.d.ts.map +1 -0
  28. package/lib/template-config.js +23 -0
  29. package/lib/template-config.js.map +1 -0
  30. package/lib/template-selector.d.ts +7 -0
  31. package/lib/template-selector.d.ts.map +1 -0
  32. package/lib/template-selector.js +56 -0
  33. package/lib/template-selector.js.map +1 -0
  34. package/lib/transforms.d.ts +33 -0
  35. package/lib/transforms.d.ts.map +1 -0
  36. package/lib/transforms.js +81 -0
  37. package/lib/transforms.js.map +1 -0
  38. package/package.json +22 -32
  39. package/bin/create-plugin.mjs +0 -2
  40. package/lib/Package.d.ts +0 -42
  41. package/lib/Package.d.ts.map +0 -1
  42. package/lib/Package.js +0 -52
  43. package/lib/Package.js.map +0 -1
  44. package/lib/TemplateInit.d.ts +0 -30
  45. package/lib/TemplateInit.d.ts.map +0 -1
  46. package/lib/TemplateInit.js +0 -48
  47. package/lib/TemplateInit.js.map +0 -1
  48. package/lib/ToolTemplateInit.d.ts +0 -10
  49. package/lib/ToolTemplateInit.d.ts.map +0 -1
  50. package/lib/ToolTemplateInit.js +0 -58
  51. package/lib/ToolTemplateInit.js.map +0 -1
  52. package/lib/WebTemplateInit.d.ts +0 -10
  53. package/lib/WebTemplateInit.d.ts.map +0 -1
  54. package/lib/WebTemplateInit.js +0 -68
  55. package/lib/WebTemplateInit.js.map +0 -1
  56. package/lib/copy.d.ts +0 -12
  57. package/lib/copy.d.ts.map +0 -1
  58. package/lib/copy.js +0 -45
  59. package/lib/copy.js.map +0 -1
  60. package/lib/deps.d.ts +0 -3
  61. package/lib/deps.d.ts.map +0 -1
  62. package/lib/deps.js +0 -20
  63. package/lib/deps.js.map +0 -1
  64. package/lib/hasBin.d.ts +0 -2
  65. package/lib/hasBin.d.ts.map +0 -1
  66. package/lib/hasBin.js +0 -14
  67. package/lib/hasBin.js.map +0 -1
  68. package/lib/init.d.ts +0 -2
  69. package/lib/init.d.ts.map +0 -1
  70. package/lib/init.js +0 -124
  71. package/lib/init.js.map +0 -1
  72. package/lib/main.d.ts +0 -2
  73. package/lib/main.d.ts.map +0 -1
  74. package/lib/main.js +0 -8
  75. package/lib/main.js.map +0 -1
  76. package/lib/template.d.ts +0 -4
  77. package/lib/template.d.ts.map +0 -1
  78. package/lib/template.js +0 -16
  79. package/lib/template.js.map +0 -1
  80. package/lib/types.d.ts +0 -12
  81. package/lib/types.d.ts.map +0 -1
  82. package/lib/types.js +0 -20
  83. package/lib/types.js.map +0 -1
  84. package/lib/utils.d.ts +0 -2
  85. package/lib/utils.d.ts.map +0 -1
  86. package/lib/utils.js +0 -7
  87. package/lib/utils.js.map +0 -1
  88. package/templates/tool/.env.example +0 -6
  89. package/templates/tool/.vscode/launch.json +0 -24
  90. package/templates/tool/README.md +0 -190
  91. package/templates/tool/api/index.ts +0 -8
  92. package/templates/tool/gitignore +0 -26
  93. package/templates/tool/rollup.config.js +0 -30
  94. package/templates/tool/src/collections/example/icon.svg.ts +0 -6
  95. package/templates/tool/src/collections/example/index.ts +0 -14
  96. package/templates/tool/src/collections/example/weather/WeatherTool.ts +0 -32
  97. package/templates/tool/src/collections/example/weather/manifest.ts +0 -16
  98. package/templates/tool/src/collections/index.ts +0 -7
  99. package/templates/tool/src/index.ts +0 -5
  100. package/templates/tool/src/server.ts +0 -71
  101. package/templates/tool/tsconfig.json +0 -24
  102. package/templates/tool/vite.config.js +0 -48
  103. package/templates/web/README.md +0 -156
  104. package/templates/web/eslint.config.js +0 -29
  105. package/templates/web/gitignore +0 -25
  106. package/templates/web/index.html.tmpl +0 -26
  107. package/templates/web/src/app.tsx +0 -8
  108. package/templates/web/src/assets.ts +0 -26
  109. package/templates/web/src/env.ts.tmpl +0 -14
  110. package/templates/web/src/index.css +0 -21
  111. package/templates/web/src/main.tsx.tmpl +0 -21
  112. package/templates/web/src/pages.tsx +0 -31
  113. package/templates/web/src/plugin.tsx.tmpl +0 -18
  114. package/templates/web/src/routes.tsx +0 -17
  115. package/templates/web/src/vite-env.d.ts +0 -1
  116. package/templates/web/tsconfig.app.json +0 -51
  117. package/templates/web/tsconfig.json +0 -7
  118. package/templates/web/tsconfig.node.json +0 -27
  119. package/templates/web/vite.config.ts.tmpl +0 -128
package/lib/hasBin.js DELETED
@@ -1,14 +0,0 @@
1
- import hasbin from "hasbin";
2
- export function hasBin(name) {
3
- return new Promise((resolve, reject) => {
4
- try {
5
- hasbin(name, (result) => {
6
- resolve(result);
7
- });
8
- }
9
- catch (err) {
10
- reject(err);
11
- }
12
- });
13
- }
14
- //# sourceMappingURL=hasBin.js.map
package/lib/hasBin.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"hasBin.js","sourceRoot":"","sources":["../src/hasBin.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,UAAU,MAAM,CAAC,IAAY;IAC/B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACnC,IAAI,CAAC;YACD,MAAM,CAAC,IAAI,EAAE,CAAC,MAAe,EAAE,EAAE;gBAC7B,OAAO,CAAC,MAAM,CAAC,CAAC;YACpB,CAAC,CAAC,CAAC;QACP,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAChB,MAAM,CAAC,GAAG,CAAC,CAAA;QACf,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
package/lib/init.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare function init(dirName?: string | undefined): Promise<void>;
2
- //# sourceMappingURL=init.d.ts.map
package/lib/init.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAcA,wBAAsB,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,iBAkHtD"}
package/lib/init.js DELETED
@@ -1,124 +0,0 @@
1
- import enquirer from 'enquirer';
2
- import { mkdirSync } from 'node:fs';
3
- import { join, resolve } from 'node:path';
4
- import { chdir } from 'node:process';
5
- import { fileURLToPath } from 'node:url';
6
- import { copyTree } from './copy.js';
7
- import { hasBin } from './hasBin.js';
8
- import { Package } from './Package.js';
9
- import { ToolTemplateInit } from './ToolTemplateInit.js';
10
- import { WebTemplateInit } from './WebTemplateInit.js';
11
- import { TemplateType, getTemplateDisplayName } from './types.js';
12
- const { prompt } = enquirer;
13
- export async function init(dirName) {
14
- let initialPm = 'npm';
15
- const currentPmPath = process.env.npm_execpath;
16
- if (!currentPmPath) {
17
- initialPm = (await hasBin('pnpm')) ? 'pnpm' : 'npm';
18
- }
19
- else if (currentPmPath.endsWith('pnpm')) {
20
- initialPm = 'pnpm';
21
- }
22
- else if (currentPmPath.endsWith('yarn')) {
23
- initialPm = 'yarn';
24
- }
25
- const pms = ['npm', 'pnpm'];
26
- const answer = await prompt([
27
- {
28
- name: 'template',
29
- type: 'select',
30
- message: 'Template to use',
31
- initial: 0,
32
- choices: [
33
- { message: getTemplateDisplayName(TemplateType.WEB), name: TemplateType.WEB },
34
- { message: getTemplateDisplayName(TemplateType.TOOL), name: TemplateType.TOOL },
35
- ],
36
- },
37
- {
38
- name: 'pm',
39
- type: 'select',
40
- message: 'Which package manager to use?',
41
- initial: pms.indexOf(initialPm),
42
- choices: pms,
43
- },
44
- {
45
- name: 'plugin_name',
46
- type: 'input',
47
- message: 'Plugin name (use kebab case, e.g. my-plugin)',
48
- required: true,
49
- validate: (input) => /[a-zA-Z_](-[a-zA-Z_0-9]+)*/g.test(input),
50
- },
51
- {
52
- name: 'plugin_version',
53
- type: 'input',
54
- message: 'PLugin version',
55
- initial: '1.0.0',
56
- required: true,
57
- validate: (input) => /[\d]\.[\d].[\d](-[a-zA-Z0-9_]+)?/g.test(input),
58
- },
59
- {
60
- name: 'plugin_description',
61
- type: 'input',
62
- required: false,
63
- message: 'Package description',
64
- initial: '',
65
- },
66
- ]);
67
- // Add isolation question only for web template
68
- if (answer.template === TemplateType.WEB) {
69
- const isolationAnswer = await prompt([
70
- {
71
- name: 'isolation',
72
- type: 'select',
73
- message: 'Isolation strategy',
74
- initial: 0,
75
- choices: [
76
- {
77
- message: 'Shadow DOM',
78
- name: 'shadow',
79
- hint: 'Shadow DOM will be used to fully isolate the plugin.',
80
- },
81
- {
82
- message: 'CSS-only isolation',
83
- name: 'css',
84
- hint: 'Injects Tailwind utilities into host DOM; not fully isolated. Lighter but may generate conflicts',
85
- },
86
- ],
87
- },
88
- ]);
89
- answer.isolation = isolationAnswer.isolation;
90
- }
91
- const templateName = answer.template;
92
- const templateInit = templateName === TemplateType.WEB ? new WebTemplateInit(answer) : new ToolTemplateInit(answer);
93
- const pluginName = templateInit.pluginName;
94
- let dir;
95
- if (!dirName) {
96
- dirName = pluginName.name;
97
- dir = join(process.cwd(), dirName);
98
- }
99
- else {
100
- dir = resolve(dirName);
101
- }
102
- mkdirSync(dir, { recursive: true });
103
- chdir(dir);
104
- const templateProps = {
105
- suffix: '.tmpl',
106
- context: templateInit.getVars(),
107
- };
108
- // copy template to current directory and process template files
109
- const templateDir = resolve(fileURLToPath(import.meta.url), '../../templates');
110
- if (templateName === TemplateType.WEB) {
111
- await copyTree(join(templateDir, TemplateType.WEB), dir, templateProps);
112
- }
113
- else if (templateName === TemplateType.TOOL) {
114
- await copyTree(join(templateDir, TemplateType.TOOL), dir, templateProps);
115
- }
116
- else {
117
- throw new Error(`Invalid template type: ${templateName}`);
118
- }
119
- console.log('Generating package.json');
120
- const pkg = new Package(templateInit.getPackageJson());
121
- pkg.saveTo(`${dir}/package.json`);
122
- templateInit.installDeps();
123
- }
124
- //# sourceMappingURL=init.js.map
package/lib/init.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAElE,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC;AAE5B,MAAM,CAAC,KAA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CAAC;IAElC,YAAY,CAAC,WAAW,EAAE,CAAC;AAC/B,CAAC"}
package/lib/main.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=main.d.ts.map
package/lib/main.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":""}
package/lib/main.js DELETED
@@ -1,8 +0,0 @@
1
- import { init } from "./init.js";
2
- async function main(argv) {
3
- await init(argv[2]);
4
- }
5
- main(process.argv).catch(err => {
6
- console.error("Error: ", err);
7
- });
8
- //# sourceMappingURL=main.js.map
package/lib/main.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,KAAK,UAAU,IAAI,CAAC,IAAc;IAC9B,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;AACvB,CAAC;AAED,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;IAC3B,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;AAClC,CAAC,CAAC,CAAC"}
package/lib/template.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export declare function expandVars(content: string, vars: Record<string, string>): string;
2
- export declare function processVarsInFile(file: string, vars: Record<string, string>): void;
3
- export declare function processAndRenameTemplateFile(file: string, vars: Record<string, string>): void;
4
- //# sourceMappingURL=template.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../src/template.ts"],"names":[],"mappings":"AAKA,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,UAEvE;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,QAG3E;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,QAKtF"}
package/lib/template.js DELETED
@@ -1,16 +0,0 @@
1
- import { readFileSync, renameSync, writeFileSync } from "fs";
2
- const VAR_RX = /\$\{\s*([a-zA-Z_$][a-zA-Z_$0-9]*)\s*\}/g;
3
- export function expandVars(content, vars) {
4
- return content.replaceAll(VAR_RX, (m, p) => p in vars ? vars[p] : m);
5
- }
6
- export function processVarsInFile(file, vars) {
7
- const content = readFileSync(file, "utf8");
8
- writeFileSync(file, expandVars(content, vars), "utf8");
9
- }
10
- export function processAndRenameTemplateFile(file, vars) {
11
- processVarsInFile(file, vars);
12
- if (file.endsWith(".template")) {
13
- renameSync(file, file.slice(0, -".template".length));
14
- }
15
- }
16
- //# sourceMappingURL=template.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"template.js","sourceRoot":"","sources":["../src/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAE7D,MAAM,MAAM,GAAG,yCAAyC,CAAC;AAGzD,MAAM,UAAU,UAAU,CAAC,OAAe,EAAE,IAA4B;IACpE,OAAO,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACzF,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,IAA4B;IACxE,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC3C,aAAa,CAAC,IAAI,EAAE,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,IAAY,EAAE,IAA4B;IACnF,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC9B,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7B,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAA;IACxD,CAAC;AACL,CAAC"}
package/lib/types.d.ts DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * Template types available for plugin creation
3
- */
4
- export declare enum TemplateType {
5
- WEB = "web",
6
- TOOL = "tool"
7
- }
8
- /**
9
- * Get display name for template type
10
- */
11
- export declare function getTemplateDisplayName(type: TemplateType): string;
12
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,YAAY;IACpB,GAAG,QAAQ;IACX,IAAI,SAAS;CAChB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAOjE"}
package/lib/types.js DELETED
@@ -1,20 +0,0 @@
1
- /**
2
- * Template types available for plugin creation
3
- */
4
- export var TemplateType;
5
- (function (TemplateType) {
6
- TemplateType["WEB"] = "web";
7
- TemplateType["TOOL"] = "tool";
8
- })(TemplateType || (TemplateType = {}));
9
- /**
10
- * Get display name for template type
11
- */
12
- export function getTemplateDisplayName(type) {
13
- switch (type) {
14
- case TemplateType.WEB:
15
- return 'Web Application Plugin';
16
- case TemplateType.TOOL:
17
- return 'Agent Tool Server';
18
- }
19
- }
20
- //# sourceMappingURL=types.js.map
package/lib/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACpB,2BAAW,CAAA;IACX,6BAAa,CAAA;AACjB,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAkB;IACrD,QAAQ,IAAI,EAAE,CAAC;QACX,KAAK,YAAY,CAAC,GAAG;YACjB,OAAO,wBAAwB,CAAC;QACpC,KAAK,YAAY,CAAC,IAAI;YAClB,OAAO,mBAAmB,CAAC;IACnC,CAAC;AACL,CAAC"}
package/lib/utils.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare function runCommand(cmd: string, args: string[]): void;
2
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAIrD"}
package/lib/utils.js DELETED
@@ -1,7 +0,0 @@
1
- import { spawnSync } from "node:child_process";
2
- export function runCommand(cmd, args) {
3
- spawnSync(cmd, args, {
4
- stdio: 'inherit'
5
- });
6
- }
7
- //# sourceMappingURL=utils.js.map
package/lib/utils.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,MAAM,UAAU,UAAU,CAAC,GAAW,EAAE,IAAc;IAClD,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE;QACjB,KAAK,EAAE,SAAS;KACnB,CAAC,CAAC;AACP,CAAC"}
@@ -1,6 +0,0 @@
1
- # Environment variables for your tool collections
2
-
3
- # Add any API keys or configuration here
4
- # Example:
5
- # OPENAI_API_KEY=your-api-key-here
6
- # WEATHER_API_KEY=your-weather-api-key
@@ -1,24 +0,0 @@
1
- {
2
- "version": "0.2.0",
3
- "configurations": [
4
- {
5
- "type": "node",
6
- "request": "launch",
7
- "name": "Debug Tools Server",
8
- "program": "${workspaceFolder}/node_modules/vite/bin/vite.js",
9
- "args": [
10
- "dev"
11
- ],
12
- "autoAttachChildProcesses": true,
13
- "smartStep": true,
14
- "skipFiles": [
15
- "<node_internals>/**",
16
- "**/node_modules/**"
17
- ],
18
- "sourceMaps": true,
19
- "env": {
20
- "NODE_ENV": "development"
21
- }
22
- }
23
- ]
24
- }
@@ -1,190 +0,0 @@
1
- # Tool Collections
2
-
3
- This project contains custom tool collections for Vertesia.
4
-
5
- ## Project Structure
6
-
7
- ```txt
8
- src/
9
- ├── collections/ # Tool collections
10
- │ ├── example/ # Example collection
11
- │ │ ├── icon.svg.ts # Collection icon
12
- │ │ ├── index.ts # Collection definition
13
- │ │ └── weather/ # Weather tool
14
- │ │ ├── manifest.ts # Tool schema/metadata
15
- │ │ └── WeatherTool.ts # Tool implementation
16
- │ └── index.ts # Export all collections
17
- ├── server.ts # Hono server with collection endpoints
18
- └── index.ts # Main exports
19
- ```
20
-
21
- ## Development
22
-
23
- Start the development server:
24
-
25
- ```bash
26
- pnpm install
27
- pnpm dev
28
- ```
29
-
30
- The server will be available at `http://localhost:5174/api`
31
-
32
- ### API Endpoints
33
-
34
- - `GET /api` - List all collections
35
- - `GET /api/{collection}` - Get collection metadata and tool definitions
36
- - `POST /api/{collection}` - Execute a tool in the collection
37
-
38
- ### Testing the API
39
-
40
- Get the example collection tools:
41
-
42
- ```bash
43
- curl http://localhost:5174/api/example
44
- ```
45
-
46
- Execute the weather tool:
47
-
48
- ```bash
49
- curl -X POST http://localhost:5174/api/example \
50
- -H "Content-Type: application/json" \
51
- -H "Authorization: Bearer YOUR_TOKEN" \
52
- -d '{
53
- "tool_use": {
54
- "id": "test-123",
55
- "tool_name": "weather",
56
- "tool_input": {
57
- "location": "New York, NY"
58
- }
59
- }
60
- }'
61
- ```
62
-
63
- ## Creating New Tools
64
-
65
- ### 1. Create a new tool in an existing collection
66
-
67
- 1. Create a new directory under `src/collections/example/` (e.g., `my-tool/`)
68
- 2. Create `manifest.ts` with your tool's schema
69
- 3. Create `MyTool.ts` with the implementation
70
- 4. Add the tool to `src/collections/example/index.ts`
71
-
72
- ### 2. Create a new collection
73
-
74
- 1. Create a new directory under `src/collections/` (e.g., `my-collection/`)
75
- 2. Create `icon.svg.ts` with an SVG icon
76
- 3. Create `index.ts` to define the collection
77
- 4. Add your tools in subdirectories
78
- 5. Export the collection in `src/collections/index.ts`
79
-
80
- ## Authentication
81
-
82
- Tools receive authentication context through the `ToolExecutionContext` parameter:
83
-
84
- ```typescript
85
- export async function myTool(
86
- payload: ToolExecutionPayload<MyToolParams>,
87
- context: ToolExecutionContext
88
- ) {
89
- // Access the decoded JWT token
90
- const userId = context.payload.sub;
91
-
92
- // Get a Vertesia client instance
93
- const client = await context.getClient();
94
-
95
- // Your tool logic here
96
- return {
97
- is_error: false,
98
- content: "Tool result"
99
- };
100
- }
101
- ```
102
-
103
- ## Building for Production
104
-
105
- Build the project:
106
-
107
- ```bash
108
- pnpm build
109
- ```
110
-
111
- This creates an optimized build in the `dist/` directory.
112
-
113
- ## Deployment
114
-
115
- Your Agent Tool Server can be deployed to various platforms. The server is built with Hono, which supports multiple runtimes including Node.js, Vercel Edge Functions, Cloudflare Workers, AWS Lambda, and more.
116
-
117
- For detailed guides on deploying to different platforms, visit the [Hono documentation](https://hono.dev/docs/). The documentation provides comprehensive examples for various deployment targets and runtimes.
118
-
119
- ### Deploying to Vercel (Example)
120
-
121
- This section demonstrates deploying to Vercel as an example, since Vercel offers a generous free tier and simple deployment process. The project includes `api/index.ts` which serves as the entry point for Vercel deployment using the Hono Vercel adapter. Vercel automatically detects and configures the Edge Function.
122
-
123
- #### Setup
124
-
125
- Install the Vercel CLI globally:
126
-
127
- ```bash
128
- npm i -g vercel
129
- ```
130
-
131
- #### Deployment Steps
132
-
133
- 1. **Login to Vercel**:
134
-
135
- ```bash
136
- vercel login
137
- ```
138
-
139
- 2. **Deploy to preview**:
140
-
141
- ```bash
142
- vercel
143
- ```
144
-
145
- This will create a preview deployment and provide you with a URL to test your tool server.
146
-
147
- 3. **Deploy to production**:
148
-
149
- ```bash
150
- vercel --prod
151
- ```
152
-
153
- Your tool server will be available at `https://your-project.vercel.app/api`
154
-
155
- For more information, visit the [Vercel CLI documentation](https://vercel.com/docs/cli).
156
-
157
- #### Verify Your Deployment
158
-
159
- Test that your server is responding correctly:
160
-
161
- ```bash
162
- curl https://your-project.vercel.app/api
163
- ```
164
-
165
- You should see a JSON response with the API information and available endpoints.
166
-
167
- #### Configure Your Tool Server in Vertesia
168
-
169
- After deploying to Vercel, update your app manifest to point to the deployed URL using the vertesia CLI:
170
-
171
- ```bash
172
- vertesia apps update <appId> --manifest '{
173
- "name": "my-app",
174
- "title": "My App",
175
- "description": "A sample app",
176
- "publisher": "your-org",
177
- "private": true,
178
- "status": "beta",
179
- "tool_collections": [
180
- "https://your-app.vercel.app/api/example"
181
- ],
182
- }'
183
- ```
184
-
185
- Replace `appId` by the actual ID and `https://your-app.vercel.app` with your actual Vercel deployment URL.
186
-
187
- ## Learn More
188
-
189
- - [Vertesia Documentation](https://docs.vertesiahq.com)
190
- - [Tool SDK Reference](https://github.com/vertesia/composableai/tree/main/packages/tools-sdk)
@@ -1,8 +0,0 @@
1
- import app from '../src/server';
2
- import { handle } from 'hono/vercel';
3
-
4
- export const config = {
5
- runtime: 'edge', // enables edge function runtime
6
- };
7
-
8
- export default handle(app);
@@ -1,26 +0,0 @@
1
- # Dependencies
2
-
3
- node_modules/
4
-
5
- # Build output
6
-
7
- dist/
8
- lib/
9
- \*.tsbuildinfo
10
-
11
- # Environment
12
-
13
- .env
14
- .env.local
15
-
16
- # IDE
17
-
18
- .vscode/
19
- .idea/
20
- _.swp
21
- _.swo
22
-
23
- # OS
24
-
25
- .DS_Store
26
- Thumbs.db
@@ -1,30 +0,0 @@
1
- import commonjs from '@rollup/plugin-commonjs';
2
- import json from '@rollup/plugin-json';
3
- import resolve from '@rollup/plugin-node-resolve';
4
-
5
- export default {
6
- input: './dist/server.js',
7
- output: {
8
- file: './dist/bundle.js',
9
- format: 'es',
10
- sourcemap: false
11
- },
12
- plugins: [
13
- resolve({
14
- preferBuiltins: true,
15
- exportConditions: ['node']
16
- }),
17
- commonjs(),
18
- json()
19
- ],
20
- external: [
21
- // Keep these as external dependencies
22
- 'hono',
23
- 'jose',
24
- 'dotenv',
25
- '@vertesia/client',
26
- '@vertesia/common',
27
- '@vertesia/tools-sdk',
28
- '@hono/node-server'
29
- ]
30
- };
@@ -1,6 +0,0 @@
1
- // Simple SVG icon for the collection
2
- // You can replace this with your own icon
3
- export const icon = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
4
- <circle cx="12" cy="12" r="10"/>
5
- <path d="M12 6v6l4 2"/>
6
- </svg>`;
@@ -1,14 +0,0 @@
1
- import { ToolCollection } from "@vertesia/tools-sdk";
2
- import { icon } from "./icon.svg.js";
3
- import { WeatherTool } from "./weather/WeatherTool.js";
4
-
5
- export const ExampleCollection = new ToolCollection({
6
- name: "example",
7
- title: "Example Tools",
8
- description: "A collection of example tools to get you started",
9
- icon,
10
- tools: [
11
- WeatherTool
12
- // Add more tools here
13
- ]
14
- });
@@ -1,32 +0,0 @@
1
- import type { Tool, ToolExecutionPayload, ToolExecutionContext } from "@vertesia/tools-sdk";
2
- import manifest from "./manifest.js";
3
- import { ToolResultContent } from "@vertesia/common";
4
-
5
- interface WeatherToolParams {
6
- location: string;
7
- }
8
-
9
- // Tool implementation function
10
- export async function weather(
11
- payload: ToolExecutionPayload<WeatherToolParams>,
12
- context: ToolExecutionContext
13
- ) {
14
- const { location } = payload.tool_use.tool_input!;
15
-
16
- console.log(`Caller: ${context.payload.user_id}`);
17
-
18
- // Simulate fetching weather data
19
- // In a real implementation, you would call a weather API here
20
- // You can use context.getClient() to access Vertesia services if needed
21
-
22
- return {
23
- is_error: false,
24
- content: `The current weather in ${location} is sunny with a temperature of 75°F.`
25
- } satisfies ToolResultContent;
26
- }
27
-
28
- // Export the complete tool with manifest and implementation
29
- export const WeatherTool = {
30
- ...manifest,
31
- run: weather
32
- } satisfies Tool<WeatherToolParams>;
@@ -1,16 +0,0 @@
1
- import { ToolDefinition } from "@vertesia/tools-sdk";
2
-
3
- export default {
4
- name: "weather",
5
- description: "Get the current weather for a given location.",
6
- input_schema: {
7
- type: "object",
8
- properties: {
9
- location: {
10
- type: "string",
11
- description: "The location to get the weather for, e.g., 'New York, NY'."
12
- }
13
- },
14
- required: ["location"]
15
- },
16
- } satisfies ToolDefinition;
@@ -1,7 +0,0 @@
1
- import { ExampleCollection } from "./example/index.js";
2
-
3
- // Export all your tool collections here
4
- export const collections = [
5
- ExampleCollection
6
- // Add more collections as you create them
7
- ];
@@ -1,5 +0,0 @@
1
- // Export collections for use in other modules or for programmatic access
2
- export { collections } from "./collections/index.js";
3
-
4
- // Export server as default for deployment
5
- export { default } from "./server.js";