@surph_ai/sdk 0.0.23 → 0.0.25

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/auth/index.js CHANGED
@@ -8,22 +8,22 @@ const utils = require('../utils')
8
8
  module.exports = {
9
9
  showPrompt: () => {
10
10
  return new Promise((resolve, reject) => {
11
- const schema = {
12
- properties: {
13
- email: {
14
- description: colors.cyan('\nEmail'),
15
- required: true
16
- },
17
- password: {
18
- description: colors.cyan('Password'),
19
- required: true,
20
- hidden: true
21
- }
22
- }
23
- }
11
+ const schema = {
12
+ properties: {
13
+ email: {
14
+ description: colors.cyan('\nEmail'),
15
+ required: true
16
+ },
17
+ password: {
18
+ description: colors.cyan('Password'),
19
+ required: true,
20
+ hidden: true
21
+ }
22
+ }
23
+ }
24
24
 
25
- prompt.message = null
26
- prompt.start()
25
+ prompt.message = null
26
+ prompt.start()
27
27
 
28
28
  // Get two properties from the user: username and email
29
29
  prompt.get(schema, (err, result) => {
@@ -8,6 +8,7 @@ export const handler = async (event) => {
8
8
  } catch (error) {
9
9
  payload = error instanceof Error ? error.message : String(error);
10
10
  }
11
+
11
12
  return {
12
13
  statusCode: 200,
13
14
  body: JSON.stringify(payload),
package/index.js CHANGED
@@ -171,6 +171,57 @@ program.command('tool <name>')
171
171
  .description('create new Surph tool')
172
172
  .action(name => scaffold(name, 'tool'))
173
173
 
174
+ program.command('manifest')
175
+ .description('update manifest for Surph tool')
176
+ .action(async (cmd, options) => {
177
+ try {
178
+ const manifestJson = require('../../../manifest.json')
179
+ const slug = Object.keys(manifestJson)[0]
180
+ const manifest = manifestJson[slug]
181
+ if (!manifest) {
182
+ throw new Error('manifest.json not found')
183
+ }
184
+
185
+ const schema = {
186
+ properties: {
187
+ description: {
188
+ description: colors.cyan('\nWhat does your tool do?'),
189
+ required: true
190
+ }
191
+ }
192
+ }
193
+
194
+ prompt.message = null
195
+ prompt.start()
196
+
197
+ const { description } = await prompt.get(schema)
198
+ // console.log('ARGS: ' + JSON.stringify(args))
199
+
200
+ const resp = await fetch('https://rpc.surph.ai/tools/manifest', {
201
+ method: "POST",
202
+ body: JSON.stringify({
203
+ description,
204
+ name: manifest.name,
205
+ slug: manifest.slug
206
+ }),
207
+ headers: {
208
+ 'Accept': 'application/json',
209
+ 'Content-type': 'application/json',
210
+ 'x-surph-client': 'surph-sdk'
211
+ }
212
+ })
213
+
214
+ const { response } = await resp.json()
215
+ const updated = { ...manifest, ...response }
216
+
217
+ utils.write('manifest.json', JSON.stringify({[slug]: updated}, null, 2) + '\n')
218
+ console.log(colors.white('\n\nManifest updated. Check manifest.json for changes.\n'))
219
+ } catch (error) {
220
+ utils.printError(error)
221
+ }
222
+ })
223
+
224
+
174
225
  /*
175
226
  program.command('connect')
176
227
  .description('Connect to Surph project')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@surph_ai/sdk",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "./types.d.ts",
package/scaffold/index.js CHANGED
@@ -60,20 +60,6 @@ module.exports = (name, type = 'app') => {
60
60
  shell.mkdir('-p', name)
61
61
  shell.cd(name)
62
62
 
63
- /*
64
- shell.mkdir('-p', 'server')
65
- shell.cp('-R', path.join(__dirname, 'tool/server/app.js'), 'server/app.js')
66
- shell.cp('-R', path.join(__dirname, 'tool/package.json'), 'package.json')
67
-
68
- // routes:
69
- shell.mkdir('-p', 'server/routes')
70
- shell.cp('-R', path.join(__dirname, `tool/server/routes/*`), 'server/routes/')
71
-
72
- // views:
73
- shell.mkdir('-p', 'server/templates')
74
- shell.cp('-R', path.join(__dirname, `tool/server/templates/*`), 'server/templates/')
75
- */
76
-
77
63
  const pkgJsonStr = utils.readFile(path.join(__dirname, 'tool/package.json'))
78
64
  const pkgJson = JSON.parse(pkgJsonStr)
79
65
  pkgJson.name = name
@@ -86,7 +72,7 @@ module.exports = (name, type = 'app') => {
86
72
  name: 'youtube-transcript',
87
73
  slug: 'y2script',
88
74
  type: 'custom',
89
- 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 general video metadata (title, channel, view count) or for non-YouTube videos.',
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).',
90
76
  parameters: {
91
77
  type: 'object',
92
78
  properties: {
@@ -1,6 +1,3 @@
1
- # demo
2
-
3
- This project was built with Saxa Labs. To learn more, click here: https://www.saxalabs.com
4
1
 
5
2
  ## Instructions
6
3
  After cloning into repo, cd to project root directory and install dependencies:
@@ -0,0 +1 @@
1
+ manifest.json is a tool summary for LLMs so they know when and how to invoke a tool. this tool, called "deal finder" scans a provided context for upcoming events, promotional sales, giveaways, specials etc and returns upcoming deals in the response. please fill out the manifest so LLM uses the tool at the appropriate time
@@ -8,6 +8,7 @@
8
8
  "test": "",
9
9
  "build": "rimraf dist && tsc",
10
10
  "watch": "tsc -w",
11
+ "manifest": "surph manifest",
11
12
  "publish": "npm run build && surph publish",
12
13
  "deploy": "npm run build && surph deploy"
13
14
  },
@@ -1,14 +1,9 @@
1
- // Your tools code goes here. When ready, export
2
- // the tool name in exports at bottom of this file
3
- // as shown in this demo code:
4
1
  import type { ToolHandler, ToolContext, User } from '@surph_ai/sdk';
5
2
 
6
- type YourToolArgs = {
3
+ type ToolArgs = {
7
4
  // your custom tool args goes here
8
5
  };
9
6
 
10
- type ToolArgs = YourToolArgs;
11
-
12
7
  const handler: ToolHandler<ToolArgs> = async ({ args, user, context }) => {
13
8
  // your custom tool code goes here
14
9
  };
@@ -96,6 +96,10 @@ router.post('/custom', async (req, res, next) => {
96
96
 
97
97
  const tools = await loadTool()
98
98
  const response = await handler({ args, context, user }, tools)
99
+ if (resp.error) {
100
+ throw new Error(resp.error);
101
+ }
102
+
99
103
  res.json({ response })
100
104
  } catch (error) {
101
105
  res.json({