@vtstech/pi-shared 1.1.0 → 1.1.2-dev

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
@@ -9,9 +9,9 @@ This is an internal dependency — you don't need to install it directly. It's p
9
9
  | Module | Description |
10
10
  |--------|-------------|
11
11
  | `format` | Section headers, indicators (ok/fail/warn/info), numeric formatters (bytes, ms, percentages), string utilities |
12
- | `ollama` | Ollama base URL resolution, models.json I/O, model family detection, Ollama API helpers |
13
- | `security` | Command blocklist, SSRF patterns, path validation, URL validation, command sanitization, audit logging |
14
- | `types` | Custom error classes, type definitions (ToolSupportLevel, StepResultType, AuditEntry, etc.) |
12
+ | `ollama` | Ollama base URL resolution, models.json I/O with TTL cache, model family detection, provider detection, Ollama API helpers |
13
+ | `security` | Command blocklist (65), SSRF patterns (29), path validation with symlink dereference, URL validation, command sanitization, audit logging (`AUDIT_LOG_PATH` exported) |
14
+ | `types` | Type definitions (ToolSupportLevel, AuditEntry, etc.) |
15
15
 
16
16
  ## Usage
17
17
 
package/ollama.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import * as fs from "node:fs";
3
3
  import * as path from "node:path";
4
4
  import os from "node:os";
5
- var EXTENSION_VERSION = "1.1.0";
5
+ var EXTENSION_VERSION = "1.1.2-dev";
6
6
  var MODELS_JSON_PATH = path.join(os.homedir(), ".pi", "agent", "models.json");
7
7
  var _modelsJsonCache = null;
8
8
  var _ollamaBaseUrlCache = null;
@@ -102,7 +102,7 @@ async function fetchContextLengthsBatched(baseUrl, modelNames, batchSize = 3) {
102
102
  }
103
103
  function isReasoningModel(name) {
104
104
  const lower = name.toLowerCase();
105
- return lower.includes("deepseek-r1") || lower.includes("qwq") || lower.includes("o1") || lower.includes("o3") || lower.includes("qwen3") || lower.includes("reasoning") || lower.includes("thinker");
105
+ return lower.includes("deepseek-r1") || lower.includes("qwq") || /\bo1\b/.test(lower) || /\bo3\b/.test(lower) || lower.includes("qwen3") || lower.includes("reasoning") || lower.includes("thinker") || lower.includes("thinking");
106
106
  }
107
107
  var BUILTIN_PROVIDERS = {
108
108
  openrouter: { api: "openai-completions", baseUrl: "https://openrouter.ai/api/v1", envKey: "OPENROUTER_API_KEY" },
package/package.json CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
2
  "name": "@vtstech/pi-shared",
3
- "version": "1.1.0",
3
+ "version": "1.1.2-dev",
4
4
  "description": "Shared utilities for Pi Coding Agent extensions",
5
- "main": "index.js",
6
- "types": "index.d.ts",
5
+ "exports": {
6
+ "./format": "./format.js",
7
+ "./ollama": "./ollama.js",
8
+ "./security": "./security.js",
9
+ "./types": "./types.js"
10
+ },
7
11
  "keywords": ["pi-extensions"],
8
12
  "license": "MIT",
9
13
  "access": "public",
package/security.js CHANGED
@@ -79,12 +79,13 @@ var BLOCKED_COMMANDS = /* @__PURE__ */ new Set([
79
79
  "man"
80
80
  ]);
81
81
  var BLOCKED_URL_PATTERNS = /* @__PURE__ */ new Set([
82
- // Loopback
82
+ // Loopback (full 127.0.0.0/8 range)
83
83
  "localhost",
84
- "127.0.0.1",
84
+ "127.",
85
85
  "0.0.0.0",
86
86
  "::1",
87
87
  "::ffff:127.0.0.1",
88
+ "::ffff:0.0.0.0",
88
89
  // RFC1918 private ranges
89
90
  "10.",
90
91
  "192.168.",
@@ -135,6 +136,10 @@ function validatePath(filePath, allowedDirs) {
135
136
  let resolved;
136
137
  try {
137
138
  resolved = path.resolve(filePath);
139
+ try {
140
+ resolved = fs.realpathSync(resolved);
141
+ } catch {
142
+ }
138
143
  } catch {
139
144
  return { valid: false, error: "Invalid path format" };
140
145
  }
@@ -179,7 +184,8 @@ function isSafeUrl(url, blockSsrf = true) {
179
184
  try {
180
185
  parsed = new URL(url);
181
186
  } catch (e) {
182
- return { safe: false, error: `Invalid URL format: ${e.message}` };
187
+ const msg = e instanceof Error ? e.message : String(e);
188
+ return { safe: false, error: `Invalid URL format: ${msg}` };
183
189
  }
184
190
  const scheme = parsed.protocol.replace(":", "").toLowerCase();
185
191
  if (scheme !== "http" && scheme !== "https") {
package/index.js DELETED
@@ -1,4 +0,0 @@
1
- module.exports.format = require("./format");
2
- module.exports.ollama = require("./ollama");
3
- module.exports.security = require("./security");
4
- module.exports.types = require("./types");