@bastani/atomic 0.9.46-alpha.1 → 0.9.46
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/CHANGELOG.md +45 -0
- package/dist/builtin/intercom/CHANGELOG.md +11 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +11 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +2 -2
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +40 -0
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +55 -28
- package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +55 -28
- package/dist/builtin/workflows/src/index.js +55 -28
- package/dist/builtin/workflows/src/local-worker-entry.mjs +55 -28
- package/dist/core/agent-session-tasks.d.ts.map +1 -1
- package/dist/core/agent-session-tasks.js +8 -1
- package/dist/core/agent-session-tasks.js.map +1 -1
- package/dist/core/extensions/ui-types.d.ts +9 -1
- package/dist/core/extensions/ui-types.d.ts.map +1 -1
- package/dist/core/extensions/ui-types.js.map +1 -1
- package/dist/core/model-resolver-defaults.js +2 -2
- package/dist/core/model-resolver-defaults.js.map +1 -1
- package/dist/core/package-manager-npm.d.ts.map +1 -1
- package/dist/core/package-manager-npm.js +7 -3
- package/dist/core/package-manager-npm.js.map +1 -1
- package/dist/core/tasks/completion.d.ts +6 -1
- package/dist/core/tasks/completion.d.ts.map +1 -1
- package/dist/core/tasks/completion.js +33 -18
- package/dist/core/tasks/completion.js.map +1 -1
- package/dist/core/tasks/pause.d.ts +2 -1
- package/dist/core/tasks/pause.d.ts.map +1 -1
- package/dist/core/tasks/pause.js +3 -2
- package/dist/core/tasks/pause.js.map +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +6 -4
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/shell-task-status.d.ts.map +1 -1
- package/dist/core/tools/shell-task-status.js +2 -1
- package/dist/core/tools/shell-task-status.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +20 -12
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-custom-ui.js +1 -1
- package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-dialogs.js +10 -4
- package/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts +3 -0
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.js +1 -0
- package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
- package/dist/modes/interactive-engine/protocol.d.ts +6 -0
- package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
- package/dist/modes/interactive-engine/protocol.js +9 -0
- package/dist/modes/interactive-engine/protocol.js.map +1 -1
- package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
- package/dist/modes/interactive-engine/remote-component.js +3 -2
- package/dist/modes/interactive-engine/remote-component.js.map +1 -1
- package/docs/llama-cpp.md +25 -14
- package/docs/tui.md +2 -0
- package/npm-shrinkwrap.json +32 -32
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grep.js","sourceRoot":"","sources":["../../../src/core/tools/grep.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe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CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;YAC1C,OAAO,IAAI,CAAC;QACb,CAAC;QACD,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO;YAC3C,MAAM,IAAI,GAAI,OAAO,CAAC,aAAkC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;YAC3E,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAyB;IACpE,OAAO,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import { readFile as fsReadFile, stat as fsStat } from \"node:fs/promises\";\nimport { createInterface } from \"node:readline\";\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Text } from \"@earendil-works/pi-tui\";\nimport { spawn } from \"child_process\";\nimport path from \"path\";\nimport { type Static, Type } from \"typebox\";\nimport { parenthesizedKeyHint } from \"../../modes/interactive/components/keybinding-hints.js\";\nimport { createChildProcessEnvironment } from \"../../utils/child-process.ts\";\nimport { ensureTool } from \"../../utils/tools-manager.ts\";\nimport type { ExtensionContext, ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\nimport { getTextOutput, invalidArgText, shortenPath, str } from \"./render-utils.ts\";\nimport { loadNativeSearchBinding, type NativeGrepMatch } from \"./search-native.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport {\n\tDEFAULT_MAX_BYTES,\n\tformatSize,\n\tGREP_MAX_LINE_LENGTH,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n} from \"./truncate.ts\";\n\nconst grepSchema = Type.Object(\n\t{\n\t\tpattern: Type.String({ description: \"Search pattern (regex or literal string)\" }),\n\t\tpath: Type.Optional(Type.String({ description: \"Directory or file to search (default: current directory)\" })),\n\t\tglob: Type.Optional(Type.String({ description: \"Filter files by glob pattern, e.g. '*.ts' or '**/*.spec.ts'\" })),\n\t\tignoreCase: Type.Optional(Type.Boolean({ description: \"Case-insensitive search (default: false)\" })),\n\t\ttype: Type.Optional(Type.String({ description: \"File type filter for native grep.\" })),\n\t\tliteral: Type.Optional(\n\t\t\tType.Boolean({ description: \"Treat pattern as literal string instead of regex (default: false)\" }),\n\t\t),\n\t\tcontext: Type.Optional(\n\t\t\tType.Number({ description: \"Number of lines to show before and after each match (default: 0)\" }),\n\t\t),\n\t\tcontextBefore: Type.Optional(Type.Number({ description: \"Lines to show before each match.\" })),\n\t\tcontextAfter: Type.Optional(Type.Number({ description: \"Lines to show after each match.\" })),\n\t\tlimit: Type.Optional(Type.Number({ description: \"Maximum number of matches to return (default: 100)\" })),\n\t\toffset: Type.Optional(Type.Number({ description: \"Skip first N matches.\" })),\n\t\tmode: Type.Optional(\n\t\t\tType.Union([Type.Literal(\"content\"), Type.Literal(\"count\"), Type.Literal(\"filesWithMatches\")]),\n\t\t),\n\t\tmaxCountPerFile: Type.Optional(Type.Number({ description: \"Maximum matches per file.\" })),\n\t\thidden: Type.Optional(Type.Boolean({ description: \"Search hidden files (default true).\" })),\n\t\tcache: Type.Optional(Type.Boolean({ description: \"Use native cache.\" })),\n\t\ttimeoutMs: Type.Optional(Type.Number({ description: \"Native grep timeout in milliseconds.\" })),\n\t\tgitignore: Type.Optional(Type.Boolean({ description: \"Respect .gitignore files (default: true)\" })),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type GrepToolInput = Static<typeof grepSchema>;\nconst DEFAULT_LIMIT = 100;\n\nexport interface GrepToolDetails {\n\ttruncation?: TruncationResult;\n\tmatchLimitReached?: number;\n\tlinesTruncated?: boolean;\n}\n\ntype RipgrepMatchEvent = {\n\ttype: \"match\";\n\tdata?: {\n\t\tpath?: { text?: unknown };\n\t\tline_number?: unknown;\n\t\tlines?: { text?: unknown };\n\t};\n};\n\nfunction isRipgrepMatchEvent(event: unknown): event is RipgrepMatchEvent {\n\treturn typeof event === \"object\" && event !== null && \"type\" in event && event.type === \"match\";\n}\n\n/**\n * Pluggable operations for the grep tool.\n * Override these to delegate search to remote systems (for example SSH).\n */\nexport interface GrepOperations {\n\t/** Check if path is a directory. Throws if path does not exist. */\n\tisDirectory: (absolutePath: string) => Promise<boolean> | boolean;\n\t/** Read file contents for context lines */\n\treadFile: (absolutePath: string) => Promise<string> | string;\n}\n\nconst defaultGrepOperations: GrepOperations = {\n\tisDirectory: async (p) => (await fsStat(p)).isDirectory(),\n\treadFile: (p) => fsReadFile(p, \"utf-8\"),\n};\n\nexport interface GrepToolOptions {\n\t/** Custom operations for grep. Default: local filesystem plus ripgrep */\n\toperations?: GrepOperations;\n\t/** Enable shared native filesystem scan cache. Defaults to false; search callers also disable it to stay fresh across out-of-band filesystem mutations. */\n\tnativeCache?: boolean;\n}\n\nfunction formatGrepCall(\n\targs: { pattern: string; path?: string; glob?: string; limit?: number } | undefined,\n\ttheme: typeof import(\"../../modes/interactive/theme/theme.js\").theme,\n): string {\n\tconst pattern = str(args?.pattern);\n\tconst rawPath = str(args?.path);\n\tconst path = rawPath !== null ? shortenPath(rawPath || \".\") : null;\n\tconst glob = str(args?.glob);\n\tconst limit = args?.limit;\n\tconst invalidArg = invalidArgText(theme);\n\tlet text =\n\t\ttheme.fg(\"toolTitle\", theme.bold(\"grep\")) +\n\t\t\" \" +\n\t\t(pattern === null ? invalidArg : theme.fg(\"accent\", `/${pattern || \"\"}/`)) +\n\t\ttheme.fg(\"toolOutput\", ` in ${path === null ? invalidArg : path}`);\n\tif (glob) text += theme.fg(\"toolOutput\", ` (${glob})`);\n\tif (limit !== undefined) text += theme.fg(\"toolOutput\", ` limit ${limit}`);\n\treturn text;\n}\n\nfunction formatGrepResult(\n\tresult: {\n\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\tdetails?: GrepToolDetails;\n\t},\n\toptions: ToolRenderResultOptions,\n\ttheme: typeof import(\"../../modes/interactive/theme/theme.js\").theme,\n\tshowImages: boolean,\n): string {\n\tconst output = getTextOutput(result, showImages).trim();\n\tlet text = \"\";\n\tif (output) {\n\t\tconst lines = output.split(\"\\n\");\n\t\tconst maxLines = options.expanded ? lines.length : 15;\n\t\tconst displayLines = lines.slice(0, maxLines);\n\t\tconst remaining = lines.length - maxLines;\n\t\ttext += `\\n${displayLines.map((line) => theme.fg(\"toolOutput\", line)).join(\"\\n\")}`;\n\t\tif (remaining > 0) {\n\t\t\ttext +=\n\t\t\t\ttheme.fg(\"muted\", \"\\n... \") + parenthesizedKeyHint(\"app.tools.expand\", \"Expand\", `${remaining} more lines`);\n\t\t}\n\t}\n\n\tconst matchLimit = result.details?.matchLimitReached;\n\tconst truncation = result.details?.truncation;\n\tconst linesTruncated = result.details?.linesTruncated;\n\tif (matchLimit || truncation?.truncated || linesTruncated) {\n\t\tconst warnings: string[] = [];\n\t\tif (matchLimit) warnings.push(`${matchLimit} matches limit`);\n\t\tif (truncation?.truncated) warnings.push(`${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit`);\n\t\tif (linesTruncated) warnings.push(\"some lines truncated\");\n\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: ${warnings.join(\", \")}]`)}`;\n\t}\n\treturn text;\n}\n\nfunction formatNativeGrepMatch(match: NativeGrepMatch, displayPath: string): string[] {\n\tconst lines: string[] = [];\n\tfor (const contextLine of match.contextBefore ?? []) {\n\t\tlines.push(`${displayPath}-${contextLine.lineNumber}- ${contextLine.line}`);\n\t}\n\tlines.push(`${displayPath}:${match.lineNumber}: ${match.line}`);\n\tfor (const contextLine of match.contextAfter ?? []) {\n\t\tlines.push(`${displayPath}-${contextLine.lineNumber}- ${contextLine.line}`);\n\t}\n\treturn lines;\n}\n\nexport function createGrepToolDefinition(\n\tcwd: string,\n\toptions?: GrepToolOptions,\n): ToolDefinition<typeof grepSchema, GrepToolDetails | undefined> {\n\tconst customOps = options?.operations;\n\treturn {\n\t\tname: \"grep\",\n\t\tlabel: \"grep\",\n\t\tdescription: `Search file contents for a pattern. Returns matching lines with file paths and line numbers. Respects .gitignore. Output is truncated to ${DEFAULT_LIMIT} matches or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). Long lines are truncated to ${GREP_MAX_LINE_LENGTH} chars.`,\n\t\tpromptSnippet: \"Search file contents for patterns (respects .gitignore)\",\n\t\tparameters: grepSchema,\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{\n\t\t\t\tpattern,\n\t\t\t\tpath: searchDir,\n\t\t\t\tglob,\n\t\t\t\tignoreCase,\n\t\t\t\tliteral,\n\t\t\t\tcontext,\n\t\t\t\tlimit,\n\t\t\t\tgitignore,\n\t\t\t\ttype,\n\t\t\t\tcontextBefore,\n\t\t\t\tcontextAfter,\n\t\t\t\toffset,\n\t\t\t\tmode,\n\t\t\t\tmaxCountPerFile,\n\t\t\t\thidden,\n\t\t\t\tcache,\n\t\t\t\ttimeoutMs,\n\t\t\t}: GrepToolInput,\n\t\t\tsignal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\tctx?: ExtensionContext,\n\t\t) {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet settled = false;\n\t\t\t\tconst settle = (fn: () => void) => {\n\t\t\t\t\tif (!settled) {\n\t\t\t\t\t\tsettled = true;\n\t\t\t\t\t\tfn();\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\t(async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst executionCwd = ctx?.cwd || cwd;\n\t\t\t\t\t\tconst searchPath = resolveToCwd(searchDir || \".\", executionCwd);\n\t\t\t\t\t\tconst ops = customOps ?? defaultGrepOperations;\n\t\t\t\t\t\tlet isDirectory: boolean;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tisDirectory = await ops.isDirectory(searchPath);\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\tsettle(() => reject(new Error(`Path not found: ${searchPath}`)));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst contextValue = context && context > 0 ? context : 0;\n\t\t\t\t\t\tconst contextBeforeValue = contextBefore ?? contextValue;\n\t\t\t\t\t\tconst contextAfterValue = contextAfter ?? contextValue;\n\t\t\t\t\t\tconst nativeCache = options?.nativeCache === true;\n\t\t\t\t\t\tconst effectiveLimit = Math.max(1, limit ?? DEFAULT_LIMIT);\n\t\t\t\t\t\tconst formatPath = (filePath: string): string => {\n\t\t\t\t\t\t\tif (isDirectory) {\n\t\t\t\t\t\t\t\tif (!path.isAbsolute(filePath)) return filePath.replace(/\\\\/g, \"/\");\n\t\t\t\t\t\t\t\tconst relative = path.relative(searchPath, filePath);\n\t\t\t\t\t\t\t\tif (relative && !relative.startsWith(\"..\")) return relative.replace(/\\\\/g, \"/\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn path.basename(filePath);\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tif (!customOps && !literal) {\n\t\t\t\t\t\t\tconst nativeBinding = loadNativeSearchBinding();\n\t\t\t\t\t\t\tif (nativeBinding) {\n\t\t\t\t\t\t\t\tconst nativeResult = await nativeBinding.grep({\n\t\t\t\t\t\t\t\t\tpattern,\n\t\t\t\t\t\t\t\t\tpath: searchPath,\n\t\t\t\t\t\t\t\t\tcwd: executionCwd,\n\t\t\t\t\t\t\t\t\tglob,\n\t\t\t\t\t\t\t\t\tignoreCase,\n\t\t\t\t\t\t\t\t\thidden: hidden ?? true,\n\t\t\t\t\t\t\t\t\tgitignore: gitignore !== false,\n\t\t\t\t\t\t\t\t\tcache: cache ?? nativeCache,\n\t\t\t\t\t\t\t\t\tmaxCount: mode === \"count\" ? undefined : effectiveLimit + 1,\n\t\t\t\t\t\t\t\t\toffset,\n\t\t\t\t\t\t\t\t\tcontext:\n\t\t\t\t\t\t\t\t\t\tcontextBefore === undefined && contextAfter === undefined ? contextValue : undefined,\n\t\t\t\t\t\t\t\t\tcontextBefore,\n\t\t\t\t\t\t\t\t\tcontextAfter,\n\t\t\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\t\t\tmode,\n\t\t\t\t\t\t\t\t\tmaxCountPerFile,\n\t\t\t\t\t\t\t\t\tmaxColumns: GREP_MAX_LINE_LENGTH,\n\t\t\t\t\t\t\t\t\tmultiline: pattern.includes(\"\\n\") || pattern.includes(\"\\\\n\"),\n\t\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t\t\ttimeoutMs: timeoutMs ?? 30_000,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (nativeResult.error) throw new Error(nativeResult.error);\n\t\t\t\t\t\t\t\tif (nativeResult.matches.length === 0) {\n\t\t\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: mode === \"count\" ? \"0\" : \"No matches found\" }],\n\t\t\t\t\t\t\t\t\t\t\tdetails: undefined,\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst visibleMatches = nativeResult.matches.slice(0, effectiveLimit);\n\t\t\t\t\t\t\t\tconst filesOutput =\n\t\t\t\t\t\t\t\t\tmode === \"filesWithMatches\" && !isDirectory && (offset ?? 0) > 0\n\t\t\t\t\t\t\t\t\t\t? \"\"\n\t\t\t\t\t\t\t\t\t\t: visibleMatches.map((match) => formatPath(match.path)).join(\"\\n\");\n\t\t\t\t\t\t\t\tconst countOutput = String(Math.max(0, nativeResult.totalMatches - (offset ?? 0)));\n\t\t\t\t\t\t\t\tconst rawOutput =\n\t\t\t\t\t\t\t\t\tmode === \"count\"\n\t\t\t\t\t\t\t\t\t\t? countOutput\n\t\t\t\t\t\t\t\t\t\t: mode === \"filesWithMatches\"\n\t\t\t\t\t\t\t\t\t\t\t? filesOutput || \"No matches found\"\n\t\t\t\t\t\t\t\t\t\t\t: visibleMatches\n\t\t\t\t\t\t\t\t\t\t\t\t\t.flatMap((match) => formatNativeGrepMatch(match, formatPath(match.path)))\n\t\t\t\t\t\t\t\t\t\t\t\t\t.join(\"\\n\");\n\t\t\t\t\t\t\t\tconst truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });\n\t\t\t\t\t\t\t\tlet output = truncation.content;\n\t\t\t\t\t\t\t\tconst details: GrepToolDetails = {};\n\t\t\t\t\t\t\t\tconst notices: string[] = [];\n\t\t\t\t\t\t\t\tif (nativeResult.matches.length > effectiveLimit || nativeResult.limitReached) {\n\t\t\t\t\t\t\t\t\tnotices.push(\n\t\t\t\t\t\t\t\t\t\t`${effectiveLimit} matches limit reached. Use limit=${effectiveLimit * 2} for more, or refine pattern`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tdetails.matchLimitReached = effectiveLimit;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (truncation.truncated) {\n\t\t\t\t\t\t\t\t\tnotices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);\n\t\t\t\t\t\t\t\t\tdetails.truncation = truncation;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (visibleMatches.some((match) => match.truncated)) {\n\t\t\t\t\t\t\t\t\tnotices.push(\n\t\t\t\t\t\t\t\t\t\t`Some lines truncated to ${GREP_MAX_LINE_LENGTH} chars. Use read tool to see full lines`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tdetails.linesTruncated = true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (notices.length > 0) output += `\\n\\n[${notices.join(\". \")}]`;\n\t\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: output }],\n\t\t\t\t\t\t\t\t\t\tdetails: Object.keys(details).length > 0 ? details : undefined,\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst fileCache = new Map<string, string[]>();\n\t\t\t\t\t\tconst getFileLines = async (filePath: string): Promise<string[]> => {\n\t\t\t\t\t\t\tlet lines = fileCache.get(filePath);\n\t\t\t\t\t\t\tif (!lines) {\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tconst content = await ops.readFile(filePath);\n\t\t\t\t\t\t\t\t\tlines = content.replace(/\\r\\n/g, \"\\n\").replace(/\\r/g, \"\\n\").split(\"\\n\");\n\t\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t\tlines = [];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tfileCache.set(filePath, lines);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn lines;\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst rgPath = await ensureTool(\"rg\");\n\t\t\t\t\t\tif (!rgPath) {\n\t\t\t\t\t\t\tsettle(() => reject(new Error(\"ripgrep (rg) is not available and could not be downloaded\")));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst args: string[] = [\"--no-config\", \"--json\", \"--line-number\", \"--color=never\"];\n\t\t\t\t\t\tif (hidden !== false) args.push(\"--hidden\");\n\t\t\t\t\t\tif (gitignore === false) args.push(\"--no-ignore\");\n\t\t\t\t\t\tif (ignoreCase) args.push(\"--ignore-case\");\n\t\t\t\t\t\tif (literal) args.push(\"--fixed-strings\");\n\t\t\t\t\t\tif (pattern.includes(\"\\n\") || pattern.includes(\"\\\\n\")) args.push(\"--multiline\");\n\t\t\t\t\t\tif (type) args.push(\"--type\", type);\n\t\t\t\t\t\tif (maxCountPerFile !== undefined) args.push(\"--max-count\", String(maxCountPerFile));\n\t\t\t\t\t\tif (glob) args.push(\"--glob\", glob);\n\t\t\t\t\t\targs.push(\"--\", pattern, searchPath);\n\n\t\t\t\t\t\tconst child = spawn(rgPath, args, {\n\t\t\t\t\t\t\tenv: createChildProcessEnvironment(),\n\t\t\t\t\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst timeoutTimer = timeoutMs !== undefined ? setTimeout(() => stopChild(), timeoutMs) : undefined;\n\t\t\t\t\t\tconst rl = createInterface({ input: child.stdout });\n\t\t\t\t\t\tlet stderr = \"\";\n\t\t\t\t\t\tlet matchCount = 0;\n\t\t\t\t\t\tlet matchLimitReached = false;\n\t\t\t\t\t\tlet linesTruncated = false;\n\t\t\t\t\t\tlet aborted = false;\n\t\t\t\t\t\tlet killedDueToLimit = false;\n\t\t\t\t\t\tconst outputLines: string[] = [];\n\n\t\t\t\t\t\tconst cleanup = () => {\n\t\t\t\t\t\t\tif (timeoutTimer) clearTimeout(timeoutTimer);\n\t\t\t\t\t\t\trl.close();\n\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst stopChild = (dueToLimit = false) => {\n\t\t\t\t\t\t\tif (!child.killed) {\n\t\t\t\t\t\t\t\tkilledDueToLimit = dueToLimit;\n\t\t\t\t\t\t\t\tchild.kill();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst onAbort = () => {\n\t\t\t\t\t\t\taborted = true;\n\t\t\t\t\t\t\tstopChild();\n\t\t\t\t\t\t};\n\t\t\t\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t\t\tchild.stderr?.on(\"data\", (chunk) => {\n\t\t\t\t\t\t\tstderr += chunk.toString();\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tconst formatBlock = async (filePath: string, lineNumber: number): Promise<string[]> => {\n\t\t\t\t\t\t\tconst relativePath = formatPath(filePath);\n\t\t\t\t\t\t\tconst lines = await getFileLines(filePath);\n\t\t\t\t\t\t\tif (!lines.length) return [`${relativePath}:${lineNumber}: (unable to read file)`];\n\t\t\t\t\t\t\tconst block: string[] = [];\n\t\t\t\t\t\t\tconst start = contextBeforeValue > 0 ? Math.max(1, lineNumber - contextBeforeValue) : lineNumber;\n\t\t\t\t\t\t\tconst end =\n\t\t\t\t\t\t\t\tcontextAfterValue > 0 ? Math.min(lines.length, lineNumber + contextAfterValue) : lineNumber;\n\t\t\t\t\t\t\tfor (let current = start; current <= end; current++) {\n\t\t\t\t\t\t\t\tconst lineText = lines[current - 1] ?? \"\";\n\t\t\t\t\t\t\t\tconst sanitized = lineText.replace(/\\r/g, \"\");\n\t\t\t\t\t\t\t\tconst isMatchLine = current === lineNumber;\n\t\t\t\t\t\t\t\t// Truncate long lines so grep output stays compact.\n\t\t\t\t\t\t\t\tconst { text: truncatedText, wasTruncated } = truncateLine(sanitized);\n\t\t\t\t\t\t\t\tif (wasTruncated) linesTruncated = true;\n\t\t\t\t\t\t\t\tif (isMatchLine) block.push(`${relativePath}:${current}: ${truncatedText}`);\n\t\t\t\t\t\t\t\telse block.push(`${relativePath}-${current}- ${truncatedText}`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn block;\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\t// Collect matches during streaming, then format them after rg exits.\n\t\t\t\t\t\tconst matches: Array<{ filePath: string; lineNumber: number; lineText?: string }> = [];\n\t\t\t\t\t\tlet seenMatches = 0,\n\t\t\t\t\t\t\tseenFiles = 0;\n\t\t\t\t\t\tconst seenFilePaths = new Set<string>(),\n\t\t\t\t\t\t\tfilesWithMatches = new Set<string>();\n\t\t\t\t\t\trl.on(\"line\", (line) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t!line.trim() ||\n\t\t\t\t\t\t\t\t(mode !== \"count\" && mode !== \"filesWithMatches\" && matchCount >= effectiveLimit)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\tlet event: unknown;\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tevent = JSON.parse(line) as unknown;\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (isRipgrepMatchEvent(event)) {\n\t\t\t\t\t\t\t\tconst filePath = event.data?.path?.text;\n\t\t\t\t\t\t\t\tif (mode === \"filesWithMatches\") {\n\t\t\t\t\t\t\t\t\tif (typeof filePath === \"string\") {\n\t\t\t\t\t\t\t\t\t\tconst formatted = formatPath(filePath);\n\t\t\t\t\t\t\t\t\t\tif (!seenFilePaths.has(formatted)) {\n\t\t\t\t\t\t\t\t\t\t\tseenFilePaths.add(formatted);\n\t\t\t\t\t\t\t\t\t\t\tseenFiles++;\n\t\t\t\t\t\t\t\t\t\t\tif (offset === undefined || seenFiles > offset) filesWithMatches.add(formatted);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tmatchCount = filesWithMatches.size;\n\t\t\t\t\t\t\t\t\tif (matchCount >= effectiveLimit) {\n\t\t\t\t\t\t\t\t\t\tmatchLimitReached = true;\n\t\t\t\t\t\t\t\t\t\tstopChild(true);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tseenMatches++;\n\t\t\t\t\t\t\t\tif (mode !== \"count\" && offset !== undefined && seenMatches <= offset) return;\n\t\t\t\t\t\t\t\tmatchCount++;\n\t\t\t\t\t\t\t\tconst lineNumber = event.data?.line_number;\n\t\t\t\t\t\t\t\tconst lineText = event.data?.lines?.text;\n\t\t\t\t\t\t\t\tif (typeof filePath === \"string\") filesWithMatches.add(formatPath(filePath));\n\t\t\t\t\t\t\t\tif (typeof filePath === \"string\" && typeof lineNumber === \"number\")\n\t\t\t\t\t\t\t\t\tmatches.push({\n\t\t\t\t\t\t\t\t\t\tfilePath,\n\t\t\t\t\t\t\t\t\t\tlineNumber,\n\t\t\t\t\t\t\t\t\t\tlineText: typeof lineText === \"string\" ? lineText : undefined,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (mode !== \"count\" && matchCount >= effectiveLimit) {\n\t\t\t\t\t\t\t\t\tmatchLimitReached = true;\n\t\t\t\t\t\t\t\t\tstopChild(true);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tchild.on(\"error\", (error) => {\n\t\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\t\tsettle(() => reject(new Error(`Failed to run ripgrep: ${error.message}`)));\n\t\t\t\t\t\t});\n\t\t\t\t\t\tchild.on(\"close\", async (code) => {\n\t\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\t\tif (aborted) {\n\t\t\t\t\t\t\t\tsettle(() => reject(new Error(\"Operation aborted\")));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!killedDueToLimit && code !== 0 && code !== 1) {\n\t\t\t\t\t\t\t\tconst errorMsg = stderr.trim() || `ripgrep exited with code ${code}`;\n\t\t\t\t\t\t\t\tsettle(() => reject(new Error(errorMsg)));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (matchCount === 0) {\n\t\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: mode === \"count\" ? \"0\" : \"No matches found\" }],\n\t\t\t\t\t\t\t\t\t\tdetails: undefined,\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (mode === \"count\" || mode === \"filesWithMatches\") {\n\t\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\t\t\t\t\t\t\tmode === \"count\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? String(Math.max(0, matchCount - (offset ?? 0)))\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: [...filesWithMatches].join(\"\\n\") || \"No matches found\",\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\tdetails: matchLimitReached ? { matchLimitReached: effectiveLimit } : undefined,\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Format matches after streaming finishes so custom readFile() backends can be async.\n\t\t\t\t\t\t\tfor (const match of matches) {\n\t\t\t\t\t\t\t\tif (contextBeforeValue === 0 && contextAfterValue === 0 && match.lineText !== undefined) {\n\t\t\t\t\t\t\t\t\tconst relativePath = formatPath(match.filePath);\n\t\t\t\t\t\t\t\t\tconst sanitized = match.lineText\n\t\t\t\t\t\t\t\t\t\t.replace(/\\r\\n/g, \"\\n\")\n\t\t\t\t\t\t\t\t\t\t.replace(/\\r/g, \"\")\n\t\t\t\t\t\t\t\t\t\t.replace(/\\n$/, \"\");\n\t\t\t\t\t\t\t\t\tconst { text: truncatedText, wasTruncated } = truncateLine(sanitized);\n\t\t\t\t\t\t\t\t\tif (wasTruncated) linesTruncated = true;\n\t\t\t\t\t\t\t\t\toutputLines.push(`${relativePath}:${match.lineNumber}: ${truncatedText}`);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tconst block = await formatBlock(match.filePath, match.lineNumber);\n\t\t\t\t\t\t\t\t\toutputLines.push(...block);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst rawOutput = outputLines.join(\"\\n\");\n\t\t\t\t\t\t\t// Apply byte truncation. There is no line limit here because the match limit already capped rows.\n\t\t\t\t\t\t\tconst truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });\n\t\t\t\t\t\t\tlet output = truncation.content;\n\t\t\t\t\t\t\tconst details: GrepToolDetails = {};\n\t\t\t\t\t\t\t// Build actionable notices for truncation and match limits.\n\t\t\t\t\t\t\tconst notices: string[] = [];\n\t\t\t\t\t\t\tif (matchLimitReached) {\n\t\t\t\t\t\t\t\tnotices.push(\n\t\t\t\t\t\t\t\t\t`${effectiveLimit} matches limit reached. Use limit=${effectiveLimit * 2} for more, or refine pattern`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tdetails.matchLimitReached = effectiveLimit;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (truncation.truncated) {\n\t\t\t\t\t\t\t\tnotices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);\n\t\t\t\t\t\t\t\tdetails.truncation = truncation;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (linesTruncated) {\n\t\t\t\t\t\t\t\tnotices.push(\n\t\t\t\t\t\t\t\t\t`Some lines truncated to ${GREP_MAX_LINE_LENGTH} chars. Use read tool to see full lines`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tdetails.linesTruncated = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (notices.length > 0) output += `\\n\\n[${notices.join(\". \")}]`;\n\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: output }],\n\t\t\t\t\t\t\t\t\tdetails: Object.keys(details).length > 0 ? details : undefined,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tsettle(() => reject(err as Error));\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t});\n\t\t},\n\t\trenderCall(args, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatGrepCall(args, theme));\n\t\t\treturn text;\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatGrepResult(result, options, theme, context.showImages));\n\t\t\treturn text;\n\t\t},\n\t};\n}\n\nexport function createGrepTool(cwd: string, options?: GrepToolOptions): AgentTool<typeof grepSchema> {\n\treturn wrapToolDefinition(createGrepToolDefinition(cwd, options));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"grep.js","sourceRoot":"","sources":["../../../src/core/tools/grep.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC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AAC,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;YAC1C,OAAO,IAAI,CAAC;QACb,CAAC;QACD,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO;YAC3C,MAAM,IAAI,GAAI,OAAO,CAAC,aAAkC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;YAC3E,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAyB;IACpE,OAAO,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import { readFile as fsReadFile, stat as fsStat } from \"node:fs/promises\";\nimport { createInterface } from \"node:readline\";\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Text } from \"@earendil-works/pi-tui\";\nimport { spawn } from \"child_process\";\nimport path from \"path\";\nimport { type Static, Type } from \"typebox\";\nimport { parenthesizedKeyHint } from \"../../modes/interactive/components/keybinding-hints.js\";\nimport { createChildProcessEnvironment } from \"../../utils/child-process.ts\";\nimport { ensureTool } from \"../../utils/tools-manager.ts\";\nimport type { ExtensionContext, ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\nimport { getTextOutput, invalidArgText, shortenPath, str } from \"./render-utils.ts\";\nimport { loadNativeSearchBinding, type NativeGrepMatch } from \"./search-native.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport {\n\tDEFAULT_MAX_BYTES,\n\tformatSize,\n\tGREP_MAX_LINE_LENGTH,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n} from \"./truncate.ts\";\n\nconst grepSchema = Type.Object(\n\t{\n\t\tpattern: Type.String({ description: \"Search pattern (regex or literal string)\" }),\n\t\tpath: Type.Optional(Type.String({ description: \"Directory or file to search (default: current directory)\" })),\n\t\tglob: Type.Optional(Type.String({ description: \"Filter files by glob pattern, e.g. '*.ts' or '**/*.spec.ts'\" })),\n\t\tignoreCase: Type.Optional(Type.Boolean({ description: \"Case-insensitive search (default: false)\" })),\n\t\ttype: Type.Optional(Type.String({ description: \"File type filter for native grep.\" })),\n\t\tliteral: Type.Optional(\n\t\t\tType.Boolean({ description: \"Treat pattern as literal string instead of regex (default: false)\" }),\n\t\t),\n\t\tcontext: Type.Optional(\n\t\t\tType.Number({ description: \"Number of lines to show before and after each match (default: 0)\" }),\n\t\t),\n\t\tcontextBefore: Type.Optional(Type.Number({ description: \"Lines to show before each match.\" })),\n\t\tcontextAfter: Type.Optional(Type.Number({ description: \"Lines to show after each match.\" })),\n\t\tlimit: Type.Optional(Type.Number({ description: \"Maximum number of matches to return (default: 100)\" })),\n\t\toffset: Type.Optional(Type.Number({ description: \"Skip first N matches.\" })),\n\t\tmode: Type.Optional(\n\t\t\tType.Union([Type.Literal(\"content\"), Type.Literal(\"count\"), Type.Literal(\"filesWithMatches\")]),\n\t\t),\n\t\tmaxCountPerFile: Type.Optional(Type.Number({ description: \"Maximum matches per file.\" })),\n\t\thidden: Type.Optional(Type.Boolean({ description: \"Search hidden files (default true).\" })),\n\t\tcache: Type.Optional(Type.Boolean({ description: \"Use native cache.\" })),\n\t\ttimeoutMs: Type.Optional(Type.Number({ description: \"Native grep timeout in milliseconds.\" })),\n\t\tgitignore: Type.Optional(Type.Boolean({ description: \"Respect .gitignore files (default: true)\" })),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type GrepToolInput = Static<typeof grepSchema>;\nconst DEFAULT_LIMIT = 100;\n\nexport interface GrepToolDetails {\n\ttruncation?: TruncationResult;\n\tmatchLimitReached?: number;\n\tlinesTruncated?: boolean;\n}\n\ntype RipgrepMatchEvent = {\n\ttype: \"match\";\n\tdata?: {\n\t\tpath?: { text?: unknown };\n\t\tline_number?: unknown;\n\t\tlines?: { text?: unknown };\n\t};\n};\n\nfunction isRipgrepMatchEvent(event: unknown): event is RipgrepMatchEvent {\n\treturn typeof event === \"object\" && event !== null && \"type\" in event && event.type === \"match\";\n}\n\n/**\n * Pluggable operations for the grep tool.\n * Override these to delegate search to remote systems (for example SSH).\n */\nexport interface GrepOperations {\n\t/** Check if path is a directory. Throws if path does not exist. */\n\tisDirectory: (absolutePath: string) => Promise<boolean> | boolean;\n\t/** Read file contents for context lines */\n\treadFile: (absolutePath: string) => Promise<string> | string;\n}\n\nconst defaultGrepOperations: GrepOperations = {\n\tisDirectory: async (p) => (await fsStat(p)).isDirectory(),\n\treadFile: (p) => fsReadFile(p, \"utf-8\"),\n};\n\nexport interface GrepToolOptions {\n\t/** Custom operations for grep. Default: local filesystem plus ripgrep */\n\toperations?: GrepOperations;\n\t/** Enable shared native filesystem scan cache. Defaults to false; search callers also disable it to stay fresh across out-of-band filesystem mutations. */\n\tnativeCache?: boolean;\n}\n\nfunction formatGrepCall(\n\targs: { pattern: string; path?: string; glob?: string; limit?: number } | undefined,\n\ttheme: typeof import(\"../../modes/interactive/theme/theme.js\").theme,\n): string {\n\tconst pattern = str(args?.pattern);\n\tconst rawPath = str(args?.path);\n\tconst path = rawPath !== null ? shortenPath(rawPath || \".\") : null;\n\tconst glob = str(args?.glob);\n\tconst limit = args?.limit;\n\tconst invalidArg = invalidArgText(theme);\n\tlet text =\n\t\ttheme.fg(\"toolTitle\", theme.bold(\"grep\")) +\n\t\t\" \" +\n\t\t(pattern === null ? invalidArg : theme.fg(\"accent\", `/${pattern || \"\"}/`)) +\n\t\ttheme.fg(\"toolOutput\", ` in ${path === null ? invalidArg : path}`);\n\tif (glob) text += theme.fg(\"toolOutput\", ` (${glob})`);\n\tif (limit !== undefined) text += theme.fg(\"toolOutput\", ` limit ${limit}`);\n\treturn text;\n}\n\nfunction formatGrepResult(\n\tresult: {\n\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\tdetails?: GrepToolDetails;\n\t},\n\toptions: ToolRenderResultOptions,\n\ttheme: typeof import(\"../../modes/interactive/theme/theme.js\").theme,\n\tshowImages: boolean,\n): string {\n\tconst output = getTextOutput(result, showImages).trim();\n\tlet text = \"\";\n\tif (output) {\n\t\tconst lines = output.split(\"\\n\");\n\t\tconst maxLines = options.expanded ? lines.length : 15;\n\t\tconst displayLines = lines.slice(0, maxLines);\n\t\tconst remaining = lines.length - maxLines;\n\t\ttext += `\\n${displayLines.map((line) => theme.fg(\"toolOutput\", line)).join(\"\\n\")}`;\n\t\tif (remaining > 0) {\n\t\t\ttext +=\n\t\t\t\ttheme.fg(\"muted\", \"\\n... \") + parenthesizedKeyHint(\"app.tools.expand\", \"Expand\", `${remaining} more lines`);\n\t\t}\n\t}\n\n\tconst matchLimit = result.details?.matchLimitReached;\n\tconst truncation = result.details?.truncation;\n\tconst linesTruncated = result.details?.linesTruncated;\n\tif (matchLimit || truncation?.truncated || linesTruncated) {\n\t\tconst warnings: string[] = [];\n\t\tif (matchLimit) warnings.push(`${matchLimit} matches limit`);\n\t\tif (truncation?.truncated) warnings.push(`${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit`);\n\t\tif (linesTruncated) warnings.push(\"some lines truncated\");\n\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: ${warnings.join(\", \")}]`)}`;\n\t}\n\treturn text;\n}\n\nfunction formatNativeGrepMatch(match: NativeGrepMatch, displayPath: string): string[] {\n\t// Lines are split only at LF, like ripgrep; a lone CR stays inside a line and is dropped from the display.\n\tconst clean = (line: string) => line.replace(/\\r/g, \"\");\n\tconst lines: string[] = [];\n\tfor (const contextLine of match.contextBefore ?? []) {\n\t\tlines.push(`${displayPath}-${contextLine.lineNumber}- ${clean(contextLine.line)}`);\n\t}\n\tlines.push(`${displayPath}:${match.lineNumber}: ${clean(match.line)}`);\n\tfor (const contextLine of match.contextAfter ?? []) {\n\t\tlines.push(`${displayPath}-${contextLine.lineNumber}- ${clean(contextLine.line)}`);\n\t}\n\treturn lines;\n}\n\nexport function createGrepToolDefinition(\n\tcwd: string,\n\toptions?: GrepToolOptions,\n): ToolDefinition<typeof grepSchema, GrepToolDetails | undefined> {\n\tconst customOps = options?.operations;\n\treturn {\n\t\tname: \"grep\",\n\t\tlabel: \"grep\",\n\t\tdescription: `Search file contents for a pattern. Returns matching lines with file paths and line numbers. Respects .gitignore. Output is truncated to ${DEFAULT_LIMIT} matches or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). Long lines are truncated to ${GREP_MAX_LINE_LENGTH} chars.`,\n\t\tpromptSnippet: \"Search file contents for patterns (respects .gitignore)\",\n\t\tparameters: grepSchema,\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{\n\t\t\t\tpattern,\n\t\t\t\tpath: searchDir,\n\t\t\t\tglob,\n\t\t\t\tignoreCase,\n\t\t\t\tliteral,\n\t\t\t\tcontext,\n\t\t\t\tlimit,\n\t\t\t\tgitignore,\n\t\t\t\ttype,\n\t\t\t\tcontextBefore,\n\t\t\t\tcontextAfter,\n\t\t\t\toffset,\n\t\t\t\tmode,\n\t\t\t\tmaxCountPerFile,\n\t\t\t\thidden,\n\t\t\t\tcache,\n\t\t\t\ttimeoutMs,\n\t\t\t}: GrepToolInput,\n\t\t\tsignal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\tctx?: ExtensionContext,\n\t\t) {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet settled = false;\n\t\t\t\tconst settle = (fn: () => void) => {\n\t\t\t\t\tif (!settled) {\n\t\t\t\t\t\tsettled = true;\n\t\t\t\t\t\tfn();\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\t(async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst executionCwd = ctx?.cwd || cwd;\n\t\t\t\t\t\tconst searchPath = resolveToCwd(searchDir || \".\", executionCwd);\n\t\t\t\t\t\tconst ops = customOps ?? defaultGrepOperations;\n\t\t\t\t\t\tlet isDirectory: boolean;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tisDirectory = await ops.isDirectory(searchPath);\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\tsettle(() => reject(new Error(`Path not found: ${searchPath}`)));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst contextValue = context && context > 0 ? context : 0;\n\t\t\t\t\t\tconst contextBeforeValue = contextBefore ?? contextValue;\n\t\t\t\t\t\tconst contextAfterValue = contextAfter ?? contextValue;\n\t\t\t\t\t\tconst nativeCache = options?.nativeCache === true;\n\t\t\t\t\t\tconst effectiveLimit = Math.max(1, limit ?? DEFAULT_LIMIT);\n\t\t\t\t\t\tconst formatPath = (filePath: string): string => {\n\t\t\t\t\t\t\tif (isDirectory) {\n\t\t\t\t\t\t\t\tif (!path.isAbsolute(filePath)) return filePath.replace(/\\\\/g, \"/\");\n\t\t\t\t\t\t\t\tconst relative = path.relative(searchPath, filePath);\n\t\t\t\t\t\t\t\tif (relative && !relative.startsWith(\"..\")) return relative.replace(/\\\\/g, \"/\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn path.basename(filePath);\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tif (!customOps && !literal) {\n\t\t\t\t\t\t\tconst nativeBinding = loadNativeSearchBinding();\n\t\t\t\t\t\t\tif (nativeBinding) {\n\t\t\t\t\t\t\t\tconst nativeResult = await nativeBinding.grep({\n\t\t\t\t\t\t\t\t\tpattern,\n\t\t\t\t\t\t\t\t\tpath: searchPath,\n\t\t\t\t\t\t\t\t\tcwd: executionCwd,\n\t\t\t\t\t\t\t\t\tglob,\n\t\t\t\t\t\t\t\t\tignoreCase,\n\t\t\t\t\t\t\t\t\thidden: hidden ?? true,\n\t\t\t\t\t\t\t\t\tgitignore: gitignore !== false,\n\t\t\t\t\t\t\t\t\tcache: cache ?? nativeCache,\n\t\t\t\t\t\t\t\t\tmaxCount: mode === \"count\" ? undefined : effectiveLimit + 1,\n\t\t\t\t\t\t\t\t\toffset,\n\t\t\t\t\t\t\t\t\tcontext:\n\t\t\t\t\t\t\t\t\t\tcontextBefore === undefined && contextAfter === undefined ? contextValue : undefined,\n\t\t\t\t\t\t\t\t\tcontextBefore,\n\t\t\t\t\t\t\t\t\tcontextAfter,\n\t\t\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\t\t\tmode,\n\t\t\t\t\t\t\t\t\tmaxCountPerFile,\n\t\t\t\t\t\t\t\t\tmaxColumns: GREP_MAX_LINE_LENGTH,\n\t\t\t\t\t\t\t\t\tmultiline: pattern.includes(\"\\n\") || pattern.includes(\"\\\\n\"),\n\t\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t\t\ttimeoutMs: timeoutMs ?? 30_000,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (nativeResult.error) throw new Error(nativeResult.error);\n\t\t\t\t\t\t\t\tif (nativeResult.matches.length === 0) {\n\t\t\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: mode === \"count\" ? \"0\" : \"No matches found\" }],\n\t\t\t\t\t\t\t\t\t\t\tdetails: undefined,\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst visibleMatches = nativeResult.matches.slice(0, effectiveLimit);\n\t\t\t\t\t\t\t\tconst filesOutput =\n\t\t\t\t\t\t\t\t\tmode === \"filesWithMatches\" && !isDirectory && (offset ?? 0) > 0\n\t\t\t\t\t\t\t\t\t\t? \"\"\n\t\t\t\t\t\t\t\t\t\t: visibleMatches.map((match) => formatPath(match.path)).join(\"\\n\");\n\t\t\t\t\t\t\t\tconst countOutput = String(Math.max(0, nativeResult.totalMatches - (offset ?? 0)));\n\t\t\t\t\t\t\t\tconst rawOutput =\n\t\t\t\t\t\t\t\t\tmode === \"count\"\n\t\t\t\t\t\t\t\t\t\t? countOutput\n\t\t\t\t\t\t\t\t\t\t: mode === \"filesWithMatches\"\n\t\t\t\t\t\t\t\t\t\t\t? filesOutput || \"No matches found\"\n\t\t\t\t\t\t\t\t\t\t\t: visibleMatches\n\t\t\t\t\t\t\t\t\t\t\t\t\t.flatMap((match) => formatNativeGrepMatch(match, formatPath(match.path)))\n\t\t\t\t\t\t\t\t\t\t\t\t\t.join(\"\\n\");\n\t\t\t\t\t\t\t\tconst truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });\n\t\t\t\t\t\t\t\tlet output = truncation.content;\n\t\t\t\t\t\t\t\tconst details: GrepToolDetails = {};\n\t\t\t\t\t\t\t\tconst notices: string[] = [];\n\t\t\t\t\t\t\t\tif (nativeResult.matches.length > effectiveLimit || nativeResult.limitReached) {\n\t\t\t\t\t\t\t\t\tnotices.push(\n\t\t\t\t\t\t\t\t\t\t`${effectiveLimit} matches limit reached. Use limit=${effectiveLimit * 2} for more, or refine pattern`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tdetails.matchLimitReached = effectiveLimit;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (truncation.truncated) {\n\t\t\t\t\t\t\t\t\tnotices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);\n\t\t\t\t\t\t\t\t\tdetails.truncation = truncation;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (visibleMatches.some((match) => match.truncated)) {\n\t\t\t\t\t\t\t\t\tnotices.push(\n\t\t\t\t\t\t\t\t\t\t`Some lines truncated to ${GREP_MAX_LINE_LENGTH} chars. Use read tool to see full lines`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tdetails.linesTruncated = true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (notices.length > 0) output += `\\n\\n[${notices.join(\". \")}]`;\n\t\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: output }],\n\t\t\t\t\t\t\t\t\t\tdetails: Object.keys(details).length > 0 ? details : undefined,\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst fileCache = new Map<string, string[]>();\n\t\t\t\t\t\tconst getFileLines = async (filePath: string): Promise<string[]> => {\n\t\t\t\t\t\t\tlet lines = fileCache.get(filePath);\n\t\t\t\t\t\t\tif (!lines) {\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tconst content = await ops.readFile(filePath);\n\t\t\t\t\t\t\t\t\tlines = content.replace(/\\r\\n/g, \"\\n\").split(\"\\n\");\n\t\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t\tlines = [];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tfileCache.set(filePath, lines);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn lines;\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst rgPath = await ensureTool(\"rg\");\n\t\t\t\t\t\tif (!rgPath) {\n\t\t\t\t\t\t\tsettle(() => reject(new Error(\"ripgrep (rg) is not available and could not be downloaded\")));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst args: string[] = [\"--no-config\", \"--json\", \"--line-number\", \"--color=never\"];\n\t\t\t\t\t\tif (hidden !== false) args.push(\"--hidden\");\n\t\t\t\t\t\tif (gitignore === false) args.push(\"--no-ignore\");\n\t\t\t\t\t\tif (ignoreCase) args.push(\"--ignore-case\");\n\t\t\t\t\t\tif (literal) args.push(\"--fixed-strings\");\n\t\t\t\t\t\tif (pattern.includes(\"\\n\") || pattern.includes(\"\\\\n\")) args.push(\"--multiline\");\n\t\t\t\t\t\tif (type) args.push(\"--type\", type);\n\t\t\t\t\t\tif (maxCountPerFile !== undefined) args.push(\"--max-count\", String(maxCountPerFile));\n\t\t\t\t\t\tif (glob) args.push(\"--glob\", glob);\n\t\t\t\t\t\targs.push(\"--\", pattern, searchPath);\n\n\t\t\t\t\t\tconst child = spawn(rgPath, args, {\n\t\t\t\t\t\t\tenv: createChildProcessEnvironment(),\n\t\t\t\t\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst timeoutTimer = timeoutMs !== undefined ? setTimeout(() => stopChild(), timeoutMs) : undefined;\n\t\t\t\t\t\tconst rl = createInterface({ input: child.stdout });\n\t\t\t\t\t\tlet stderr = \"\";\n\t\t\t\t\t\tlet matchCount = 0;\n\t\t\t\t\t\tlet matchLimitReached = false;\n\t\t\t\t\t\tlet linesTruncated = false;\n\t\t\t\t\t\tlet aborted = false;\n\t\t\t\t\t\tlet killedDueToLimit = false;\n\t\t\t\t\t\tconst outputLines: string[] = [];\n\n\t\t\t\t\t\tconst cleanup = () => {\n\t\t\t\t\t\t\tif (timeoutTimer) clearTimeout(timeoutTimer);\n\t\t\t\t\t\t\trl.close();\n\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst stopChild = (dueToLimit = false) => {\n\t\t\t\t\t\t\tif (!child.killed) {\n\t\t\t\t\t\t\t\tkilledDueToLimit = dueToLimit;\n\t\t\t\t\t\t\t\tchild.kill();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst onAbort = () => {\n\t\t\t\t\t\t\taborted = true;\n\t\t\t\t\t\t\tstopChild();\n\t\t\t\t\t\t};\n\t\t\t\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t\t\tchild.stderr?.on(\"data\", (chunk) => {\n\t\t\t\t\t\t\tstderr += chunk.toString();\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tconst formatBlock = async (filePath: string, lineNumber: number): Promise<string[]> => {\n\t\t\t\t\t\t\tconst relativePath = formatPath(filePath);\n\t\t\t\t\t\t\tconst lines = await getFileLines(filePath);\n\t\t\t\t\t\t\tif (!lines.length) return [`${relativePath}:${lineNumber}: (unable to read file)`];\n\t\t\t\t\t\t\tconst block: string[] = [];\n\t\t\t\t\t\t\tconst start = contextBeforeValue > 0 ? Math.max(1, lineNumber - contextBeforeValue) : lineNumber;\n\t\t\t\t\t\t\tconst end =\n\t\t\t\t\t\t\t\tcontextAfterValue > 0 ? Math.min(lines.length, lineNumber + contextAfterValue) : lineNumber;\n\t\t\t\t\t\t\tfor (let current = start; current <= end; current++) {\n\t\t\t\t\t\t\t\tconst lineText = lines[current - 1] ?? \"\";\n\t\t\t\t\t\t\t\tconst sanitized = lineText.replace(/\\r/g, \"\");\n\t\t\t\t\t\t\t\tconst isMatchLine = current === lineNumber;\n\t\t\t\t\t\t\t\t// Truncate long lines so grep output stays compact.\n\t\t\t\t\t\t\t\tconst { text: truncatedText, wasTruncated } = truncateLine(sanitized);\n\t\t\t\t\t\t\t\tif (wasTruncated) linesTruncated = true;\n\t\t\t\t\t\t\t\tif (isMatchLine) block.push(`${relativePath}:${current}: ${truncatedText}`);\n\t\t\t\t\t\t\t\telse block.push(`${relativePath}-${current}- ${truncatedText}`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn block;\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\t// Collect matches during streaming, then format them after rg exits.\n\t\t\t\t\t\tconst matches: Array<{ filePath: string; lineNumber: number; lineText?: string }> = [];\n\t\t\t\t\t\tlet seenMatches = 0,\n\t\t\t\t\t\t\tseenFiles = 0;\n\t\t\t\t\t\tconst seenFilePaths = new Set<string>(),\n\t\t\t\t\t\t\tfilesWithMatches = new Set<string>();\n\t\t\t\t\t\trl.on(\"line\", (line) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t!line.trim() ||\n\t\t\t\t\t\t\t\t(mode !== \"count\" && mode !== \"filesWithMatches\" && matchCount >= effectiveLimit)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\tlet event: unknown;\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tevent = JSON.parse(line) as unknown;\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (isRipgrepMatchEvent(event)) {\n\t\t\t\t\t\t\t\tconst filePath = event.data?.path?.text;\n\t\t\t\t\t\t\t\tif (mode === \"filesWithMatches\") {\n\t\t\t\t\t\t\t\t\tif (typeof filePath === \"string\") {\n\t\t\t\t\t\t\t\t\t\tconst formatted = formatPath(filePath);\n\t\t\t\t\t\t\t\t\t\tif (!seenFilePaths.has(formatted)) {\n\t\t\t\t\t\t\t\t\t\t\tseenFilePaths.add(formatted);\n\t\t\t\t\t\t\t\t\t\t\tseenFiles++;\n\t\t\t\t\t\t\t\t\t\t\tif (offset === undefined || seenFiles > offset) filesWithMatches.add(formatted);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tmatchCount = filesWithMatches.size;\n\t\t\t\t\t\t\t\t\tif (matchCount >= effectiveLimit) {\n\t\t\t\t\t\t\t\t\t\tmatchLimitReached = true;\n\t\t\t\t\t\t\t\t\t\tstopChild(true);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tseenMatches++;\n\t\t\t\t\t\t\t\tif (mode !== \"count\" && offset !== undefined && seenMatches <= offset) return;\n\t\t\t\t\t\t\t\tmatchCount++;\n\t\t\t\t\t\t\t\tconst lineNumber = event.data?.line_number;\n\t\t\t\t\t\t\t\tconst lineText = event.data?.lines?.text;\n\t\t\t\t\t\t\t\tif (typeof filePath === \"string\") filesWithMatches.add(formatPath(filePath));\n\t\t\t\t\t\t\t\tif (typeof filePath === \"string\" && typeof lineNumber === \"number\")\n\t\t\t\t\t\t\t\t\tmatches.push({\n\t\t\t\t\t\t\t\t\t\tfilePath,\n\t\t\t\t\t\t\t\t\t\tlineNumber,\n\t\t\t\t\t\t\t\t\t\tlineText: typeof lineText === \"string\" ? lineText : undefined,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (mode !== \"count\" && matchCount >= effectiveLimit) {\n\t\t\t\t\t\t\t\t\tmatchLimitReached = true;\n\t\t\t\t\t\t\t\t\tstopChild(true);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tchild.on(\"error\", (error) => {\n\t\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\t\tsettle(() => reject(new Error(`Failed to run ripgrep: ${error.message}`)));\n\t\t\t\t\t\t});\n\t\t\t\t\t\tchild.on(\"close\", async (code) => {\n\t\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\t\tif (aborted) {\n\t\t\t\t\t\t\t\tsettle(() => reject(new Error(\"Operation aborted\")));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!killedDueToLimit && code !== 0 && code !== 1) {\n\t\t\t\t\t\t\t\tconst errorMsg = stderr.trim() || `ripgrep exited with code ${code}`;\n\t\t\t\t\t\t\t\tsettle(() => reject(new Error(errorMsg)));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (matchCount === 0) {\n\t\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: mode === \"count\" ? \"0\" : \"No matches found\" }],\n\t\t\t\t\t\t\t\t\t\tdetails: undefined,\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (mode === \"count\" || mode === \"filesWithMatches\") {\n\t\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\t\t\t\t\t\t\tmode === \"count\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? String(Math.max(0, matchCount - (offset ?? 0)))\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: [...filesWithMatches].join(\"\\n\") || \"No matches found\",\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\tdetails: matchLimitReached ? { matchLimitReached: effectiveLimit } : undefined,\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Format matches after streaming finishes so custom readFile() backends can be async.\n\t\t\t\t\t\t\tfor (const match of matches) {\n\t\t\t\t\t\t\t\tif (contextBeforeValue === 0 && contextAfterValue === 0 && match.lineText !== undefined) {\n\t\t\t\t\t\t\t\t\tconst relativePath = formatPath(match.filePath);\n\t\t\t\t\t\t\t\t\tconst sanitized = match.lineText\n\t\t\t\t\t\t\t\t\t\t.replace(/\\r\\n/g, \"\\n\")\n\t\t\t\t\t\t\t\t\t\t.replace(/\\r/g, \"\")\n\t\t\t\t\t\t\t\t\t\t.replace(/\\n$/, \"\");\n\t\t\t\t\t\t\t\t\tconst { text: truncatedText, wasTruncated } = truncateLine(sanitized);\n\t\t\t\t\t\t\t\t\tif (wasTruncated) linesTruncated = true;\n\t\t\t\t\t\t\t\t\toutputLines.push(`${relativePath}:${match.lineNumber}: ${truncatedText}`);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tconst block = await formatBlock(match.filePath, match.lineNumber);\n\t\t\t\t\t\t\t\t\toutputLines.push(...block);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst rawOutput = outputLines.join(\"\\n\");\n\t\t\t\t\t\t\t// Apply byte truncation. There is no line limit here because the match limit already capped rows.\n\t\t\t\t\t\t\tconst truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });\n\t\t\t\t\t\t\tlet output = truncation.content;\n\t\t\t\t\t\t\tconst details: GrepToolDetails = {};\n\t\t\t\t\t\t\t// Build actionable notices for truncation and match limits.\n\t\t\t\t\t\t\tconst notices: string[] = [];\n\t\t\t\t\t\t\tif (matchLimitReached) {\n\t\t\t\t\t\t\t\tnotices.push(\n\t\t\t\t\t\t\t\t\t`${effectiveLimit} matches limit reached. Use limit=${effectiveLimit * 2} for more, or refine pattern`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tdetails.matchLimitReached = effectiveLimit;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (truncation.truncated) {\n\t\t\t\t\t\t\t\tnotices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);\n\t\t\t\t\t\t\t\tdetails.truncation = truncation;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (linesTruncated) {\n\t\t\t\t\t\t\t\tnotices.push(\n\t\t\t\t\t\t\t\t\t`Some lines truncated to ${GREP_MAX_LINE_LENGTH} chars. Use read tool to see full lines`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tdetails.linesTruncated = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (notices.length > 0) output += `\\n\\n[${notices.join(\". \")}]`;\n\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: output }],\n\t\t\t\t\t\t\t\t\tdetails: Object.keys(details).length > 0 ? details : undefined,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tsettle(() => reject(err as Error));\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t});\n\t\t},\n\t\trenderCall(args, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatGrepCall(args, theme));\n\t\t\treturn text;\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatGrepResult(result, options, theme, context.showImages));\n\t\t\treturn text;\n\t\t},\n\t};\n}\n\nexport function createGrepTool(cwd: string, options?: GrepToolOptions): AgentTool<typeof grepSchema> {\n\treturn wrapToolDefinition(createGrepToolDefinition(cwd, options));\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell-task-status.d.ts","sourceRoot":"","sources":["../../../src/core/tools/shell-task-status.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAEX,WAAW,EACX,aAAa,EACb,OAAO,EACP,OAAO,EACP,WAAW,EACX,UAAU,EACV,SAAS,EACT,WAAW,EACX,UAAU,EACV,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,KAAK,CAAC;AAErE,iHAAiH;AACjH,MAAM,WAAW,UA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gB,qBAAqB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAepE;AAED,oFAAoF;AACpF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,aAAa,GAAG,UAAU,CAYtE;AAED,+GAA+G;AAC/G,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAM1E;AAED,MAAM,MAAM,mBAAmB,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;AAyCrH;;;GAGG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACvC,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,YAAY,OAAO,EAAE,OAAO,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,MAAM,EAOhE;CACD;AAED,MAAM,WAAW,qBAAqB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,kHAAkH;AAClH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,qBAAqB,GAAG,SAAS,CAS5G"}
|
|
@@ -5,7 +5,8 @@ const CANCEL_CAUSE_TEXT = {
|
|
|
5
5
|
"execution-timeout": "timed out",
|
|
6
6
|
"output-limit": "output limit reached",
|
|
7
7
|
"parent-handoff": "handed off",
|
|
8
|
-
|
|
8
|
+
// A shell cannot resume: a pause stops it, and the resumed work redoes the step.
|
|
9
|
+
pause: "stopped by a pause",
|
|
9
10
|
quit: "quit · paused · awaiting resume",
|
|
10
11
|
shutdown: "Atomic shut down",
|
|
11
12
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell-task-status.js","sourceRoot":"","sources":["../../../src/core/tools/shell-task-status.ts"],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nF,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC;AACjE,CAAC","sourcesContent":["/**\n * Plain-language wording for shell task observations (`wait`) and cancellations (`kill`).\n *\n * One source of truth for two audiences: the model reads compact sentences in the tool result text, and the\n * transcript renders the same facts as a single status line. Structured data stays in the result `details`.\n */\nimport type {\n\tCancelCause,\n\tCancelError,\n\tCancelReceipt,\n\tCleanup,\n\tFailure,\n\tOutputError,\n\tTaskResult,\n\tWaitError,\n\tWaitOutcome,\n\tWatchError,\n} from \"../tasks/contracts.js\";\n\nexport type TaskStatusTone = \"success\" | \"error\" | \"warning\" | \"dim\";\n\n/** One line of task state: `✓ completed · exit 0`. The glyph and label alone carry the meaning without color. */\nexport interface TaskStatus {\n\tglyph: \"✓\" | \"✗\" | \"●\" | \"○\";\n\ttone: TaskStatusTone;\n\tlabel: string;\n\tdetail?: string;\n}\n\nexport const EMPTY_OUTPUT_TEXT = \"(no output)\";\n\nconst CANCEL_CAUSE_TEXT: Record<CancelCause, string> = {\n\tuser: \"stop requested\",\n\t\"owner-close\": \"session closed\",\n\t\"execution-timeout\": \"timed out\",\n\t\"output-limit\": \"output limit reached\",\n\t\"parent-handoff\": \"handed off\",\n\tpause: \"paused · awaiting resume\",\n\tquit: \"quit · paused · awaiting resume\",\n\tshutdown: \"Atomic shut down\",\n};\n\nfunction firstLine(text: string): string {\n\treturn text.trim().split(/\\r?\\n/, 1)[0]?.trim() ?? \"\";\n}\n\nfunction withoutTrailingPeriods(text: string): string {\n\tlet end = text.length;\n\twhile (end > 0 && (text[end - 1] === \".\" || /\\s/.test(text[end - 1] ?? \"\"))) end--;\n\treturn text.slice(0, end);\n}\n\n/** The message of a failure, unless it only repeats the failure code. */\nfunction informativeMessage(code: string, message: string): string | undefined {\n\tconst line = firstLine(message);\n\treturn line && line !== code ? line : undefined;\n}\n\nfunction withDetail(status: Omit<TaskStatus, \"detail\">, detail: string | undefined): TaskStatus {\n\treturn detail === undefined ? status : { ...status, detail };\n}\n\nexport function taskResultStatus(result: TaskResult): TaskStatus {\n\tswitch (result.kind) {\n\t\tcase \"completed\":\n\t\t\tif (result.exitCode === 0) return { glyph: \"✓\", tone: \"success\", label: \"completed\", detail: \"exit 0\" };\n\t\t\tif (result.exitCode === undefined) return { glyph: \"✗\", tone: \"error\", label: \"ended without an exit code\" };\n\t\t\treturn { glyph: \"✗\", tone: \"error\", label: `exited ${result.exitCode}` };\n\t\tcase \"failed\":\n\t\t\treturn withDetail(\n\t\t\t\t{ glyph: \"✗\", tone: \"error\", label: \"failed\" },\n\t\t\t\tinformativeMessage(result.code, result.message),\n\t\t\t);\n\t\tcase \"cancelled\":\n\t\t\treturn withDetail(\n\t\t\t\t{ glyph: \"○\", tone: \"dim\", label: \"cancelled\" },\n\t\t\t\tresult.cause === \"user\" ? undefined : CANCEL_CAUSE_TEXT[result.cause],\n\t\t\t);\n\t}\n}\n\n/** What happened to a task, as a verb phrase that follows its subject: `exited with code 1`. */\nfunction taskResultPhrase(result: TaskResult): string {\n\tswitch (result.kind) {\n\t\tcase \"completed\":\n\t\t\tif (result.exitCode === 0) return \"completed with exit code 0\";\n\t\t\tif (result.exitCode === undefined) return \"ended without an exit code\";\n\t\t\treturn `exited with code ${result.exitCode}`;\n\t\tcase \"failed\": {\n\t\t\tconst message = informativeMessage(result.code, result.message);\n\t\t\tconst reason = message === undefined ? undefined : withoutTrailingPeriods(message);\n\t\t\treturn `failed (${result.code})${reason ? `: ${reason}` : \"\"}${result.exitCode === undefined ? \"\" : ` (exit code ${result.exitCode})`}`;\n\t\t}\n\t\tcase \"cancelled\":\n\t\t\treturn `was cancelled (${CANCEL_CAUSE_TEXT[result.cause]})`;\n\t}\n}\n\n/** Status line for a `wait` result. `hasOutput` says whether any output is shown below it. */\nexport function waitStatus(observation: WaitOutcome, hasOutput: boolean): TaskStatus {\n\tif (observation.kind === \"settled\") return taskResultStatus(observation.result);\n\treturn withDetail(\n\t\t{ glyph: \"●\", tone: \"warning\", label: \"still running\" },\n\t\thasOutput ? \"showing output so far\" : undefined,\n\t);\n}\n\nfunction waitSentence(observation: WaitOutcome): string {\n\tif (observation.kind === \"yielded\")\n\t\treturn `Task ${observation.taskId} is still running (yielded: ${observation.reason}).`;\n\treturn `Task ${observation.taskId} ${taskResultPhrase(observation.result)}.`;\n}\n\nexport interface WaitResultTail {\n\tobservation: WaitOutcome;\n\ttruncated: boolean;\n\tfullOutputPath?: string;\n}\n\n/**\n * Everything the model reads after a wait's output: the truncation marker, one sentence with the task's state and\n * exit code, and the path of the full output when it was truncated. The renderer strips the same tail.\n */\nexport function waitResultTail({ observation, truncated, fullOutputPath }: WaitResultTail): string {\n\treturn `${truncated ? \"\\n[Output truncated.]\" : \"\"}\\n\\n${waitSentence(observation)}${fullOutputPath ? `\\nFull output: ${fullOutputPath}` : \"\"}`;\n}\n\nfunction cleanupSentence(cleanup: Cleanup): string {\n\tif (cleanup.kind !== \"failed\") return `Cleanup: ${cleanup.kind}.`;\n\tconst resources = cleanup.resources.map(\n\t\t(entry) => `${entry.resource} (${entry.code}): ${withoutTrailingPeriods(firstLine(entry.message))}`,\n\t);\n\treturn `Cleanup failed: ${resources.join(\"; \")}.`;\n}\n\n/** Model-facing text of a `kill` result. The receipt itself stays in the result details. */\nexport function cancelReceiptSentence(receipt: CancelReceipt): string {\n\tconst { taskId, execution } = receipt;\n\tlet lead: string;\n\tif (execution.kind === \"settled\") {\n\t\tconst phrase = taskResultPhrase(execution.result);\n\t\tlead =\n\t\t\treceipt.decision === \"already-settled\"\n\t\t\t\t? `Task ${taskId} had already finished; nothing to stop. It ${phrase}.`\n\t\t\t\t: `Task ${taskId} ${phrase}.`;\n\t} else if (execution.kind === \"cancelling\") {\n\t\tlead = `Cancellation requested for task ${taskId}; it has not stopped yet.`;\n\t} else {\n\t\tlead = `Cancellation requested for task ${taskId}; it is still ${execution.kind}.`;\n\t}\n\treturn `${lead} ${cleanupSentence(receipt.cleanup)}`;\n}\n\n/** Status line for a `kill` result, describing the task rather than the request. */\nexport function cancelReceiptStatus(receipt: CancelReceipt): TaskStatus {\n\tconst { execution } = receipt;\n\tif (execution.kind === \"settled\") {\n\t\tconst status = taskResultStatus(execution.result);\n\t\treturn receipt.decision === \"already-settled\" ? { ...status, label: `already ${status.label}` } : status;\n\t}\n\treturn {\n\t\tglyph: \"●\",\n\t\ttone: \"warning\",\n\t\tlabel: execution.kind === \"cancelling\" ? \"stopping\" : \"still running\",\n\t\tdetail: \"cancellation requested\",\n\t};\n}\n\n/** The first resource that could not be cleaned up, for a status line; undefined when cleanup did not fail. */\nexport function cleanupFailureSummary(cleanup: Cleanup): string | undefined {\n\tif (cleanup.kind !== \"failed\") return undefined;\n\tconst [first, ...rest] = cleanup.resources;\n\tif (!first) return undefined;\n\tconst message = informativeMessage(first.code, first.message);\n\treturn `${first.resource}${message ? `: ${message}` : \"\"}${rest.length ? ` (+${rest.length} more)` : \"\"}`;\n}\n\nexport type TaskToolFailureCode = WaitError[\"code\"] | CancelError[\"code\"] | OutputError[\"code\"] | WatchError[\"code\"];\n\ninterface TaskErrorCopy {\n\t/** Names the id and what went wrong; `detail` is the supervisor's message when it says more than the code. */\n\theadline: (taskId: string, detail: string | undefined) => string;\n\t/** The next step. Shown in the transcript only, not sent to the model. */\n\thint?: string;\n}\n\nconst TASKS_HINT = \"Run /tasks to check on it.\";\n\nconst TASK_ERROR_COPY: Record<TaskToolFailureCode, TaskErrorCopy> = {\n\tUnknownTask: {\n\t\theadline: (taskId) => `No background task \"${taskId}\" in this session`,\n\t\thint: \"It may have finished and been cleaned up, or belong to another session. Run /tasks to see current tasks.\",\n\t},\n\tScopeMismatch: {\n\t\theadline: (taskId) => `Task \"${taskId}\" belongs to another session`,\n\t\thint: \"Run /tasks to see the tasks in this session.\",\n\t},\n\tOwnerClosed: {\n\t\theadline: () => \"This session's background tasks are closed\",\n\t\thint: \"Run the command again to start a new task.\",\n\t},\n\tEnvironmentClosing: { headline: () => \"Atomic is shutting down\" },\n\tObserverCancelled: { headline: (taskId) => `Stopped waiting for task \"${taskId}\"`, hint: TASKS_HINT },\n\tOutputUnavailable: {\n\t\theadline: (taskId) => `Output for task \"${taskId}\" is no longer available`,\n\t\thint: \"Run /tasks to check on the task.\",\n\t},\n\tCleanupFailed: {\n\t\theadline: (taskId, detail) => `Could not stop task \"${taskId}\"${detail ? `: ${detail}` : \"\"}`,\n\t\thint: \"Run /tasks to check whether it is still running.\",\n\t},\n\tStaleGeneration: { headline: () => \"The task list changed while it was being read\", hint: \"Try again.\" },\n};\n\nfunction isTaskToolFailureCode(code: string): code is TaskToolFailureCode {\n\treturn Object.hasOwn(TASK_ERROR_COPY, code);\n}\n\n/**\n * A task failure on the `wait`/`kill` path. The message is `<Code>: <plain-language headline naming the task>`;\n * callers that branch on the failure read `code` instead of parsing it.\n */\nexport class TaskToolError extends Error {\n\treadonly code: TaskToolFailureCode;\n\treadonly taskId: string;\n\n\tconstructor(failure: Failure<TaskToolFailureCode>, taskId: string) {\n\t\tsuper(\n\t\t\t`${failure.code}: ${TASK_ERROR_COPY[failure.code].headline(taskId, informativeMessage(failure.code, failure.message))}`,\n\t\t);\n\t\tthis.name = \"TaskToolError\";\n\t\tthis.code = failure.code;\n\t\tthis.taskId = taskId;\n\t}\n}\n\nexport interface TaskErrorPresentation {\n\theadline: string;\n\thint?: string;\n}\n\n/** How the transcript presents the text of a thrown {@link TaskToolError}; undefined for any other error text. */\nexport function presentTaskError(text: string, taskId: string | undefined): TaskErrorPresentation | undefined {\n\tconst match = /^(\\w+): ([^\\n]*)$/.exec(text.trim());\n\tif (!match) return undefined;\n\tconst [, code, rest] = match;\n\tif (code === undefined || rest === undefined || !isTaskToolFailureCode(code)) return undefined;\n\tconst copy = TASK_ERROR_COPY[code];\n\t// Sessions saved before the message was plain language hold only the code, repeated as the message.\n\tconst headline = rest === code && taskId ? copy.headline(taskId, undefined) : rest;\n\treturn copy.hint ? { headline, hint: copy.hint } : { headline };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"shell-task-status.js","sourceRoot":"","sources":["../../../src/core/tools/shell-task-status.ts"],"names":[],"mappings":"AA6BA,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAE/C,MAAM,iBAAiB,GAAgC;IACtD,IAAI,EAAE,gBAAgB;IACtB,aAAa,EAAE,gBAAgB;IAC/B,mBAAmB,EAAE,WAAW;IAChC,cAAc,EAAE,sBAAsB;IACtC,gBAAgB,EAAE,YAAY;IAC9B,iFAAiF;IACjF,KAAK,EAAE,oBAAoB;IAC3B,IAAI,EAAE,iCAAiC;IACvC,QAAQ,EAAE,kBAAkB;CAC5B,CAAC;AAEF,SAAS,SAAS,CAAC,IAAY;IAC9B,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACvD,CAAC;AAED,SAAS,sBAAsB,CAAC,IAAY;IAC3C,IAAI,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC;IACtB,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QAAE,GAAG,EAAE,CAAC;IACnF,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC3B,CAAC;AAED,yEAAyE;AACzE,SAAS,kBAAkB,CAAC,IAAY,EAAE,OAAe;IACxD,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IAChC,OAAO,IAAI,IAAI,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AACjD,CAAC;AA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AM,QAAQ,GAAG,IAAI,KAAK,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACnF,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC;AACjE,CAAC","sourcesContent":["/**\n * Plain-language wording for shell task observations (`wait`) and cancellations (`kill`).\n *\n * One source of truth for two audiences: the model reads compact sentences in the tool result text, and the\n * transcript renders the same facts as a single status line. Structured data stays in the result `details`.\n */\nimport type {\n\tCancelCause,\n\tCancelError,\n\tCancelReceipt,\n\tCleanup,\n\tFailure,\n\tOutputError,\n\tTaskResult,\n\tWaitError,\n\tWaitOutcome,\n\tWatchError,\n} from \"../tasks/contracts.js\";\n\nexport type TaskStatusTone = \"success\" | \"error\" | \"warning\" | \"dim\";\n\n/** One line of task state: `✓ completed · exit 0`. The glyph and label alone carry the meaning without color. */\nexport interface TaskStatus {\n\tglyph: \"✓\" | \"✗\" | \"●\" | \"○\";\n\ttone: TaskStatusTone;\n\tlabel: string;\n\tdetail?: string;\n}\n\nexport const EMPTY_OUTPUT_TEXT = \"(no output)\";\n\nconst CANCEL_CAUSE_TEXT: Record<CancelCause, string> = {\n\tuser: \"stop requested\",\n\t\"owner-close\": \"session closed\",\n\t\"execution-timeout\": \"timed out\",\n\t\"output-limit\": \"output limit reached\",\n\t\"parent-handoff\": \"handed off\",\n\t// A shell cannot resume: a pause stops it, and the resumed work redoes the step.\n\tpause: \"stopped by a pause\",\n\tquit: \"quit · paused · awaiting resume\",\n\tshutdown: \"Atomic shut down\",\n};\n\nfunction firstLine(text: string): string {\n\treturn text.trim().split(/\\r?\\n/, 1)[0]?.trim() ?? \"\";\n}\n\nfunction withoutTrailingPeriods(text: string): string {\n\tlet end = text.length;\n\twhile (end > 0 && (text[end - 1] === \".\" || /\\s/.test(text[end - 1] ?? \"\"))) end--;\n\treturn text.slice(0, end);\n}\n\n/** The message of a failure, unless it only repeats the failure code. */\nfunction informativeMessage(code: string, message: string): string | undefined {\n\tconst line = firstLine(message);\n\treturn line && line !== code ? line : undefined;\n}\n\nfunction withDetail(status: Omit<TaskStatus, \"detail\">, detail: string | undefined): TaskStatus {\n\treturn detail === undefined ? status : { ...status, detail };\n}\n\nexport function taskResultStatus(result: TaskResult): TaskStatus {\n\tswitch (result.kind) {\n\t\tcase \"completed\":\n\t\t\tif (result.exitCode === 0) return { glyph: \"✓\", tone: \"success\", label: \"completed\", detail: \"exit 0\" };\n\t\t\tif (result.exitCode === undefined) return { glyph: \"✗\", tone: \"error\", label: \"ended without an exit code\" };\n\t\t\treturn { glyph: \"✗\", tone: \"error\", label: `exited ${result.exitCode}` };\n\t\tcase \"failed\":\n\t\t\treturn withDetail(\n\t\t\t\t{ glyph: \"✗\", tone: \"error\", label: \"failed\" },\n\t\t\t\tinformativeMessage(result.code, result.message),\n\t\t\t);\n\t\tcase \"cancelled\":\n\t\t\treturn withDetail(\n\t\t\t\t{ glyph: \"○\", tone: \"dim\", label: \"cancelled\" },\n\t\t\t\tresult.cause === \"user\" ? undefined : CANCEL_CAUSE_TEXT[result.cause],\n\t\t\t);\n\t}\n}\n\n/** What happened to a task, as a verb phrase that follows its subject: `exited with code 1`. */\nfunction taskResultPhrase(result: TaskResult): string {\n\tswitch (result.kind) {\n\t\tcase \"completed\":\n\t\t\tif (result.exitCode === 0) return \"completed with exit code 0\";\n\t\t\tif (result.exitCode === undefined) return \"ended without an exit code\";\n\t\t\treturn `exited with code ${result.exitCode}`;\n\t\tcase \"failed\": {\n\t\t\tconst message = informativeMessage(result.code, result.message);\n\t\t\tconst reason = message === undefined ? undefined : withoutTrailingPeriods(message);\n\t\t\treturn `failed (${result.code})${reason ? `: ${reason}` : \"\"}${result.exitCode === undefined ? \"\" : ` (exit code ${result.exitCode})`}`;\n\t\t}\n\t\tcase \"cancelled\":\n\t\t\treturn `was cancelled (${CANCEL_CAUSE_TEXT[result.cause]})`;\n\t}\n}\n\n/** Status line for a `wait` result. `hasOutput` says whether any output is shown below it. */\nexport function waitStatus(observation: WaitOutcome, hasOutput: boolean): TaskStatus {\n\tif (observation.kind === \"settled\") return taskResultStatus(observation.result);\n\treturn withDetail(\n\t\t{ glyph: \"●\", tone: \"warning\", label: \"still running\" },\n\t\thasOutput ? \"showing output so far\" : undefined,\n\t);\n}\n\nfunction waitSentence(observation: WaitOutcome): string {\n\tif (observation.kind === \"yielded\")\n\t\treturn `Task ${observation.taskId} is still running (yielded: ${observation.reason}).`;\n\treturn `Task ${observation.taskId} ${taskResultPhrase(observation.result)}.`;\n}\n\nexport interface WaitResultTail {\n\tobservation: WaitOutcome;\n\ttruncated: boolean;\n\tfullOutputPath?: string;\n}\n\n/**\n * Everything the model reads after a wait's output: the truncation marker, one sentence with the task's state and\n * exit code, and the path of the full output when it was truncated. The renderer strips the same tail.\n */\nexport function waitResultTail({ observation, truncated, fullOutputPath }: WaitResultTail): string {\n\treturn `${truncated ? \"\\n[Output truncated.]\" : \"\"}\\n\\n${waitSentence(observation)}${fullOutputPath ? `\\nFull output: ${fullOutputPath}` : \"\"}`;\n}\n\nfunction cleanupSentence(cleanup: Cleanup): string {\n\tif (cleanup.kind !== \"failed\") return `Cleanup: ${cleanup.kind}.`;\n\tconst resources = cleanup.resources.map(\n\t\t(entry) => `${entry.resource} (${entry.code}): ${withoutTrailingPeriods(firstLine(entry.message))}`,\n\t);\n\treturn `Cleanup failed: ${resources.join(\"; \")}.`;\n}\n\n/** Model-facing text of a `kill` result. The receipt itself stays in the result details. */\nexport function cancelReceiptSentence(receipt: CancelReceipt): string {\n\tconst { taskId, execution } = receipt;\n\tlet lead: string;\n\tif (execution.kind === \"settled\") {\n\t\tconst phrase = taskResultPhrase(execution.result);\n\t\tlead =\n\t\t\treceipt.decision === \"already-settled\"\n\t\t\t\t? `Task ${taskId} had already finished; nothing to stop. It ${phrase}.`\n\t\t\t\t: `Task ${taskId} ${phrase}.`;\n\t} else if (execution.kind === \"cancelling\") {\n\t\tlead = `Cancellation requested for task ${taskId}; it has not stopped yet.`;\n\t} else {\n\t\tlead = `Cancellation requested for task ${taskId}; it is still ${execution.kind}.`;\n\t}\n\treturn `${lead} ${cleanupSentence(receipt.cleanup)}`;\n}\n\n/** Status line for a `kill` result, describing the task rather than the request. */\nexport function cancelReceiptStatus(receipt: CancelReceipt): TaskStatus {\n\tconst { execution } = receipt;\n\tif (execution.kind === \"settled\") {\n\t\tconst status = taskResultStatus(execution.result);\n\t\treturn receipt.decision === \"already-settled\" ? { ...status, label: `already ${status.label}` } : status;\n\t}\n\treturn {\n\t\tglyph: \"●\",\n\t\ttone: \"warning\",\n\t\tlabel: execution.kind === \"cancelling\" ? \"stopping\" : \"still running\",\n\t\tdetail: \"cancellation requested\",\n\t};\n}\n\n/** The first resource that could not be cleaned up, for a status line; undefined when cleanup did not fail. */\nexport function cleanupFailureSummary(cleanup: Cleanup): string | undefined {\n\tif (cleanup.kind !== \"failed\") return undefined;\n\tconst [first, ...rest] = cleanup.resources;\n\tif (!first) return undefined;\n\tconst message = informativeMessage(first.code, first.message);\n\treturn `${first.resource}${message ? `: ${message}` : \"\"}${rest.length ? ` (+${rest.length} more)` : \"\"}`;\n}\n\nexport type TaskToolFailureCode = WaitError[\"code\"] | CancelError[\"code\"] | OutputError[\"code\"] | WatchError[\"code\"];\n\ninterface TaskErrorCopy {\n\t/** Names the id and what went wrong; `detail` is the supervisor's message when it says more than the code. */\n\theadline: (taskId: string, detail: string | undefined) => string;\n\t/** The next step. Shown in the transcript only, not sent to the model. */\n\thint?: string;\n}\n\nconst TASKS_HINT = \"Run /tasks to check on it.\";\n\nconst TASK_ERROR_COPY: Record<TaskToolFailureCode, TaskErrorCopy> = {\n\tUnknownTask: {\n\t\theadline: (taskId) => `No background task \"${taskId}\" in this session`,\n\t\thint: \"It may have finished and been cleaned up, or belong to another session. Run /tasks to see current tasks.\",\n\t},\n\tScopeMismatch: {\n\t\theadline: (taskId) => `Task \"${taskId}\" belongs to another session`,\n\t\thint: \"Run /tasks to see the tasks in this session.\",\n\t},\n\tOwnerClosed: {\n\t\theadline: () => \"This session's background tasks are closed\",\n\t\thint: \"Run the command again to start a new task.\",\n\t},\n\tEnvironmentClosing: { headline: () => \"Atomic is shutting down\" },\n\tObserverCancelled: { headline: (taskId) => `Stopped waiting for task \"${taskId}\"`, hint: TASKS_HINT },\n\tOutputUnavailable: {\n\t\theadline: (taskId) => `Output for task \"${taskId}\" is no longer available`,\n\t\thint: \"Run /tasks to check on the task.\",\n\t},\n\tCleanupFailed: {\n\t\theadline: (taskId, detail) => `Could not stop task \"${taskId}\"${detail ? `: ${detail}` : \"\"}`,\n\t\thint: \"Run /tasks to check whether it is still running.\",\n\t},\n\tStaleGeneration: { headline: () => \"The task list changed while it was being read\", hint: \"Try again.\" },\n};\n\nfunction isTaskToolFailureCode(code: string): code is TaskToolFailureCode {\n\treturn Object.hasOwn(TASK_ERROR_COPY, code);\n}\n\n/**\n * A task failure on the `wait`/`kill` path. The message is `<Code>: <plain-language headline naming the task>`;\n * callers that branch on the failure read `code` instead of parsing it.\n */\nexport class TaskToolError extends Error {\n\treadonly code: TaskToolFailureCode;\n\treadonly taskId: string;\n\n\tconstructor(failure: Failure<TaskToolFailureCode>, taskId: string) {\n\t\tsuper(\n\t\t\t`${failure.code}: ${TASK_ERROR_COPY[failure.code].headline(taskId, informativeMessage(failure.code, failure.message))}`,\n\t\t);\n\t\tthis.name = \"TaskToolError\";\n\t\tthis.code = failure.code;\n\t\tthis.taskId = taskId;\n\t}\n}\n\nexport interface TaskErrorPresentation {\n\theadline: string;\n\thint?: string;\n}\n\n/** How the transcript presents the text of a thrown {@link TaskToolError}; undefined for any other error text. */\nexport function presentTaskError(text: string, taskId: string | undefined): TaskErrorPresentation | undefined {\n\tconst match = /^(\\w+): ([^\\n]*)$/.exec(text.trim());\n\tif (!match) return undefined;\n\tconst [, code, rest] = match;\n\tif (code === undefined || rest === undefined || !isTaskToolFailureCode(code)) return undefined;\n\tconst copy = TASK_ERROR_COPY[code];\n\t// Sessions saved before the message was plain language hold only the code, repeated as the message.\n\tconst headline = rest === code && taskId ? copy.headline(taskId, undefined) : rest;\n\treturn copy.hint ? { headline, hint: copy.hint } : { headline };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistant-message.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/assistant-message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,
|
|
1
|
+
{"version":3,"file":"assistant-message.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/assistant-message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAkB,SAAS,EAAY,KAAK,aAAa,EAAgB,MAAM,wBAAwB,CAAC;AAC/G,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAQ7E;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,SAAS;IACvD,OAAO,CAAC,gBAAgB,CAAY;IACpC,OAAO,CAAC,iBAAiB,CAAU;IACnC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,mBAAmB,CAAS;IACpC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,oBAAoB,CAAiC;IAC7D,OAAO,CAAC,WAAW,CAAC,CAAmB;IACvC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAU;IAC7B,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B,OAAO,CAAC,SAAS,CAAC,CAAS;IAE3B,YACC,OAAO,CAAC,EAAE,gBAAgB,EAC1B,iBAAiB,UAAQ,EACzB,aAAa,GAAE,aAAkC,EACjD,mBAAmB,SAAgB,EACnC,SAAS,SAAI,EACb,oBAAoB,GAAE,SAAS,mBAAmB,EAAO,EAEzD,WAAW,UAAQ,EACnB,WAAW,UAAO,EAClB,SAAS,CAAC,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM,EAmBlB;IAEQ,UAAU,IAAI,IAAI,CAK1B;IAED,oBAAoB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAKxC;IAED,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAK1C;IAED,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAKlC;IAEQ,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CASvC;IAED,aAAa,CAAC,OAAO,EAAE,gBAAgB,EAAE,WAAW,UAAmB,GAAG,IAAI,CA2G7E;CACD"}
|
|
@@ -77,17 +77,24 @@ export class AssistantMessageComponent extends Container {
|
|
|
77
77
|
this.isStreaming = isStreaming;
|
|
78
78
|
// Clear content container
|
|
79
79
|
this.contentContainer.clear();
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
// Spacers are added lazily, right before the next visible content block. This puts a blank
|
|
81
|
+
// line before the first visible block and after each visible thinking run that is followed
|
|
82
|
+
// by more visible content, while hidden thinking runs without a label contribute nothing.
|
|
83
|
+
let needsSpacer = true;
|
|
84
|
+
const addVisibleChild = (child) => {
|
|
85
|
+
if (needsSpacer) {
|
|
86
|
+
this.contentContainer.addChild(new Spacer(1));
|
|
87
|
+
needsSpacer = false;
|
|
88
|
+
}
|
|
89
|
+
this.contentContainer.addChild(child);
|
|
90
|
+
};
|
|
84
91
|
// Render content in order
|
|
85
92
|
for (let i = 0; i < message.content.length; i++) {
|
|
86
93
|
const content = message.content[i];
|
|
87
94
|
if (content.type === "text" && content.text.trim()) {
|
|
88
95
|
// Assistant text messages with no background - trim the text
|
|
89
96
|
// Set paddingY=0 to avoid extra spacing before tool executions
|
|
90
|
-
|
|
97
|
+
addVisibleChild(new Markdown(content.text.trim(), this.outputPad, 0, this.markdownTheme, undefined, {
|
|
91
98
|
transform: createMarkdownTransform("assistant", this.isStreaming, this.markdownTransformers, this.messageId, this.timestamp),
|
|
92
99
|
renderLatex: this.renderLatex,
|
|
93
100
|
}));
|
|
@@ -106,14 +113,14 @@ export class AssistantMessageComponent extends Container {
|
|
|
106
113
|
if (thinkingBlocks.length === 0)
|
|
107
114
|
continue;
|
|
108
115
|
// Keep text and tool calls as run boundaries; only adjacent thinking is coalesced.
|
|
109
|
-
const hasVisibleContentAfter = message.content
|
|
110
|
-
.slice(i + 1)
|
|
111
|
-
.some((c) => (c.type === "text" && c.text.trim()) || (c.type === "thinking" && c.thinking.trim()));
|
|
112
116
|
if (this.hideThinkingBlock) {
|
|
113
|
-
|
|
117
|
+
// A hidden run with an empty label renders nothing, including no spacing.
|
|
118
|
+
if (!this.hiddenThinkingLabel.trim())
|
|
119
|
+
continue;
|
|
120
|
+
addVisibleChild(new Text(theme.italic(theme.fg("muted", this.hiddenThinkingLabel)), this.outputPad, 0));
|
|
114
121
|
}
|
|
115
122
|
else {
|
|
116
|
-
|
|
123
|
+
addVisibleChild(new Markdown(thinkingBlocks.join("\n\n"), this.outputPad, 0, this.markdownTheme, {
|
|
117
124
|
color: (text) => theme.fg("muted", text),
|
|
118
125
|
italic: true,
|
|
119
126
|
}, {
|
|
@@ -121,8 +128,9 @@ export class AssistantMessageComponent extends Container {
|
|
|
121
128
|
renderLatex: this.renderLatex,
|
|
122
129
|
}));
|
|
123
130
|
}
|
|
124
|
-
|
|
125
|
-
|
|
131
|
+
// Add spacing only when another visible assistant content block follows.
|
|
132
|
+
// This avoids a superfluous blank line before separately-rendered tool execution blocks.
|
|
133
|
+
needsSpacer = true;
|
|
126
134
|
}
|
|
127
135
|
}
|
|
128
136
|
// Check if incomplete/failed - show after partial content.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistant-message.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/assistant-message.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAsB,MAAM,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAE/F,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAElE,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAC3C,MAAM,eAAe,GAAG,gBAAgB,CAAC;AACzC,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,yBAA0B,SAAQ,SAAS;IAC/C,gBAAgB,CAAY;IAC5B,iBAAiB,CAAU;IAC3B,aAAa,CAAgB;IAC7B,mBAAmB,CAAS;IAC5B,SAAS,CAAS;IAClB,oBAAoB,CAAiC;IACrD,WAAW,CAAoB;IAC/B,YAAY,GAAG,KAAK,CAAC;IACrB,WAAW,GAAG,KAAK,CAAC;IACpB,WAAW,CAAU;IACrB,SAAS,CAAU;IACnB,SAAS,CAAU;IAE3B,YACC,OAA0B,EAC1B,iBAAiB,GAAG,KAAK,EACzB,aAAa,GAAkB,gBAAgB,EAAE,EACjD,mBAAmB,GAAG,aAAa,EACnC,SAAS,GAAG,CAAC,EACb,oBAAoB,GAAmC,EAAE;IACzD,uFAAuF;IACvF,WAAW,GAAG,KAAK,EACnB,WAAW,GAAG,IAAI,EAClB,SAAkB,EAClB,SAAkB;QAElB,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC3C,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;QAC/C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;QACjD,IAAI,CAAC,W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AAS,EAAE,CAAC,CAAC,CAAC,CAAC;YACtG,CAAC;QACF,CAAC;IACF,CAAC;CACD","sourcesContent":["import type { AssistantMessage } from \"@bastani/pi-ai/compat\";\nimport { Container, Markdown, type MarkdownTheme, Spacer, Text } from \"@earendil-works/pi-tui\";\nimport type { MarkdownTransformer } from \"../../../core/extensions/types.ts\";\nimport { getMarkdownTheme, theme } from \"../theme/theme.js\";\nimport { createMarkdownTransform } from \"./markdown-transform.ts\";\n\nconst OSC133_ZONE_START = \"\\x1b]133;A\\x07\";\nconst OSC133_ZONE_END = \"\\x1b]133;B\\x07\";\nconst OSC133_ZONE_FINAL = \"\\x1b]133;C\\x07\";\n\n/**\n * Component that renders a complete assistant message\n */\nexport class AssistantMessageComponent extends Container {\n\tprivate contentContainer: Container;\n\tprivate hideThinkingBlock: boolean;\n\tprivate markdownTheme: MarkdownTheme;\n\tprivate hiddenThinkingLabel: string;\n\tprivate outputPad: number;\n\tprivate markdownTransformers: readonly MarkdownTransformer[];\n\tprivate lastMessage?: AssistantMessage;\n\tprivate hasToolCalls = false;\n\tprivate isStreaming = false;\n\tprivate renderLatex: boolean;\n\tprivate messageId?: string;\n\tprivate timestamp?: string;\n\n\tconstructor(\n\t\tmessage?: AssistantMessage,\n\t\thideThinkingBlock = false,\n\t\tmarkdownTheme: MarkdownTheme = getMarkdownTheme(),\n\t\thiddenThinkingLabel = \"Thinking...\",\n\t\toutputPad = 1,\n\t\tmarkdownTransformers: readonly MarkdownTransformer[] = [],\n\t\t// ChatSessionHost creates components per render, so it needs the initial stream state.\n\t\tisStreaming = false,\n\t\trenderLatex = true,\n\t\tmessageId?: string,\n\t\ttimestamp?: string,\n\t) {\n\t\tsuper();\n\n\t\tthis.hideThinkingBlock = hideThinkingBlock;\n\t\tthis.markdownTheme = markdownTheme;\n\t\tthis.hiddenThinkingLabel = hiddenThinkingLabel;\n\t\tthis.outputPad = outputPad;\n\t\tthis.markdownTransformers = markdownTransformers;\n\t\tthis.renderLatex = renderLatex;\n\t\tthis.messageId = messageId;\n\t\tthis.timestamp = timestamp;\n\t\t// Container for text/thinking content\n\t\tthis.contentContainer = new Container();\n\t\tthis.addChild(this.contentContainer);\n\n\t\tif (message) {\n\t\t\tthis.updateContent(message, isStreaming);\n\t\t}\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\tsetHideThinkingBlock(hide: boolean): void {\n\t\tthis.hideThinkingBlock = hide;\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\tsetHiddenThinkingLabel(label: string): void {\n\t\tthis.hiddenThinkingLabel = label;\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\tsetOutputPad(padding: number): void {\n\t\tthis.outputPad = padding;\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\toverride render(width: number): string[] {\n\t\tconst lines = super.render(width);\n\t\tif (this.hasToolCalls || lines.length === 0) {\n\t\t\treturn lines;\n\t\t}\n\n\t\tlines[0] = OSC133_ZONE_START + lines[0];\n\t\tlines[lines.length - 1] = OSC133_ZONE_END + OSC133_ZONE_FINAL + lines[lines.length - 1];\n\t\treturn lines;\n\t}\n\n\tupdateContent(message: AssistantMessage, isStreaming = this.isStreaming): void {\n\t\tthis.lastMessage = message;\n\t\tthis.isStreaming = isStreaming;\n\n\t\t// Clear content container\n\t\tthis.contentContainer.clear();\n\n\t\tconst hasVisibleContent = message.content.some(\n\t\t\t(c) => (c.type === \"text\" && c.text.trim()) || (c.type === \"thinking\" && c.thinking.trim()),\n\t\t);\n\n\t\tif (hasVisibleContent) {\n\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t}\n\n\t\t// Render content in order\n\t\tfor (let i = 0; i < message.content.length; i++) {\n\t\t\tconst content = message.content[i];\n\t\t\tif (content.type === \"text\" && content.text.trim()) {\n\t\t\t\t// Assistant text messages with no background - trim the text\n\t\t\t\t// Set paddingY=0 to avoid extra spacing before tool executions\n\t\t\t\tthis.contentContainer.addChild(\n\t\t\t\t\tnew Markdown(content.text.trim(), this.outputPad, 0, this.markdownTheme, undefined, {\n\t\t\t\t\t\ttransform: createMarkdownTransform(\n\t\t\t\t\t\t\t\"assistant\",\n\t\t\t\t\t\t\tthis.isStreaming,\n\t\t\t\t\t\t\tthis.markdownTransformers,\n\t\t\t\t\t\t\tthis.messageId,\n\t\t\t\t\t\t\tthis.timestamp,\n\t\t\t\t\t\t),\n\t\t\t\t\t\trenderLatex: this.renderLatex,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t} else if (content.type === \"thinking\") {\n\t\t\t\tconst thinkingBlocks: string[] = [];\n\t\t\t\tfor (; i < message.content.length; i++) {\n\t\t\t\t\tconst thinkingContent = message.content[i];\n\t\t\t\t\tif (thinkingContent.type !== \"thinking\") break;\n\t\t\t\t\tconst thinking = thinkingContent.thinking.trim();\n\t\t\t\t\tif (thinking) thinkingBlocks.push(thinking);\n\t\t\t\t}\n\t\t\t\ti--;\n\t\t\t\tif (thinkingBlocks.length === 0) continue;\n\n\t\t\t\t// Keep text and tool calls as run boundaries; only adjacent thinking is coalesced.\n\t\t\t\tconst hasVisibleContentAfter = message.content\n\t\t\t\t\t.slice(i + 1)\n\t\t\t\t\t.some((c) => (c.type === \"text\" && c.text.trim()) || (c.type === \"thinking\" && c.thinking.trim()));\n\t\t\t\tif (this.hideThinkingBlock) {\n\t\t\t\t\tthis.contentContainer.addChild(\n\t\t\t\t\t\tnew Text(theme.italic(theme.fg(\"muted\", this.hiddenThinkingLabel)), this.outputPad, 0),\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthis.contentContainer.addChild(\n\t\t\t\t\t\tnew Markdown(\n\t\t\t\t\t\t\tthinkingBlocks.join(\"\\n\\n\"),\n\t\t\t\t\t\t\tthis.outputPad,\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\tthis.markdownTheme,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcolor: (text: string) => theme.fg(\"muted\", text),\n\t\t\t\t\t\t\t\titalic: true,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttransform: createMarkdownTransform(\n\t\t\t\t\t\t\t\t\t\"assistant-thinking\",\n\t\t\t\t\t\t\t\t\tthis.isStreaming,\n\t\t\t\t\t\t\t\t\tthis.markdownTransformers,\n\t\t\t\t\t\t\t\t\tthis.messageId,\n\t\t\t\t\t\t\t\t\tthis.timestamp,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\trenderLatex: this.renderLatex,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (hasVisibleContentAfter) this.contentContainer.addChild(new Spacer(1));\n\t\t\t}\n\t\t}\n\n\t\t// Check if incomplete/failed - show after partial content.\n\t\t// For aborted/error tool calls, tool execution components show the error.\n\t\t// Length stops can happen before a tool call is complete, so surface them here too.\n\t\tconst hasToolCalls = message.content.some((c) => c.type === \"toolCall\");\n\t\tthis.hasToolCalls = hasToolCalls;\n\t\tif (message.stopReason === \"length\") {\n\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\tthis.contentContainer.addChild(\n\t\t\t\tnew Text(theme.fg(\"error\", \"Response was truncated before completion.\"), this.outputPad, 0),\n\t\t\t);\n\t\t} else if (!hasToolCalls) {\n\t\t\tif (message.stopReason === \"aborted\") {\n\t\t\t\tconst abortMessage =\n\t\t\t\t\tmessage.errorMessage && message.errorMessage !== \"Request was aborted\"\n\t\t\t\t\t\t? message.errorMessage\n\t\t\t\t\t\t: \"Operation aborted\";\n\t\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\t\tthis.contentContainer.addChild(new Text(theme.fg(\"error\", abortMessage), this.outputPad, 0));\n\t\t\t} else if (message.stopReason === \"error\") {\n\t\t\t\tconst errorMsg = message.errorMessage || \"Unknown error\";\n\t\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\t\tthis.contentContainer.addChild(new Text(theme.fg(\"error\", `Error: ${errorMsg}`), this.outputPad, 0));\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"assistant-message.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/assistant-message.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,SAAS,EAAE,QAAQ,EAAsB,MAAM,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAE/G,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAElE,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAC3C,MAAM,eAAe,GAAG,gBAAgB,CAAC;AACzC,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,yBAA0B,SAAQ,SAAS;IAC/C,gBAAgB,CAAY;IAC5B,iBAAiB,CAAU;IAC3B,aAAa,CAAgB;IAC7B,mBAAmB,CAAS;IAC5B,SAAS,CAAS;IAClB,oBAAoB,CAAiC;IACrD,WAAW,CAAoB;IAC/B,YAAY,GAAG,KAAK,CAAC;IACrB,WAAW,GAAG,KAAK,CAAC;IACpB,WAAW,CAAU;IACrB,SAAS,CAAU;IACnB,SAAS,CAAU;IAE3B,YACC,OAA0B,EAC1B,iBAAiB,GAAG,KAAK,EACzB,aAAa,GAAkB,gBAAgB,EAAE,EACjD,mBAAmB,GAAG,aAAa,EACnC,SAAS,GAAG,CAAC,EACb,oBAAoB,GAAmC,EAAE;IACzD,uFAAuF;IACvF,WAAW,GAAG,KAAK,EACnB,WAAW,GAAG,IAAI,EAClB,SAAkB,EAClB,SAAkB;QAElB,KAAK,EAAE,CAAC;QAER,IAAI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AC;YAC9C,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAC7B,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,2CAA2C,CAAC,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAC3F,CAAC;QACH,CAAC;aAAM,IAAI,CAAC,YAAY,EAAE,CAAC;YAC1B,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;gBACtC,MAAM,YAAY,GACjB,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,YAAY,KAAK,qBAAqB;oBACrE,CAAC,CAAC,OAAO,CAAC,YAAY;oBACtB,CAAC,CAAC,mBAAmB,CAAC;gBACxB,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC9C,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;YAC9F,CAAC;iBAAM,IAAI,OAAO,CAAC,UAAU,KAAK,OAAO,EAAE,CAAC;gBAC3C,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,IAAI,eAAe,CAAC;gBACzD,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC9C,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,QAAQ,EAAE,CAAC,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;YACtG,CAAC;QACF,CAAC;IACF,CAAC;CACD","sourcesContent":["import type { AssistantMessage } from \"@bastani/pi-ai/compat\";\nimport { type Component, Container, Markdown, type MarkdownTheme, Spacer, Text } from \"@earendil-works/pi-tui\";\nimport type { MarkdownTransformer } from \"../../../core/extensions/types.ts\";\nimport { getMarkdownTheme, theme } from \"../theme/theme.js\";\nimport { createMarkdownTransform } from \"./markdown-transform.ts\";\n\nconst OSC133_ZONE_START = \"\\x1b]133;A\\x07\";\nconst OSC133_ZONE_END = \"\\x1b]133;B\\x07\";\nconst OSC133_ZONE_FINAL = \"\\x1b]133;C\\x07\";\n\n/**\n * Component that renders a complete assistant message\n */\nexport class AssistantMessageComponent extends Container {\n\tprivate contentContainer: Container;\n\tprivate hideThinkingBlock: boolean;\n\tprivate markdownTheme: MarkdownTheme;\n\tprivate hiddenThinkingLabel: string;\n\tprivate outputPad: number;\n\tprivate markdownTransformers: readonly MarkdownTransformer[];\n\tprivate lastMessage?: AssistantMessage;\n\tprivate hasToolCalls = false;\n\tprivate isStreaming = false;\n\tprivate renderLatex: boolean;\n\tprivate messageId?: string;\n\tprivate timestamp?: string;\n\n\tconstructor(\n\t\tmessage?: AssistantMessage,\n\t\thideThinkingBlock = false,\n\t\tmarkdownTheme: MarkdownTheme = getMarkdownTheme(),\n\t\thiddenThinkingLabel = \"Thinking...\",\n\t\toutputPad = 1,\n\t\tmarkdownTransformers: readonly MarkdownTransformer[] = [],\n\t\t// ChatSessionHost creates components per render, so it needs the initial stream state.\n\t\tisStreaming = false,\n\t\trenderLatex = true,\n\t\tmessageId?: string,\n\t\ttimestamp?: string,\n\t) {\n\t\tsuper();\n\n\t\tthis.hideThinkingBlock = hideThinkingBlock;\n\t\tthis.markdownTheme = markdownTheme;\n\t\tthis.hiddenThinkingLabel = hiddenThinkingLabel;\n\t\tthis.outputPad = outputPad;\n\t\tthis.markdownTransformers = markdownTransformers;\n\t\tthis.renderLatex = renderLatex;\n\t\tthis.messageId = messageId;\n\t\tthis.timestamp = timestamp;\n\t\t// Container for text/thinking content\n\t\tthis.contentContainer = new Container();\n\t\tthis.addChild(this.contentContainer);\n\n\t\tif (message) {\n\t\t\tthis.updateContent(message, isStreaming);\n\t\t}\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\tsetHideThinkingBlock(hide: boolean): void {\n\t\tthis.hideThinkingBlock = hide;\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\tsetHiddenThinkingLabel(label: string): void {\n\t\tthis.hiddenThinkingLabel = label;\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\tsetOutputPad(padding: number): void {\n\t\tthis.outputPad = padding;\n\t\tif (this.lastMessage) {\n\t\t\tthis.updateContent(this.lastMessage);\n\t\t}\n\t}\n\n\toverride render(width: number): string[] {\n\t\tconst lines = super.render(width);\n\t\tif (this.hasToolCalls || lines.length === 0) {\n\t\t\treturn lines;\n\t\t}\n\n\t\tlines[0] = OSC133_ZONE_START + lines[0];\n\t\tlines[lines.length - 1] = OSC133_ZONE_END + OSC133_ZONE_FINAL + lines[lines.length - 1];\n\t\treturn lines;\n\t}\n\n\tupdateContent(message: AssistantMessage, isStreaming = this.isStreaming): void {\n\t\tthis.lastMessage = message;\n\t\tthis.isStreaming = isStreaming;\n\n\t\t// Clear content container\n\t\tthis.contentContainer.clear();\n\n\t\t// Spacers are added lazily, right before the next visible content block. This puts a blank\n\t\t// line before the first visible block and after each visible thinking run that is followed\n\t\t// by more visible content, while hidden thinking runs without a label contribute nothing.\n\t\tlet needsSpacer = true;\n\t\tconst addVisibleChild = (child: Component) => {\n\t\t\tif (needsSpacer) {\n\t\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\t\tneedsSpacer = false;\n\t\t\t}\n\t\t\tthis.contentContainer.addChild(child);\n\t\t};\n\n\t\t// Render content in order\n\t\tfor (let i = 0; i < message.content.length; i++) {\n\t\t\tconst content = message.content[i];\n\t\t\tif (content.type === \"text\" && content.text.trim()) {\n\t\t\t\t// Assistant text messages with no background - trim the text\n\t\t\t\t// Set paddingY=0 to avoid extra spacing before tool executions\n\t\t\t\taddVisibleChild(\n\t\t\t\t\tnew Markdown(content.text.trim(), this.outputPad, 0, this.markdownTheme, undefined, {\n\t\t\t\t\t\ttransform: createMarkdownTransform(\n\t\t\t\t\t\t\t\"assistant\",\n\t\t\t\t\t\t\tthis.isStreaming,\n\t\t\t\t\t\t\tthis.markdownTransformers,\n\t\t\t\t\t\t\tthis.messageId,\n\t\t\t\t\t\t\tthis.timestamp,\n\t\t\t\t\t\t),\n\t\t\t\t\t\trenderLatex: this.renderLatex,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t} else if (content.type === \"thinking\") {\n\t\t\t\tconst thinkingBlocks: string[] = [];\n\t\t\t\tfor (; i < message.content.length; i++) {\n\t\t\t\t\tconst thinkingContent = message.content[i];\n\t\t\t\t\tif (thinkingContent.type !== \"thinking\") break;\n\t\t\t\t\tconst thinking = thinkingContent.thinking.trim();\n\t\t\t\t\tif (thinking) thinkingBlocks.push(thinking);\n\t\t\t\t}\n\t\t\t\ti--;\n\t\t\t\tif (thinkingBlocks.length === 0) continue;\n\n\t\t\t\t// Keep text and tool calls as run boundaries; only adjacent thinking is coalesced.\n\t\t\t\tif (this.hideThinkingBlock) {\n\t\t\t\t\t// A hidden run with an empty label renders nothing, including no spacing.\n\t\t\t\t\tif (!this.hiddenThinkingLabel.trim()) continue;\n\t\t\t\t\taddVisibleChild(new Text(theme.italic(theme.fg(\"muted\", this.hiddenThinkingLabel)), this.outputPad, 0));\n\t\t\t\t} else {\n\t\t\t\t\taddVisibleChild(\n\t\t\t\t\t\tnew Markdown(\n\t\t\t\t\t\t\tthinkingBlocks.join(\"\\n\\n\"),\n\t\t\t\t\t\t\tthis.outputPad,\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\tthis.markdownTheme,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcolor: (text: string) => theme.fg(\"muted\", text),\n\t\t\t\t\t\t\t\titalic: true,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttransform: createMarkdownTransform(\n\t\t\t\t\t\t\t\t\t\"assistant-thinking\",\n\t\t\t\t\t\t\t\t\tthis.isStreaming,\n\t\t\t\t\t\t\t\t\tthis.markdownTransformers,\n\t\t\t\t\t\t\t\t\tthis.messageId,\n\t\t\t\t\t\t\t\t\tthis.timestamp,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\trenderLatex: this.renderLatex,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// Add spacing only when another visible assistant content block follows.\n\t\t\t\t// This avoids a superfluous blank line before separately-rendered tool execution blocks.\n\t\t\t\tneedsSpacer = true;\n\t\t\t}\n\t\t}\n\n\t\t// Check if incomplete/failed - show after partial content.\n\t\t// For aborted/error tool calls, tool execution components show the error.\n\t\t// Length stops can happen before a tool call is complete, so surface them here too.\n\t\tconst hasToolCalls = message.content.some((c) => c.type === \"toolCall\");\n\t\tthis.hasToolCalls = hasToolCalls;\n\t\tif (message.stopReason === \"length\") {\n\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\tthis.contentContainer.addChild(\n\t\t\t\tnew Text(theme.fg(\"error\", \"Response was truncated before completion.\"), this.outputPad, 0),\n\t\t\t);\n\t\t} else if (!hasToolCalls) {\n\t\t\tif (message.stopReason === \"aborted\") {\n\t\t\t\tconst abortMessage =\n\t\t\t\t\tmessage.errorMessage && message.errorMessage !== \"Request was aborted\"\n\t\t\t\t\t\t? message.errorMessage\n\t\t\t\t\t\t: \"Operation aborted\";\n\t\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\t\tthis.contentContainer.addChild(new Text(theme.fg(\"error\", abortMessage), this.outputPad, 0));\n\t\t\t} else if (message.stopReason === \"error\") {\n\t\t\t\tconst errorMsg = message.errorMessage || \"Unknown error\";\n\t\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\t\tthis.contentContainer.addChild(new Text(theme.fg(\"error\", `Error: ${errorMsg}`), this.outputPad, 0));\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
@@ -313,7 +313,7 @@ InteractiveModeBase.prototype.showExtensionCustom = async function (factory, opt
|
|
|
313
313
|
else {
|
|
314
314
|
inlineMount = component;
|
|
315
315
|
const deferFocus = this.shouldDeferInlineCustomUiFocus();
|
|
316
|
-
this.pushExtensionDialog(component,
|
|
316
|
+
this.pushExtensionDialog(component, options?.blocked, !deferFocus);
|
|
317
317
|
if (deferFocus) {
|
|
318
318
|
this.pendingInlineCustomUiFocus = component;
|
|
319
319
|
this.notifyHostCustomUiStateListeners();
|