@surph_ai/sdk 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.
Files changed (70) hide show
  1. package/auth/index.js +147 -0
  2. package/base/vinely-base/.nvmrc +1 -0
  3. package/base/vinely-base/README.md +30 -0
  4. package/base/vinely-base/app.js +5 -0
  5. package/base/vinely-base/declarations.d.ts +1 -0
  6. package/base/vinely-base/package.json +103 -0
  7. package/base/vinely-base/public/css/globals-2.css +3699 -0
  8. package/base/vinely-base/public/css/globals.css +3695 -0
  9. package/base/vinely-base/public/js/app.js +1 -0
  10. package/base/vinely-base/public/js/jquery.js +2 -0
  11. package/base/vinely-base/scratch.js +21 -0
  12. package/base/vinely-base/src/client/components/app-sidebar.tsx +59 -0
  13. package/base/vinely-base/src/client/components/assistant-ui/markdown-text.tsx +153 -0
  14. package/base/vinely-base/src/client/components/assistant-ui/thread-list.tsx +67 -0
  15. package/base/vinely-base/src/client/components/assistant-ui/thread.tsx +666 -0
  16. package/base/vinely-base/src/client/components/assistant-ui/tool-fallback.tsx +44 -0
  17. package/base/vinely-base/src/client/components/assistant-ui/tooltip-icon-button.tsx +44 -0
  18. package/base/vinely-base/src/client/components/ui/breadcrumb.tsx +109 -0
  19. package/base/vinely-base/src/client/components/ui/button.tsx +59 -0
  20. package/base/vinely-base/src/client/components/ui/input.tsx +21 -0
  21. package/base/vinely-base/src/client/components/ui/separator.tsx +28 -0
  22. package/base/vinely-base/src/client/components/ui/sheet.tsx +139 -0
  23. package/base/vinely-base/src/client/components/ui/sidebar.tsx +726 -0
  24. package/base/vinely-base/src/client/components/ui/skeleton.tsx +14 -0
  25. package/base/vinely-base/src/client/components/ui/tooltip.tsx +61 -0
  26. package/base/vinely-base/src/client/components/vines-sidebar.tsx +182 -0
  27. package/base/vinely-base/src/client/contexts/SessionContext.tsx +28 -0
  28. package/base/vinely-base/src/client/contexts/SessionReducer.tsx +32 -0
  29. package/base/vinely-base/src/client/hooks/use-mobile.ts +19 -0
  30. package/base/vinely-base/src/client/index.tsx +154 -0
  31. package/base/vinely-base/src/client/lib/API.ts +155 -0
  32. package/base/vinely-base/src/client/lib/RPC.ts +49 -0
  33. package/base/vinely-base/src/client/lib/utils.ts +96 -0
  34. package/base/vinely-base/src/server/index.ts +63 -0
  35. package/base/vinely-base/src/server/routes/api.ts +38 -0
  36. package/base/vinely-base/src/server/routes/chat.ts +133 -0
  37. package/base/vinely-base/src/server/routes/main.ts +36 -0
  38. package/base/vinely-base/src/server/routes/mcp.ts +52 -0
  39. package/base/vinely-base/src/server/routes/rpc.ts +64 -0
  40. package/base/vinely-base/src/server/routes/thread.ts +44 -0
  41. package/base/vinely-base/src/server/utils/APIMgr.ts +156 -0
  42. package/base/vinely-base/src/server/utils/Auth.ts +235 -0
  43. package/base/vinely-base/src/server/utils/fetchManifest.ts +15 -0
  44. package/base/vinely-base/src/server/utils/mcp-auth.ts +251 -0
  45. package/base/vinely-base/tsconfig.json +16 -0
  46. package/base/vinely-base/views/landing.html +187 -0
  47. package/base/vinely-base/views/partials/imports.dev.html +3 -0
  48. package/base/vinely-base/webpack.config.js +112 -0
  49. package/deploy/Dockerfile +9 -0
  50. package/deploy/index.js +244 -0
  51. package/index.js +266 -0
  52. package/package.json +28 -0
  53. package/scaffold/app/gulpfile.js +12 -0
  54. package/scaffold/app/package.json +24 -0
  55. package/scaffold/app/src/index.js +14 -0
  56. package/scaffold/index.js +171 -0
  57. package/scaffold/project/README.md +28 -0
  58. package/scaffold/project/app.js +20 -0
  59. package/scaffold/project/apps/README.md +1 -0
  60. package/scaffold/project/env.txt +4 -0
  61. package/scaffold/project/package-lock.json +2459 -0
  62. package/scaffold/project/package.json +21 -0
  63. package/scaffold/project/public/css/bootstrap.css +5926 -0
  64. package/scaffold/project/public/js/app.js +1 -0
  65. package/scaffold/project/public/js/jquery.js +2 -0
  66. package/scaffold/project/routes/index.js +8 -0
  67. package/scaffold/project/templates/index.mustache +20 -0
  68. package/utils/Realm.js +60 -0
  69. package/utils/http.js +22 -0
  70. package/utils/index.js +276 -0
