@iroaxel/arcena 4.3.157

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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../ggcoder/src/core/pixel-fix.ts","../../ggcoder/src/core/pixel-fix-agent.ts","../../ggcoder/src/core/source-maps.ts","../../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/src/vlq.ts","../../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/src/strings.ts","../../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/src/scopes.ts","../../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/src/sourcemap-codec.ts","../../../node_modules/.pnpm/@jridgewell+resolve-uri@3.1.2/node_modules/@jridgewell/resolve-uri/src/resolve-uri.ts","../../../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/src/trace-mapping.ts","../../../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/src/resolve.ts","../../../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/src/strip-filename.ts","../../../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/src/sourcemap-segment.ts","../../../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/src/sort.ts","../../../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/src/by-source.ts","../../../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/src/binary-search.ts","../../../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/src/types.ts","../../../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/src/flatten-map.ts"],"sourcesContent":["import { spawn, type ChildProcess, type SpawnOptions } from \"node:child_process\";\nimport { readFileSync, existsSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport chalk from \"chalk\";\nimport { DEFAULT_INGEST_URL } from \"@iroaxel/gg-pixel\";\nimport { PIXEL_FIX_SYSTEM_PROMPT } from \"./pixel-fix-agent.js\";\nimport { tryResolveStack } from \"./source-maps.js\";\n\ninterface StackFrame {\n file: string;\n line: number;\n col: number;\n fn: string;\n in_app: boolean;\n}\n\ninterface CodeContext {\n file: string;\n error_line: number;\n lines: string[];\n}\n\nexport interface ErrorRow {\n id: string;\n project_id: string;\n fingerprint: string;\n status: string;\n type: string | null;\n message: string | null;\n stack: string | null;\n code_context: string | null;\n runtime: string | null;\n occurrences: number;\n recurrence_count: number;\n branch: string | null;\n}\n\ninterface ProjectMapping {\n name: string;\n path: string;\n secret?: string;\n}\n\nexport type SpawnFn = (\n command: string,\n args: readonly string[],\n options: SpawnOptions,\n) => ChildProcess;\n\nexport interface FixOptions {\n ingestUrl?: string;\n homeDir?: string;\n fetchFn?: typeof fetch;\n spawnFn?: SpawnFn;\n ggcoderBin?: string;\n inheritStdio?: boolean;\n maxTurns?: number;\n}\n\nexport interface FixResult {\n errorId: string;\n projectName: string;\n branch: string;\n outcome: \"awaiting_review\" | \"failed\";\n reason: string;\n}\n\nexport async function fixError(errorId: string, opts: FixOptions = {}): Promise<FixResult> {\n const ingestUrl = (opts.ingestUrl ?? DEFAULT_INGEST_URL).replace(/\\/+$/, \"\");\n const fetchFn = opts.fetchFn ?? fetch;\n const home = opts.homeDir ?? homedir();\n\n const owner = await resolveErrorOwner(fetchFn, ingestUrl, errorId, home);\n const { error, project, secret } = owner;\n\n const branch = `fix/pixel-${error.id}`;\n await patchError(fetchFn, ingestUrl, error.id, { status: \"in_progress\", branch }, secret);\n\n const exitCode = await runAgent({\n cwd: project.path,\n prompt: buildAgentPrompt(error, branch, project.path),\n systemPrompt: PIXEL_FIX_SYSTEM_PROMPT,\n spawnFn: opts.spawnFn ?? spawn,\n ggcoderBin: opts.ggcoderBin ?? \"arcicoder\",\n inheritStdio: opts.inheritStdio ?? true,\n maxTurns: opts.maxTurns ?? 60,\n });\n\n const observed = await observeOutcome(project.path, branch, opts.spawnFn ?? spawn);\n\n let outcome: \"awaiting_review\" | \"failed\";\n let reason: string;\n if (exitCode !== 0) {\n outcome = \"failed\";\n reason = `Agent exited with code ${exitCode}`;\n } else if (!observed.branchExists) {\n outcome = \"failed\";\n reason = `Branch ${branch} was not created`;\n } else if (!observed.hasCommits) {\n outcome = \"failed\";\n reason = `Branch ${branch} has no new commits`;\n } else {\n outcome = \"awaiting_review\";\n reason = `Branch ${branch} created with ${observed.commitCount} commit(s) — ready for review`;\n }\n\n await patchError(fetchFn, ingestUrl, error.id, { status: outcome, branch }, secret);\n\n return { errorId: error.id, projectName: project.name, branch, outcome, reason };\n}\n\nexport interface QueueOptions extends FixOptions {\n onProgress?: (msg: string) => void;\n}\n\nexport async function runQueue(opts: QueueOptions = {}): Promise<{\n fixed: number;\n failed: number;\n total: number;\n}> {\n const ingestUrl = (opts.ingestUrl ?? DEFAULT_INGEST_URL).replace(/\\/+$/, \"\");\n const fetchFn = opts.fetchFn ?? fetch;\n const home = opts.homeDir ?? homedir();\n const log = opts.onProgress ?? ((msg: string) => console.log(msg));\n\n const projectsPath = join(home, \".gg\", \"projects.json\");\n if (!existsSync(projectsPath)) {\n log(chalk.dim(\"No projects registered. Run `arcicoder pixel install` first.\"));\n return { fixed: 0, failed: 0, total: 0 };\n }\n const projects = JSON.parse(readFileSync(projectsPath, \"utf8\")) as Record<string, ProjectMapping>;\n\n const queue: Array<{ projectName: string; errorId: string }> = [];\n for (const [projectId, project] of Object.entries(projects)) {\n if (!project.secret) continue; // legacy entry: cannot list, must re-install\n try {\n const res = await fetchFn(`${ingestUrl}/api/projects/${projectId}/errors?status=open`, {\n headers: { authorization: `Bearer ${project.secret}` },\n });\n if (!res.ok) continue;\n const body = (await res.json()) as { errors: Array<{ id: string }> };\n for (const e of body.errors) {\n queue.push({ projectName: project.name, errorId: e.id });\n }\n } catch {\n // skip unreachable project\n }\n }\n\n if (queue.length === 0) {\n log(chalk.hex(\"#4ade80\")(\"No open errors. Queue is clean.\"));\n return { fixed: 0, failed: 0, total: 0 };\n }\n\n log(chalk.bold(`Fixing ${queue.length} ${queue.length === 1 ? \"error\" : \"errors\"}...`));\n log(\"\");\n\n let fixed = 0;\n let failed = 0;\n for (const item of queue) {\n log(chalk.hex(\"#a78bfa\").bold(`▸ ${item.projectName}`) + chalk.dim(` ${item.errorId}`));\n try {\n const result = await fixError(item.errorId, opts);\n if (result.outcome === \"awaiting_review\") {\n log(chalk.hex(\"#4ade80\")(` ✓ ${result.reason}`));\n fixed++;\n } else {\n log(chalk.hex(\"#ef4444\")(` ✗ ${result.reason}`));\n failed++;\n }\n } catch (err) {\n log(chalk.hex(\"#ef4444\")(` ✗ ${err instanceof Error ? err.message : String(err)}`));\n failed++;\n }\n log(\"\");\n }\n\n return { fixed, failed, total: queue.length };\n}\n\n/**\n * In-Ink fix flow: prepares the fix (fetch, mark in_progress, build prompt) so\n * the caller can hand the prompt to its existing agent loop. Pair with\n * `finalizePixelFix` after the agent run completes.\n */\nexport interface PreparedPixelFix {\n errorId: string;\n projectId: string;\n projectName: string;\n projectPath: string;\n branch: string;\n prompt: string;\n}\n\nexport interface PrepareOptions {\n ingestUrl?: string;\n homeDir?: string;\n fetchFn?: typeof fetch;\n}\n\nexport async function preparePixelFix(\n errorId: string,\n opts: PrepareOptions = {},\n): Promise<PreparedPixelFix> {\n const ingestUrl = (opts.ingestUrl ?? DEFAULT_INGEST_URL).replace(/\\/+$/, \"\");\n const fetchFn = opts.fetchFn ?? fetch;\n const home = opts.homeDir ?? homedir();\n\n const owner = await resolveErrorOwner(fetchFn, ingestUrl, errorId, home);\n const { error, project, secret } = owner;\n const branch = `fix/pixel-${error.id}`;\n\n await patchError(fetchFn, ingestUrl, error.id, { status: \"in_progress\", branch }, secret);\n\n return {\n errorId: error.id,\n projectId: error.project_id,\n projectName: project.name,\n projectPath: project.path,\n branch,\n prompt: buildAgentPrompt(error, branch, project.path),\n };\n}\n\nexport interface FinalizeOptions extends PrepareOptions {\n spawnFn?: SpawnFn;\n agentExitedCleanly?: boolean;\n}\n\nexport async function finalizePixelFix(\n prep: PreparedPixelFix,\n opts: FinalizeOptions = {},\n): Promise<{ outcome: \"awaiting_review\" | \"failed\"; reason: string }> {\n const ingestUrl = (opts.ingestUrl ?? DEFAULT_INGEST_URL).replace(/\\/+$/, \"\");\n const fetchFn = opts.fetchFn ?? fetch;\n const home = opts.homeDir ?? homedir();\n const observed = await observeOutcome(prep.projectPath, prep.branch, opts.spawnFn ?? spawn);\n\n let outcome: \"awaiting_review\" | \"failed\";\n let reason: string;\n if (opts.agentExitedCleanly === false) {\n outcome = \"failed\";\n reason = \"Agent did not finish cleanly\";\n } else if (!observed.branchExists) {\n outcome = \"failed\";\n reason = `Branch ${prep.branch} was not created`;\n } else if (!observed.hasCommits) {\n outcome = \"failed\";\n reason = `Branch ${prep.branch} has no new commits`;\n } else {\n outcome = \"awaiting_review\";\n reason = `Branch ${prep.branch} created with ${observed.commitCount} commit(s) — ready for review`;\n }\n\n const secret = lookupProjectSecret(home, prep.projectId);\n await patchError(\n fetchFn,\n ingestUrl,\n prep.errorId,\n { status: outcome, branch: prep.branch },\n secret,\n );\n return { outcome, reason };\n}\n\nexport function buildAgentPrompt(error: ErrorRow, branch: string, projectDir?: string): string {\n let stack = parseStackJson(error.stack);\n // For browser stacks (URLs in the file field), try to resolve via local\n // source maps before showing the agent. Resolved frames point at the\n // user's TS/JS source — much more actionable than `app.min.js:1:48201`.\n if (projectDir && stack.length > 0 && looksLikeMinifiedBrowserStack(stack)) {\n stack = tryResolveStack(stack, projectDir);\n }\n const ctx = parseCodeContext(error.code_context);\n\n const lines: string[] = [];\n lines.push(\"An error has been identified in this project. Investigate and fix it.\");\n lines.push(\"\");\n lines.push(`Error: ${error.type ?? \"Error\"} — ${error.message ?? \"(no message)\"}`);\n\n const topInApp = stack.find((f) => f.in_app) ?? stack[0];\n if (topInApp) lines.push(`Location: ${topInApp.file}:${topInApp.line}`);\n\n if (ctx && ctx.lines.length > 0) {\n lines.push(\"\");\n lines.push(\"Code at site:\");\n const startLine = ctx.error_line - Math.floor((ctx.lines.length - 1) / 2);\n ctx.lines.forEach((line, i) => {\n const lineNum = startLine + i;\n const marker = lineNum === ctx.error_line ? \">\" : \" \";\n lines.push(` ${marker}${String(lineNum).padStart(4)} | ${line}`);\n });\n }\n\n if (stack.length > 0) {\n lines.push(\"\");\n lines.push(\"Stack:\");\n for (const f of stack.slice(0, 10)) {\n const lib = f.in_app ? \"\" : \" (lib)\";\n lines.push(` ${f.fn || \"<anon>\"} ${f.file}:${f.line}${lib}`);\n }\n }\n\n if (error.runtime) lines.push(`\\nRuntime: ${error.runtime}`);\n lines.push(`Occurrences: ${error.occurrences}`);\n if (error.recurrence_count > 0) {\n lines.push(\"\");\n lines.push(\n `Recurrence: this is the ${ordinal(error.recurrence_count)} time this fingerprint has appeared after a previous fix was merged. The earlier fix did not hold — investigate why.`,\n );\n }\n\n lines.push(\"\");\n lines.push(\"When done:\");\n lines.push(` 1. Create branch: ${branch}`);\n lines.push(\" 2. Commit the fix on that branch\");\n lines.push(\" 3. Run the project's quality checks (only commit if they pass)\");\n lines.push(\"\");\n lines.push(\"Do not merge. Do not push. Do not switch back to main.\");\n\n return lines.join(\"\\n\");\n}\n\n/**\n * Walks ~/.gg/projects.json trying each project's bearer secret against\n * GET /api/errors/:id until one returns 200. Wrong secrets get 403/404 from\n * the server, so this scan exits as soon as the rightful owner is found.\n *\n * Bounded by the number of registered projects on this machine (typically\n * single digits) so cost is negligible per fix.\n */\nasync function resolveErrorOwner(\n fetchFn: typeof fetch,\n ingestUrl: string,\n errorId: string,\n home: string,\n): Promise<{ error: ErrorRow; project: ProjectMapping; secret: string }> {\n const projectsPath = join(home, \".gg\", \"projects.json\");\n if (!existsSync(projectsPath)) {\n throw new Error(\n `No projects mapping at ${projectsPath} — run \\`arcicoder pixel install\\` in the project first.`,\n );\n }\n const projects = JSON.parse(readFileSync(projectsPath, \"utf8\")) as Record<string, ProjectMapping>;\n const ownersWithSecret = Object.entries(projects).filter(([, p]) => Boolean(p.secret));\n if (ownersWithSecret.length === 0) {\n throw new Error(\n \"No managed projects on this machine — run `arcicoder pixel install` in the project to refresh management access.\",\n );\n }\n for (const [, project] of ownersWithSecret) {\n const res = await fetchFn(`${ingestUrl}/api/errors/${errorId}`, {\n headers: { authorization: `Bearer ${project.secret}` },\n });\n if (res.ok) {\n const error = (await res.json()) as ErrorRow;\n return { error, project, secret: project.secret! };\n }\n // 401/403/404 → not this project; keep scanning.\n }\n throw new Error(\n `Error ${errorId} was not found in any registered project. Ensure the project is installed (\\`arcicoder pixel install\\`).`,\n );\n}\n\nfunction lookupProjectSecret(home: string, projectId: string): string {\n const projectsPath = join(home, \".gg\", \"projects.json\");\n if (!existsSync(projectsPath)) {\n throw new Error(\n `No projects mapping at ${projectsPath} — run \\`arcicoder pixel install\\` in the project first.`,\n );\n }\n const projects = JSON.parse(readFileSync(projectsPath, \"utf8\")) as Record<string, ProjectMapping>;\n const project = projects[projectId];\n if (!project) {\n throw new Error(\n `No local mapping for project ${projectId} in ${projectsPath}. Run \\`arcicoder pixel install\\` in the project's directory.`,\n );\n }\n if (!project.secret) {\n throw new Error(\n `Project ${projectId} is missing its bearer secret in ${projectsPath} — re-run \\`arcicoder pixel install\\` to refresh.`,\n );\n }\n return project.secret;\n}\n\nasync function patchError(\n fetchFn: typeof fetch,\n ingestUrl: string,\n errorId: string,\n body: { status: string; branch?: string },\n secret: string,\n): Promise<void> {\n const res = await fetchFn(`${ingestUrl}/api/errors/${errorId}`, {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n authorization: `Bearer ${secret}`,\n },\n body: JSON.stringify(body),\n });\n if (!res.ok) throw new Error(`PATCH /api/errors/${errorId} failed: ${res.status}`);\n}\n\ninterface AgentRunOptions {\n cwd: string;\n prompt: string;\n systemPrompt: string;\n spawnFn: SpawnFn;\n ggcoderBin: string;\n inheritStdio: boolean;\n maxTurns: number;\n}\n\nasync function runAgent(opts: AgentRunOptions): Promise<number> {\n return new Promise((resolve, reject) => {\n const args = [\n \"--json\",\n \"--max-turns\",\n String(opts.maxTurns),\n \"--system-prompt\",\n opts.systemPrompt,\n opts.prompt,\n ];\n const child = opts.spawnFn(opts.ggcoderBin, args, {\n cwd: opts.cwd,\n stdio: opts.inheritStdio ? \"inherit\" : [\"ignore\", \"pipe\", \"pipe\"],\n });\n child.on(\"error\", reject);\n child.on(\"exit\", (code) => resolve(code ?? 1));\n });\n}\n\ninterface ObservedOutcome {\n branchExists: boolean;\n hasCommits: boolean;\n commitCount: number;\n}\n\nasync function observeOutcome(\n cwd: string,\n branch: string,\n spawnFn: SpawnFn,\n): Promise<ObservedOutcome> {\n const exists = await runGit(cwd, [\"show-ref\", \"--verify\", `refs/heads/${branch}`], spawnFn);\n if (exists.code !== 0) return { branchExists: false, hasCommits: false, commitCount: 0 };\n\n let baseBranch: string | null = null;\n for (const candidate of [\"main\", \"master\"]) {\n const r = await runGit(cwd, [\"show-ref\", \"--verify\", `refs/heads/${candidate}`], spawnFn);\n if (r.code === 0) {\n baseBranch = candidate;\n break;\n }\n }\n if (!baseBranch) return { branchExists: true, hasCommits: false, commitCount: 0 };\n\n const ahead = await runGit(cwd, [\"rev-list\", \"--count\", `${baseBranch}..${branch}`], spawnFn);\n const count = ahead.code === 0 ? parseInt(ahead.stdout.trim(), 10) || 0 : 0;\n return { branchExists: true, hasCommits: count > 0, commitCount: count };\n}\n\ninterface GitResult {\n code: number;\n stdout: string;\n stderr: string;\n}\n\nfunction runGit(cwd: string, args: string[], spawnFn: SpawnFn): Promise<GitResult> {\n return new Promise((resolve) => {\n const child = spawnFn(\"git\", args, { cwd, stdio: [\"ignore\", \"pipe\", \"pipe\"] });\n let stdout = \"\";\n let stderr = \"\";\n child.stdout?.on(\"data\", (b: Buffer) => (stdout += b.toString()));\n child.stderr?.on(\"data\", (b: Buffer) => (stderr += b.toString()));\n child.on(\"error\", () => resolve({ code: 1, stdout, stderr }));\n child.on(\"exit\", (code) => resolve({ code: code ?? 1, stdout, stderr }));\n });\n}\n\nfunction looksLikeMinifiedBrowserStack(stack: StackFrame[]): boolean {\n // Heuristic: any frame whose file is an http(s) URL = browser stack.\n // We try map resolution for these. Native Node paths don't need it.\n return stack.some((f) => /^https?:\\/\\//.test(f.file));\n}\n\nfunction parseStackJson(raw: string | null): StackFrame[] {\n if (!raw) return [];\n try {\n const parsed = JSON.parse(raw) as unknown;\n if (Array.isArray(parsed)) return parsed as StackFrame[];\n } catch {\n // ignore\n }\n return [];\n}\n\nfunction parseCodeContext(raw: string | null): CodeContext | null {\n if (!raw) return null;\n try {\n return JSON.parse(raw) as CodeContext;\n } catch {\n return null;\n }\n}\n\nfunction ordinal(n: number): string {\n const s = [\"th\", \"st\", \"nd\", \"rd\"];\n const v = n % 100;\n return `${n}${s[(v - 20) % 10] ?? s[v] ?? s[0]}`;\n}\n","/**\n * Pixel-fix agent definition.\n *\n * This is a SEPARATE agent from the interactive arcicoder chat agent.\n * It has its own identity, its own system prompt, and runs as a fresh\n * `arcicoder --json` subprocess per error. Its single job is to fix one\n * specific error reported by gg-pixel and stop.\n *\n * The runner (pixel-fix.ts) owns the lifecycle: spawn → observe git →\n * mark `awaiting_review` or `failed`. This agent does NOT mark its own\n * status — that's by design (outcome-observed, not self-reported).\n */\n\nexport const PIXEL_FIX_AGENT_NAME = \"gg-pixel fix agent\";\nexport const PIXEL_FIX_AGENT_DESCRIPTION =\n \"Autonomous single-error fixer invoked by `arcicoder pixel fix` / `arcicoder pixel run`.\";\n\n/**\n * The pixel-fix agent's system prompt. Replaces arcicoder's default chat\n * prompt for this session — this agent is a different role, not a\n * conversational coder.\n *\n * Tools are still wired up by arcicoder (read/edit/bash/grep/etc.); their\n * descriptions come from the tool definitions, not from this prompt.\n */\nexport const PIXEL_FIX_SYSTEM_PROMPT = `You are the gg-pixel fix agent — a non-interactive coding agent invoked by the gg-pixel fix-queue runner.\n\nYour single job for this session is to fix the one specific error described in the user message. You do not chat. You do not ask questions. You investigate, fix, commit, stop.\n\n# Identity\n- You are NOT the regular arcicoder interactive assistant.\n- You are a one-shot fix worker. Your work will be reviewed by a human after you stop.\n- Be terse. Don't narrate your reasoning unless it materially affects the fix.\n\n# Required workflow\n1. Read the error in the user message (type, message, file:line, code window, stack).\n2. Use your tools (read, grep, find, edit, bash) to investigate. Prefer reading the exact file:line referenced in the error first.\n3. Make the smallest fix that resolves the actual error. Do not refactor surrounding code, do not improve unrelated things, do not add tests unless the error is in a test.\n4. Create the git branch named in the user message. Do NOT switch back to main afterward.\n5. Commit your changes on that branch with a clear message.\n6. If the project has quality checks (\\`pnpm check\\`, \\`pnpm test\\`, \\`pytest\\`, \\`cargo check\\`, etc.), run them. Only commit if they pass — if checks fail, fix and retry, do not commit broken code.\n7. Stop. The runner will inspect git state and mark the result.\n\n# Hard rules\n- Do NOT merge. Do NOT push. Do NOT open a PR.\n- Do NOT switch back to main/master after committing on the fix branch.\n- Do NOT mark the error status yourself — the runner observes git state and updates status.\n- If you cannot fix the error (genuinely stuck, missing context, ambiguous), commit nothing and stop. The runner will mark it as failed; a human will look.\n\n# Recurrence signal\nIf the user message says \"Recurrence: Nth time\", the previous fix did not hold. Investigate why before patching again — a quick re-patch is likely to regress.`;\n","import { existsSync, readFileSync, readdirSync, statSync } from \"node:fs\";\nimport { dirname, join, posix } from \"node:path\";\nimport { TraceMap, originalPositionFor } from \"@jridgewell/trace-mapping\";\n\n/**\n * Stack-frame source map resolution.\n *\n * Browser SDKs send minified frames like\n * { file: \"https://app.com/dist/main.abc123.js\", line: 1, col: 48201, fn: \"<anon>\" }\n *\n * Source maps emitted by bundlers (Vite, Webpack, Rollup, esbuild) translate\n * those `(line, col)` coordinates back to the original source `(file, line, col, name)`.\n *\n * We resolve **client-side** in the runner: we walk the user's project\n * directory looking for `.map` files whose name matches the minified\n * filename in the stack frame. If found, we use `@jridgewell/trace-mapping`\n * to look up each frame's original position.\n *\n * Limitations (deliberately documented):\n * - Requires the maps to exist locally (project's `dist/`, `build/`, etc.).\n * For deployed apps where the dev's machine has no build, server-side\n * symbolication via uploaded maps is needed — that's a separate slice.\n * - Walks up to 4 levels deep into common build dirs to keep cost bounded.\n */\n\nexport interface StackFrame {\n file: string;\n line: number;\n col: number;\n fn: string;\n in_app: boolean;\n}\n\nconst COMMON_BUILD_DIRS = [\"dist\", \"build\", \".next\", \"out\", \"public\", \".vite\"];\nconst MAX_DEPTH = 4;\n\ninterface MapCacheEntry {\n trace: TraceMap;\n mapDir: string;\n}\n\nexport class SourceMapResolver {\n private readonly cache = new Map<string, MapCacheEntry | null>();\n\n constructor(private readonly projectDir: string) {}\n\n /**\n * Resolve a minified stack into the original source. Frames that can't\n * be resolved are returned unchanged so the caller still sees something.\n */\n resolveStack(stack: StackFrame[]): StackFrame[] {\n return stack.map((f) => this.resolveFrame(f));\n }\n\n resolveFrame(frame: StackFrame): StackFrame {\n const minifiedName = filenameFromUrl(frame.file);\n if (!minifiedName) return frame;\n const entry = this.findMap(minifiedName);\n if (!entry) return frame;\n let resolved;\n try {\n resolved = originalPositionFor(entry.trace, { line: frame.line, column: frame.col });\n } catch {\n return frame;\n }\n if (!resolved.source) return frame;\n const sourceAbs = posix.normalize(posix.join(entry.mapDir, resolved.source));\n return {\n file: sourceAbs,\n line: resolved.line ?? frame.line,\n col: resolved.column ?? frame.col,\n fn: resolved.name || frame.fn,\n in_app: !sourceAbs.includes(\"/node_modules/\") && !sourceAbs.startsWith(\"webpack:///\"),\n };\n }\n\n private findMap(minifiedName: string): MapCacheEntry | null {\n const cached = this.cache.get(minifiedName);\n if (cached !== undefined) return cached;\n const result = this.searchForMap(minifiedName);\n this.cache.set(minifiedName, result);\n return result;\n }\n\n private searchForMap(minifiedName: string): MapCacheEntry | null {\n for (const dir of COMMON_BUILD_DIRS) {\n const root = join(this.projectDir, dir);\n if (!existsSync(root)) continue;\n const found = walkForMap(root, minifiedName, MAX_DEPTH);\n if (found) return loadMap(found);\n }\n const rootCandidate = join(this.projectDir, minifiedName + \".map\");\n if (existsSync(rootCandidate)) return loadMap(rootCandidate);\n return null;\n }\n}\n\nfunction filenameFromUrl(file: string): string | null {\n if (!file) return null;\n const cleaned = file.split(\"?\")[0]!.split(\"#\")[0]!;\n const last = cleaned.split(\"/\").pop();\n return last || null;\n}\n\nfunction walkForMap(root: string, minifiedName: string, depth: number): string | null {\n const target = minifiedName + \".map\";\n const direct = join(root, target);\n if (existsSync(direct)) return direct;\n if (depth <= 0) return null;\n let entries: string[];\n try {\n entries = readdirSync(root);\n } catch {\n return null;\n }\n for (const entry of entries) {\n if (entry.startsWith(\".\")) continue;\n const child = join(root, entry);\n if (!isDirectorySafe(child)) continue;\n const found = walkForMap(child, minifiedName, depth - 1);\n if (found) return found;\n }\n return null;\n}\n\nfunction isDirectorySafe(path: string): boolean {\n try {\n return statSync(path).isDirectory();\n } catch {\n return false;\n }\n}\n\nfunction loadMap(mapPath: string): MapCacheEntry | null {\n try {\n const raw = readFileSync(mapPath, \"utf8\");\n const parsed = JSON.parse(raw) as object;\n return { trace: new TraceMap(parsed as never), mapDir: dirname(mapPath) };\n } catch {\n return null;\n }\n}\n\n/**\n * Best-effort wrapper that swallows all errors. The runner calls this on\n * every error fetch — if anything goes wrong, we don't want to break the\n * whole TUI.\n */\nexport function tryResolveStack(stack: StackFrame[], projectDir: string): StackFrame[] {\n try {\n const resolver = new SourceMapResolver(projectDir);\n return resolver.resolveStack(stack);\n } catch {\n return stack;\n }\n}\n","import type { StringReader, StringWriter } from './strings';\n\nexport const comma = ','.charCodeAt(0);\nexport const semicolon = ';'.charCodeAt(0);\n\nconst chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nconst intToChar = new Uint8Array(64); // 64 possible chars.\nconst charToInt = new Uint8Array(128); // z is 122 in ASCII\n\nfor (let i = 0; i < chars.length; i++) {\n const c = chars.charCodeAt(i);\n intToChar[i] = c;\n charToInt[c] = i;\n}\n\nexport function decodeInteger(reader: StringReader, relative: number): number {\n let value = 0;\n let shift = 0;\n let integer = 0;\n\n do {\n const c = reader.next();\n integer = charToInt[c];\n value |= (integer & 31) << shift;\n shift += 5;\n } while (integer & 32);\n\n const shouldNegate = value & 1;\n value >>>= 1;\n\n if (shouldNegate) {\n value = -0x80000000 | -value;\n }\n\n return relative + value;\n}\n\nexport function encodeInteger(builder: StringWriter, num: number, relative: number): number {\n let delta = num - relative;\n\n delta = delta < 0 ? (-delta << 1) | 1 : delta << 1;\n do {\n let clamped = delta & 0b011111;\n delta >>>= 5;\n if (delta > 0) clamped |= 0b100000;\n builder.write(intToChar[clamped]);\n } while (delta > 0);\n\n return num;\n}\n\nexport function hasMoreVlq(reader: StringReader, max: number) {\n if (reader.pos >= max) return false;\n return reader.peek() !== comma;\n}\n","const bufLength = 1024 * 16;\n\n// Provide a fallback for older environments.\nconst td =\n typeof TextDecoder !== 'undefined'\n ? /* #__PURE__ */ new TextDecoder()\n : typeof Buffer !== 'undefined'\n ? {\n decode(buf: Uint8Array): string {\n const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);\n return out.toString();\n },\n }\n : {\n decode(buf: Uint8Array): string {\n let out = '';\n for (let i = 0; i < buf.length; i++) {\n out += String.fromCharCode(buf[i]);\n }\n return out;\n },\n };\n\nexport class StringWriter {\n pos = 0;\n private out = '';\n private buffer = new Uint8Array(bufLength);\n\n write(v: number): void {\n const { buffer } = this;\n buffer[this.pos++] = v;\n if (this.pos === bufLength) {\n this.out += td.decode(buffer);\n this.pos = 0;\n }\n }\n\n flush(): string {\n const { buffer, out, pos } = this;\n return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;\n }\n}\n\nexport class StringReader {\n pos = 0;\n declare private buffer: string;\n\n constructor(buffer: string) {\n this.buffer = buffer;\n }\n\n next(): number {\n return this.buffer.charCodeAt(this.pos++);\n }\n\n peek(): number {\n return this.buffer.charCodeAt(this.pos);\n }\n\n indexOf(char: string): number {\n const { buffer, pos } = this;\n const idx = buffer.indexOf(char, pos);\n return idx === -1 ? buffer.length : idx;\n }\n}\n","import { StringReader, StringWriter } from './strings';\nimport { comma, decodeInteger, encodeInteger, hasMoreVlq, semicolon } from './vlq';\n\nconst EMPTY: any[] = [];\n\ntype Line = number;\ntype Column = number;\ntype Kind = number;\ntype Name = number;\ntype Var = number;\ntype SourcesIndex = number;\ntype ScopesIndex = number;\n\ntype Mix<A, B, O> = (A & O) | (B & O);\n\nexport type OriginalScope = Mix<\n [Line, Column, Line, Column, Kind],\n [Line, Column, Line, Column, Kind, Name],\n { vars: Var[] }\n>;\n\nexport type GeneratedRange = Mix<\n [Line, Column, Line, Column],\n [Line, Column, Line, Column, SourcesIndex, ScopesIndex],\n {\n callsite: CallSite | null;\n bindings: Binding[];\n isScope: boolean;\n }\n>;\nexport type CallSite = [SourcesIndex, Line, Column];\ntype Binding = BindingExpressionRange[];\nexport type BindingExpressionRange = [Name] | [Name, Line, Column];\n\nexport function decodeOriginalScopes(input: string): OriginalScope[] {\n const { length } = input;\n const reader = new StringReader(input);\n const scopes: OriginalScope[] = [];\n const stack: OriginalScope[] = [];\n let line = 0;\n\n for (; reader.pos < length; reader.pos++) {\n line = decodeInteger(reader, line);\n const column = decodeInteger(reader, 0);\n\n if (!hasMoreVlq(reader, length)) {\n const last = stack.pop()!;\n last[2] = line;\n last[3] = column;\n continue;\n }\n\n const kind = decodeInteger(reader, 0);\n const fields = decodeInteger(reader, 0);\n const hasName = fields & 0b0001;\n\n const scope: OriginalScope = (\n hasName ? [line, column, 0, 0, kind, decodeInteger(reader, 0)] : [line, column, 0, 0, kind]\n ) as OriginalScope;\n\n let vars: Var[] = EMPTY;\n if (hasMoreVlq(reader, length)) {\n vars = [];\n do {\n const varsIndex = decodeInteger(reader, 0);\n vars.push(varsIndex);\n } while (hasMoreVlq(reader, length));\n }\n scope.vars = vars;\n\n scopes.push(scope);\n stack.push(scope);\n }\n\n return scopes;\n}\n\nexport function encodeOriginalScopes(scopes: OriginalScope[]): string {\n const writer = new StringWriter();\n\n for (let i = 0; i < scopes.length; ) {\n i = _encodeOriginalScopes(scopes, i, writer, [0]);\n }\n\n return writer.flush();\n}\n\nfunction _encodeOriginalScopes(\n scopes: OriginalScope[],\n index: number,\n writer: StringWriter,\n state: [\n number, // GenColumn\n ],\n): number {\n const scope = scopes[index];\n const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, 4: kind, vars } = scope;\n\n if (index > 0) writer.write(comma);\n\n state[0] = encodeInteger(writer, startLine, state[0]);\n encodeInteger(writer, startColumn, 0);\n encodeInteger(writer, kind, 0);\n\n const fields = scope.length === 6 ? 0b0001 : 0;\n encodeInteger(writer, fields, 0);\n if (scope.length === 6) encodeInteger(writer, scope[5], 0);\n\n for (const v of vars) {\n encodeInteger(writer, v, 0);\n }\n\n for (index++; index < scopes.length; ) {\n const next = scopes[index];\n const { 0: l, 1: c } = next;\n if (l > endLine || (l === endLine && c >= endColumn)) {\n break;\n }\n index = _encodeOriginalScopes(scopes, index, writer, state);\n }\n\n writer.write(comma);\n state[0] = encodeInteger(writer, endLine, state[0]);\n encodeInteger(writer, endColumn, 0);\n\n return index;\n}\n\nexport function decodeGeneratedRanges(input: string): GeneratedRange[] {\n const { length } = input;\n const reader = new StringReader(input);\n const ranges: GeneratedRange[] = [];\n const stack: GeneratedRange[] = [];\n\n let genLine = 0;\n let definitionSourcesIndex = 0;\n let definitionScopeIndex = 0;\n let callsiteSourcesIndex = 0;\n let callsiteLine = 0;\n let callsiteColumn = 0;\n let bindingLine = 0;\n let bindingColumn = 0;\n\n do {\n const semi = reader.indexOf(';');\n let genColumn = 0;\n\n for (; reader.pos < semi; reader.pos++) {\n genColumn = decodeInteger(reader, genColumn);\n\n if (!hasMoreVlq(reader, semi)) {\n const last = stack.pop()!;\n last[2] = genLine;\n last[3] = genColumn;\n continue;\n }\n\n const fields = decodeInteger(reader, 0);\n const hasDefinition = fields & 0b0001;\n const hasCallsite = fields & 0b0010;\n const hasScope = fields & 0b0100;\n\n let callsite: CallSite | null = null;\n let bindings: Binding[] = EMPTY;\n let range: GeneratedRange;\n if (hasDefinition) {\n const defSourcesIndex = decodeInteger(reader, definitionSourcesIndex);\n definitionScopeIndex = decodeInteger(\n reader,\n definitionSourcesIndex === defSourcesIndex ? definitionScopeIndex : 0,\n );\n\n definitionSourcesIndex = defSourcesIndex;\n range = [genLine, genColumn, 0, 0, defSourcesIndex, definitionScopeIndex] as GeneratedRange;\n } else {\n range = [genLine, genColumn, 0, 0] as GeneratedRange;\n }\n\n range.isScope = !!hasScope;\n\n if (hasCallsite) {\n const prevCsi = callsiteSourcesIndex;\n const prevLine = callsiteLine;\n callsiteSourcesIndex = decodeInteger(reader, callsiteSourcesIndex);\n const sameSource = prevCsi === callsiteSourcesIndex;\n callsiteLine = decodeInteger(reader, sameSource ? callsiteLine : 0);\n callsiteColumn = decodeInteger(\n reader,\n sameSource && prevLine === callsiteLine ? callsiteColumn : 0,\n );\n\n callsite = [callsiteSourcesIndex, callsiteLine, callsiteColumn];\n }\n range.callsite = callsite;\n\n if (hasMoreVlq(reader, semi)) {\n bindings = [];\n do {\n bindingLine = genLine;\n bindingColumn = genColumn;\n const expressionsCount = decodeInteger(reader, 0);\n let expressionRanges: BindingExpressionRange[];\n if (expressionsCount < -1) {\n expressionRanges = [[decodeInteger(reader, 0)]];\n for (let i = -1; i > expressionsCount; i--) {\n const prevBl = bindingLine;\n bindingLine = decodeInteger(reader, bindingLine);\n bindingColumn = decodeInteger(reader, bindingLine === prevBl ? bindingColumn : 0);\n const expression = decodeInteger(reader, 0);\n expressionRanges.push([expression, bindingLine, bindingColumn]);\n }\n } else {\n expressionRanges = [[expressionsCount]];\n }\n bindings.push(expressionRanges);\n } while (hasMoreVlq(reader, semi));\n }\n range.bindings = bindings;\n\n ranges.push(range);\n stack.push(range);\n }\n\n genLine++;\n reader.pos = semi + 1;\n } while (reader.pos < length);\n\n return ranges;\n}\n\nexport function encodeGeneratedRanges(ranges: GeneratedRange[]): string {\n if (ranges.length === 0) return '';\n\n const writer = new StringWriter();\n\n for (let i = 0; i < ranges.length; ) {\n i = _encodeGeneratedRanges(ranges, i, writer, [0, 0, 0, 0, 0, 0, 0]);\n }\n\n return writer.flush();\n}\n\nfunction _encodeGeneratedRanges(\n ranges: GeneratedRange[],\n index: number,\n writer: StringWriter,\n state: [\n number, // GenLine\n number, // GenColumn\n number, // DefSourcesIndex\n number, // DefScopesIndex\n number, // CallSourcesIndex\n number, // CallLine\n number, // CallColumn\n ],\n): number {\n const range = ranges[index];\n const {\n 0: startLine,\n 1: startColumn,\n 2: endLine,\n 3: endColumn,\n isScope,\n callsite,\n bindings,\n } = range;\n\n if (state[0] < startLine) {\n catchupLine(writer, state[0], startLine);\n state[0] = startLine;\n state[1] = 0;\n } else if (index > 0) {\n writer.write(comma);\n }\n\n state[1] = encodeInteger(writer, range[1], state[1]);\n\n const fields =\n (range.length === 6 ? 0b0001 : 0) | (callsite ? 0b0010 : 0) | (isScope ? 0b0100 : 0);\n encodeInteger(writer, fields, 0);\n\n if (range.length === 6) {\n const { 4: sourcesIndex, 5: scopesIndex } = range;\n if (sourcesIndex !== state[2]) {\n state[3] = 0;\n }\n state[2] = encodeInteger(writer, sourcesIndex, state[2]);\n state[3] = encodeInteger(writer, scopesIndex, state[3]);\n }\n\n if (callsite) {\n const { 0: sourcesIndex, 1: callLine, 2: callColumn } = range.callsite!;\n if (sourcesIndex !== state[4]) {\n state[5] = 0;\n state[6] = 0;\n } else if (callLine !== state[5]) {\n state[6] = 0;\n }\n state[4] = encodeInteger(writer, sourcesIndex, state[4]);\n state[5] = encodeInteger(writer, callLine, state[5]);\n state[6] = encodeInteger(writer, callColumn, state[6]);\n }\n\n if (bindings) {\n for (const binding of bindings) {\n if (binding.length > 1) encodeInteger(writer, -binding.length, 0);\n const expression = binding[0][0];\n encodeInteger(writer, expression, 0);\n let bindingStartLine = startLine;\n let bindingStartColumn = startColumn;\n for (let i = 1; i < binding.length; i++) {\n const expRange = binding[i];\n bindingStartLine = encodeInteger(writer, expRange[1]!, bindingStartLine);\n bindingStartColumn = encodeInteger(writer, expRange[2]!, bindingStartColumn);\n encodeInteger(writer, expRange[0]!, 0);\n }\n }\n }\n\n for (index++; index < ranges.length; ) {\n const next = ranges[index];\n const { 0: l, 1: c } = next;\n if (l > endLine || (l === endLine && c >= endColumn)) {\n break;\n }\n index = _encodeGeneratedRanges(ranges, index, writer, state);\n }\n\n if (state[0] < endLine) {\n catchupLine(writer, state[0], endLine);\n state[0] = endLine;\n state[1] = 0;\n } else {\n writer.write(comma);\n }\n state[1] = encodeInteger(writer, endColumn, state[1]);\n\n return index;\n}\n\nfunction catchupLine(writer: StringWriter, lastLine: number, line: number) {\n do {\n writer.write(semicolon);\n } while (++lastLine < line);\n}\n","import { comma, decodeInteger, encodeInteger, hasMoreVlq, semicolon } from './vlq';\nimport { StringWriter, StringReader } from './strings';\n\nexport {\n decodeOriginalScopes,\n encodeOriginalScopes,\n decodeGeneratedRanges,\n encodeGeneratedRanges,\n} from './scopes';\nexport type { OriginalScope, GeneratedRange, CallSite, BindingExpressionRange } from './scopes';\n\nexport type SourceMapSegment =\n | [number]\n | [number, number, number, number]\n | [number, number, number, number, number];\nexport type SourceMapLine = SourceMapSegment[];\nexport type SourceMapMappings = SourceMapLine[];\n\nexport function decode(mappings: string): SourceMapMappings {\n const { length } = mappings;\n const reader = new StringReader(mappings);\n const decoded: SourceMapMappings = [];\n let genColumn = 0;\n let sourcesIndex = 0;\n let sourceLine = 0;\n let sourceColumn = 0;\n let namesIndex = 0;\n\n do {\n const semi = reader.indexOf(';');\n const line: SourceMapLine = [];\n let sorted = true;\n let lastCol = 0;\n genColumn = 0;\n\n while (reader.pos < semi) {\n let seg: SourceMapSegment;\n\n genColumn = decodeInteger(reader, genColumn);\n if (genColumn < lastCol) sorted = false;\n lastCol = genColumn;\n\n if (hasMoreVlq(reader, semi)) {\n sourcesIndex = decodeInteger(reader, sourcesIndex);\n sourceLine = decodeInteger(reader, sourceLine);\n sourceColumn = decodeInteger(reader, sourceColumn);\n\n if (hasMoreVlq(reader, semi)) {\n namesIndex = decodeInteger(reader, namesIndex);\n seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];\n } else {\n seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];\n }\n } else {\n seg = [genColumn];\n }\n\n line.push(seg);\n reader.pos++;\n }\n\n if (!sorted) sort(line);\n decoded.push(line);\n reader.pos = semi + 1;\n } while (reader.pos <= length);\n\n return decoded;\n}\n\nfunction sort(line: SourceMapSegment[]) {\n line.sort(sortComparator);\n}\n\nfunction sortComparator(a: SourceMapSegment, b: SourceMapSegment): number {\n return a[0] - b[0];\n}\n\nexport function encode(decoded: SourceMapMappings): string;\nexport function encode(decoded: Readonly<SourceMapMappings>): string;\nexport function encode(decoded: Readonly<SourceMapMappings>): string {\n const writer = new StringWriter();\n let sourcesIndex = 0;\n let sourceLine = 0;\n let sourceColumn = 0;\n let namesIndex = 0;\n\n for (let i = 0; i < decoded.length; i++) {\n const line = decoded[i];\n if (i > 0) writer.write(semicolon);\n if (line.length === 0) continue;\n\n let genColumn = 0;\n\n for (let j = 0; j < line.length; j++) {\n const segment = line[j];\n if (j > 0) writer.write(comma);\n\n genColumn = encodeInteger(writer, segment[0], genColumn);\n\n if (segment.length === 1) continue;\n sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);\n sourceLine = encodeInteger(writer, segment[2], sourceLine);\n sourceColumn = encodeInteger(writer, segment[3], sourceColumn);\n\n if (segment.length === 4) continue;\n namesIndex = encodeInteger(writer, segment[4], namesIndex);\n }\n }\n\n return writer.flush();\n}\n","// Matches the scheme of a URL, eg \"http://\"\nconst schemeRegex = /^[\\w+.-]+:\\/\\//;\n\n/**\n * Matches the parts of a URL:\n * 1. Scheme, including \":\", guaranteed.\n * 2. User/password, including \"@\", optional.\n * 3. Host, guaranteed.\n * 4. Port, including \":\", optional.\n * 5. Path, including \"/\", optional.\n * 6. Query, including \"?\", optional.\n * 7. Hash, including \"#\", optional.\n */\nconst urlRegex = /^([\\w+.-]+:)\\/\\/([^@/#?]*@)?([^:/#?]*)(:\\d+)?(\\/[^#?]*)?(\\?[^#]*)?(#.*)?/;\n\n/**\n * File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start\n * with a leading `/`, they can have a domain (but only if they don't start with a Windows drive).\n *\n * 1. Host, optional.\n * 2. Path, which may include \"/\", guaranteed.\n * 3. Query, including \"?\", optional.\n * 4. Hash, including \"#\", optional.\n */\nconst fileRegex = /^file:(?:\\/\\/((?![a-z]:)[^/#?]*)?)?(\\/?[^#?]*)(\\?[^#]*)?(#.*)?/i;\n\ntype Url = {\n scheme: string;\n user: string;\n host: string;\n port: string;\n path: string;\n query: string;\n hash: string;\n type: UrlType;\n};\n\nconst enum UrlType {\n Empty = 1,\n Hash = 2,\n Query = 3,\n RelativePath = 4,\n AbsolutePath = 5,\n SchemeRelative = 6,\n Absolute = 7,\n}\n\nfunction isAbsoluteUrl(input: string): boolean {\n return schemeRegex.test(input);\n}\n\nfunction isSchemeRelativeUrl(input: string): boolean {\n return input.startsWith('//');\n}\n\nfunction isAbsolutePath(input: string): boolean {\n return input.startsWith('/');\n}\n\nfunction isFileUrl(input: string): boolean {\n return input.startsWith('file:');\n}\n\nfunction isRelative(input: string): boolean {\n return /^[.?#]/.test(input);\n}\n\nfunction parseAbsoluteUrl(input: string): Url {\n const match = urlRegex.exec(input)!;\n return makeUrl(\n match[1],\n match[2] || '',\n match[3],\n match[4] || '',\n match[5] || '/',\n match[6] || '',\n match[7] || '',\n );\n}\n\nfunction parseFileUrl(input: string): Url {\n const match = fileRegex.exec(input)!;\n const path = match[2];\n return makeUrl(\n 'file:',\n '',\n match[1] || '',\n '',\n isAbsolutePath(path) ? path : '/' + path,\n match[3] || '',\n match[4] || '',\n );\n}\n\nfunction makeUrl(\n scheme: string,\n user: string,\n host: string,\n port: string,\n path: string,\n query: string,\n hash: string,\n): Url {\n return {\n scheme,\n user,\n host,\n port,\n path,\n query,\n hash,\n type: UrlType.Absolute,\n };\n}\n\nfunction parseUrl(input: string): Url {\n if (isSchemeRelativeUrl(input)) {\n const url = parseAbsoluteUrl('http:' + input);\n url.scheme = '';\n url.type = UrlType.SchemeRelative;\n return url;\n }\n\n if (isAbsolutePath(input)) {\n const url = parseAbsoluteUrl('http://foo.com' + input);\n url.scheme = '';\n url.host = '';\n url.type = UrlType.AbsolutePath;\n return url;\n }\n\n if (isFileUrl(input)) return parseFileUrl(input);\n\n if (isAbsoluteUrl(input)) return parseAbsoluteUrl(input);\n\n const url = parseAbsoluteUrl('http://foo.com/' + input);\n url.scheme = '';\n url.host = '';\n url.type = input\n ? input.startsWith('?')\n ? UrlType.Query\n : input.startsWith('#')\n ? UrlType.Hash\n : UrlType.RelativePath\n : UrlType.Empty;\n return url;\n}\n\nfunction stripPathFilename(path: string): string {\n // If a path ends with a parent directory \"..\", then it's a relative path with excess parent\n // paths. It's not a file, so we can't strip it.\n if (path.endsWith('/..')) return path;\n const index = path.lastIndexOf('/');\n return path.slice(0, index + 1);\n}\n\nfunction mergePaths(url: Url, base: Url) {\n normalizePath(base, base.type);\n\n // If the path is just a \"/\", then it was an empty path to begin with (remember, we're a relative\n // path).\n if (url.path === '/') {\n url.path = base.path;\n } else {\n // Resolution happens relative to the base path's directory, not the file.\n url.path = stripPathFilename(base.path) + url.path;\n }\n}\n\n/**\n * The path can have empty directories \"//\", unneeded parents \"foo/..\", or current directory\n * \"foo/.\". We need to normalize to a standard representation.\n */\nfunction normalizePath(url: Url, type: UrlType) {\n const rel = type <= UrlType.RelativePath;\n const pieces = url.path.split('/');\n\n // We need to preserve the first piece always, so that we output a leading slash. The item at\n // pieces[0] is an empty string.\n let pointer = 1;\n\n // Positive is the number of real directories we've output, used for popping a parent directory.\n // Eg, \"foo/bar/..\" will have a positive 2, and we can decrement to be left with just \"foo\".\n let positive = 0;\n\n // We need to keep a trailing slash if we encounter an empty directory (eg, splitting \"foo/\" will\n // generate `[\"foo\", \"\"]` pieces). And, if we pop a parent directory. But once we encounter a\n // real directory, we won't need to append, unless the other conditions happen again.\n let addTrailingSlash = false;\n\n for (let i = 1; i < pieces.length; i++) {\n const piece = pieces[i];\n\n // An empty directory, could be a trailing slash, or just a double \"//\" in the path.\n if (!piece) {\n addTrailingSlash = true;\n continue;\n }\n\n // If we encounter a real directory, then we don't need to append anymore.\n addTrailingSlash = false;\n\n // A current directory, which we can always drop.\n if (piece === '.') continue;\n\n // A parent directory, we need to see if there are any real directories we can pop. Else, we\n // have an excess of parents, and we'll need to keep the \"..\".\n if (piece === '..') {\n if (positive) {\n addTrailingSlash = true;\n positive--;\n pointer--;\n } else if (rel) {\n // If we're in a relativePath, then we need to keep the excess parents. Else, in an absolute\n // URL, protocol relative URL, or an absolute path, we don't need to keep excess.\n pieces[pointer++] = piece;\n }\n continue;\n }\n\n // We've encountered a real directory. Move it to the next insertion pointer, which accounts for\n // any popped or dropped directories.\n pieces[pointer++] = piece;\n positive++;\n }\n\n let path = '';\n for (let i = 1; i < pointer; i++) {\n path += '/' + pieces[i];\n }\n if (!path || (addTrailingSlash && !path.endsWith('/..'))) {\n path += '/';\n }\n url.path = path;\n}\n\n/**\n * Attempts to resolve `input` URL/path relative to `base`.\n */\nexport default function resolve(input: string, base: string | undefined): string {\n if (!input && !base) return '';\n\n const url = parseUrl(input);\n let inputType = url.type;\n\n if (base && inputType !== UrlType.Absolute) {\n const baseUrl = parseUrl(base);\n const baseType = baseUrl.type;\n\n switch (inputType) {\n case UrlType.Empty:\n url.hash = baseUrl.hash;\n // fall through\n\n case UrlType.Hash:\n url.query = baseUrl.query;\n // fall through\n\n case UrlType.Query:\n case UrlType.RelativePath:\n mergePaths(url, baseUrl);\n // fall through\n\n case UrlType.AbsolutePath:\n // The host, user, and port are joined, you can't copy one without the others.\n url.user = baseUrl.user;\n url.host = baseUrl.host;\n url.port = baseUrl.port;\n // fall through\n\n case UrlType.SchemeRelative:\n // The input doesn't have a schema at least, so we need to copy at least that over.\n url.scheme = baseUrl.scheme;\n }\n if (baseType > inputType) inputType = baseType;\n }\n\n normalizePath(url, inputType);\n\n const queryHash = url.query + url.hash;\n switch (inputType) {\n // This is impossible, because of the empty checks at the start of the function.\n // case UrlType.Empty:\n\n case UrlType.Hash:\n case UrlType.Query:\n return queryHash;\n\n case UrlType.RelativePath: {\n // The first char is always a \"/\", and we need it to be relative.\n const path = url.path.slice(1);\n\n if (!path) return queryHash || '.';\n\n if (isRelative(base || input) && !isRelative(path)) {\n // If base started with a leading \".\", or there is no base and input started with a \".\",\n // then we need to ensure that the relative path starts with a \".\". We don't know if\n // relative starts with a \"..\", though, so check before prepending.\n return './' + path + queryHash;\n }\n\n return path + queryHash;\n }\n\n case UrlType.AbsolutePath:\n return url.path + queryHash;\n\n default:\n return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash;\n }\n}\n","import { encode, decode } from '@jridgewell/sourcemap-codec';\n\nimport resolver from './resolve';\nimport maybeSort from './sort';\nimport buildBySources from './by-source';\nimport {\n memoizedState,\n memoizedBinarySearch,\n upperBound,\n lowerBound,\n found as bsFound,\n} from './binary-search';\nimport {\n COLUMN,\n SOURCES_INDEX,\n SOURCE_LINE,\n SOURCE_COLUMN,\n NAMES_INDEX,\n REV_GENERATED_LINE,\n REV_GENERATED_COLUMN,\n} from './sourcemap-segment';\nimport { parse } from './types';\n\nimport type { SourceMapSegment, ReverseSegment } from './sourcemap-segment';\nimport type {\n SourceMapV3,\n DecodedSourceMap,\n EncodedSourceMap,\n InvalidOriginalMapping,\n OriginalMapping,\n InvalidGeneratedMapping,\n GeneratedMapping,\n SourceMapInput,\n Needle,\n SourceNeedle,\n SourceMap,\n EachMapping,\n Bias,\n XInput,\n SectionedSourceMap,\n Ro,\n} from './types';\nimport type { Source } from './by-source';\nimport type { MemoState } from './binary-search';\n\nexport type { SourceMapSegment } from './sourcemap-segment';\nexport type {\n SourceMap,\n DecodedSourceMap,\n EncodedSourceMap,\n Section,\n SectionedSourceMap,\n SourceMapV3,\n Bias,\n EachMapping,\n GeneratedMapping,\n InvalidGeneratedMapping,\n InvalidOriginalMapping,\n Needle,\n OriginalMapping,\n OriginalMapping as Mapping,\n SectionedSourceMapInput,\n SourceMapInput,\n SourceNeedle,\n XInput,\n EncodedSourceMapXInput,\n DecodedSourceMapXInput,\n SectionedSourceMapXInput,\n SectionXInput,\n} from './types';\n\ninterface PublicMap {\n _encoded: TraceMap['_encoded'];\n _decoded: TraceMap['_decoded'];\n _decodedMemo: TraceMap['_decodedMemo'];\n _bySources: TraceMap['_bySources'];\n _bySourceMemos: TraceMap['_bySourceMemos'];\n}\n\nconst LINE_GTR_ZERO = '`line` must be greater than 0 (lines start at line 1)';\nconst COL_GTR_EQ_ZERO = '`column` must be greater than or equal to 0 (columns start at column 0)';\n\nexport const LEAST_UPPER_BOUND = -1;\nexport const GREATEST_LOWER_BOUND = 1;\n\nexport { FlattenMap, FlattenMap as AnyMap } from './flatten-map';\n\nexport class TraceMap implements SourceMap {\n declare version: SourceMapV3['version'];\n declare file: SourceMapV3['file'];\n declare names: SourceMapV3['names'];\n declare sourceRoot: SourceMapV3['sourceRoot'];\n declare sources: SourceMapV3['sources'];\n declare sourcesContent: SourceMapV3['sourcesContent'];\n declare ignoreList: SourceMapV3['ignoreList'];\n\n declare resolvedSources: string[];\n declare private _encoded: string | undefined;\n\n declare private _decoded: SourceMapSegment[][] | undefined;\n declare private _decodedMemo: MemoState;\n\n declare private _bySources: Source[] | undefined;\n declare private _bySourceMemos: MemoState[] | undefined;\n\n constructor(map: Ro<SourceMapInput>, mapUrl?: string | null) {\n const isString = typeof map === 'string';\n if (!isString && (map as unknown as { _decodedMemo: any })._decodedMemo) return map as TraceMap;\n\n const parsed = parse(map as Exclude<SourceMapInput, TraceMap>);\n\n const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;\n this.version = version;\n this.file = file;\n this.names = names || [];\n this.sourceRoot = sourceRoot;\n this.sources = sources;\n this.sourcesContent = sourcesContent;\n this.ignoreList = parsed.ignoreList || (parsed as XInput).x_google_ignoreList || undefined;\n\n const resolve = resolver(mapUrl, sourceRoot);\n this.resolvedSources = sources.map(resolve);\n\n const { mappings } = parsed;\n if (typeof mappings === 'string') {\n this._encoded = mappings;\n this._decoded = undefined;\n } else if (Array.isArray(mappings)) {\n this._encoded = undefined;\n this._decoded = maybeSort(mappings, isString);\n } else if ((parsed as unknown as SectionedSourceMap).sections) {\n throw new Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`);\n } else {\n throw new Error(`invalid source map: ${JSON.stringify(parsed)}`);\n }\n\n this._decodedMemo = memoizedState();\n this._bySources = undefined;\n this._bySourceMemos = undefined;\n }\n}\n\n/**\n * Typescript doesn't allow friend access to private fields, so this just casts the map into a type\n * with public access modifiers.\n */\nfunction cast(map: unknown): PublicMap {\n return map as any;\n}\n\n/**\n * Returns the encoded (VLQ string) form of the SourceMap's mappings field.\n */\nexport function encodedMappings(map: TraceMap): EncodedSourceMap['mappings'] {\n return (cast(map)._encoded ??= encode(cast(map)._decoded!));\n}\n\n/**\n * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.\n */\nexport function decodedMappings(map: TraceMap): Readonly<DecodedSourceMap['mappings']> {\n return (cast(map)._decoded ||= decode(cast(map)._encoded!));\n}\n\n/**\n * A low-level API to find the segment associated with a generated line/column (think, from a\n * stack trace). Line and column here are 0-based, unlike `originalPositionFor`.\n */\nexport function traceSegment(\n map: TraceMap,\n line: number,\n column: number,\n): Readonly<SourceMapSegment> | null {\n const decoded = decodedMappings(map);\n\n // It's common for parent source maps to have pointers to lines that have no\n // mapping (like a \"//# sourceMappingURL=\") at the end of the child file.\n if (line >= decoded.length) return null;\n\n const segments = decoded[line];\n const index = traceSegmentInternal(\n segments,\n cast(map)._decodedMemo,\n line,\n column,\n GREATEST_LOWER_BOUND,\n );\n\n return index === -1 ? null : segments[index];\n}\n\n/**\n * A higher-level API to find the source/line/column associated with a generated line/column\n * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in\n * `source-map` library.\n */\nexport function originalPositionFor(\n map: TraceMap,\n needle: Needle,\n): OriginalMapping | InvalidOriginalMapping {\n let { line, column, bias } = needle;\n line--;\n if (line < 0) throw new Error(LINE_GTR_ZERO);\n if (column < 0) throw new Error(COL_GTR_EQ_ZERO);\n\n const decoded = decodedMappings(map);\n\n // It's common for parent source maps to have pointers to lines that have no\n // mapping (like a \"//# sourceMappingURL=\") at the end of the child file.\n if (line >= decoded.length) return OMapping(null, null, null, null);\n\n const segments = decoded[line];\n const index = traceSegmentInternal(\n segments,\n cast(map)._decodedMemo,\n line,\n column,\n bias || GREATEST_LOWER_BOUND,\n );\n\n if (index === -1) return OMapping(null, null, null, null);\n\n const segment = segments[index];\n if (segment.length === 1) return OMapping(null, null, null, null);\n\n const { names, resolvedSources } = map;\n return OMapping(\n resolvedSources[segment[SOURCES_INDEX]],\n segment[SOURCE_LINE] + 1,\n segment[SOURCE_COLUMN],\n segment.length === 5 ? names[segment[NAMES_INDEX]] : null,\n );\n}\n\n/**\n * Finds the generated line/column position of the provided source/line/column source position.\n */\nexport function generatedPositionFor(\n map: TraceMap,\n needle: SourceNeedle,\n): GeneratedMapping | InvalidGeneratedMapping {\n const { source, line, column, bias } = needle;\n return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND, false);\n}\n\n/**\n * Finds all generated line/column positions of the provided source/line/column source position.\n */\nexport function allGeneratedPositionsFor(map: TraceMap, needle: SourceNeedle): GeneratedMapping[] {\n const { source, line, column, bias } = needle;\n // SourceMapConsumer uses LEAST_UPPER_BOUND for some reason, so we follow suit.\n return generatedPosition(map, source, line, column, bias || LEAST_UPPER_BOUND, true);\n}\n\n/**\n * Iterates each mapping in generated position order.\n */\nexport function eachMapping(map: TraceMap, cb: (mapping: EachMapping) => void): void {\n const decoded = decodedMappings(map);\n const { names, resolvedSources } = map;\n\n for (let i = 0; i < decoded.length; i++) {\n const line = decoded[i];\n for (let j = 0; j < line.length; j++) {\n const seg = line[j];\n\n const generatedLine = i + 1;\n const generatedColumn = seg[0];\n let source = null;\n let originalLine = null;\n let originalColumn = null;\n let name = null;\n if (seg.length !== 1) {\n source = resolvedSources[seg[1]];\n originalLine = seg[2] + 1;\n originalColumn = seg[3];\n }\n if (seg.length === 5) name = names[seg[4]];\n\n cb({\n generatedLine,\n generatedColumn,\n source,\n originalLine,\n originalColumn,\n name,\n } as EachMapping);\n }\n }\n}\n\nfunction sourceIndex(map: TraceMap, source: string): number {\n const { sources, resolvedSources } = map;\n let index = sources.indexOf(source);\n if (index === -1) index = resolvedSources.indexOf(source);\n return index;\n}\n\n/**\n * Retrieves the source content for a particular source, if its found. Returns null if not.\n */\nexport function sourceContentFor(map: TraceMap, source: string): string | null {\n const { sourcesContent } = map;\n if (sourcesContent == null) return null;\n const index = sourceIndex(map, source);\n return index === -1 ? null : sourcesContent[index];\n}\n\n/**\n * Determines if the source is marked to ignore by the source map.\n */\nexport function isIgnored(map: TraceMap, source: string): boolean {\n const { ignoreList } = map;\n if (ignoreList == null) return false;\n const index = sourceIndex(map, source);\n return index === -1 ? false : ignoreList.includes(index);\n}\n\n/**\n * A helper that skips sorting of the input map's mappings array, which can be expensive for larger\n * maps.\n */\nexport function presortedDecodedMap(map: DecodedSourceMap, mapUrl?: string): TraceMap {\n const tracer = new TraceMap(clone(map, []), mapUrl);\n cast(tracer)._decoded = map.mappings;\n return tracer;\n}\n\n/**\n * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects\n * a sourcemap, or to JSON.stringify.\n */\nexport function decodedMap(\n map: TraceMap,\n): Omit<DecodedSourceMap, 'mappings'> & { mappings: readonly SourceMapSegment[][] } {\n return clone(map, decodedMappings(map));\n}\n\n/**\n * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects\n * a sourcemap, or to JSON.stringify.\n */\nexport function encodedMap(map: TraceMap): EncodedSourceMap {\n return clone(map, encodedMappings(map));\n}\n\nfunction clone<T extends string | readonly SourceMapSegment[][]>(\n map: TraceMap | DecodedSourceMap,\n mappings: T,\n): T extends string ? EncodedSourceMap : DecodedSourceMap {\n return {\n version: map.version,\n file: map.file,\n names: map.names,\n sourceRoot: map.sourceRoot,\n sources: map.sources,\n sourcesContent: map.sourcesContent,\n mappings,\n ignoreList: map.ignoreList || (map as XInput).x_google_ignoreList,\n } as any;\n}\n\nfunction OMapping(source: null, line: null, column: null, name: null): InvalidOriginalMapping;\nfunction OMapping(\n source: string,\n line: number,\n column: number,\n name: string | null,\n): OriginalMapping;\nfunction OMapping(\n source: string | null,\n line: number | null,\n column: number | null,\n name: string | null,\n): OriginalMapping | InvalidOriginalMapping {\n return { source, line, column, name } as any;\n}\n\nfunction GMapping(line: null, column: null): InvalidGeneratedMapping;\nfunction GMapping(line: number, column: number): GeneratedMapping;\nfunction GMapping(\n line: number | null,\n column: number | null,\n): GeneratedMapping | InvalidGeneratedMapping {\n return { line, column } as any;\n}\n\nfunction traceSegmentInternal(\n segments: SourceMapSegment[],\n memo: MemoState,\n line: number,\n column: number,\n bias: Bias,\n): number;\nfunction traceSegmentInternal(\n segments: ReverseSegment[],\n memo: MemoState,\n line: number,\n column: number,\n bias: Bias,\n): number;\nfunction traceSegmentInternal(\n segments: SourceMapSegment[] | ReverseSegment[],\n memo: MemoState,\n line: number,\n column: number,\n bias: Bias,\n): number {\n let index = memoizedBinarySearch(segments, column, memo, line);\n if (bsFound) {\n index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);\n } else if (bias === LEAST_UPPER_BOUND) index++;\n\n if (index === -1 || index === segments.length) return -1;\n return index;\n}\n\nfunction sliceGeneratedPositions(\n segments: ReverseSegment[],\n memo: MemoState,\n line: number,\n column: number,\n bias: Bias,\n): GeneratedMapping[] {\n let min = traceSegmentInternal(segments, memo, line, column, GREATEST_LOWER_BOUND);\n\n // We ignored the bias when tracing the segment so that we're guarnateed to find the first (in\n // insertion order) segment that matched. Even if we did respect the bias when tracing, we would\n // still need to call `lowerBound()` to find the first segment, which is slower than just looking\n // for the GREATEST_LOWER_BOUND to begin with. The only difference that matters for us is when the\n // binary search didn't match, in which case GREATEST_LOWER_BOUND just needs to increment to\n // match LEAST_UPPER_BOUND.\n if (!bsFound && bias === LEAST_UPPER_BOUND) min++;\n\n if (min === -1 || min === segments.length) return [];\n\n // We may have found the segment that started at an earlier column. If this is the case, then we\n // need to slice all generated segments that match _that_ column, because all such segments span\n // to our desired column.\n const matchedColumn = bsFound ? column : segments[min][COLUMN];\n\n // The binary search is not guaranteed to find the lower bound when a match wasn't found.\n if (!bsFound) min = lowerBound(segments, matchedColumn, min);\n const max = upperBound(segments, matchedColumn, min);\n\n const result = [];\n for (; min <= max; min++) {\n const segment = segments[min];\n result.push(GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]));\n }\n return result;\n}\n\nfunction generatedPosition(\n map: TraceMap,\n source: string,\n line: number,\n column: number,\n bias: Bias,\n all: false,\n): GeneratedMapping | InvalidGeneratedMapping;\nfunction generatedPosition(\n map: TraceMap,\n source: string,\n line: number,\n column: number,\n bias: Bias,\n all: true,\n): GeneratedMapping[];\nfunction generatedPosition(\n map: TraceMap,\n source: string,\n line: number,\n column: number,\n bias: Bias,\n all: boolean,\n): GeneratedMapping | InvalidGeneratedMapping | GeneratedMapping[] {\n line--;\n if (line < 0) throw new Error(LINE_GTR_ZERO);\n if (column < 0) throw new Error(COL_GTR_EQ_ZERO);\n\n const { sources, resolvedSources } = map;\n let sourceIndex = sources.indexOf(source);\n if (sourceIndex === -1) sourceIndex = resolvedSources.indexOf(source);\n if (sourceIndex === -1) return all ? [] : GMapping(null, null);\n\n const bySourceMemos = (cast(map)._bySourceMemos ||= sources.map(memoizedState));\n const generated = (cast(map)._bySources ||= buildBySources(decodedMappings(map), bySourceMemos));\n\n const segments = generated[sourceIndex][line];\n if (segments == null) return all ? [] : GMapping(null, null);\n\n const memo = bySourceMemos[sourceIndex];\n\n if (all) return sliceGeneratedPositions(segments, memo, line, column, bias);\n\n const index = traceSegmentInternal(segments, memo, line, column, bias);\n if (index === -1) return GMapping(null, null);\n\n const segment = segments[index];\n return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]);\n}\n","import resolveUri from '@jridgewell/resolve-uri';\nimport stripFilename from './strip-filename';\n\ntype Resolve = (source: string | null) => string;\nexport default function resolver(\n mapUrl: string | null | undefined,\n sourceRoot: string | undefined,\n): Resolve {\n const from = stripFilename(mapUrl);\n // The sourceRoot is always treated as a directory, if it's not empty.\n // https://github.com/mozilla/source-map/blob/8cb3ee57/lib/util.js#L327\n // https://github.com/chromium/chromium/blob/da4adbb3/third_party/blink/renderer/devtools/front_end/sdk/SourceMap.js#L400-L401\n const prefix = sourceRoot ? sourceRoot + '/' : '';\n\n return (source) => resolveUri(prefix + (source || ''), from);\n}\n","/**\n * Removes everything after the last \"/\", but leaves the slash.\n */\nexport default function stripFilename(path: string | undefined | null): string {\n if (!path) return '';\n const index = path.lastIndexOf('/');\n return path.slice(0, index + 1);\n}\n","type GeneratedColumn = number;\ntype SourcesIndex = number;\ntype SourceLine = number;\ntype SourceColumn = number;\ntype NamesIndex = number;\n\ntype GeneratedLine = number;\n\nexport type SourceMapSegment =\n | [GeneratedColumn]\n | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn]\n | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex];\n\nexport type ReverseSegment = [SourceColumn, GeneratedLine, GeneratedColumn];\n\nexport const COLUMN = 0;\nexport const SOURCES_INDEX = 1;\nexport const SOURCE_LINE = 2;\nexport const SOURCE_COLUMN = 3;\nexport const NAMES_INDEX = 4;\n\nexport const REV_GENERATED_LINE = 1;\nexport const REV_GENERATED_COLUMN = 2;\n","import { COLUMN } from './sourcemap-segment';\n\nimport type { ReverseSegment, SourceMapSegment } from './sourcemap-segment';\n\nexport default function maybeSort(\n mappings: SourceMapSegment[][],\n owned: boolean,\n): SourceMapSegment[][] {\n const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);\n if (unsortedIndex === mappings.length) return mappings;\n\n // If we own the array (meaning we parsed it from JSON), then we're free to directly mutate it. If\n // not, we do not want to modify the consumer's input array.\n if (!owned) mappings = mappings.slice();\n\n for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {\n mappings[i] = sortSegments(mappings[i], owned);\n }\n return mappings;\n}\n\nfunction nextUnsortedSegmentLine(mappings: SourceMapSegment[][], start: number): number {\n for (let i = start; i < mappings.length; i++) {\n if (!isSorted(mappings[i])) return i;\n }\n return mappings.length;\n}\n\nfunction isSorted(line: SourceMapSegment[]): boolean {\n for (let j = 1; j < line.length; j++) {\n if (line[j][COLUMN] < line[j - 1][COLUMN]) {\n return false;\n }\n }\n return true;\n}\n\nfunction sortSegments(line: SourceMapSegment[], owned: boolean): SourceMapSegment[] {\n if (!owned) line = line.slice();\n return line.sort(sortComparator);\n}\n\nexport function sortComparator<T extends SourceMapSegment | ReverseSegment>(a: T, b: T): number {\n return a[COLUMN] - b[COLUMN];\n}\n","import { COLUMN, SOURCES_INDEX, SOURCE_LINE, SOURCE_COLUMN } from './sourcemap-segment';\nimport { sortComparator } from './sort';\n\nimport type { ReverseSegment, SourceMapSegment } from './sourcemap-segment';\n\nexport type Source = ReverseSegment[][];\n\n// Rebuilds the original source files, with mappings that are ordered by source line/column instead\n// of generated line/column.\nexport default function buildBySources(\n decoded: readonly SourceMapSegment[][],\n memos: unknown[],\n): Source[] {\n const sources: Source[] = memos.map(() => []);\n\n for (let i = 0; i < decoded.length; i++) {\n const line = decoded[i];\n for (let j = 0; j < line.length; j++) {\n const seg = line[j];\n if (seg.length === 1) continue;\n\n const sourceIndex = seg[SOURCES_INDEX];\n const sourceLine = seg[SOURCE_LINE];\n const sourceColumn = seg[SOURCE_COLUMN];\n\n const source = sources[sourceIndex];\n const segs = (source[sourceLine] ||= []);\n segs.push([sourceColumn, i, seg[COLUMN]]);\n }\n }\n\n for (let i = 0; i < sources.length; i++) {\n const source = sources[i];\n for (let j = 0; j < source.length; j++) {\n const line = source[j];\n if (line) line.sort(sortComparator);\n }\n }\n\n return sources;\n}\n","import type { SourceMapSegment, ReverseSegment } from './sourcemap-segment';\nimport { COLUMN } from './sourcemap-segment';\n\nexport type MemoState = {\n lastKey: number;\n lastNeedle: number;\n lastIndex: number;\n};\n\nexport let found = false;\n\n/**\n * A binary search implementation that returns the index if a match is found.\n * If no match is found, then the left-index (the index associated with the item that comes just\n * before the desired index) is returned. To maintain proper sort order, a splice would happen at\n * the next index:\n *\n * ```js\n * const array = [1, 3];\n * const needle = 2;\n * const index = binarySearch(array, needle, (item, needle) => item - needle);\n *\n * assert.equal(index, 0);\n * array.splice(index + 1, 0, needle);\n * assert.deepEqual(array, [1, 2, 3]);\n * ```\n */\nexport function binarySearch(\n haystack: SourceMapSegment[] | ReverseSegment[],\n needle: number,\n low: number,\n high: number,\n): number {\n while (low <= high) {\n const mid = low + ((high - low) >> 1);\n const cmp = haystack[mid][COLUMN] - needle;\n\n if (cmp === 0) {\n found = true;\n return mid;\n }\n\n if (cmp < 0) {\n low = mid + 1;\n } else {\n high = mid - 1;\n }\n }\n\n found = false;\n return low - 1;\n}\n\nexport function upperBound(\n haystack: SourceMapSegment[] | ReverseSegment[],\n needle: number,\n index: number,\n): number {\n for (let i = index + 1; i < haystack.length; index = i++) {\n if (haystack[i][COLUMN] !== needle) break;\n }\n return index;\n}\n\nexport function lowerBound(\n haystack: SourceMapSegment[] | ReverseSegment[],\n needle: number,\n index: number,\n): number {\n for (let i = index - 1; i >= 0; index = i--) {\n if (haystack[i][COLUMN] !== needle) break;\n }\n return index;\n}\n\nexport function memoizedState(): MemoState {\n return {\n lastKey: -1,\n lastNeedle: -1,\n lastIndex: -1,\n };\n}\n\n/**\n * This overly complicated beast is just to record the last tested line/column and the resulting\n * index, allowing us to skip a few tests if mappings are monotonically increasing.\n */\nexport function memoizedBinarySearch(\n haystack: SourceMapSegment[] | ReverseSegment[],\n needle: number,\n state: MemoState,\n key: number,\n): number {\n const { lastKey, lastNeedle, lastIndex } = state;\n\n let low = 0;\n let high = haystack.length - 1;\n if (key === lastKey) {\n if (needle === lastNeedle) {\n found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;\n return lastIndex;\n }\n\n if (needle >= lastNeedle) {\n // lastIndex may be -1 if the previous needle was not found.\n low = lastIndex === -1 ? 0 : lastIndex;\n } else {\n high = lastIndex;\n }\n }\n state.lastKey = key;\n state.lastNeedle = needle;\n\n return (state.lastIndex = binarySearch(haystack, needle, low, high));\n}\n","import type { SourceMapSegment } from './sourcemap-segment';\nimport type { GREATEST_LOWER_BOUND, LEAST_UPPER_BOUND, TraceMap } from './trace-mapping';\n\nexport interface SourceMapV3 {\n file?: string | null;\n names: string[];\n sourceRoot?: string;\n sources: (string | null)[];\n sourcesContent?: (string | null)[];\n version: 3;\n ignoreList?: number[];\n}\n\nexport interface EncodedSourceMap extends SourceMapV3 {\n mappings: string;\n}\n\nexport interface DecodedSourceMap extends SourceMapV3 {\n mappings: SourceMapSegment[][];\n}\n\nexport interface Section {\n offset: { line: number; column: number };\n map: EncodedSourceMap | DecodedSourceMap | SectionedSourceMap;\n}\n\nexport interface SectionedSourceMap {\n file?: string | null;\n sections: Section[];\n version: 3;\n}\n\nexport type OriginalMapping = {\n source: string | null;\n line: number;\n column: number;\n name: string | null;\n};\n\nexport type InvalidOriginalMapping = {\n source: null;\n line: null;\n column: null;\n name: null;\n};\n\nexport type GeneratedMapping = {\n line: number;\n column: number;\n};\nexport type InvalidGeneratedMapping = {\n line: null;\n column: null;\n};\n\nexport type Bias = typeof GREATEST_LOWER_BOUND | typeof LEAST_UPPER_BOUND;\n\nexport type XInput = { x_google_ignoreList?: SourceMapV3['ignoreList'] };\nexport type EncodedSourceMapXInput = EncodedSourceMap & XInput;\nexport type DecodedSourceMapXInput = DecodedSourceMap & XInput;\nexport type SectionedSourceMapXInput = Omit<SectionedSourceMap, 'sections'> & {\n sections: SectionXInput[];\n};\nexport type SectionXInput = Omit<Section, 'map'> & {\n map: SectionedSourceMapInput;\n};\n\nexport type SourceMapInput = string | EncodedSourceMapXInput | DecodedSourceMapXInput | TraceMap;\nexport type SectionedSourceMapInput = SourceMapInput | SectionedSourceMapXInput;\n\nexport type Needle = { line: number; column: number; bias?: Bias };\nexport type SourceNeedle = { source: string; line: number; column: number; bias?: Bias };\n\nexport type EachMapping =\n | {\n generatedLine: number;\n generatedColumn: number;\n source: null;\n originalLine: null;\n originalColumn: null;\n name: null;\n }\n | {\n generatedLine: number;\n generatedColumn: number;\n source: string | null;\n originalLine: number;\n originalColumn: number;\n name: string | null;\n };\n\nexport abstract class SourceMap {\n declare version: SourceMapV3['version'];\n declare file: SourceMapV3['file'];\n declare names: SourceMapV3['names'];\n declare sourceRoot: SourceMapV3['sourceRoot'];\n declare sources: SourceMapV3['sources'];\n declare sourcesContent: SourceMapV3['sourcesContent'];\n declare resolvedSources: SourceMapV3['sources'];\n declare ignoreList: SourceMapV3['ignoreList'];\n}\n\nexport type Ro<T> =\n T extends Array<infer V>\n ? V[] | Readonly<V[]> | RoArray<V> | Readonly<RoArray<V>>\n : T extends object\n ? T | Readonly<T> | RoObject<T> | Readonly<RoObject<T>>\n : T;\ntype RoArray<T> = Ro<T>[];\ntype RoObject<T> = { [K in keyof T]: T[K] | Ro<T[K]> };\n\nexport function parse<T>(map: T): Exclude<T, string> {\n return typeof map === 'string' ? JSON.parse(map) : (map as Exclude<T, string>);\n}\n","import { TraceMap, presortedDecodedMap, decodedMappings } from './trace-mapping';\nimport {\n COLUMN,\n SOURCES_INDEX,\n SOURCE_LINE,\n SOURCE_COLUMN,\n NAMES_INDEX,\n} from './sourcemap-segment';\nimport { parse } from './types';\n\nimport type {\n DecodedSourceMap,\n DecodedSourceMapXInput,\n EncodedSourceMapXInput,\n SectionedSourceMapXInput,\n SectionedSourceMapInput,\n SectionXInput,\n Ro,\n} from './types';\nimport type { SourceMapSegment } from './sourcemap-segment';\n\ntype FlattenMap = {\n new (map: Ro<SectionedSourceMapInput>, mapUrl?: string | null): TraceMap;\n (map: Ro<SectionedSourceMapInput>, mapUrl?: string | null): TraceMap;\n};\n\nexport const FlattenMap: FlattenMap = function (map, mapUrl) {\n const parsed = parse(map as SectionedSourceMapInput);\n\n if (!('sections' in parsed)) {\n return new TraceMap(parsed as DecodedSourceMapXInput | EncodedSourceMapXInput, mapUrl);\n }\n\n const mappings: SourceMapSegment[][] = [];\n const sources: string[] = [];\n const sourcesContent: (string | null)[] = [];\n const names: string[] = [];\n const ignoreList: number[] = [];\n\n recurse(\n parsed,\n mapUrl,\n mappings,\n sources,\n sourcesContent,\n names,\n ignoreList,\n 0,\n 0,\n Infinity,\n Infinity,\n );\n\n const joined: DecodedSourceMap = {\n version: 3,\n file: parsed.file,\n names,\n sources,\n sourcesContent,\n mappings,\n ignoreList,\n };\n\n return presortedDecodedMap(joined);\n} as FlattenMap;\n\nfunction recurse(\n input: SectionedSourceMapXInput,\n mapUrl: string | null | undefined,\n mappings: SourceMapSegment[][],\n sources: string[],\n sourcesContent: (string | null)[],\n names: string[],\n ignoreList: number[],\n lineOffset: number,\n columnOffset: number,\n stopLine: number,\n stopColumn: number,\n) {\n const { sections } = input;\n for (let i = 0; i < sections.length; i++) {\n const { map, offset } = sections[i];\n\n let sl = stopLine;\n let sc = stopColumn;\n if (i + 1 < sections.length) {\n const nextOffset = sections[i + 1].offset;\n sl = Math.min(stopLine, lineOffset + nextOffset.line);\n\n if (sl === stopLine) {\n sc = Math.min(stopColumn, columnOffset + nextOffset.column);\n } else if (sl < stopLine) {\n sc = columnOffset + nextOffset.column;\n }\n }\n\n addSection(\n map,\n mapUrl,\n mappings,\n sources,\n sourcesContent,\n names,\n ignoreList,\n lineOffset + offset.line,\n columnOffset + offset.column,\n sl,\n sc,\n );\n }\n}\n\nfunction addSection(\n input: SectionXInput['map'],\n mapUrl: string | null | undefined,\n mappings: SourceMapSegment[][],\n sources: string[],\n sourcesContent: (string | null)[],\n names: string[],\n ignoreList: number[],\n lineOffset: number,\n columnOffset: number,\n stopLine: number,\n stopColumn: number,\n) {\n const parsed = parse(input);\n if ('sections' in parsed) return recurse(...(arguments as unknown as Parameters<typeof recurse>));\n\n const map = new TraceMap(parsed, mapUrl);\n const sourcesOffset = sources.length;\n const namesOffset = names.length;\n const decoded = decodedMappings(map);\n const { resolvedSources, sourcesContent: contents, ignoreList: ignores } = map;\n\n append(sources, resolvedSources);\n append(names, map.names);\n\n if (contents) append(sourcesContent, contents);\n else for (let i = 0; i < resolvedSources.length; i++) sourcesContent.push(null);\n\n if (ignores) for (let i = 0; i < ignores.length; i++) ignoreList.push(ignores[i] + sourcesOffset);\n\n for (let i = 0; i < decoded.length; i++) {\n const lineI = lineOffset + i;\n\n // We can only add so many lines before we step into the range that the next section's map\n // controls. When we get to the last line, then we'll start checking the segments to see if\n // they've crossed into the column range. But it may not have any columns that overstep, so we\n // still need to check that we don't overstep lines, too.\n if (lineI > stopLine) return;\n\n // The out line may already exist in mappings (if we're continuing the line started by a\n // previous section). Or, we may have jumped ahead several lines to start this section.\n const out = getLine(mappings, lineI);\n // On the 0th loop, the section's column offset shifts us forward. On all other lines (since the\n // map can be multiple lines), it doesn't.\n const cOffset = i === 0 ? columnOffset : 0;\n\n const line = decoded[i];\n for (let j = 0; j < line.length; j++) {\n const seg = line[j];\n const column = cOffset + seg[COLUMN];\n\n // If this segment steps into the column range that the next section's map controls, we need\n // to stop early.\n if (lineI === stopLine && column >= stopColumn) return;\n\n if (seg.length === 1) {\n out.push([column]);\n continue;\n }\n\n const sourcesIndex = sourcesOffset + seg[SOURCES_INDEX];\n const sourceLine = seg[SOURCE_LINE];\n const sourceColumn = seg[SOURCE_COLUMN];\n out.push(\n seg.length === 4\n ? [column, sourcesIndex, sourceLine, sourceColumn]\n : [column, sourcesIndex, sourceLine, sourceColumn, namesOffset + seg[NAMES_INDEX]],\n );\n }\n }\n}\n\nfunction append<T>(arr: T[], other: T[]) {\n for (let i = 0; i < other.length; i++) arr.push(other[i]);\n}\n\nfunction getLine<T>(arr: T[][], index: number): T[] {\n for (let i = arr.length; i <= index; i++) arr[i] = [];\n return arr[index];\n}\n"],"mappings":";;;;;;;;;;AAAA;SAAS,aAAmD;AAC5D,SAAS,gBAAAA,eAAc,cAAAC,mBAAkB;AACzC,SAAS,eAAe;AACxB,SAAS,QAAAC,aAAY;;;ACHrB;AAyBO,IAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACzBvC;SAAS,YAAY,cAAc,aAAa,gBAAgB;AAChE,SAAS,SAAS,MAAM,aAAa;A;;;;;;ACC9B,IAAM,QAAQ,IAAI,WAAW,CAAC;AAC9B,IAAM,YAAY,IAAI,WAAW,CAAC;AAEzC,IAAM,QAAQ;AACd,IAAM,YAAY,IAAI,WAAW,EAAE;AACnC,IAAM,YAAY,IAAI,WAAW,GAAG;AAEpC,SAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,QAAM,IAAI,MAAM,WAAW,CAAC;AAC5B,YAAU,CAAC,IAAI;AACf,YAAU,CAAC,IAAI;AACjB;AAEO,SAAS,cAAc,QAAsB,UAA0B;AAC5E,MAAI,QAAQ;AACZ,MAAI,QAAQ;AACZ,MAAI,UAAU;AAEd,KAAG;AACD,UAAM,IAAI,OAAO,KAAK;AACtB,cAAU,UAAU,CAAC;AACrB,cAAU,UAAU,OAAO;AAC3B,aAAS;EACX,SAAS,UAAU;AAEnB,QAAM,eAAe,QAAQ;AAC7B,aAAW;AAEX,MAAI,cAAc;AAChB,YAAQ,cAAc,CAAC;EACzB;AAEA,SAAO,WAAW;AACpB;AAgBO,SAAS,WAAW,QAAsB,KAAa;AAC5D,MAAI,OAAO,OAAO,IAAK,QAAO;AAC9B,S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Q,QAAQ,OAAO,MAAM,EAAE,KAAK,OAAO,CAAC,UAAU,QAAQ,MAAM,EAAC,CAAE;AAC7E,QAAI,SAAS;AACb,QAAI,SAAS;AACb,UAAM,QAAQ,GAAG,QAAQ,CAAC,MAAe,UAAU,EAAE,SAAQ,CAAG;AAChE,UAAM,QAAQ,GAAG,QAAQ,CAAC,MAAe,UAAU,EAAE,SAAQ,CAAG;AAChE,UAAM,GAAG,SAAS,MAAMA,SAAQ,EAAE,MAAM,GAAG,QAAQ,OAAM,CAAE,CAAC;AAC5D,UAAM,GAAG,QAAQ,CAAC,SAASA,SAAQ,EAAE,MAAM,QAAQ,GAAG,QAAQ,OAAM,CAAE,CAAC;EACzE,CAAC;AACH;AAEA,SAAS,8BAA8B,OAAmB;AAGxD,SAAO,MAAM,KAAK,CAAC,MAAM,eAAe,KAAK,EAAE,IAAI,CAAC;AACtD;AAEA,SAAS,eAAe,KAAkB;AACxC,MAAI,CAAC;AAAK,WAAO,CAAA;AACjB,MAAI;AACF,UAAM,SAAS,KAAK,MAAM,GAAG;AAC7B,QAAI,MAAM,QAAQ,MAAM;AAAG,aAAO;EACpC,QAAQ;EAER;AACA,SAAO,CAAA;AACT;AAEA,SAAS,iBAAiB,KAAkB;AAC1C,MAAI,CAAC;AAAK,WAAO;AACjB,MAAI;AACF,WAAO,KAAK,MAAM,GAAG;EACvB,QAAQ;AACN,WAAO;EACT;AACF;AAEA,SAAS,QAAQ,GAAS;AACxB,QAAM,IAAI,CAAC,MAAM,MAAM,MAAM,IAAI;AACjC,QAAM,IAAI,IAAI;AACd,SAAO,GAAG,CAAC,GAAG,GAAG,IAAI,MAAM,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC;AAChD;","names":["readFileSync","existsSync","join","url","sortComparator","resolve","found","resolver","join","existsSync","readFileSync","resolve"]}
package/dist/ready.mp3 ADDED
Binary file
Binary file
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@iroaxel/arcena",
3
+ "version": "4.3.157",
4
+ "type": "module",
5
+ "description": "Orchestrator agent that drives multiple arcicoder sessions across projects from a single chat",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/BigBlindGorg/ARCena.git",
10
+ "directory": "packages/gg-boss"
11
+ },
12
+ "bin": {
13
+ "arcena": "./dist/cli.js"
14
+ },
15
+ "exports": {
16
+ ".": {
17
+ "import": "./dist/index.js",
18
+ "types": "./dist/index.d.ts"
19
+ }
20
+ },
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "devDependencies": {
25
+ "@types/node": "^25.6.0",
26
+ "@types/react": "^19.2.14",
27
+ "chalk": "^5.6.2",
28
+ "ink": "^7.0.2",
29
+ "react": "^19.2.5",
30
+ "tsup": "^8.5.1",
31
+ "typescript": "^6.0.3",
32
+ "vitest": "^4.1.4",
33
+ "zod": "^4.4.3",
34
+ "@iroaxel/gg-agent": "4.3.166",
35
+ "@iroaxel/gg-ai": "4.3.166",
36
+ "@iroaxel/arcicoder": "4.3.166"
37
+ },
38
+ "optionalDependencies": {
39
+ "@huggingface/transformers": "^3.6.0",
40
+ "ogg-opus-decoder": "^1.6.13"
41
+ },
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "scripts": {
46
+ "build": "tsup && cp -R assets/. dist/ && chmod +x dist/cli.js",
47
+ "check": "tsc --noEmit",
48
+ "test": "vitest run"
49
+ }
50
+ }