tune-sdk 0.2.22 → 0.2.24

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/README.md CHANGED
@@ -15,7 +15,7 @@ install tune-sdk
15
15
  ```bash
16
16
  npm install -g tune-sdk
17
17
 
18
- tune-sdk init
18
+ tune init
19
19
  ```
20
20
 
21
21
  edit `~/.tune/.env` file and add `OPENAI_KEY` and other keys
@@ -64,8 +64,8 @@ require('tune-models')
64
64
 
65
65
  MD1 --> |cli middlewares| CTX
66
66
  MD2 --> |app middlewares| CTX
67
- Editor -->| $ tune-sdk rpc | Core
68
- CLI --> | $ tune-sdk --user hello | Core
67
+ Editor -->| $ tune rpc | Core
68
+ CLI --> | $ tune --user hello | Core
69
69
  App --> Core
70
70
 
71
71
 
@@ -85,6 +85,8 @@ Extend Tune with middlewares:
85
85
  * [tune-basic-toolset](https://www.npmjs.com/package/tune-basic-toolset) - basic tools like read file, write file, shell etc.
86
86
  * [tune-s3](https://www.npmjs.com/package/tune-s3) - read/write files from s3
87
87
  * [tune-mcp](https://www.npmjs.com/package/tune-mcp) - connect tools from mcp servers
88
+ * [maik](https://www.npmjs.com/package/@iovdin/maik) - fetch all you emails, and index them into sqlite database
89
+
88
90
 
89
91
  For example:
90
92
  ```sh
@@ -136,14 +138,14 @@ image generated
136
138
  npm install -g tune-sdk
137
139
 
138
140
  # append user message to newchat.chat run and save
139
- tune-sdk --user "hi how are you?" --filename newchat.chat --save
141
+ tune --user "hi how are you?" --filename newchat.chat --save
140
142
 
141
143
  # start new chat with system prompt and initial user message
142
144
  # print result to console
143
- tune-sdk --system "You are Groot" --user "Hi how are you?"
145
+ tune --system "You are Groot" --user "Hi how are you?"
144
146
 
145
147
  #set context variable
146
- tune-sdk --set-test "hello" --user "@test" --system "You are echo you print everythting back"
148
+ tune --set-test "hello" --user "@test" --system "You are echo you print everythting back"
147
149
  ```
148
150
 
149
151
 
@@ -15,8 +15,8 @@ module.exports = [
15
15
  basics(),
16
16
  tunefs({ paths: dirs, makeSchema: true }),
17
17
  models({
18
- default: "gpt-5-mini",
19
- alias: { "sonnet": "claude-sonnet-4-20250514"}
18
+ default: "gpt-5.4",
19
+ alias: { "sonnet": "claude-sonnet-4-6"}
20
20
  }),
21
21
  writer()
22
22
  ]
package/dist/tune.js CHANGED
@@ -1195,6 +1195,8 @@ Context.prototype.envmd = envmd;
1195
1195
  Context.prototype.text2roles = text2roles;
1196
1196
  Context.prototype.roles2text = roles2text;
1197
1197
  Context.prototype.text2call = text2call;
1198
+ Context.prototype.escape = escape;
1199
+ Context.prototype.unescape = unescape;
1198
1200
  Context.prototype.read = (async function(name, args) {
1199
1201
  var resolved, _ref;
1200
1202
  var resolved;
@@ -2280,7 +2282,7 @@ function text2run(text, ctx, opts) {
2280
2282
  }
2281
2283
  text2run;
2282
2284
  async function file2run(args, params, ctx) {
2283
- var lctx, text, stop, errors, turnsSaved, longFormatRegex, isLong, initialText, node, response, res, r, chunk, itergeNE023, _ref;
2285
+ var lctx, text, stop, errors, turnsSaved, node, longFormatRegex, isLong, initialText, response, res, r, chunk, itergMKZ8fG, _ref;
2284
2286
  var lctx;
2285
2287
  lctx = ctx.clone();
2286
2288
  if (params) lctx.ms.unshift(envmd(params));
@@ -2288,10 +2290,12 @@ async function file2run(args, params, ctx) {
2288
2290
  var stop;
2289
2291
  var errors;
2290
2292
  var turnsSaved;
2293
+ var node;
2291
2294
  text = args.text;
2292
2295
  stop = (((typeof args !== "undefined") && (args !== null) && !Number.isNaN(args) && (typeof args.stop !== "undefined") && (args.stop !== null) && !Number.isNaN(args.stop)) ? args.stop : (((typeof "assistant" !== "undefined") && ("assistant" !== null) && !Number.isNaN("assistant")) ? "assistant" : undefined));
2293
2296
  errors = (((typeof args !== "undefined") && (args !== null) && !Number.isNaN(args) && (typeof args.errors !== "undefined") && (args.errors !== null) && !Number.isNaN(args.errors)) ? args.errors : (((typeof "throw" !== "undefined") && ("throw" !== null) && !Number.isNaN("throw")) ? "throw" : undefined));
2294
2297
  turnsSaved = 0;
2298
+ node = null;
2295
2299
  var longFormatRegex;
2296
2300
  var isLong;
2297
2301
  longFormatRegex = /^(system|user|tool_call|tool_result|assistant|error):/;
@@ -2312,19 +2316,21 @@ async function file2run(args, params, ctx) {
2312
2316
  initialText = (args.system ? tpl("system:\n{system}", args) : "");
2313
2317
  if (args.filename) {
2314
2318
  node = await ctx.resolve(args.filename);
2315
- node ? lctx.stack.push(node) : lctx.stack.push({
2316
- name: args.filename,
2317
- type: "text",
2318
- fullname: args.filename,
2319
- read: (async function() {
2320
- return initialText;
2321
- })
2322
- });
2323
2319
  if ((node && !text)) text = await node.read();
2324
2320
  }
2325
2321
  if ((!text && args.system)) text = initialText;
2326
2322
  text = text || "";
2327
2323
  if (args.user) text += ((text ? "\n" : "") + tpl("user:\n{user}", args));
2324
+ node = node || {
2325
+ type: "text"
2326
+ }
2327
+ node.name = args.filename;
2328
+ node.fullname = args.filename;
2329
+ node.mimetype = "text/chat";
2330
+ node.read = (async function() {
2331
+ return text;
2332
+ });
2333
+ lctx.stack.push(node);
2328
2334
  if (!text) throw new TuneError("ether 'text' or 'system' or 'user' should be specified or 'filename' should exist ");
2329
2335
  isLong = longFormatRegex.test(text);
2330
2336
  var response;
@@ -2368,7 +2374,7 @@ async function file2run(args, params, ctx) {
2368
2374
  hookTurnEnd: save
2369
2375
  });
2370
2376
  chunk = {};
2371
- itergeNE023 = new AsyncIter();
2377
+ itergMKZ8fG = new AsyncIter();
2372
2378
  (async function($lastRes) {
2373
2379
  var _ref;
2374
2380
  try {
@@ -2376,20 +2382,20 @@ async function file2run(args, params, ctx) {
2376
2382
  chunk = await r.next();
2377
2383
  res = (chunk.value || "");
2378
2384
  $lastRes = transformOutput(res) || $lastRes;
2379
- itergeNE023.result = {
2385
+ itergMKZ8fG.result = {
2380
2386
  value: $lastRes
2381
2387
  }
2382
2388
  }
2383
- _ref = itergeNE023.result = {
2389
+ _ref = itergMKZ8fG.result = {
2384
2390
  value: $lastRes,
2385
2391
  done: true
2386
2392
  }
2387
2393
  } catch (e) {
2388
- _ref = (itergeNE023.err = e);
2394
+ _ref = (itergMKZ8fG.err = e);
2389
2395
  }
2390
2396
  return _ref;
2391
2397
  })();
2392
- _ref = itergeNE023;
2398
+ _ref = itergMKZ8fG;
2393
2399
  }
2394
2400
  return _ref;
2395
2401
  }
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "tune-sdk",
3
- "version": "0.2.22",
3
+ "version": "0.2.24",
4
4
  "description": "tune - LLM chat in text file",
5
5
  "main": "dist/tune.js",
6
6
  "module": "dist/tune.mjs",
7
- "bin": "bin/cli.js",
7
+ "bin": {
8
+ "tune": "bin/cli.js",
9
+ "tune-sdk": "bin/cli.js"
10
+ },
8
11
  "exports": {
9
12
  ".": {
10
13
  "require": "./dist/tune.js",
package/src/cli.js CHANGED
@@ -1,6 +1,16 @@
1
1
  var assert, tune, rpc, path, fs, os, cp, stream;
2
2
  assert = require("assert");
3
3
 
4
+
5
+ // tune app - run web server from current directory serving index.html and making it availble to call ctx via websocket
6
+ // tune ps - list of executing agents or the ones finished
7
+ // tune spawn - spawn an agent
8
+ // tune kill - kill/stop agent
9
+ // tune serve - tune manage server, run in background and spawn agents
10
+ // tune - execute call/file and quit
11
+ // tune rpc - run rpc server
12
+
13
+
4
14
  function tpl(str) {
5
15
  var _i;
6
16
  var params = 2 <= arguments.length ? [].slice.call(arguments, 1, _i = arguments.length - 0) : (_i = 1, []);
@@ -21,10 +31,10 @@ function tpl(str) {
21
31
  }
22
32
 
23
33
  function showHelp() {
24
- console.log("TUNE-CLI - Command Line Interface for Tune SDK");
34
+ console.log("TUNE-CLI - Command Line Interface for Tune");
25
35
  console.log("");
26
36
  console.log("USAGE:");
27
- console.log(" tune-sdk [cmd] [OPTIONS]");
37
+ console.log(" tune [cmd] [OPTIONS]");
28
38
  console.log("");
29
39
  console.log("COMMANDS:");
30
40
  console.log(" rpc Start RPC server mode");
@@ -32,19 +42,19 @@ function showHelp() {
32
42
  console.log("");
33
43
  console.log("EXAMPLES:");
34
44
  console.log(" # Quick chat with system prompt");
35
- console.log(" tune-sdk --system \"You are Groot\" --user \"Hi how are you?\"");
45
+ console.log(" tune --system \"You are Groot\" --user \"Hi how are you?\"");
36
46
  console.log("");
37
47
  console.log(" # Continue existing chat");
38
- console.log(" tune-sdk --user \"continue the conversation\" --filename chat.chat --save");
48
+ console.log(" tune --user \"continue the conversation\" --filename chat.chat --save");
39
49
  console.log("");
40
50
  console.log(" # Set context variables");
41
- console.log(" tune-sdk --set-test=hello --user \"@test\" --system \"Echo assistant\"");
51
+ console.log(" tune --set-test=hello --user \"@test\" --system \"Echo assistant\"");
42
52
  console.log("");
43
53
  console.log(" # RPC mode for editor integration");
44
- console.log(" tune-sdk rpc");
54
+ console.log(" tune rpc");
45
55
  console.log("");
46
56
  console.log(" # Initialize or reinitialize config directory");
47
- console.log(" tune-sdk init --force");
57
+ console.log(" tune init --force");
48
58
  console.log("");
49
59
  console.log("OPTIONS:");
50
60
  console.log(" --user <text> User message to send");
@@ -80,8 +90,8 @@ function validateArgs(args) {
80
90
  if (!!args.debug) assert(typeof args.debug === "boolean" || typeof args.debug === "string", "--debug must be a boolean");
81
91
  if (!!args.silent) assert(typeof args.silent === "boolean", "--silent must be a boolean");
82
92
  if (!!args.force) assert(typeof args.force === "boolean", "--force must be a boolean");
83
- if (typeof args.rpc !== "undefined") assert(false, "Use 'tune-sdk rpc' instead of --rpc");
84
- if (typeof args.forceInit !== "undefined") assert(false, "Use 'tune-sdk init --force' instead of --force-init");
93
+ if (typeof args.rpc !== "undefined") assert(false, "Use 'tune rpc' instead of --rpc");
94
+ if (typeof args.forceInit !== "undefined") assert(false, "Use 'tune init --force' instead of --force-init");
85
95
  if (args.params) assert(!!args.params && (typeof args.params === "object"), "--set-* parameters must form a valid object");
86
96
  if ((args.stop && (typeof args.stop === "string"))) assert((args.stop === "assistant") || (args.stop === "step") || (args.stop.length > 0), "--stop must be 'assistant', 'step', or a non-empty custom string");
87
97
  if (args.cmd) {
@@ -189,26 +199,26 @@ async function initConfig(args) {
189
199
  homedir = getHomedir(args);
190
200
  assert(typeof homedir === "string", "Home directory must be a string");
191
201
  if ((!args.force && fs.existsSync(homedir))) return;
192
- console.error("[tune-sdk] initialize " + homedir);
202
+ console.error("[tune] initialize " + homedir);
193
203
  fs.mkdirSync(homedir, {
194
204
  recursive: true
195
205
  });
196
- console.error("[tune-sdk] copying files");
206
+ console.error("[tune] copying files");
197
207
  fs.cpSync(path.resolve(__dirname, "../config"), path.resolve(homedir), { recursive: true });
198
- console.error("[tune-sdk] installing npm");
208
+ console.error("[tune] installing npm");
199
209
  try {
200
210
  _ref = cp.execSync("npm i", {
201
211
  cwd: homedir,
202
212
  encoding: "utf8"
203
213
  });
204
214
  stdout = _ref;
205
- if (stdout.trim()) console.error("[tune-sdk]", stdout.trim());
206
- //stderr.trim() ? console.error("[tune-sdk]", stderr.trim()) : undefined;
215
+ if (stdout.trim()) console.error("[tune]", stdout.trim());
216
+ //stderr.trim() ? console.error("[tune]", stderr.trim()) : undefined;
207
217
  } catch (err) {
208
218
  console.error(err)
209
219
  }
210
- console.error("[tune-sdk] done");
211
- console.error(`[tune-sdk] edit ${homedir}/.env and add OPENAI_KEY and other keys, change ${homedir}/default.ctx.js to customize tune`);
220
+ console.error("[tune] done");
221
+ console.error(`[tune] edit ${homedir}/.env and add OPENAI_KEY and other keys, change ${homedir}/default.ctx.js to customize tune`);
212
222
  }
213
223
  initConfig;
214
224
  async function suggest(params, ctx) {