@surph_ai/sdk 0.0.9 → 0.0.12

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
@@ -225,17 +225,6 @@ program.command('connect')
225
225
  }
226
226
  })
227
227
 
228
- program.command('build')
229
- .description('compile Surph app')
230
- .action(name => {
231
- shell.exec('gulp build --gulpfile node_modules/@turbo360/turbo-sdk/src/gulpfile.js --silent')
232
-
233
- console.log('BUILD COMPLETE')
234
- // const gulpfilePath = path.join(__dirname, 'scaffold/app/gulpfile.js')
235
- // shell.exec(`gulp build --gulpfile ${gulpfilePath}`)
236
- })
237
-
238
-
239
228
  program.command('deploy')
240
229
  .option('-t, --type <default_or_static>', 'deployment type | static or default', 'default') // https://www.npmjs.com/package/commander#default-option-value
241
230
  .description('Deploy to Surph')
@@ -288,7 +277,3 @@ program.command('deploy')
288
277
  })
289
278
 
290
279
  program.parse(process.argv)
291
-
292
- module.exports = {
293
-
294
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@surph_ai/sdk",
3
- "version": "0.0.9",
3
+ "version": "0.0.12",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
@@ -20,10 +20,16 @@
20
20
  "adm-zip": "^0.5.10",
21
21
  "axios": "^1.12.2",
22
22
  "bestzip": "^2.2.1",
23
+ "cheerio": "^1.2.0",
23
24
  "colors": "^1.4.0",
25
+ "cookie": "^0.5.0",
24
26
  "commander": "^14.0.1",
27
+ "cors": "^2.8.6",
25
28
  "dotenv": "^16.0.3",
29
+ "express": "^4.18.1",
30
+ "impit": "^0.14.0",
26
31
  "prompt": "^1.3.0",
27
- "shelljs": "^0.8.5"
32
+ "shelljs": "^0.8.5",
33
+ "mustache": "^4.2.0"
28
34
  }
29
35
  }
package/scaffold/index.js CHANGED
@@ -82,28 +82,48 @@ module.exports = (name, type = 'app') => {
82
82
  shell.mkdir('-p', 'tools')
83
83
  shell.cp('-R', path.join(__dirname, `tool/tools/index.js`), 'tools/index.js')
84
84
 
85
- const manifest = {
86
- name,
87
- slug: slugify(name, 8),
85
+ utils.write('tools/manifest-example.json', JSON.stringify({
86
+ name: 'youtube-transcript',
87
+ slug: 'y2script',
88
88
  type: 'custom',
89
- description: '',
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.',
90
90
  parameters: {
91
- type: "object",
92
- properties: {},
93
- required: []
91
+ type: 'object',
92
+ properties: {
93
+ video: {
94
+ type: 'string',
95
+ 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.'
96
+ }
97
+ },
98
+ required: ['video']
99
+ }
100
+ } , null, 2) + '\n')
101
+
102
+ const slug = slugify(name, 8)
103
+ const manifest = {
104
+ slug: {
105
+ name,
106
+ slug,
107
+ type: 'custom',
108
+ description: '',
109
+ parameters: {
110
+ type: "object",
111
+ properties: {},
112
+ required: []
113
+ }
94
114
  }
95
115
  }
96
116
 
97
117
  utils.write('tools/manifest.json', JSON.stringify(manifest, null, 2) + '\n')
98
118
 
99
119
  const envStr = utils.readFile(path.join(__dirname, 'tool/env.txt'))
100
- utils.write('.env', envStr.replace('<SURPH_TOOL>', manifest.slug))
120
+ utils.write('.env', envStr.replace('<SURPH_TOOL>', slug))
101
121
 
102
122
  console.log('\n- - - - - Next Steps - - - - - ')
103
123
  console.log('1. $ cd ' + name)
104
124
  console.log('2. $ npm install or $ yarn install')
105
125
  console.log('3. $ npm run dev')
106
- console.log('4. Open http://localhost:3000 in a browser')
126
+ console.log('4. Open http://localhost:5000 in a browser')
107
127
  console.log('\nFor full documentation, visit https://docs.surph.ai\n')
108
128
 
109
129
  }
@@ -9,13 +9,7 @@
9
9
  },
10
10
  "dependencies": {
11
11
  "@surph_ai/sdk": "latest",
12
- "@vinely-ai/sdk": "^0.0.6",
13
- "cookie": "^0.5.0",
14
- "cors": "^2.8.6",
15
- "express": "^4.18.1",
16
- "mustache": "^4.2.0",
17
- "cheerio": "^1.2.0",
18
- "impit": "^0.14.0"
12
+ "@vinely-ai/sdk": "^0.0.6"
19
13
  },
20
14
  "devDependencies": {
21
15
  "nodemon": "^2.0.2"
@@ -46564,8 +46564,8 @@ var require_customTool = __commonJS({
46564
46564
  const controller = new AbortController();
46565
46565
  const timer = setTimeout(() => controller.abort(), TOOL_TIMEOUT_MS);
46566
46566
  try {
46567
- const res = await fetch(`${SURPH_RPC_URL}/tools/custom`, {
46568
- // const res = await fetch(`http://localhost:8675/tools/custom`, {
46567
+ const rpcBase = process.env.SURPH_CUSTOM_TOOL_RPC || SURPH_RPC_URL;
46568
+ const res = await fetch(`${rpcBase}/tools/custom`, {
46569
46569
  method: "POST",
46570
46570
  headers: { "Content-Type": "application/json" },
46571
46571
  body: JSON.stringify({
@@ -94771,6 +94771,7 @@ ${STREAM_LABEL} provider:${provider} tide:${params?.tide ? "present" : "none"} s
94771
94771
 
94772
94772
  // server/sdk.js
94773
94773
  require_main().config();
94774
+ process.env.SURPH_CUSTOM_TOOL_RPC = "http://localhost:5000";
94774
94775
  var express = require_express2();
94775
94776
  var cors = require_lib3();
94776
94777
  var { handleStreamChat } = require_stream_chat();
@@ -94791,10 +94792,30 @@ var openStream = (res) => {
94791
94792
  });
94792
94793
  return res;
94793
94794
  };
94795
+ var fetchLocalTools = async () => {
94796
+ try {
94797
+ const res = await fetch("http://localhost:5000/tools");
94798
+ if (!res.ok) {
94799
+ console.warn(`sdk: /tools returned HTTP ${res.status}`);
94800
+ return [];
94801
+ }
94802
+ const json2 = await res.json();
94803
+ const map2 = json2?.response;
94804
+ if (!map2 || typeof map2 !== "object") return [];
94805
+ return Object.values(map2);
94806
+ } catch (err) {
94807
+ console.warn("sdk: failed to fetch local tools manifest:", err.message);
94808
+ return [];
94809
+ }
94810
+ };
94794
94811
  app.post("/chat", async (req, res) => {
94795
94812
  try {
94813
+ const body = req.body || {};
94814
+ const tools = await fetchLocalTools();
94815
+ body.session = body.session || {};
94816
+ body.session.user = { ...body.session.user || {}, tools };
94796
94817
  openStream(res);
94797
- await handleStreamChat(req.body || {}, res);
94818
+ await handleStreamChat(body, res);
94798
94819
  res.end();
94799
94820
  } catch (error2) {
94800
94821
  console.error("sdk /chat error:", error2);
@@ -95144,4 +95165,4 @@ object-assign/index.js:
95144
95165
  * limitations under the License.
95145
95166
  *)
95146
95167
  */
95147
- //# sourceMappingURL=sdk.js.map
95168
+ //# sourceMappingURL=chat.js.map