@surph_ai/sdk 0.0.6 → 0.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@surph_ai/sdk",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
package/scaffold/index.js CHANGED
@@ -5,6 +5,30 @@ const fs = require('fs')
5
5
  const dotenv = require('dotenv')
6
6
  const utils = require('../utils')
7
7
 
8
+ function generateRandomSuffix(length = 6) {
9
+ const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
10
+ let result = '';
11
+ for (let i = 0; i < length; i++) {
12
+ result += chars.charAt(Math.floor(Math.random() * chars.length));
13
+ }
14
+ return result;
15
+ }
16
+
17
+ function slugify(text, randomLength = 8) {
18
+ const slug = (text || '')
19
+ .toLowerCase()
20
+ .trim()
21
+ .replace(/[^\w\s-]/g, '')
22
+ .replace(/[\s_]+/g, '-')
23
+ .replace(/-+/g, '-')
24
+ .replace(/^-+|-+$/g, '');
25
+
26
+ if (randomLength > 0) {
27
+ return `${slug}-${generateRandomSuffix(randomLength)}`;
28
+ }
29
+ return slug;
30
+ }
31
+
8
32
  // var PLATFORM_VECTOR_URL = 'https://platform.turbo360-vector.com'
9
33
  // var VERTEX_NPM_VERSION = "^0.30.25"
10
34
  // var TURBO_NPM_VERSION = "^1.8.69"
@@ -91,12 +115,27 @@ module.exports = (name, type = 'app') => {
91
115
  pkgJson.name = name
92
116
  utils.write('package.json', JSON.stringify(pkgJson, null, 2) + '\n')
93
117
 
94
- const envStr = utils.readFile(path.join(__dirname, 'tool/env.txt'))
95
- utils.write('.env', envStr)
96
-
97
118
  shell.mkdir('-p', 'tools')
98
- shell.cp('-R', path.join(__dirname, `tool/tools/*`), 'tools/')
119
+ shell.cp('-R', path.join(__dirname, `tool/tools/index.js`), 'tools/index.js')
120
+
121
+ const manifestStr = utils.readFile(path.join(__dirname, 'tool/tools/manifest.json'))
122
+ const manifest = JSON.parse(manifestStr)
123
+ const slug = slugify(name, 8)
124
+ manifest[slug] = {
125
+ name,
126
+ slug,
127
+ type: 'custom',
128
+ description: '',
129
+ parameters: {
130
+ type: "object",
131
+ properties: {},
132
+ required: []
133
+ }
134
+ }
135
+
136
+ utils.write('tools/manifest.json', JSON.stringify(manifest, null, 2) + '\n')
99
137
 
138
+ const envStr = utils.readFile(path.join(__dirname, 'tool/env.txt'))
139
+ utils.write('.env', envStr.replace('<SURPH_TOOL>', slug))
100
140
  }
101
-
102
141
  }
@@ -0,0 +1 @@
1
+ {}
@@ -1,5 +1,6 @@
1
1
  const { Router, response } = require('express')
2
2
  const tools = require('../../../../../tools')
3
+ const manifest = require('../../../../../tools/manifest.json')
3
4
 
4
5
  const router = Router()
5
6
 
@@ -18,6 +19,19 @@ const handler = async (args, tool) => {
18
19
  }
19
20
  }
20
21
 
22
+ router.get('/', async (req, res, next) => {
23
+ try {
24
+ res.json({ response: manifest })
25
+ } catch (error) {
26
+ res.json({
27
+ response: {
28
+ success: false,
29
+ error: error.message
30
+ }
31
+ })
32
+ }
33
+ })
34
+
21
35
  router.get('/:tool', async (req, res, next) => {
22
36
  try {
23
37
  const tool = tools[req.params.tool]