opencode-router 0.11.206 → 0.11.208

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 CHANGED
@@ -2,7 +2,7 @@ Copyright (c) 2026-present Different AI, Inc.
2
2
 
3
3
  Portions of this software are licensed as follows:
4
4
 
5
- * All content that resides under the /ee directory of this repository (Fair Source License) is licensed under the license defined in "ee/LICENSE".
5
+ * All content that resides under the /ee directory of this repository is licensed under the license defined in "ee/LICENSE" (Fair Source License).
6
6
  * All third party components incorporated into the OpenWork Software are licensed under the original license provided by the owner of the applicable component.
7
7
  * Content outside of the above mentioned directories or restrictions above is available under the "MIT" license as defined below.
8
8
 
package/dist/bridge.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { setTimeout as delay } from "node:timers/promises";
2
2
  import { createHash } from "node:crypto";
3
3
  import { readFile, stat } from "node:fs/promises";
4
- import { isAbsolute, join, relative, resolve, sep } from "node:path";
4
+ import { isAbsolute, join, resolve } from "node:path";
5
5
  import { readConfigFile, writeConfigFile } from "./config.js";
6
6
  import { BridgeStore } from "./db.js";
7
7
  import { classifyDeliveryError } from "./delivery.js";
@@ -10,6 +10,7 @@ import { startHealthServer } from "./health.js";
10
10
  import { normalizeOutboundParts, summarizeInboundPartsForPrompt, summarizeInboundPartsForReporter, textFromInboundParts } from "./media.js";
11
11
  import { MediaStore } from "./media-store.js";
12
12
  import { buildPermissionRules, createClient } from "./opencode.js";
13
+ import { isWithinWorkspaceRootPath, normalizeScopedDirectoryPath } from "./path-scope.js";
13
14
  import { chunkText, formatInputSummary, truncateText } from "./text.js";
14
15
  import { createSlackAdapter } from "./slack.js";
15
16
  import { createTelegramAdapter, isTelegramPeerId } from "./telegram.js";
@@ -302,27 +303,14 @@ export async function startBridge(config, logger, reporter, deps = {}) {
302
303
  const sessionModels = new Map();
303
304
  const typingLoops = new Map();
304
305
  const formatPeer = (_channel, peerId) => peerId;
305
- const normalizeDirectory = (input) => {
306
- const trimmed = input.trim();
307
- if (!trimmed)
308
- return "";
309
- const unified = trimmed.replace(/\\/g, "/");
310
- const withoutTrailing = unified.replace(/\/+$/, "");
311
- const normalized = withoutTrailing || "/";
312
- return process.platform === "win32" ? normalized.toLowerCase() : normalized;
313
- };
306
+ const normalizeDirectory = (input) => normalizeScopedDirectoryPath(input, process.platform);
314
307
  const workspaceRootNormalized = normalizeDirectory(workspaceRoot);
315
308
  const isWithinWorkspaceRoot = (candidate) => {
316
- const resolved = resolve(candidate || workspaceRoot);
317
- const relativePath = relative(workspaceRoot, resolved);
318
- if (!relativePath)
319
- return true;
320
- if (relativePath === ".")
321
- return true;
322
- if (relativePath.startsWith("..") || isAbsolute(relativePath))
323
- return false;
324
- const boundary = workspaceRoot.endsWith(sep) ? workspaceRoot : `${workspaceRoot}${sep}`;
325
- return resolved === workspaceRoot || resolved.startsWith(boundary);
309
+ return isWithinWorkspaceRootPath({
310
+ workspaceRoot,
311
+ candidate,
312
+ platform: process.platform,
313
+ });
326
314
  };
327
315
  const resolveScopedDirectory = (input) => {
328
316
  const trimmed = input.trim();
@@ -0,0 +1,35 @@
1
+ import { isAbsolute, relative, resolve } from "node:path";
2
+ export function normalizeScopedDirectoryPath(input, platform = process.platform) {
3
+ const trimmed = input.trim();
4
+ if (!trimmed)
5
+ return "";
6
+ const withoutVerbatim = /^\\\\\?\\UNC[\\/]/i.test(trimmed)
7
+ ? `\\${trimmed.slice(8)}`
8
+ : /^\\\\\?\\[a-zA-Z]:[\\/]/.test(trimmed)
9
+ ? trimmed.slice(4)
10
+ : trimmed;
11
+ const unified = withoutVerbatim.replace(/\\/g, "/");
12
+ const withoutTrailing = unified.replace(/\/+$/, "");
13
+ const normalized = withoutTrailing || "/";
14
+ return platform === "win32" ? normalized.toLowerCase() : normalized;
15
+ }
16
+ export function isWithinWorkspaceRootPath(input) {
17
+ const platform = input.platform ?? process.platform;
18
+ const rootForComparison = platform === "win32"
19
+ ? normalizeScopedDirectoryPath(input.workspaceRoot, platform)
20
+ : input.workspaceRoot;
21
+ const resolved = resolve(input.candidate || input.workspaceRoot);
22
+ const resolvedForComparison = platform === "win32"
23
+ ? normalizeScopedDirectoryPath(resolved, platform)
24
+ : resolved;
25
+ const relativePath = relative(rootForComparison, resolvedForComparison);
26
+ if (!relativePath || relativePath === ".")
27
+ return true;
28
+ if (relativePath.startsWith("..") || isAbsolute(relativePath))
29
+ return false;
30
+ const boundary = rootForComparison.endsWith("/")
31
+ ? rootForComparison
32
+ : `${rootForComparison}/`;
33
+ return (resolvedForComparison === rootForComparison ||
34
+ resolvedForComparison.startsWith(boundary));
35
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-router",
3
- "version": "0.11.206",
3
+ "version": "0.11.208",
4
4
  "description": "opencode-router: Slack + Telegram bridge + directory routing for a running opencode server",
5
5
  "private": false,
6
6
  "type": "module",
@@ -29,7 +29,7 @@
29
29
  "install.sh"
30
30
  ],
31
31
  "dependencies": {
32
- "@opencode-ai/sdk": "^1.1.31",
32
+ "@opencode-ai/sdk": "^1.4.9",
33
33
  "@slack/socket-mode": "^2.0.5",
34
34
  "@slack/web-api": "^7.13.0",
35
35
  "commander": "^12.1.0",