prior-cli 1.7.7 → 1.7.9

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Prior Network
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Prior CLI
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/prior-cli?color=00ffcc&label=prior-cli)](https://www.npmjs.com/package/prior-cli)
4
+ [![npm downloads](https://img.shields.io/npm/dw/prior-cli?color=8DE0FC)](https://www.npmjs.com/package/prior-cli)
5
+ [![license](https://img.shields.io/npm/l/prior-cli)](./LICENSE)
6
+ [![node](https://img.shields.io/node/v/prior-cli)](https://nodejs.org)
7
+
3
8
  **Prior** is an AI assistant for your terminal — built on the Prior Network platform.
4
9
 
5
10
  ```
@@ -62,8 +67,14 @@ Prior will list the directory, check file sizes, and report back — all in one
62
67
  |---|---|
63
68
  | `/help` | Show available commands |
64
69
  | `/clear` | Clear the conversation |
65
- | `/uncensored` | Enable uncensored mode |
66
- | `/censored` | Return to default mode |
70
+ | `/save <name>` | Save the current session |
71
+ | `/load <name>` | Load a saved session |
72
+ | `/saves` | List all saved sessions |
73
+ | `/delete <name>` | Delete a saved session |
74
+ | `/timer <duration>` | Start a countdown timer (e.g. `30s`, `5m`, `1m30s`) |
75
+ | `/update` | Check for updates and install if behind |
76
+ | `/uncensored` | Load Prior Uncensored model |
77
+ | `/censored` | Load Prior Standard model |
67
78
  | `/exit` | Exit the CLI |
68
79
 
69
80
  ## Tips
@@ -75,7 +86,7 @@ Prior will list the directory, check file sizes, and report back — all in one
75
86
  ## Requirements
76
87
 
77
88
  - Node.js 16+
78
- - A [Prior Network](https://prior.ngrok.app) account
89
+ - A [Prior Network](https://priornetwork.com) account
79
90
 
80
91
  ## License
81
92
 
package/bin/prior.js CHANGED
@@ -408,7 +408,7 @@ function banner() {
408
408
  console.log(c.brand(' ██║ ██║ ██║██║╚██████╔╝██║ ██║'));
409
409
  console.log(c.brand(' ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═╝'));
410
410
  console.log('');
411
- console.log(c.muted(` v${version} · prior.ngrok.app`));
411
+ console.log(c.muted(` v${version} · priornetwork.com`));
412
412
  console.log('');
413
413
  }
414
414
 
@@ -692,7 +692,7 @@ async function loginViaBrowser() {
692
692
 
693
693
  // Generate a random state token to match the browser session to this CLI wait
694
694
  const state = crypto.randomBytes(16).toString('hex');
695
- const url = `https://prior.ngrok.app/cli-auth?state=${state}`;
695
+ const url = `https://priornetwork.com/cli-auth?state=${state}`;
696
696
 
697
697
  await open(url).catch(() => {
698
698
  process.stdout.write('\n');
@@ -701,7 +701,7 @@ async function loginViaBrowser() {
701
701
 
702
702
  // Long-poll the CLI backend until browser completes login (3 min timeout handled server-side)
703
703
  const fetch = require('node-fetch');
704
- const res = await fetch(`https://prior.ngrok.app/cli-backend/wait?state=${state}`, {
704
+ const res = await fetch(`https://priornetwork.com/cli-backend/wait?state=${state}`, {
705
705
  timeout: 185000,
706
706
  });
707
707
 
@@ -1493,7 +1493,7 @@ Be concise but thorough — this summary replaces the full history to save conte
1493
1493
  ];
1494
1494
 
1495
1495
  const token = require('../lib/config').getToken();
1496
- const res = await fetch('https://prior.ngrok.app/cli-backend/api/infer', {
1496
+ const res = await fetch('https://priornetwork.com/cli-backend/api/infer', {
1497
1497
  method: 'POST',
1498
1498
  headers: { 'Content-Type': 'application/json' },
1499
1499
  body: JSON.stringify({ messages: compactPrompt, model: currentModel, token, cwd: process.cwd() }),
package/lib/agent.js CHANGED
@@ -4,8 +4,8 @@ const fetch = require('node-fetch');
4
4
  const { executeTool, TOOL_NAMES } = require('./tools');
5
5
  const { getToken, getUsername } = require('./config');
6
6
 
7
- const CLI_BASE = 'https://prior.ngrok.app/cli-backend';
8
- const PRIOR_BASE = 'https://prior.ngrok.app';
7
+ const CLI_BASE = 'https://priornetwork.com/cli-backend';
8
+ const PRIOR_BASE = 'https://priornetwork.com';
9
9
  const MAX_ITER = 14;
10
10
 
11
11
  // ── Single inference call ─────────────────────────────────────
@@ -300,7 +300,7 @@ async function runAgent({ messages, model, uncensored, cwd, projectContext, imag
300
300
  const approved = await confirm({ name: call.name, args: call.args });
301
301
  if (!approved) {
302
302
  send({ type: 'tool_skip', name: call.name });
303
- resultParts.push(`<tool_result name="${call.name}">\nUser declined action was not executed.\n</tool_result>`);
303
+ resultParts.push(`<tool_result name="${call.name}">\nThe user declined this action. Do NOT retry it, rephrase it, or attempt a workaround — that would go against their explicit choice. Simply acknowledge and move on, or ask what they'd like to do instead.\n</tool_result>`);
304
304
  continue;
305
305
  }
306
306
  }
@@ -310,6 +310,16 @@ async function runAgent({ messages, model, uncensored, cwd, projectContext, imag
310
310
  // Pass output snippet so the CLI can show a rich preview
311
311
  send({ type: 'tool_done', name: call.name, summary: toolResult.summary, preview: toolResult.output, weather: toolResult.weather });
312
312
  resultParts.push(`<tool_result name="${call.name}">\n${toolResult.output}\n</tool_result>`);
313
+
314
+ // generate_image pre-generates its caption before queuing (queuing kills Ollama
315
+ // for VRAM) — emit it directly as the final response instead of looping back
316
+ // into infer(), which would race the ~65-70s restart+prewarm cycle
317
+ if (call.name === 'generate_image' && toolResult.preDescription && call === calls[calls.length - 1]) {
318
+ await trackTokenUsage(token, totalPromptTokens, totalCompletionTokens);
319
+ send({ type: 'text', content: toolResult.preDescription });
320
+ send({ type: 'done', promptTokens: totalPromptTokens, completionTokens: totalCompletionTokens });
321
+ return;
322
+ }
313
323
  } catch (err) {
314
324
  send({ type: 'tool_error', name: call.name, error: err.message });
315
325
  resultParts.push(`<tool_result name="${call.name}">\nERROR: ${err.message}\n</tool_result>`);
package/lib/api.js CHANGED
@@ -3,8 +3,8 @@
3
3
  const fetch = require('node-fetch');
4
4
  const { getToken } = require('./config');
5
5
 
6
- const BASE = 'https://prior.ngrok.app';
7
- const CLI_BASE = 'https://prior.ngrok.app/cli-backend';
6
+ const BASE = 'https://priornetwork.com';
7
+ const CLI_BASE = 'https://priornetwork.com/cli-backend';
8
8
 
9
9
  // ── Infer — single AI call, returns { content, promptTokens, completionTokens }
10
10
 
package/lib/tools.js CHANGED
@@ -1,12 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  const fs = require('fs');
4
+ const os = require('os');
4
5
  const path = require('path');
5
6
  const { exec } = require('child_process');
6
7
  const fetch = require('node-fetch');
7
8
 
8
- const CLI_BASE = 'https://prior.ngrok.app/cli-backend';
9
- const PRIOR_BASE = 'https://prior.ngrok.app';
9
+ const CLI_BASE = 'https://priornetwork.com/cli-backend';
10
+ const PRIOR_BASE = 'https://priornetwork.com';
10
11
  const MAX_FILE_SIZE = 500 * 1024; // 500 KB
11
12
 
12
13
  const BLOCKED_PATTERNS = [
@@ -269,6 +270,22 @@ const TOOLS = {
269
270
  const totalSteps = steps || 20;
270
271
  const authHdr = token ? { Authorization: `Bearer ${token}` } : {};
271
272
 
273
+ // Pre-generate the caption BEFORE queuing — queuing kills Ollama for VRAM right
274
+ // after, and the restart+prewarm cycle outlasts a normal post-gen inference call
275
+ let preDescription = null;
276
+ try {
277
+ const descRes = await fetch(`${CLI_BASE}/api/describe-image`, {
278
+ method: 'POST',
279
+ headers: { 'Content-Type': 'application/json' },
280
+ body: JSON.stringify({ prompt, token }),
281
+ timeout: 30000,
282
+ });
283
+ if (descRes.ok) {
284
+ const d = await descRes.json();
285
+ preDescription = (d.description || '').trim() || null;
286
+ }
287
+ } catch { /* non-fatal — falls back to a normal post-gen description */ }
288
+
272
289
  // Step 1: Queue
273
290
  const queueRes = await fetch(`${CLI_BASE}/api/generate-image/queue`, {
274
291
  method: 'POST',
@@ -319,11 +336,22 @@ const TOOLS = {
319
336
  }
320
337
  const data = await wmRes.json();
321
338
  if (!data.filename || !data.data) throw new Error('Invalid response from image generation service');
322
- const savePath = path.join(cwd, data.filename);
323
- fs.writeFileSync(savePath, Buffer.from(data.data, 'base64'));
339
+ const buffer = Buffer.from(data.data, 'base64');
340
+ let savePath = path.join(cwd, data.filename);
341
+ try {
342
+ fs.writeFileSync(savePath, buffer);
343
+ } catch (err) {
344
+ if (err.code !== 'EPERM' && err.code !== 'EACCES') throw err;
345
+ // cwd requires elevated permissions (e.g. C:\Windows\System32) — fall back to Downloads
346
+ const downloads = path.join(os.homedir(), 'Downloads');
347
+ if (!fs.existsSync(downloads)) fs.mkdirSync(downloads, { recursive: true });
348
+ savePath = path.join(downloads, data.filename);
349
+ fs.writeFileSync(savePath, buffer);
350
+ }
324
351
  return {
325
352
  output: `Image saved to: ${savePath}`,
326
353
  summary: savePath,
354
+ preDescription,
327
355
  };
328
356
  },
329
357
 
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "prior-cli",
3
- "version": "1.7.7",
3
+ "version": "1.7.9",
4
4
  "description": "Prior Network AI — command-line interface",
5
5
  "author": "Prior Network",
6
- "homepage": "https://prior.ngrok.app",
6
+ "homepage": "https://priornetwork.com",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "https://github.com/Niceguygamer/prior-cli.git"