opencode-swarm 6.41.0 → 6.41.1

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.
@@ -106,7 +106,7 @@ export declare function validateAndRecordAttestation(dir: string, findingId: str
106
106
  /**
107
107
  * Checks whether the given agent is authorised to write to the given file path.
108
108
  */
109
- export declare function checkFileAuthority(agentName: string, filePath: string, _cwd: string): {
109
+ export declare function checkFileAuthority(agentName: string, filePath: string, cwd: string): {
110
110
  allowed: true;
111
111
  } | {
112
112
  allowed: false;
package/dist/index.js CHANGED
@@ -41431,6 +41431,9 @@ function isValidTaskId(taskId) {
41431
41431
  if (taskId === null || taskId === undefined) {
41432
41432
  return false;
41433
41433
  }
41434
+ if (typeof taskId !== "string") {
41435
+ return false;
41436
+ }
41434
41437
  const trimmed = taskId.trim();
41435
41438
  return trimmed.length > 0;
41436
41439
  }
@@ -52386,10 +52389,11 @@ function getCurrentTaskId(sessionId) {
52386
52389
  const session = swarmState.agentSessions.get(sessionId);
52387
52390
  return session?.currentTaskId ?? `${sessionId}:unknown`;
52388
52391
  }
52389
- function isInDeclaredScope(filePath, scopeEntries) {
52390
- const resolvedFile = path32.resolve(filePath);
52392
+ function isInDeclaredScope(filePath, scopeEntries, cwd) {
52393
+ const dir = cwd ?? process.cwd();
52394
+ const resolvedFile = path32.resolve(dir, filePath);
52391
52395
  return scopeEntries.some((scope) => {
52392
- const resolvedScope = path32.resolve(scope);
52396
+ const resolvedScope = path32.resolve(dir, scope);
52393
52397
  if (resolvedFile === resolvedScope)
52394
52398
  return true;
52395
52399
  const rel = path32.relative(resolvedScope, resolvedFile);
@@ -52847,7 +52851,7 @@ function createGuardrailsHooks(directory, directoryOrConfig, config3) {
52847
52851
  }
52848
52852
  session.partialGateWarningsIssuedForTask?.delete(session.currentTaskId);
52849
52853
  if (session.declaredCoderScope !== null) {
52850
- const undeclaredFiles = session.modifiedFilesThisCoderTask.map((f) => f.replace(/[\r\n\t]/g, "_")).filter((f) => !isInDeclaredScope(f, session.declaredCoderScope));
52854
+ const undeclaredFiles = session.modifiedFilesThisCoderTask.map((f) => f.replace(/[\r\n\t]/g, "_")).filter((f) => !isInDeclaredScope(f, session.declaredCoderScope, directory));
52851
52855
  if (undeclaredFiles.length >= 1) {
52852
52856
  const safeTaskId = String(session.currentTaskId ?? "").replace(/[\r\n\t]/g, "_");
52853
52857
  session.lastScopeViolation = `Scope violation for task ${safeTaskId}: ` + `${undeclaredFiles.length} undeclared files modified: ` + undeclaredFiles.join(", ");
@@ -53290,9 +53294,11 @@ var AGENT_AUTHORITY_RULES = {
53290
53294
  blockedZones: ["generated"]
53291
53295
  }
53292
53296
  };
53293
- function checkFileAuthority(agentName, filePath, _cwd) {
53297
+ function checkFileAuthority(agentName, filePath, cwd) {
53294
53298
  const normalizedAgent = agentName.toLowerCase();
53295
- const normalizedPath = filePath.replace(/\\/g, "/");
53299
+ const dir = cwd || process.cwd();
53300
+ const resolved = path32.resolve(dir, filePath);
53301
+ const normalizedPath = path32.relative(dir, resolved).replace(/\\/g, "/");
53296
53302
  const rules = AGENT_AUTHORITY_RULES[normalizedAgent];
53297
53303
  if (!rules) {
53298
53304
  return { allowed: false, reason: `Unknown agent: ${agentName}` };
@@ -58966,7 +58972,29 @@ async function executeDeclareScope(args2, fallbackDir) {
58966
58972
  };
58967
58973
  }
58968
58974
  }
58969
- const mergedFiles = [...args2.files, ...args2.whitelist ?? []];
58975
+ const rawMergedFiles = [...args2.files, ...args2.whitelist ?? []];
58976
+ const warnings = [];
58977
+ const normalizeErrors = [];
58978
+ const dir = normalizedDir || fallbackDir || process.cwd();
58979
+ const mergedFiles = rawMergedFiles.map((file3) => {
58980
+ if (path48.isAbsolute(file3)) {
58981
+ const relativePath = path48.relative(dir, file3).replace(/\\/g, "/");
58982
+ if (relativePath.startsWith("..")) {
58983
+ normalizeErrors.push(`Path '${file3}' resolves outside the project directory`);
58984
+ return file3;
58985
+ }
58986
+ warnings.push(`Absolute path normalized to relative: '${relativePath}' (was '${file3}')`);
58987
+ return relativePath;
58988
+ }
58989
+ return file3;
58990
+ });
58991
+ if (normalizeErrors.length > 0) {
58992
+ return {
58993
+ success: false,
58994
+ message: "Validation failed",
58995
+ errors: normalizeErrors
58996
+ };
58997
+ }
58970
58998
  for (const [_sessionId, session] of swarmState.agentSessions) {
58971
58999
  session.declaredCoderScope = mergedFiles;
58972
59000
  session.lastScopeViolation = null;
@@ -58975,7 +59003,8 @@ async function executeDeclareScope(args2, fallbackDir) {
58975
59003
  success: true,
58976
59004
  message: "Scope declared successfully",
58977
59005
  taskId: args2.taskId,
58978
- fileCount: mergedFiles.length
59006
+ fileCount: mergedFiles.length,
59007
+ ...warnings.length > 0 ? { warnings } : {}
58979
59008
  };
58980
59009
  }
58981
59010
  var declare_scope = createSwarmTool({
@@ -64018,13 +64047,13 @@ function validatePath(inputPath, baseDir, workspaceDir) {
64018
64047
  resolved = path56.resolve(baseDir, inputPath);
64019
64048
  }
64020
64049
  const workspaceResolved = path56.resolve(workspaceDir);
64021
- let relative6;
64050
+ let relative7;
64022
64051
  if (isWinAbs) {
64023
- relative6 = path56.win32.relative(workspaceResolved, resolved);
64052
+ relative7 = path56.win32.relative(workspaceResolved, resolved);
64024
64053
  } else {
64025
- relative6 = path56.relative(workspaceResolved, resolved);
64054
+ relative7 = path56.relative(workspaceResolved, resolved);
64026
64055
  }
64027
- if (relative6.startsWith("..")) {
64056
+ if (relative7.startsWith("..")) {
64028
64057
  return "path traversal detected";
64029
64058
  }
64030
64059
  return null;
@@ -22,6 +22,7 @@ export interface DeclareScopeResult {
22
22
  taskId?: string;
23
23
  fileCount?: number;
24
24
  errors?: string[];
25
+ warnings?: string[];
25
26
  }
26
27
  /**
27
28
  * Validate that taskId matches the required format (N.M or N.M.P).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm",
3
- "version": "6.41.0",
3
+ "version": "6.41.1",
4
4
  "description": "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",