@surph_ai/sdk 0.0.6 → 0.0.8

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/index.js CHANGED
@@ -125,6 +125,7 @@ program.command('toolserver')
125
125
  .action(async (cmd, options) => {
126
126
  try {
127
127
  shell.exec('nodemon --quiet ./node_modules/@surph_ai/sdk/toolserver/app')
128
+ shell.exec('nodemon --quiet ./node_modules/@surph_ai/sdk/toolserver/chat')
128
129
  } catch (error) {
129
130
  utils.printError(error)
130
131
  }
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.8",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
@@ -16,6 +16,7 @@
16
16
  "author": "SurphAI",
17
17
  "license": "ISC",
18
18
  "dependencies": {
19
+ "@aws-sdk/client-bedrock-runtime": "^3.1096.0",
19
20
  "adm-zip": "^0.5.10",
20
21
  "axios": "^1.12.2",
21
22
  "bestzip": "^2.2.1",
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"
@@ -31,42 +55,6 @@ module.exports = (name, type = 'app') => {
31
55
 
32
56
  const { platform } = process
33
57
 
34
- /*
35
- if (type === 'project') {
36
- console.log('create project: ' + name)
37
- shell.mkdir('-p', name)
38
- shell.cd(name)
39
-
40
- shell.cp('-R', path.join(__dirname, 'project/app.js'), 'app.js')
41
- shell.cp('-R', path.join(__dirname, 'project/package.json'), 'package.json')
42
-
43
- // www:
44
- // shell.mkdir('-p', 'www')
45
- // shell.cp('-R', path.join(__dirname, `project/www/*`), 'www/')
46
-
47
- shell.mkdir('-p', 'apps')
48
- shell.cp('-R', path.join(__dirname, `project/apps/*`), 'apps/')
49
-
50
- // routes:
51
- shell.mkdir('-p', 'routes')
52
- shell.cp('-R', path.join(__dirname, `project/routes/*`), 'routes/')
53
-
54
- // views:
55
- shell.mkdir('-p', 'templates')
56
- shell.cp('-R', path.join(__dirname, `project/templates/*`), 'templates/')
57
- shell.cd('templates')
58
-
59
- shell.cd('..')
60
- shell.mkdir('-p', 'public')
61
- shell.cp('-R', path.join(__dirname, `project/public/*`), 'public/')
62
-
63
- const pkgJsonStr = utils.readFile(path.join(__dirname, 'project/package.json'))
64
- const pkgJson = JSON.parse(pkgJsonStr)
65
- pkgJson.name = name
66
- utils.write('package.json', JSON.stringify(pkgJson, null, 2) + '\n')
67
- }
68
- */
69
-
70
58
  if (type === 'tool') {
71
59
  console.log('create tool: ' + name)
72
60
  shell.mkdir('-p', name)
@@ -91,12 +79,32 @@ module.exports = (name, type = 'app') => {
91
79
  pkgJson.name = name
92
80
  utils.write('package.json', JSON.stringify(pkgJson, null, 2) + '\n')
93
81
 
82
+ shell.mkdir('-p', 'tools')
83
+ shell.cp('-R', path.join(__dirname, `tool/tools/index.js`), 'tools/index.js')
84
+
85
+ const manifest = {
86
+ name,
87
+ slug: slugify(name, 8),
88
+ type: 'custom',
89
+ description: '',
90
+ parameters: {
91
+ type: "object",
92
+ properties: {},
93
+ required: []
94
+ }
95
+ }
96
+
97
+ utils.write('tools/manifest.json', JSON.stringify(manifest, null, 2) + '\n')
98
+
94
99
  const envStr = utils.readFile(path.join(__dirname, 'tool/env.txt'))
95
- utils.write('.env', envStr)
100
+ utils.write('.env', envStr.replace('<SURPH_TOOL>', manifest.slug))
96
101
 
97
- shell.mkdir('-p', 'tools')
98
- shell.cp('-R', path.join(__dirname, `tool/tools/*`), 'tools/')
102
+ console.log('\n- - - - - Next Steps - - - - - ')
103
+ console.log('1. $ cd ' + name)
104
+ console.log('2. $ npm install or $ yarn install')
105
+ console.log('3. $ npm run dev')
106
+ console.log('4. Open http://localhost:3000 in a browser')
107
+ console.log('\nFor full documentation, visit https://docs.surph.ai\n')
99
108
 
100
109
  }
101
-
102
110
  }
@@ -1,2 +1,2 @@
1
1
  SURPH_TOOL=<SURPH_TOOL>
2
- PORT=8675
2
+ PORT=5000
@@ -11,8 +11,11 @@
11
11
  "@surph_ai/sdk": "latest",
12
12
  "@vinely-ai/sdk": "^0.0.6",
13
13
  "cookie": "^0.5.0",
14
+ "cors": "^2.8.6",
14
15
  "express": "^4.18.1",
15
- "mustache": "^4.2.0"
16
+ "mustache": "^4.2.0",
17
+ "cheerio": "^1.2.0",
18
+ "impit": "^0.14.0"
16
19
  },
17
20
  "devDependencies": {
18
21
  "nodemon": "^2.0.2"