@surph_ai/cli 0.0.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/cli.js +447 -0
- package/deploy/index.js +153 -0
- package/deploy/tool-handler.js +16 -0
- package/index.js +3 -0
- package/package.json +35 -0
- package/scaffold/index.js +137 -0
- package/scaffold/project/README.md +28 -0
- package/scaffold/project/app.js +20 -0
- package/scaffold/project/apps/README.md +1 -0
- package/scaffold/project/env.txt +4 -0
- package/scaffold/project/package-lock.json +2459 -0
- package/scaffold/project/package.json +21 -0
- package/scaffold/project/public/css/bootstrap.css +5926 -0
- package/scaffold/project/public/js/app.js +1 -0
- package/scaffold/project/public/js/jquery.js +2 -0
- package/scaffold/project/routes/index.js +8 -0
- package/scaffold/project/templates/index.mustache +20 -0
- package/scaffold/tool/README.md +25 -0
- package/scaffold/tool/env.txt +2 -0
- package/scaffold/tool/example.txt +1 -0
- package/scaffold/tool/package.json +27 -0
- package/scaffold/tool/tools/index.ts +13 -0
- package/toolserver/app.js +25 -0
- package/toolserver/chat.js +95222 -0
- package/toolserver/routes/index.js +8 -0
- package/toolserver/routes/tool.js +118 -0
- package/toolserver/templates/index.html +20 -0
- package/types.d.ts +73 -0
- package/utils/index.js +275 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
// const program = require('commander')
|
|
2
|
+
const shell = require('shelljs')
|
|
3
|
+
const path = require('path')
|
|
4
|
+
const fs = require('fs')
|
|
5
|
+
const dotenv = require('dotenv')
|
|
6
|
+
const utils = require('../utils')
|
|
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
|
+
|
|
32
|
+
// var PLATFORM_VECTOR_URL = 'https://platform.turbo360-vector.com'
|
|
33
|
+
// var VERTEX_NPM_VERSION = "^0.30.25"
|
|
34
|
+
// var TURBO_NPM_VERSION = "^1.8.69"
|
|
35
|
+
|
|
36
|
+
const nextSteps = function(name){
|
|
37
|
+
console.log('\n- - - - - Next Steps - - - - - ')
|
|
38
|
+
console.log('1. $ cd ' + name)
|
|
39
|
+
console.log('2. $ npm install')
|
|
40
|
+
console.log('3. $ turbo devserver')
|
|
41
|
+
console.log('4. Open http://localhost:3000 in a browser')
|
|
42
|
+
console.log('- - - - - - - - - - - - - - - - -\n')
|
|
43
|
+
console.log('For full documentation, visit https://docs.turbo360.co\n')
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
module.exports = (name, type = 'app') => {
|
|
48
|
+
/*
|
|
49
|
+
https://stackoverflow.com/questions/8683895/how-do-i-determine-the-current-operating-system-with-node-js
|
|
50
|
+
Returns the operating system platform. Possible values are 'darwin', 'freebsd', 'linux',
|
|
51
|
+
'sunos' or 'win32'. Returns the value of process.platform.
|
|
52
|
+
'darwin' == mac
|
|
53
|
+
'win32' == windows
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
const { platform } = process
|
|
57
|
+
|
|
58
|
+
if (type === 'tool') {
|
|
59
|
+
console.log('create tool: ' + name)
|
|
60
|
+
shell.mkdir('-p', name)
|
|
61
|
+
shell.cd(name)
|
|
62
|
+
|
|
63
|
+
const pkgJsonStr = utils.readFile(path.join(__dirname, 'tool/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
|
+
shell.mkdir('-p', 'tools')
|
|
69
|
+
shell.cp('-R', path.join(__dirname, `tool/tools/index.ts`), 'tools/index.ts')
|
|
70
|
+
|
|
71
|
+
utils.write('manifest-example.json', JSON.stringify({
|
|
72
|
+
name: 'youtube-transcript',
|
|
73
|
+
slug: 'y2script',
|
|
74
|
+
type: 'custom',
|
|
75
|
+
description: 'Fetch the plain-text transcript (spoken words) of a YouTube video. Use this whenever the user asks about, quotes from, summarizes, or wants to search inside the content of a YouTube video — including questions like "what does this video say about X", "summarize this video", "pull the transcript", or when the user pastes a YouTube URL and expects you to know its contents. Do NOT use this for non-YouTube videos (it will fail on other video sources).',
|
|
76
|
+
parameters: {
|
|
77
|
+
type: 'object',
|
|
78
|
+
properties: {
|
|
79
|
+
video: {
|
|
80
|
+
type: 'string',
|
|
81
|
+
description: 'The YouTube video to transcribe. Accepts either a full URL (e.g. "https://www.youtube.com/watch?v=EwusdkKUlwI", "https://youtu.be/EwusdkKUlwI") or the bare 11-character video id (e.g. "EwusdkKUlwI"). Extract this from the user\'s message when they paste a link.'
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
required: ['video']
|
|
85
|
+
}
|
|
86
|
+
} , null, 2) + '\n')
|
|
87
|
+
|
|
88
|
+
const slug = slugify(name, 8)
|
|
89
|
+
|
|
90
|
+
const manifest = {}
|
|
91
|
+
manifest[slug] = {
|
|
92
|
+
name,
|
|
93
|
+
slug,
|
|
94
|
+
type: 'custom',
|
|
95
|
+
description: '',
|
|
96
|
+
parameters: {
|
|
97
|
+
type: "object",
|
|
98
|
+
properties: {},
|
|
99
|
+
required: []
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
utils.write('manifest.json', JSON.stringify(manifest, null, 2) + '\n')
|
|
104
|
+
|
|
105
|
+
const envStr = utils.readFile(path.join(__dirname, 'tool/env.txt'))
|
|
106
|
+
utils.write('.env', envStr.replace('<SURPH_TOOL>', slug))
|
|
107
|
+
|
|
108
|
+
const tsConfig = {
|
|
109
|
+
"compilerOptions": {
|
|
110
|
+
"target": "ES2022",
|
|
111
|
+
"module": "Node16",
|
|
112
|
+
"moduleResolution": "Node16",
|
|
113
|
+
"lib": ["ES2022"],
|
|
114
|
+
"types": ["node"],
|
|
115
|
+
"outDir": "./dist",
|
|
116
|
+
"rootDir": ".",
|
|
117
|
+
"strict": true,
|
|
118
|
+
"esModuleInterop": true,
|
|
119
|
+
"skipLibCheck": true,
|
|
120
|
+
"forceConsistentCasingInFileNames": true,
|
|
121
|
+
"resolveJsonModule": true
|
|
122
|
+
},
|
|
123
|
+
"include": ["tools/**/*.ts"],
|
|
124
|
+
"exclude": ["node_modules", "dist"]
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
utils.write('tsconfig.json', JSON.stringify(tsConfig, null, 2) + '\n')
|
|
128
|
+
|
|
129
|
+
console.log('\n- - - - - Next Steps - - - - - ')
|
|
130
|
+
console.log('1. $ cd ' + name)
|
|
131
|
+
console.log('2. $ npm install or $ yarn install')
|
|
132
|
+
console.log('3. $ npm run dev')
|
|
133
|
+
console.log('4. Open http://localhost:5000 in a browser')
|
|
134
|
+
console.log('\nFor full documentation, visit https://docs.surph.ai\n')
|
|
135
|
+
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# demo
|
|
2
|
+
|
|
3
|
+
This project was built with Saxa Labs. To learn more, click here: https://www.saxalabs.com
|
|
4
|
+
|
|
5
|
+
## Instructions
|
|
6
|
+
After cloning into repo, cd to project root directory and install dependencies:
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
$ npm install
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
To run dev server, install Turbo CLI globally:
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
$ sudo npm install saxa-cli -g
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Then run devserver from project root directory:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
$ turbo devserver
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
To build for production, run build:
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
$ npm run build
|
|
28
|
+
```
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const express = require('express')
|
|
2
|
+
const turbo = require('@turbo360/turbo-sdk')
|
|
3
|
+
const { configureApp, appContext } = require('saxa')
|
|
4
|
+
|
|
5
|
+
const app = express()
|
|
6
|
+
|
|
7
|
+
configureApp(app, {
|
|
8
|
+
views: 'templates',
|
|
9
|
+
static: 'public',
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
app.use(appContext())
|
|
13
|
+
|
|
14
|
+
// import routes
|
|
15
|
+
const index = require('./routes/index')
|
|
16
|
+
|
|
17
|
+
// set routes
|
|
18
|
+
app.use('/', index)
|
|
19
|
+
|
|
20
|
+
module.exports.entry = turbo.entry(() => app)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
README!
|