package/utils/index.js ADDED
@@ -0,0 +1,276 @@
1
+ const fs = require('fs')
2
+ const colors = require('colors/safe')
3
+ // const superagent = require('superagent')
4
+ const dotenv = require('dotenv')
5
+ const MODE_0666 = parseInt('0666', 8)
6
+
7
+ module.exports = {
8
+
9
+ /*
10
+ isTurboApp: function(){
11
+ var packageJson = null
12
+ var env = null
13
+ try {
14
+ packageJson = fs.readFileSync('package.json', 'utf8')
15
+ var json = JSON.parse(packageJson)
16
+ var dependencies = json.dependencies
17
+ if (dependencies.turbo360==null || dependencies.vertex360==null){
18
+ return {
19
+ isTurboApp: false,
20
+ missing: 'turbo360 and/or vertex 360',
21
+ reason: 'Missing turbo360 and/or vertex 360 dependencies'
22
+ }
23
+ }
24
+
25
+ var envData = fs.readFileSync('.env', 'utf8')
26
+ env = dotenv.parse(envData)
27
+ var turboEnv = env['TURBO_ENV']
28
+ if (turboEnv == null){
29
+ return {
30
+ isTurboApp: false,
31
+ missing: 'TURBO_ENV environment variable',
32
+ reason: 'Missing TURBO_ENV environment variable. Please set "TURBO_ENV=dev" in the .env file'
33
+ }
34
+ }
35
+
36
+ // this is definitely a turbo project
37
+ return {
38
+ isTurboApp: true,
39
+ turboEnv: turboEnv,
40
+ turbo360: dependencies.turbo360,
41
+ vertex360: dependencies.vertex360
42
+ }
43
+ }
44
+ catch(err){
45
+ // console.log('ERR - ' + err.message)
46
+ var missing = (packageJson == null) ? 'package.json' : '.env'
47
+ var reason = (packageJson == null) ? 'Missing package.json file' : 'Missing .env file. Please add .env file with "TURBO_ENV=dev" variable set.'
48
+ return {
49
+ isTurboApp: false,
50
+ missing: missing,
51
+ reason: reason
52
+ }
53
+ }
54
+ },
55
+
56
+ defaultTurboDeploy: function() {
57
+ var turboDeployString = '## Do NOT check this file into version control\n'
58
+ turboDeployString += '\nBUCKET=<AWS_HOST_BUCKET>'
59
+ turboDeployString += '\nAWS_KEY=<AWS_KEY>'
60
+ turboDeployString += '\nAWS_SECRET=<AWS_SECRET>'
61
+ turboDeployString += '\nAWS_ACCT=<AWS_ACCT>'
62
+ turboDeployString += '\nAWS_ROLE=<AWS_ROLE>'
63
+ turboDeployString += '\nAWS_REGION=<AWS_REGION>'
64
+ return turboDeployString
65
+ },
66
+ */
67
+
68
+ defaultEnv: function() {
69
+ var envString = '## Do NOT check this file into version control\n'
70
+ envString += '\nTURBO_ENV=dev'
71
+ envString += '\nTURBO_CDN=https://cdn.turbo360-vertex.com'
72
+ envString += '\nSESSION_SECRET=YOUR_SESSION_SECRET'
73
+ envString += '\nTURBO_APP_ID=<TURBO_APP_ID>'
74
+ envString += '\nTMP_DIR=/tmp'
75
+ envString += '\nTURBO_API_KEY=<TURBO_API_KEY>'
76
+ envString += '\nTURBO_APP_SLUG=<TURBO_APP_SLUG>'
77
+ return envString
78
+ },
79
+
80
+ validateEnv: function(env, fields) { // fields is an array
81
+ if (!fields) {
82
+ // required env values to deploy:
83
+ fields = [
84
+ {text:'TURBO_CDN', min:20, placeholder:'https://cdn.turbo360-vertex.com'},
85
+ {text:'TURBO_APP_SLUG', min:6, placeholder:'<TURBO_APP_SLUG>'},
86
+ {text:'TURBO_API_KEY', min:20, placeholder:'<TURBO_API_KEY>'},
87
+ {text:'TURBO_APP_ID', min:20, placeholder:'<TURBO_APP_ID>'}
88
+ ]
89
+ }
90
+
91
+ var missing = null
92
+ fields.forEach(function(field){
93
+ // e.g. - {text:"TURBO_APP_ID", min:20}
94
+ var key = field.text
95
+ if (env[key] == null){
96
+ missing = key
97
+ return
98
+ }
99
+
100
+ if (env[key] == field.placeholder){ // still default placeholder string
101
+ missing = key
102
+ return
103
+ }
104
+
105
+ if (env[key].length < field.min){ // doesn't meet min str length
106
+ missing = key
107
+ return
108
+ }
109
+ })
110
+
111
+ return missing
112
+ },
113
+
114
+ write: (path, str, mode = MODE_0666) => {
115
+ fs.writeFileSync(path, str, { mode })
116
+ // console.log(' \x1b[36mcreate\x1b[0m : ' + path)
117
+ },
118
+
119
+ // readFile: function(filepath, errMessage){
120
+ // return new Promise(function(resolve, reject){
121
+ // fs.readFile(filepath, 'utf8', function(err, data) {
122
+ // if (err) {
123
+ // var error = (errMessage) ? Error(errMessage) : err
124
+ // reject(error)
125
+ // return
126
+ // }
127
+
128
+ // resolve(data)
129
+ // })
130
+ // })
131
+ // },
132
+
133
+ readFile: (filepath, encoding = 'utf8') => {
134
+ // if (!encoding)
135
+ // encoding = 'utf8'
136
+
137
+ try {
138
+ const file = fs.readFileSync(filepath, encoding)
139
+ return file
140
+ } catch (error) {
141
+ return null
142
+ }
143
+ },
144
+
145
+ printError: (error) => {
146
+ if (error.response) {
147
+ const { data } = error.response
148
+ const errorText = `${colors.red(`\nError: `)} ${colors.white(`${data.error}\n`)}`
149
+ console.log(errorText)
150
+
151
+ return
152
+ }
153
+
154
+ const errorText = `${colors.red(`\nError: `)} ${colors.white(`${error.message}\n`)}`
155
+ console.log(errorText)
156
+ }
157
+
158
+ /*
159
+ postRequest: function(endpoint, params){
160
+ return new Promise(function(resolve, reject){
161
+ superagent
162
+ .post(endpoint)
163
+ .send(params)
164
+ .set('Accept', 'application/json')
165
+ .end(function(err, response){
166
+ // console.log('POST CALLBACK: ' + JSON.stringify(response))
167
+ if (err){
168
+ // console.log('err 1: ' + err)
169
+ if (!response){
170
+ reject(err)
171
+ return
172
+ }
173
+
174
+ if (response.text){
175
+ try {
176
+ var parsed = JSON.parse(response.text)
177
+ var message = parsed.message || 'Something went wrong. Please try again.'
178
+ reject(new Error(message))
179
+ return
180
+ } catch(parseError){
181
+
182
+ }
183
+ }
184
+
185
+ reject(err)
186
+ return
187
+ }
188
+
189
+ if (response.body.confirmation != 'success'){
190
+ // console.log('POST ERROR: ' + JSON.stringify(response))
191
+ reject(new Error(response.body.message))
192
+ return
193
+ }
194
+
195
+ resolve(response.body)
196
+ })
197
+ })
198
+ },
199
+
200
+ putRequest: function(endpoint, params){
201
+ return new Promise(function(resolve, reject){
202
+ superagent
203
+ .put(endpoint)
204
+ .send(params)
205
+ .set('Accept', 'application/json')
206
+ .end(function(err, response){
207
+ if (err){
208
+ if (!response){
209
+ reject(err)
210
+ return
211
+ }
212
+
213
+ if (response.text){
214
+ try {
215
+ var parsed = JSON.parse(response.text)
216
+ var message = parsed.message || 'Something went wrong. Please try again.'
217
+ reject(new Error(message))
218
+ return
219
+ } catch(parseError){
220
+
221
+ }
222
+ }
223
+
224
+ reject(err)
225
+ return
226
+ }
227
+
228
+ if (response.body.confirmation != 'success'){
229
+ // console.log('POST ERROR: ' + JSON.stringify(response))
230
+ reject(new Error(response.body.message))
231
+ return
232
+ }
233
+
234
+ resolve(response.body)
235
+ })
236
+ })
237
+ },
238
+
239
+ getRequest: function(endpoint){
240
+ return new Promise(function(resolve, reject){
241
+ superagent
242
+ .get(endpoint)
243
+ .set('Accept', 'application/json')
244
+ .end(function(err, response){
245
+ if (err){
246
+ if (!response){
247
+ reject(err)
248
+ return
249
+ }
250
+
251
+ if (response.text){
252
+ try {
253
+ var parsed = JSON.parse(response.text)
254
+ var message = parsed.message || 'Something went wrong. Please try again.'
255
+ reject(new Error(message))
256
+ return
257
+ } catch(parseError){
258
+
259
+ }
260
+ }
261
+
262
+ reject(err)
263
+ return
264
+ }
265
+
266
+ if (response.body.confirmation != 'success'){
267
+ reject(new Error(response.body.message))
268
+ return
269
+ }
270
+
271
+ resolve(response.body)
272
+ })
273
+ })
274
+ }
275
+ */
276
+ }