@bastani/atomic 0.9.84 → 0.9.85

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.
Files changed (183) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +16 -0
  3. package/dist/builtin/intercom/broker/broker.ts +25 -7
  4. package/dist/builtin/intercom/broker/spawn.ts +83 -17
  5. package/dist/builtin/intercom/index.bundle.mjs +89 -26
  6. package/dist/builtin/intercom/package.json +1 -1
  7. package/dist/builtin/mcp/package.json +1 -1
  8. package/dist/builtin/subagents/package.json +1 -1
  9. package/dist/builtin/web-access/package.json +1 -1
  10. package/dist/builtin/workflows/CHANGELOG.md +16 -0
  11. package/dist/builtin/workflows/package.json +1 -1
  12. package/dist/builtin/workflows/src/authoring.d.ts +1 -1
  13. package/dist/builtin/workflows/src/extension/index.bundle.mjs +48 -9
  14. package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +48 -9
  15. package/dist/builtin/workflows/src/index.js +48 -9
  16. package/dist/builtin/workflows/src/local-worker-entry.mjs +48 -9
  17. package/dist/config.d.ts +3 -2
  18. package/dist/config.d.ts.map +1 -1
  19. package/dist/config.js +4 -3
  20. package/dist/config.js.map +1 -1
  21. package/dist/core/agent-session-export.d.ts +2 -2
  22. package/dist/core/agent-session-export.d.ts.map +1 -1
  23. package/dist/core/agent-session-export.js +4 -5
  24. package/dist/core/agent-session-export.js.map +1 -1
  25. package/dist/core/agent-session-services.js +1 -1
  26. package/dist/core/agent-session-services.js.map +1 -1
  27. package/dist/core/agent-session-summary.d.ts.map +1 -1
  28. package/dist/core/agent-session-summary.js +8 -1
  29. package/dist/core/agent-session-summary.js.map +1 -1
  30. package/dist/core/agent-session-tree.d.ts.map +1 -1
  31. package/dist/core/agent-session-tree.js +3 -6
  32. package/dist/core/agent-session-tree.js.map +1 -1
  33. package/dist/core/builtin-resource-loader.d.ts.map +1 -1
  34. package/dist/core/builtin-resource-loader.js +1 -1
  35. package/dist/core/builtin-resource-loader.js.map +1 -1
  36. package/dist/core/extensions/loader-core.d.ts +6 -2
  37. package/dist/core/extensions/loader-core.d.ts.map +1 -1
  38. package/dist/core/extensions/loader-core.js +13 -9
  39. package/dist/core/extensions/loader-core.js.map +1 -1
  40. package/dist/core/extensions/loader-discovery.js +1 -1
  41. package/dist/core/extensions/loader-discovery.js.map +1 -1
  42. package/dist/core/extensions/loader-virtual-modules.d.ts +20 -14
  43. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  44. package/dist/core/extensions/loader-virtual-modules.js +133 -78
  45. package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
  46. package/dist/core/extensions/ts-source-specifiers.d.ts +1 -0
  47. package/dist/core/extensions/ts-source-specifiers.d.ts.map +1 -1
  48. package/dist/core/extensions/ts-source-specifiers.js +18 -2
  49. package/dist/core/extensions/ts-source-specifiers.js.map +1 -1
  50. package/dist/core/mandatory-resource-loader.d.ts +5 -2
  51. package/dist/core/mandatory-resource-loader.d.ts.map +1 -1
  52. package/dist/core/mandatory-resource-loader.js +17 -12
  53. package/dist/core/mandatory-resource-loader.js.map +1 -1
  54. package/dist/core/model-fallback-failures.d.ts.map +1 -1
  55. package/dist/core/model-fallback-failures.js +10 -3
  56. package/dist/core/model-fallback-failures.js.map +1 -1
  57. package/dist/core/resource-loader-extensions.d.ts.map +1 -1
  58. package/dist/core/resource-loader-extensions.js +1 -1
  59. package/dist/core/resource-loader-extensions.js.map +1 -1
  60. package/dist/core/resource-loader-reload.js +1 -1
  61. package/dist/core/resource-loader-reload.js.map +1 -1
  62. package/dist/core/resume/blueprint/resume.d.ts +4 -4
  63. package/dist/core/resume/blueprint/resume.js +4 -4
  64. package/dist/core/resume/blueprint/resume.js.map +1 -1
  65. package/dist/core/resume/session-resume.d.ts +6 -3
  66. package/dist/core/resume/session-resume.d.ts.map +1 -1
  67. package/dist/core/resume/session-resume.js +159 -37
  68. package/dist/core/resume/session-resume.js.map +1 -1
  69. package/dist/core/sdk.js +1 -1
  70. package/dist/core/sdk.js.map +1 -1
  71. package/dist/core/session-manager-core.d.ts +10 -4
  72. package/dist/core/session-manager-core.d.ts.map +1 -1
  73. package/dist/core/session-manager-core.js +23 -6
  74. package/dist/core/session-manager-core.js.map +1 -1
  75. package/dist/core/session-manager-entries.d.ts +2 -2
  76. package/dist/core/session-manager-entries.d.ts.map +1 -1
  77. package/dist/core/session-manager-entries.js +2 -1
  78. package/dist/core/session-manager-entries.js.map +1 -1
  79. package/dist/core/session-manager-history.d.ts +13 -1
  80. package/dist/core/session-manager-history.d.ts.map +1 -1
  81. package/dist/core/session-manager-history.js +21 -1
  82. package/dist/core/session-manager-history.js.map +1 -1
  83. package/dist/core/session-manager-types.d.ts +3 -1
  84. package/dist/core/session-manager-types.d.ts.map +1 -1
  85. package/dist/core/session-manager-types.js.map +1 -1
  86. package/dist/core/session-manager.d.ts +1 -1
  87. package/dist/core/session-manager.d.ts.map +1 -1
  88. package/dist/core/session-manager.js +1 -1
  89. package/dist/core/session-manager.js.map +1 -1
  90. package/dist/core/session-worktree-snapshots.d.ts +61 -4
  91. package/dist/core/session-worktree-snapshots.d.ts.map +1 -1
  92. package/dist/core/session-worktree-snapshots.js +261 -28
  93. package/dist/core/session-worktree-snapshots.js.map +1 -1
  94. package/dist/core/storage/session/entry-structure.js +31 -1
  95. package/dist/core/storage/session/entry-structure.js.map +1 -1
  96. package/dist/core/tools/ask-user-question/state/build-questionnaire.d.ts.map +1 -1
  97. package/dist/core/tools/ask-user-question/state/build-questionnaire.js +2 -1
  98. package/dist/core/tools/ask-user-question/state/build-questionnaire.js.map +1 -1
  99. package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts.map +1 -1
  100. package/dist/core/tools/ask-user-question/state/questionnaire-session.js +2 -0
  101. package/dist/core/tools/ask-user-question/state/questionnaire-session.js.map +1 -1
  102. package/dist/core/tools/ask-user-question/state/selectors/field-tone.d.ts +26 -0
  103. package/dist/core/tools/ask-user-question/state/selectors/field-tone.d.ts.map +1 -0
  104. package/dist/core/tools/ask-user-question/state/selectors/field-tone.js +27 -0
  105. package/dist/core/tools/ask-user-question/state/selectors/field-tone.js.map +1 -0
  106. package/dist/core/tools/ask-user-question/state/selectors/projections.d.ts.map +1 -1
  107. package/dist/core/tools/ask-user-question/state/selectors/projections.js +1 -0
  108. package/dist/core/tools/ask-user-question/state/selectors/projections.js.map +1 -1
  109. package/dist/core/tools/ask-user-question/state/state-reducer.js +1 -1
  110. package/dist/core/tools/ask-user-question/state/state-reducer.js.map +1 -1
  111. package/dist/core/tools/ask-user-question/view/components/multi-select-view.d.ts.map +1 -1
  112. package/dist/core/tools/ask-user-question/view/components/multi-select-view.js +6 -6
  113. package/dist/core/tools/ask-user-question/view/components/multi-select-view.js.map +1 -1
  114. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts +5 -3
  115. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts.map +1 -1
  116. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js +14 -4
  117. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js.map +1 -1
  118. package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.d.ts +2 -0
  119. package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.d.ts.map +1 -1
  120. package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.js +3 -3
  121. package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.js.map +1 -1
  122. package/dist/core/tools/ask-user-question/view/components/wrapping-select.d.ts +16 -6
  123. package/dist/core/tools/ask-user-question/view/components/wrapping-select.d.ts.map +1 -1
  124. package/dist/core/tools/ask-user-question/view/components/wrapping-select.js +42 -24
  125. package/dist/core/tools/ask-user-question/view/components/wrapping-select.js.map +1 -1
  126. package/dist/core/tools/ask-user-question/view/tab-content-strategy.d.ts.map +1 -1
  127. package/dist/core/tools/ask-user-question/view/tab-content-strategy.js +12 -3
  128. package/dist/core/tools/ask-user-question/view/tab-content-strategy.js.map +1 -1
  129. package/dist/core/tools/read.d.ts +1 -0
  130. package/dist/core/tools/read.d.ts.map +1 -1
  131. package/dist/core/tools/read.js +13 -14
  132. package/dist/core/tools/read.js.map +1 -1
  133. package/dist/core/worktree-snapshot/index.d.ts +2 -2
  134. package/dist/core/worktree-snapshot/index.d.ts.map +1 -1
  135. package/dist/core/worktree-snapshot/index.js +1 -1
  136. package/dist/core/worktree-snapshot/index.js.map +1 -1
  137. package/dist/core/worktree-snapshot/records.d.ts +6 -0
  138. package/dist/core/worktree-snapshot/records.d.ts.map +1 -1
  139. package/dist/core/worktree-snapshot/records.js +18 -4
  140. package/dist/core/worktree-snapshot/records.js.map +1 -1
  141. package/dist/core/worktree-snapshot/restore.d.ts +24 -1
  142. package/dist/core/worktree-snapshot/restore.d.ts.map +1 -1
  143. package/dist/core/worktree-snapshot/restore.js +443 -72
  144. package/dist/core/worktree-snapshot/restore.js.map +1 -1
  145. package/dist/core/worktree-snapshot/types.d.ts +44 -0
  146. package/dist/core/worktree-snapshot/types.d.ts.map +1 -1
  147. package/dist/core/worktree-snapshot/types.js.map +1 -1
  148. package/dist/index.d.ts +2 -2
  149. package/dist/index.d.ts.map +1 -1
  150. package/dist/index.js +2 -2
  151. package/dist/index.js.map +1 -1
  152. package/dist/modes/interactive/components/tool-execution.js +2 -1
  153. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  154. package/dist/modes/interactive/interactive-slash-commands.js +4 -1
  155. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  156. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  157. package/dist/modes/interactive-engine/isolated-runtime.js +8 -0
  158. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  159. package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
  160. package/dist/modes/rpc/rpc-command-handler.js +11 -2
  161. package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
  162. package/dist/modes/rpc/rpc-command-timeouts.d.ts.map +1 -1
  163. package/dist/modes/rpc/rpc-command-timeouts.js +1 -0
  164. package/dist/modes/rpc/rpc-command-timeouts.js.map +1 -1
  165. package/dist/modes/rpc/rpc-input-scheduler.d.ts.map +1 -1
  166. package/dist/modes/rpc/rpc-input-scheduler.js +1 -0
  167. package/dist/modes/rpc/rpc-input-scheduler.js.map +1 -1
  168. package/dist/modes/rpc/rpc-types.d.ts +11 -1
  169. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  170. package/dist/modes/rpc/rpc-types.js.map +1 -1
  171. package/docs/environment-variables.md +1 -1
  172. package/docs/guides/resume-on-any-machine.md +6 -4
  173. package/docs/intercom/operations.md +4 -0
  174. package/docs/rpc/protocol.md +2 -2
  175. package/docs/sdk/reference.md +3 -0
  176. package/docs/sdk.md +2 -2
  177. package/docs/session-format.md +11 -2
  178. package/docs/sessions.md +4 -2
  179. package/docs/settings.md +1 -1
  180. package/docs/workflows/api-reference.md +2 -2
  181. package/docs/worktree-snapshots.md +13 -5
  182. package/npm-shrinkwrap.json +32 -32
  183. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"read.js","sourceRoot":"","sources":["../../../src/core/tools/read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,IAAI,WAAW,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGjG,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,QAAQ,IAAI,UAAU,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AACzF,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wDAAwD,CAAC;AA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C,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,CAAC,CACjG,CAAC;YACF,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,CACX,gBAAgB,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,CACxG,CAAC;YACF,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;AACH,CAAC;AACD,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAyB;IACpE,OAAO,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import { basename, dirname, isAbsolute, relative, resolve as resolvePath, sep } from \"node:path\";\nimport type { Api, ImageContent, Model, ModelImageResizeOptions, TextContent } from \"@bastani/pi-ai/compat\";\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Text } from \"@earendil-works/pi-tui\";\nimport { constants } from \"fs\";\nimport { access as fsAccess, readFile as fsReadFile, stat as fsStat } from \"fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport { getReadmePath } from \"../../config.js\";\nimport { parenthesizedKeyHint } from \"../../modes/interactive/components/keybinding-hints.js\";\nimport { getLanguageFromPath, highlightCode, type Theme } from \"../../modes/interactive/theme/theme.js\";\nimport { processImage } from \"../../utils/image-process.ts\";\nimport { detectSupportedImageMimeTypeFromFile } from \"../../utils/mime.ts\";\nimport { formatPathRelativeToCwdOrAbsolute } from \"../../utils/paths.ts\";\nimport type { ExtensionContext, ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { parseConflictBlocks, registerConflictBlocks } from \"./conflict-registry.ts\";\nimport {\n\tbuildDirectoryTree,\n\tbuildDirectoryTreeFromOperations,\n\ttype DirectoryTreeEntry,\n\ttype DirectoryTreeResult,\n} from \"./directory-tree.ts\";\nimport { isReadableUrlPath } from \"./fetch-url.ts\";\nimport { FileToolAbortedError } from \"./file-tool-errors.ts\";\nimport { isNotebookPath, readEditableNotebookText } from \"./notebook.ts\";\nimport { resolveReadPathAsync, resolveToCwd } from \"./path-utils.ts\";\nimport { applyReadLineSelection, extractDocumentMarkdown, isDocumentPath } from \"./read-document-extract.ts\";\nimport {\n\ttype ReadLinePlan,\n\treadLocalFileChunks,\n\ttype SelectedReadLines,\n\tselectReadLinesFromChunks,\n\tselectReadLinesFromList,\n} from \"./read-line-stream.ts\";\nimport {\n\tformatSelectedLines,\n\tisReadResourceSelector,\n\ttype ReadLineSelector,\n\tselectExactReadRanges,\n\tselectReadRanges,\n\tsplitReadLineSelector,\n} from \"./read-selectors.ts\";\nimport { readUrlBranch } from \"./read-url.ts\";\nimport { getTextOutput, invalidArgText, replaceTabs, shortenPath, str } from \"./render-utils.ts\";\nimport {\n\ttype InternalResourceContext,\n\tisInternalUrl,\n\tparseArchiveSelector,\n\treadArchiveSelector,\n\treadInternalSelector,\n\treadSqliteSelector,\n\tresolveArchiveSelector,\n\tresolveInternalSelector,\n\tsqliteSelectorForPath,\n} from \"./resource-selectors.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, type TruncationResult, truncateHead } from \"./truncate.ts\";\n\nconst readSchema = Type.Object(\n\t{\n\t\tpath: Type.String({\n\t\t\tdescription:\n\t\t\t\t\"File, directory, archive member, SQLite selector, internal resource (skill://, local://, artifact://, conflict://, history://), image, document, or URL to read. Append selectors such as :raw, :conflicts, :N, :A-B, :A+C, or :A-B,C-D to scope output.\",\n\t\t}),\n\t},\n\t{ additionalProperties: false },\n);\nexport const readToolSystemPromptContribution = Object.freeze({\n\tsnippet: \"Read a path selector.\",\n\tguidelines: Object.freeze([\n\t\t\"Use read to inspect file and resource contents; use path selectors for line ranges, raw output, and conflict views.\",\n\t] as const),\n} as const);\nexport type ReadToolInput = Static<typeof readSchema>;\n\nconst readOutputSchema = Type.Union([\n\tType.String(),\n\tType.Object({ type: Type.Literal(\"image\"), data: Type.String(), mimeType: Type.String(), note: Type.String() }),\n]);\nexport type ReadToolOutput = Static<typeof readOutputSchema>;\nconst READ_TOOL_MAX_RESULT_CHARS = 50_000;\nexport interface OversizedReadDetails {\n\tblocked: true;\n\tpath: string;\n\tchars: number;\n\tmaxChars: number;\n\tstartLine: number;\n\trequestedLimit?: number;\n\ttotalFileLines: number;\n\tfirstLineBytes: number;\n\tbyteGuidance: boolean;\n}\nexport interface ReadToolDetails {\n\tisDirectory?: boolean;\n\tresolvedPath?: string;\n\ttruncation?: TruncationResult;\n\toversizedRead?: OversizedReadDetails;\n\tmeta?: {\n\t\tsource?: string;\n\t\tsourcePath?: string;\n\t\tartifactId?: string;\n\t\ttruncation?: TruncationResult;\n\t\tlimits?: Record<string, number>;\n\t};\n}\ninterface CompactReadClassification {\n\tkind: \"docs\" | \"resource\" | \"skill\";\n\tlabel: string;\n}\nconst COMPACT_RESOURCE_FILE_NAMES = new Set([\"AGENTS.override.md\", \"AGENTS.md\", \"AGENTS.MD\", \"CLAUDE.md\", \"CLAUDE.MD\"]);\nexport interface ReadOperations {\n\treadFile: (absolutePath: string) => Promise<Buffer>;\n\taccess: (absolutePath: string) => Promise<void>;\n\tstat?: (absolutePath: string) => Promise<{ isFile: boolean; isDirectory: boolean } | undefined>;\n\tlistDir?: (absolutePath: string) => Promise<DirectoryTreeEntry[] | undefined>;\n\tdetectImageMimeType?: (absolutePath: string) => Promise<string | null | undefined>;\n\t/**\n\t * Stream file contents in chunks. When present, text files are read through it and only the lines a read shows\n\t * are kept in memory; otherwise `readFile` loads the whole file. Stop reading when the signal aborts; `read` also\n\t * stops consuming the stream then.\n\t */\n\tcreateReadStream?: (absolutePath: string, options: { signal?: AbortSignal }) => AsyncIterable<Uint8Array>;\n}\nconst defaultReadOperations: ReadOperations = {\n\treadFile: (path) => fsReadFile(path),\n\tcreateReadStream: readLocalFileChunks,\n\taccess: (path) => fsAccess(path, constants.R_OK),\n\tdetectImageMimeType: detectSupportedImageMimeTypeFromFile,\n};\nasync function* readWholeFile(ops: ReadOperations, absolutePath: string): AsyncGenerator<Uint8Array> {\n\tyield await ops.readFile(absolutePath);\n}\nexport interface ReadToolOptions {\n\t/** Whether to auto-resize images. Default: true */\n\tautoResizeImages?: boolean;\n\t/** Fallback resize profile when the execution context has no model metadata. */\n\tresizeOptions?: ModelImageResizeOptions;\n\toperations?: ReadOperations;\n}\ntype ReadRenderArgs = { path?: string };\nfunction formatReadLineRange(_args: ReadRenderArgs | undefined, _theme: Theme): string {\n\treturn \"\";\n}\nfunction formatReadCall(args: ReadRenderArgs | undefined, theme: Theme): string {\n\tconst rawPath = str(args?.path);\n\tconst path = rawPath !== null ? shortenPath(rawPath) : null;\n\tconst invalidArg = invalidArgText(theme);\n\tconst pathDisplay = path === null ? invalidArg : path ? theme.fg(\"accent\", path) : theme.fg(\"toolOutput\", \"...\");\n\treturn `${theme.fg(\"toolTitle\", theme.bold(\"read\"))} ${pathDisplay}${formatReadLineRange(args, theme)}`;\n}\nfunction trimTrailingEmptyLines(lines: string[]): string[] {\n\tlet end = lines.length;\n\twhile (end > 0 && lines[end - 1] === \"\") end--;\n\treturn lines.slice(0, end);\n}\nfunction toReadOutput(content: (TextContent | ImageContent)[]): ReadToolOutput {\n\tconst text = content.find((block) => block.type === \"text\")?.text ?? \"\";\n\tconst image = content.find((block) => block.type === \"image\");\n\treturn image ? { type: \"image\", data: image.data, mimeType: image.mimeType, note: text } : text;\n}\nfunction getNonVisionImageNote(model: Model<Api> | undefined): string | undefined {\n\treturn !model || model.input.includes(\"image\")\n\t\t? undefined\n\t\t: \"[Current model does not support images. The image will be omitted from this request.]\";\n}\nfunction toPosixPath(filePath: string): string {\n\treturn filePath.split(sep).join(\"/\");\n}\nfunction formatCount(count: number): string {\n\treturn count.toLocaleString(\"en-US\");\n}\nfunction shellQuote(value: string): string {\n\treturn `'${value.replace(/'/g, `'\\\\''`)}'`;\n}\nfunction buildOversizedReadMessage(details: OversizedReadDetails): string {\n\tconst pathForExample = JSON.stringify(details.path);\n\tconst rangePathForExample = JSON.stringify(`${details.path}:${details.startLine}+200`);\n\tconst shellPathForExample = shellQuote(details.path);\n\tconst requestedLimitLine =\n\t\tdetails.requestedLimit !== undefined ? [`Requested line limit: ${formatCount(details.requestedLimit)}`] : [];\n\tif (details.byteGuidance) {\n\t\treturn [\n\t\t\t`File read blocked: requested selected range is too large (${formatCount(details.chars)} chars; threshold: ${formatCount(details.maxChars)} chars).`,\n\t\t\t`Path: ${details.path}`,\n\t\t\t...requestedLimitLine,\n\t\t\t\"\",\n\t\t\t\"The selected content starts with a single oversized line, so line pagination is not useful. Read byte slices instead. Examples:\",\n\t\t\t`- Inspect the start of line ${details.startLine}: sed -n '${details.startLine}p' ${shellPathForExample} | head -c ${DEFAULT_MAX_BYTES}`,\n\t\t\t`- Inspect a later byte window: sed -n '${details.startLine}p' ${shellPathForExample} | tail -c +${DEFAULT_MAX_BYTES + 1} | head -c ${DEFAULT_MAX_BYTES}`,\n\t\t\t`- Search for relevant text first: search({ \"pattern\": \"functionName\", \"paths\": ${pathForExample} })`,\n\t\t].join(\"\\n\");\n\t}\n\tconst targetedSnippetOffset = Math.max(details.startLine, 120);\n\tconst snippetPathForExample = JSON.stringify(`${details.path}:${targetedSnippetOffset}+80`);\n\treturn [\n\t\t`File read blocked: requested selected range is too large (${formatCount(details.chars)} chars; threshold: ${formatCount(details.maxChars)} chars).`,\n\t\t`Path: ${details.path}`,\n\t\t...requestedLimitLine,\n\t\t\"\",\n\t\t\"Read only the needed context incrementally. Examples:\",\n\t\t`- Search for relevant symbols first: search({ \"pattern\": \"functionName\", \"paths\": ${pathForExample} })`,\n\t\t`- Read a smaller line range: read({ \"path\": ${rangePathForExample} })`,\n\t\t`- Read a targeted snippet around a match: read({ \"path\": ${snippetPathForExample} })`,\n\t].join(\"\\n\");\n}\nfunction readSourceMeta(source: string): ReadToolDetails {\n\treturn { meta: { source, sourcePath: source } };\n}\nfunction oversizedReadResult(details: OversizedReadDetails): { content: TextContent[]; details: ReadToolDetails } {\n\treturn {\n\t\tcontent: [{ type: \"text\", text: buildOversizedReadMessage(details) }],\n\t\tdetails: {\n\t\t\toversizedRead: details,\n\t\t\tmeta: { source: details.path, sourcePath: details.path, limits: { maxChars: details.maxChars } },\n\t\t},\n\t};\n}\nfunction getPiDocsClassification(absolutePath: string): CompactReadClassification | undefined {\n\tconst packageRoot = dirname(getReadmePath());\n\tconst relativePath = relative(resolvePath(packageRoot), resolvePath(absolutePath));\n\tif (\n\t\trelativePath === \"\" ||\n\t\trelativePath === \"..\" ||\n\t\trelativePath.startsWith(`..${sep}`) ||\n\t\tisAbsolute(relativePath)\n\t) {\n\t\treturn undefined;\n\t}\n\tconst label = toPosixPath(relativePath);\n\tif (label === \"README.md\" || label.startsWith(\"docs/\") || label.startsWith(\"examples/\")) {\n\t\treturn { kind: \"docs\", label };\n\t}\n\treturn undefined;\n}\nfunction getCompactReadClassification(\n\targs: ReadRenderArgs | undefined,\n\tcwd: string,\n): CompactReadClassification | undefined {\n\tconst rawPath = str(args?.path);\n\tif (!rawPath) return undefined;\n\tconst absolutePath = resolveToCwd(rawPath, cwd);\n\tconst fileName = basename(absolutePath);\n\tif (fileName === \"SKILL.md\") {\n\t\treturn { kind: \"skill\", label: basename(dirname(absolutePath)) || fileName };\n\t}\n\tconst docsClassification = getPiDocsClassification(absolutePath);\n\tif (docsClassification) return docsClassification;\n\tif (COMPACT_RESOURCE_FILE_NAMES.has(fileName)) {\n\t\treturn { kind: \"resource\", label: formatPathRelativeToCwdOrAbsolute(absolutePath, cwd) };\n\t}\n\treturn undefined;\n}\nfunction formatCompactReadCall(\n\tclassification: CompactReadClassification,\n\targs: ReadRenderArgs | undefined,\n\ttheme: Theme,\n): string {\n\tconst hint = parenthesizedKeyHint(\"app.tools.expand\", \"Expand\");\n\tconst expandHint = hint ? ` ${hint}` : \"\";\n\tif (classification.kind === \"skill\") {\n\t\treturn (\n\t\t\ttheme.fg(\"customMessageLabel\", `\\x1b[1m[skill]\\x1b[22m `) +\n\t\t\ttheme.fg(\"customMessageText\", classification.label) +\n\t\t\tformatReadLineRange(args, theme) +\n\t\t\texpandHint\n\t\t);\n\t}\n\treturn (\n\t\ttheme.fg(\"toolTitle\", theme.bold(`read ${classification.kind}`)) +\n\t\t\" \" +\n\t\ttheme.fg(\"accent\", classification.label) +\n\t\tformatReadLineRange(args, theme) +\n\t\texpandHint\n\t);\n}\nfunction formatReadResult(\n\targs: ReadRenderArgs | undefined,\n\tresult: { content: (TextContent | ImageContent)[]; details?: ReadToolDetails },\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tshowImages: boolean,\n\t_cwd: string,\n\tisError: boolean,\n): string {\n\tconst oversizedRead = result.details?.oversizedRead;\n\tconst oversizedReadBlocked = oversizedRead?.blocked === true;\n\tif (!options.expanded && !isError && !oversizedReadBlocked) {\n\t\treturn \"\";\n\t}\n\tconst rawPath = str(args?.path);\n\tconst output = oversizedRead ? buildOversizedReadMessage(oversizedRead) : getTextOutput(result, showImages);\n\tconst lang = !isError && rawPath && !oversizedReadBlocked ? getLanguageFromPath(rawPath) : undefined;\n\tconst renderedLines = lang ? highlightCode(replaceTabs(output), lang) : output.split(\"\\n\");\n\tconst lines = trimTrailingEmptyLines(renderedLines);\n\tconst maxLines = options.expanded ? lines.length : 10;\n\tconst displayLines = lines.slice(0, maxLines);\n\tconst remaining = lines.length - maxLines;\n\tlet text = `\\n${displayLines.map((line) => (lang ? replaceTabs(line) : theme.fg(\"toolOutput\", replaceTabs(line)))).join(\"\\n\")}`;\n\tif (remaining > 0) {\n\t\ttext +=\n\t\t\ttheme.fg(\"muted\", \"\\n... \") + parenthesizedKeyHint(\"app.tools.expand\", \"Expand\", `${remaining} more lines`);\n\t}\n\tconst truncation = result.details?.truncation;\n\tif (truncation?.truncated) {\n\t\tif (truncation.firstLineExceedsLimit) {\n\t\t\ttext += `\\n${theme.fg(\"warning\", `[First line exceeds ${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit]`)}`;\n\t\t} else if (truncation.truncatedBy === \"lines\") {\n\t\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: showing ${truncation.outputLines} of ${truncation.totalLines} lines (${truncation.maxLines ?? DEFAULT_MAX_LINES} line limit)]`)}`;\n\t\t} else {\n\t\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: ${truncation.outputLines} lines shown (${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit)]`)}`;\n\t\t}\n\t}\n\treturn text;\n}\nfunction archiveSelectorMemberExists(pathValue: string, cwd: string): boolean {\n\tconst archive = parseArchiveSelector(pathValue);\n\tif (!archive?.memberPath) return false;\n\ttry {\n\t\treadArchiveSelector(resolveArchiveSelector(archive, cwd));\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\nfunction appendReadSelectors(pathValue: string, selector: ReadLineSelector): string {\n\tconst range =\n\t\tselector.ranges\n\t\t\t?.map((item) => (item.end === undefined ? `${item.start}` : `${item.start}-${item.end}`))\n\t\t\t.join(\",\") ?? (selector.offset ? `${selector.offset}` : \"\");\n\treturn `${pathValue}${range ? `:${range}` : \"\"}${selector.conflicts ? \":conflicts\" : \"\"}${selector.raw ? \":raw\" : \"\"}`;\n}\nexport function createReadToolDefinition(\n\tcwd: string,\n\toptions?: ReadToolOptions,\n): ToolDefinition<typeof readSchema, ReadToolDetails | undefined> {\n\tconst autoResizeImages = options?.autoResizeImages ?? true;\n\tconst fallbackResizeOptions = options?.resizeOptions;\n\tconst ops = options?.operations ?? defaultReadOperations;\n\treturn {\n\t\tname: \"read\",\n\t\tlabel: \"read\",\n\t\tdescription:\n\t\t\t\"Read files, directories, archives, SQLite databases, internal resources (including history:// for past sessions and workflow runs), images, documents, and URLs through one path string.\",\n\t\tpromptSnippet: readToolSystemPromptContribution.snippet,\n\t\tpromptGuidelines: [...readToolSystemPromptContribution.guidelines],\n\t\tconstrainedSampling: { type: \"json_schema\", strict: \"prefer\" },\n\t\tparameters: readSchema,\n\t\toutputSchema: readOutputSchema,\n\t\tmaxResultSizeChars: Infinity,\n\t\tasync execute(_toolCallId, { path }: ReadToolInput, signal?: AbortSignal, _onUpdate?, ctx?: ExtensionContext) {\n\t\t\tconst resourceCtx = ctx as InternalResourceContext | undefined;\n\t\t\tconst executionCwd = ctx?.cwd || cwd;\n\t\t\tconst splitSelector = splitReadLineSelector(path),\n\t\t\t\tmarkerless = path.replace(/:raw(?=(:|$))/g, \"\").replace(/:conflicts(?=(:|$))/g, \"\"),\n\t\t\t\tsqliteOriginal = sqliteSelectorForPath(markerless, executionCwd),\n\t\t\t\tsqliteDirect = sqliteSelectorForPath(path, executionCwd);\n\t\t\tconst selector = archiveSelectorMemberExists(path, executionCwd)\n\t\t\t\t? { path }\n\t\t\t\t: sqliteDirect && (sqliteDirect.table === \"raw\" || sqliteDirect.table === \"conflicts\")\n\t\t\t\t\t? { path }\n\t\t\t\t\t: sqliteOriginal?.rowId && splitSelector.path !== markerless\n\t\t\t\t\t\t? { path: markerless, raw: splitSelector.raw, conflicts: splitSelector.conflicts }\n\t\t\t\t\t\t: sqliteOriginal && splitSelector.path === markerless && markerless !== path\n\t\t\t\t\t\t\t? { path: markerless, raw: splitSelector.raw, conflicts: splitSelector.conflicts }\n\t\t\t\t\t\t\t: splitSelector.path === path && sqliteDirect\n\t\t\t\t\t\t\t\t? { path }\n\t\t\t\t\t\t\t\t: splitSelector;\n\t\t\tconst effectivePath = selector.path;\n\t\t\tconst effectiveOffset = selector.offset;\n\t\t\tconst effectiveLimit = selector.limit;\n\t\t\tconst effectiveRanges = selector.ranges;\n\t\t\tconst rawOutput = selector.raw;\n\t\t\tconst conflictsOnly = selector.conflicts;\n\t\t\treturn new Promise<{ content: (TextContent | ImageContent)[]; details: ReadToolDetails | undefined }>(\n\t\t\t\t(resolve, reject) => {\n\t\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\t\treject(new FileToolAbortedError(signal.reason));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tlet aborted = false;\n\t\t\t\t\tconst onAbort = () => {\n\t\t\t\t\t\taborted = true;\n\t\t\t\t\t\treject(new FileToolAbortedError(signal?.reason));\n\t\t\t\t\t};\n\t\t\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t\t(async () => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst archive = parseArchiveSelector(effectivePath);\n\t\t\t\t\t\t\tconst sqlite = sqliteSelectorForPath(effectivePath, executionCwd);\n\t\t\t\t\t\t\tif (isReadableUrlPath(effectivePath)) {\n\t\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t\tawait readUrlBranch({\n\t\t\t\t\t\t\t\t\t\teffectivePath,\n\t\t\t\t\t\t\t\t\t\trawOutput: rawOutput === true,\n\t\t\t\t\t\t\t\t\t\teffectiveRanges,\n\t\t\t\t\t\t\t\t\t\teffectiveOffset,\n\t\t\t\t\t\t\t\t\t\teffectiveLimit,\n\t\t\t\t\t\t\t\t\t\tcwd: executionCwd,\n\t\t\t\t\t\t\t\t\t\tctx,\n\t\t\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t\t\t\tmaxChars: READ_TOOL_MAX_RESULT_CHARS,\n\t\t\t\t\t\t\t\t\t\tmaxBytes: DEFAULT_MAX_BYTES,\n\t\t\t\t\t\t\t\t\t\toversized: oversizedReadResult,\n\t\t\t\t\t\t\t\t\t\tsourceMeta: readSourceMeta,\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 (sqlite) {\n\t\t\t\t\t\t\t\tconst textContent = readSqliteSelector(sqlite),\n\t\t\t\t\t\t\t\t\tselection = applyReadLineSelection(\n\t\t\t\t\t\t\t\t\t\ttextContent.split(\"\\n\"),\n\t\t\t\t\t\t\t\t\t\teffectiveRanges,\n\t\t\t\t\t\t\t\t\t\teffectiveOffset,\n\t\t\t\t\t\t\t\t\t\teffectiveLimit,\n\t\t\t\t\t\t\t\t\t\trawOutput,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tselectedText = selection.lines.join(\"\\n\");\n\t\t\t\t\t\t\t\tif ((effectiveRanges || effectiveOffset) && selection.lines.length === 0) {\n\t\t\t\t\t\t\t\t\tconst requested = effectiveRanges?.[0]?.start ?? effectiveOffset ?? 1;\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: `Requested line ${requested} is beyond end of resource (${textContent.split(\"\\n\").length} lines total).`,\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: undefined,\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\tif (\n\t\t\t\t\t\t\t\t\tselectedText.length > READ_TOOL_MAX_RESULT_CHARS ||\n\t\t\t\t\t\t\t\t\tBuffer.byteLength(selectedText, \"utf8\") > DEFAULT_MAX_BYTES\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t\t\toversizedReadResult({\n\t\t\t\t\t\t\t\t\t\t\tblocked: true,\n\t\t\t\t\t\t\t\t\t\t\tpath: effectivePath,\n\t\t\t\t\t\t\t\t\t\t\tchars: selectedText.length,\n\t\t\t\t\t\t\t\t\t\t\tmaxChars: READ_TOOL_MAX_RESULT_CHARS,\n\t\t\t\t\t\t\t\t\t\t\tstartLine: selection.firstLine,\n\t\t\t\t\t\t\t\t\t\t\ttotalFileLines: textContent.split(\"\\n\").length,\n\t\t\t\t\t\t\t\t\t\t\tfirstLineBytes: Buffer.byteLength(selection.lines[0] ?? \"\", \"utf8\"),\n\t\t\t\t\t\t\t\t\t\t\tbyteGuidance: false,\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\tresolve({\n\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: selectedText }],\n\t\t\t\t\t\t\t\t\tdetails: readSourceMeta(effectivePath),\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 (archive) {\n\t\t\t\t\t\t\t\tconst resolvedArchive = resolveArchiveSelector(archive, executionCwd);\n\t\t\t\t\t\t\t\tconst textContent = readArchiveSelector(resolvedArchive);\n\t\t\t\t\t\t\t\tlet allLines = textContent.split(\"\\n\");\n\t\t\t\t\t\t\t\tif (conflictsOnly) {\n\t\t\t\t\t\t\t\t\tlet inConflict = false;\n\t\t\t\t\t\t\t\t\tconst conflictLines = allLines.filter((line) => {\n\t\t\t\t\t\t\t\t\t\tif (line.startsWith(\"<<<<<<<\")) inConflict = true;\n\t\t\t\t\t\t\t\t\t\tconst keep = inConflict;\n\t\t\t\t\t\t\t\t\t\tif (line.startsWith(\">>>>>>>\")) inConflict = false;\n\t\t\t\t\t\t\t\t\t\treturn keep;\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tif (conflictLines.length === 0) {\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: \"No conflict markers 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\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tallLines = conflictLines;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst rangeSelection = (rawOutput ? selectExactReadRanges : selectReadRanges)(\n\t\t\t\t\t\t\t\t\tallLines,\n\t\t\t\t\t\t\t\t\teffectiveRanges,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tconst startLine = rangeSelection\n\t\t\t\t\t\t\t\t\t? rangeSelection.firstLine - 1\n\t\t\t\t\t\t\t\t\t: effectiveOffset\n\t\t\t\t\t\t\t\t\t\t? Math.max(0, effectiveOffset - 1)\n\t\t\t\t\t\t\t\t\t\t: 0;\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tstartLine >= allLines.length ||\n\t\t\t\t\t\t\t\t\t(effectiveRanges && rangeSelection?.selectedLines.length === 0)\n\t\t\t\t\t\t\t\t) {\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: `Requested line ${startLine + 1} is beyond end of resource (${allLines.length} lines total).`,\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: undefined,\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 endLine =\n\t\t\t\t\t\t\t\t\teffectiveLimit !== undefined\n\t\t\t\t\t\t\t\t\t\t? Math.min(startLine + effectiveLimit, allLines.length)\n\t\t\t\t\t\t\t\t\t\t: allLines.length;\n\t\t\t\t\t\t\t\tconst selectedLines = rangeSelection?.selectedLines ?? allLines.slice(startLine, endLine);\n\t\t\t\t\t\t\t\tconst selectedText = selectedLines.join(\"\\n\");\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tselectedText.length > READ_TOOL_MAX_RESULT_CHARS ||\n\t\t\t\t\t\t\t\t\tBuffer.byteLength(selectedText, \"utf8\") > DEFAULT_MAX_BYTES\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t\t\toversizedReadResult({\n\t\t\t\t\t\t\t\t\t\t\tblocked: true,\n\t\t\t\t\t\t\t\t\t\t\tpath: `${resolvedArchive.archivePath}:${resolvedArchive.memberPath}`,\n\t\t\t\t\t\t\t\t\t\t\tchars: selectedText.length,\n\t\t\t\t\t\t\t\t\t\t\tmaxChars: READ_TOOL_MAX_RESULT_CHARS,\n\t\t\t\t\t\t\t\t\t\t\tstartLine: startLine + 1,\n\t\t\t\t\t\t\t\t\t\t\ttotalFileLines: allLines.length,\n\t\t\t\t\t\t\t\t\t\t\tfirstLineBytes: Buffer.byteLength(selectedLines[0] ?? \"\", \"utf8\"),\n\t\t\t\t\t\t\t\t\t\t\tbyteGuidance: false,\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\tresolve({\n\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: selectedText }],\n\t\t\t\t\t\t\t\t\tdetails: readSourceMeta(`${resolvedArchive.archivePath}:${resolvedArchive.memberPath}`),\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 (isInternalUrl(effectivePath)) {\n\t\t\t\t\t\t\t\tconst sourcePath = effectivePath.startsWith(\"local://\")\n\t\t\t\t\t\t\t\t\t? resolveInternalSelector(effectivePath, executionCwd)\n\t\t\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\t\t\tif (sourcePath) {\n\t\t\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t\t\tawait createReadToolDefinition(executionCwd, options).execute(\n\t\t\t\t\t\t\t\t\t\t\t_toolCallId,\n\t\t\t\t\t\t\t\t\t\t\t{ path: appendReadSelectors(sourcePath, selector) },\n\t\t\t\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t\t\t\t\t_onUpdate,\n\t\t\t\t\t\t\t\t\t\t\tctx as never,\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 allLines = (await readInternalSelector(effectivePath, executionCwd, resourceCtx)).split(\n\t\t\t\t\t\t\t\t\t\"\\n\",\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tconst rangeSelection = (rawOutput ? selectExactReadRanges : selectReadRanges)(\n\t\t\t\t\t\t\t\t\tallLines,\n\t\t\t\t\t\t\t\t\teffectiveRanges,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tconst startLine = rangeSelection\n\t\t\t\t\t\t\t\t\t? rangeSelection.firstLine - 1\n\t\t\t\t\t\t\t\t\t: effectiveOffset\n\t\t\t\t\t\t\t\t\t\t? Math.max(0, effectiveOffset - 1)\n\t\t\t\t\t\t\t\t\t\t: 0;\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tstartLine >= allLines.length ||\n\t\t\t\t\t\t\t\t\t(effectiveRanges && rangeSelection?.selectedLines.length === 0)\n\t\t\t\t\t\t\t\t) {\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: `Requested line ${startLine + 1} is beyond end of resource (${allLines.length} lines total).`,\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: undefined,\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 endLine =\n\t\t\t\t\t\t\t\t\teffectiveLimit !== undefined\n\t\t\t\t\t\t\t\t\t\t? Math.min(startLine + effectiveLimit, allLines.length)\n\t\t\t\t\t\t\t\t\t\t: allLines.length;\n\t\t\t\t\t\t\t\tconst selectedLines = rangeSelection?.selectedLines ?? allLines.slice(startLine, endLine);\n\t\t\t\t\t\t\t\tconst selectedText = selectedLines.join(\"\\n\");\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tselectedText.length > READ_TOOL_MAX_RESULT_CHARS ||\n\t\t\t\t\t\t\t\t\tBuffer.byteLength(selectedText, \"utf8\") > DEFAULT_MAX_BYTES\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t\t\toversizedReadResult({\n\t\t\t\t\t\t\t\t\t\t\tblocked: true,\n\t\t\t\t\t\t\t\t\t\t\tpath: effectivePath,\n\t\t\t\t\t\t\t\t\t\t\tchars: selectedText.length,\n\t\t\t\t\t\t\t\t\t\t\tmaxChars: READ_TOOL_MAX_RESULT_CHARS,\n\t\t\t\t\t\t\t\t\t\t\tstartLine: startLine + 1,\n\t\t\t\t\t\t\t\t\t\t\ttotalFileLines: allLines.length,\n\t\t\t\t\t\t\t\t\t\t\tfirstLineBytes: Buffer.byteLength(selectedLines[0] ?? \"\", \"utf8\"),\n\t\t\t\t\t\t\t\t\t\t\tbyteGuidance: false,\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\tresolve({\n\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: selectedText }],\n\t\t\t\t\t\t\t\t\tdetails: readSourceMeta(effectivePath),\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 (isReadResourceSelector(effectivePath))\n\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t`Read resource selectors are not supported by this filesystem backend: ${path}`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst absolutePath = await resolveReadPathAsync(effectivePath, executionCwd);\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\tlet content: (TextContent | ImageContent)[];\n\t\t\t\t\t\t\tlet details: ReadToolDetails | undefined;\n\t\t\t\t\t\t\tawait ops.access(absolutePath);\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\tif (isDocumentPath(absolutePath) && !rawOutput && !isNotebookPath(absolutePath)) {\n\t\t\t\t\t\t\t\tconst buffer = await ops.readFile(absolutePath);\n\t\t\t\t\t\t\t\tconst textContent = await extractDocumentMarkdown(buffer, absolutePath);\n\t\t\t\t\t\t\t\tconst selection = applyReadLineSelection(\n\t\t\t\t\t\t\t\t\ttextContent.split(\"\\n\"),\n\t\t\t\t\t\t\t\t\teffectiveRanges,\n\t\t\t\t\t\t\t\t\teffectiveOffset,\n\t\t\t\t\t\t\t\t\teffectiveLimit,\n\t\t\t\t\t\t\t\t\trawOutput,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (selection.lines.length === 0) {\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: `Requested line ${selection.firstLine} is beyond end of document (${textContent.split(\"\\n\").length} lines total).`,\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: undefined,\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 selectedText = selection.lines.join(\"\\n\");\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tselectedText.length > READ_TOOL_MAX_RESULT_CHARS ||\n\t\t\t\t\t\t\t\t\tBuffer.byteLength(selectedText, \"utf8\") > DEFAULT_MAX_BYTES\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t\t\toversizedReadResult({\n\t\t\t\t\t\t\t\t\t\t\tblocked: true,\n\t\t\t\t\t\t\t\t\t\t\tpath: absolutePath,\n\t\t\t\t\t\t\t\t\t\t\tchars: selectedText.length,\n\t\t\t\t\t\t\t\t\t\t\tmaxChars: READ_TOOL_MAX_RESULT_CHARS,\n\t\t\t\t\t\t\t\t\t\t\tstartLine: selection.firstLine,\n\t\t\t\t\t\t\t\t\t\t\ttotalFileLines: textContent.split(\"\\n\").length,\n\t\t\t\t\t\t\t\t\t\t\tfirstLineBytes: Buffer.byteLength(selection.lines[0] ?? \"\", \"utf8\"),\n\t\t\t\t\t\t\t\t\t\t\tbyteGuidance: false,\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\tcontent = [{ type: \"text\", text: selectedText }];\n\t\t\t\t\t\t\t\tresolve({ content, details: readSourceMeta(absolutePath) });\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tlet tree: DirectoryTreeResult | undefined;\n\t\t\t\t\t\t\tif (ops.stat && ops.listDir) {\n\t\t\t\t\t\t\t\tconst stat = await ops.stat(absolutePath);\n\t\t\t\t\t\t\t\tif (stat?.isDirectory)\n\t\t\t\t\t\t\t\t\ttree = await buildDirectoryTreeFromOperations(\n\t\t\t\t\t\t\t\t\t\tabsolutePath,\n\t\t\t\t\t\t\t\t\t\t{ listDir: ops.listDir },\n\t\t\t\t\t\t\t\t\t\t{ maxDepth: 2, perDirLimit: 12, rootLimit: null },\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else if (!options?.operations && (await fsStat(absolutePath)).isDirectory()) {\n\t\t\t\t\t\t\t\ttree = await buildDirectoryTree(absolutePath, {\n\t\t\t\t\t\t\t\t\tmaxDepth: 2,\n\t\t\t\t\t\t\t\t\tperDirLimit: 12,\n\t\t\t\t\t\t\t\t\trootLimit: null,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (tree) {\n\t\t\t\t\t\t\t\tconst allLines = tree.rendered.split(\"\\n\"),\n\t\t\t\t\t\t\t\t\trangeSelection = (rawOutput ? selectExactReadRanges : selectReadRanges)(\n\t\t\t\t\t\t\t\t\t\tallLines,\n\t\t\t\t\t\t\t\t\t\teffectiveRanges,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tstartLine = rangeSelection\n\t\t\t\t\t\t\t\t\t\t? rangeSelection.firstLine - 1\n\t\t\t\t\t\t\t\t\t\t: effectiveOffset\n\t\t\t\t\t\t\t\t\t\t\t? Math.max(0, effectiveOffset - 1)\n\t\t\t\t\t\t\t\t\t\t\t: 0;\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tstartLine >= allLines.length ||\n\t\t\t\t\t\t\t\t\t(effectiveRanges && rangeSelection?.selectedLines.length === 0)\n\t\t\t\t\t\t\t\t) {\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: `Requested line ${startLine + 1} is beyond end of directory (${allLines.length} lines total).`,\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: undefined,\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 endLine =\n\t\t\t\t\t\t\t\t\t\teffectiveLimit !== undefined\n\t\t\t\t\t\t\t\t\t\t\t? Math.min(startLine + effectiveLimit, allLines.length)\n\t\t\t\t\t\t\t\t\t\t\t: allLines.length,\n\t\t\t\t\t\t\t\t\tselectedLines = rangeSelection?.selectedLines ?? allLines.slice(startLine, endLine);\n\t\t\t\t\t\t\t\tcontent = [{ type: \"text\", text: selectedLines.join(\"\\n\") }];\n\t\t\t\t\t\t\t\tconst meta = {\n\t\t\t\t\t\t\t\t\t...readSourceMeta(absolutePath).meta,\n\t\t\t\t\t\t\t\t\t...(tree.truncated ? { limits: { perDirLimit: 12, totalLines: tree.totalLines } } : {}),\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tresolve({ content, details: { isDirectory: true, resolvedPath: absolutePath, meta } });\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst mimeType = ops.detectImageMimeType ? await ops.detectImageMimeType(absolutePath) : undefined;\n\t\t\t\t\t\t\tconst nonVisionImageNote = getNonVisionImageNote(ctx?.model);\n\t\t\t\t\t\t\tif (mimeType) {\n\t\t\t\t\t\t\t\t// Read image as binary.\n\t\t\t\t\t\t\t\tconst buffer = await ops.readFile(absolutePath);\n\t\t\t\t\t\t\t\tconst processed = await processImage(buffer, mimeType, {\n\t\t\t\t\t\t\t\t\tautoResizeImages,\n\t\t\t\t\t\t\t\t\tresizeOptions: ctx?.model?.inputLimits?.images?.resize ?? fallbackResizeOptions,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (!processed.ok) {\n\t\t\t\t\t\t\t\t\tlet textNote = `Read image file [${mimeType}]\\n${processed.message}`;\n\t\t\t\t\t\t\t\t\tif (nonVisionImageNote) textNote += `\\n${nonVisionImageNote}`;\n\t\t\t\t\t\t\t\t\tcontent = [{ type: \"text\", text: textNote }];\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tlet textNote = `Read image file [${processed.mimeType}]`;\n\t\t\t\t\t\t\t\t\tif (processed.hints.length > 0) textNote += `\\n${processed.hints.join(\"\\n\")}`;\n\t\t\t\t\t\t\t\t\tif (nonVisionImageNote) textNote += `\\n${nonVisionImageNote}`;\n\t\t\t\t\t\t\t\t\tcontent = [\n\t\t\t\t\t\t\t\t\t\t{ type: \"text\", text: textNote },\n\t\t\t\t\t\t\t\t\t\t{ type: \"image\", data: processed.data, mimeType: processed.mimeType },\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} else {\n\t\t\t\t\t\t\t\tconst offsetStartLine = effectiveOffset ? Math.max(0, effectiveOffset - 1) : 0;\n\t\t\t\t\t\t\t\tconst plan: ReadLinePlan = effectiveRanges?.length\n\t\t\t\t\t\t\t\t\t? { ranges: effectiveRanges, exact: rawOutput === true }\n\t\t\t\t\t\t\t\t\t: { firstLine: offsetStartLine + 1 };\n\t\t\t\t\t\t\t\tconst notebookView = isNotebookPath(absolutePath) && !rawOutput;\n\t\t\t\t\t\t\t\tlet selection: SelectedReadLines;\n\t\t\t\t\t\t\t\tif (conflictsOnly || notebookView) {\n\t\t\t\t\t\t\t\t\tconst buffer = await ops.readFile(absolutePath);\n\t\t\t\t\t\t\t\t\tconst textContent = notebookView\n\t\t\t\t\t\t\t\t\t\t? readEditableNotebookText(absolutePath, effectivePath)\n\t\t\t\t\t\t\t\t\t\t: buffer.toString(\"utf-8\");\n\t\t\t\t\t\t\t\t\t// Formatted output reads LF-normalized lines. Keep raw reads on the source bytes so\n\t\t\t\t\t\t\t\t\t// :raw preserves CRLF and terminal-newline bytes exactly.\n\t\t\t\t\t\t\t\t\tconst lineTextContent = rawOutput ? textContent : textContent.replace(/\\r\\n/g, \"\\n\");\n\t\t\t\t\t\t\t\t\tconst sourceLines = lineTextContent.split(\"\\n\");\n\t\t\t\t\t\t\t\t\t// A terminal newline separates real lines; omit only its synthetic split item.\n\t\t\t\t\t\t\t\t\tlet allLines =\n\t\t\t\t\t\t\t\t\t\trawOutput || !lineTextContent.endsWith(\"\\n\") ? sourceLines : sourceLines.slice(0, -1);\n\t\t\t\t\t\t\t\t\tif (conflictsOnly) {\n\t\t\t\t\t\t\t\t\t\tregisterConflictBlocks(executionCwd, parseConflictBlocks(absolutePath, textContent));\n\t\t\t\t\t\t\t\t\t\tconst conflictLines: string[] = [];\n\t\t\t\t\t\t\t\t\t\tlet inConflict = false;\n\t\t\t\t\t\t\t\t\t\tfor (const line of allLines) {\n\t\t\t\t\t\t\t\t\t\t\tif (line.startsWith(\"<<<<<<<\")) inConflict = true;\n\t\t\t\t\t\t\t\t\t\t\tif (inConflict) conflictLines.push(line);\n\t\t\t\t\t\t\t\t\t\t\tif (line.startsWith(\">>>>>>>\")) inConflict = false;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tif (conflictLines.length > 0) allLines = conflictLines;\n\t\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: \"No conflict markers found\" }],\n\t\t\t\t\t\t\t\t\t\t\t\tdetails: undefined,\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\treturn;\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\tselection = selectReadLinesFromList(allLines, plan, READ_TOOL_MAX_RESULT_CHARS);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// Stream plain text: only the selected lines are kept, so memory does not grow with the file.\n\t\t\t\t\t\t\t\t\tselection = await selectReadLinesFromChunks(\n\t\t\t\t\t\t\t\t\t\tops.createReadStream?.(absolutePath, { signal }) ?? readWholeFile(ops, absolutePath),\n\t\t\t\t\t\t\t\t\t\tplan,\n\t\t\t\t\t\t\t\t\t\t{ raw: rawOutput === true, maxChars: READ_TOOL_MAX_RESULT_CHARS, signal },\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\tconst totalFileLines = selection.totalLines;\n\t\t\t\t\t\t\t\tconst startLine = \"ranges\" in plan ? selection.firstLineNumber - 1 : offsetStartLine;\n\t\t\t\t\t\t\t\tconst startLineDisplay = startLine + 1;\n\t\t\t\t\t\t\t\tif (startLine >= totalFileLines || (\"ranges\" in plan && selection.count === 0)) {\n\t\t\t\t\t\t\t\t\tconst requested = effectiveRanges?.[0]?.start ?? startLineDisplay;\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: `Requested line ${requested} is beyond end of file (${totalFileLines} lines total). Use ${effectivePath}:${Math.max(1, totalFileLines)} to read the final line.`,\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: undefined,\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 selectedLines = selection.lines;\n\t\t\t\t\t\t\t\tif (selection.chars > READ_TOOL_MAX_RESULT_CHARS) {\n\t\t\t\t\t\t\t\t\tconst firstLineBytes = selection.firstLineBytes;\n\t\t\t\t\t\t\t\t\tconst byteGuidance =\n\t\t\t\t\t\t\t\t\t\tselection.countBeforeTrailingEmpty <= 1 || firstLineBytes > DEFAULT_MAX_BYTES;\n\t\t\t\t\t\t\t\t\tconst oversizedRead: OversizedReadDetails = {\n\t\t\t\t\t\t\t\t\t\tblocked: true,\n\t\t\t\t\t\t\t\t\t\tpath: absolutePath,\n\t\t\t\t\t\t\t\t\t\tchars: selection.chars,\n\t\t\t\t\t\t\t\t\t\tmaxChars: READ_TOOL_MAX_RESULT_CHARS,\n\t\t\t\t\t\t\t\t\t\tstartLine: startLineDisplay,\n\t\t\t\t\t\t\t\t\t\ttotalFileLines,\n\t\t\t\t\t\t\t\t\t\tfirstLineBytes,\n\t\t\t\t\t\t\t\t\t\tbyteGuidance,\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\tdetails = { oversizedRead, meta: readSourceMeta(absolutePath).meta };\n\t\t\t\t\t\t\t\t\tcontent = [{ type: \"text\", text: buildOversizedReadMessage(oversizedRead) }];\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tconst truncation = truncateHead(selectedLines.join(\"\\n\"));\n\t\t\t\t\t\t\t\t\tconst shownLines = truncation.truncated ? truncation.outputLines : selectedLines.length;\n\t\t\t\t\t\t\t\t\tconst shownLineNumbers =\n\t\t\t\t\t\t\t\t\t\t\"ranges\" in plan ? selection.lineNumbers.slice(0, shownLines) : undefined;\n\t\t\t\t\t\t\t\t\tconst lastShownLine = shownLineNumbers?.at(-1) ?? startLine + shownLines;\n\t\t\t\t\t\t\t\t\tlet outputText =\n\t\t\t\t\t\t\t\t\t\tshownLineNumbers && !rawOutput\n\t\t\t\t\t\t\t\t\t\t\t? formatSelectedLines(\n\t\t\t\t\t\t\t\t\t\t\t\t\tselectedLines.slice(0, shownLines),\n\t\t\t\t\t\t\t\t\t\t\t\t\tshownLineNumbers,\n\t\t\t\t\t\t\t\t\t\t\t\t\ttotalFileLines,\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t: truncation.content;\n\t\t\t\t\t\t\t\t\tif (truncation.firstLineExceedsLimit) {\n\t\t\t\t\t\t\t\t\t\tconst firstLineSize = formatSize(selection.firstLineBytes);\n\t\t\t\t\t\t\t\t\t\toutputText = `[Line ${startLineDisplay} is ${firstLineSize}, exceeds ${formatSize(DEFAULT_MAX_BYTES)} limit. Use bash: sed -n '${startLineDisplay}p' ${effectivePath} | head -c ${DEFAULT_MAX_BYTES}]`;\n\t\t\t\t\t\t\t\t\t\tdetails = {\n\t\t\t\t\t\t\t\t\t\t\ttruncation,\n\t\t\t\t\t\t\t\t\t\t\tmeta: { source: absolutePath, sourcePath: absolutePath, truncation },\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t} else if (truncation.truncated) {\n\t\t\t\t\t\t\t\t\t\tconst nextOffset = lastShownLine + 1;\n\t\t\t\t\t\t\t\t\t\toutputText +=\n\t\t\t\t\t\t\t\t\t\t\ttruncation.truncatedBy === \"lines\"\n\t\t\t\t\t\t\t\t\t\t\t\t? `\\n\\n[Showing lines ${startLineDisplay}-${lastShownLine} of ${totalFileLines}. Continue with path selector :${nextOffset}.]`\n\t\t\t\t\t\t\t\t\t\t\t\t: `\\n\\n[Showing lines ${startLineDisplay}-${lastShownLine} of ${totalFileLines} (${formatSize(DEFAULT_MAX_BYTES)} limit). Continue with path selector :${nextOffset}.]`;\n\t\t\t\t\t\t\t\t\t\tdetails = {\n\t\t\t\t\t\t\t\t\t\t\ttruncation,\n\t\t\t\t\t\t\t\t\t\t\tmeta: { source: absolutePath, sourcePath: absolutePath, truncation },\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t} else if (!rawOutput && lastShownLine < totalFileLines) {\n\t\t\t\t\t\t\t\t\t\tconst remaining = totalFileLines - lastShownLine;\n\t\t\t\t\t\t\t\t\t\toutputText += `\\n\\n[${remaining} more lines in file. Continue with path selector :${lastShownLine + 1}.]`;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcontent = [{ type: \"text\", text: outputText }];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\tresolve({ content, details: details ?? readSourceMeta(absolutePath) });\n\t\t\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\tif (!aborted) reject(error);\n\t\t\t\t\t\t}\n\t\t\t\t\t})();\n\t\t\t\t},\n\t\t\t).then((result) =>\n\t\t\t\tresult.details?.oversizedRead?.blocked\n\t\t\t\t\t? { ...result, isError: true }\n\t\t\t\t\t: { ...result, structuredContent: toReadOutput(result.content) },\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\tconst classification = !context.expanded ? getCompactReadClassification(args, context.cwd) : undefined;\n\t\t\ttext.setText(\n\t\t\t\tclassification ? formatCompactReadCall(classification, args, theme) : formatReadCall(args, theme),\n\t\t\t);\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(\n\t\t\t\tformatReadResult(context.args, result, options, theme, context.showImages, context.cwd, context.isError),\n\t\t\t);\n\t\t\treturn text;\n\t\t},\n\t};\n}\nexport function createReadTool(cwd: string, options?: ReadToolOptions): AgentTool<typeof readSchema> {\n\treturn wrapToolDefinition(createReadToolDefinition(cwd, options));\n}\n"]}
1
+ {"version":3,"file":"read.js","sourceRoot":"","sources":["../../../src/core/tools/read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAA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EAAE,iBAAiB,EAAE,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CACjE,CAAC;QACH,CAAC;QACD,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO;YAC9B,MAAM,IAAI,GAAI,OAAO,CAAC,aAAkC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,MAAM,cAAc,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,4BAA4B,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACvG,IAAI,CAAC,OAAO,CACX,cAAc,CAAC,CAAC,CAAC,qBAAqB,CAAC,cAAc,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,CAAC,CACjG,CAAC;YACF,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,CACX,gBAAgB,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,CACxG,CAAC;YACF,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;AACH,CAAC;AACD,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAyB;IACpE,OAAO,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import { basename, dirname, isAbsolute, relative, resolve as resolvePath, sep } from \"node:path\";\nimport type { ImageContent, ModelImageResizeOptions, TextContent } from \"@bastani/pi-ai/compat\";\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Text } from \"@earendil-works/pi-tui\";\nimport { constants } from \"fs\";\nimport { access as fsAccess, readFile as fsReadFile, stat as fsStat } from \"fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport { getReadmePath } from \"../../config.js\";\nimport { parenthesizedKeyHint } from \"../../modes/interactive/components/keybinding-hints.js\";\nimport { getLanguageFromPath, highlightCode, type Theme } from \"../../modes/interactive/theme/theme.js\";\nimport { processImage } from \"../../utils/image-process.ts\";\nimport { detectSupportedImageMimeTypeFromFile } from \"../../utils/mime.ts\";\nimport { formatPathRelativeToCwdOrAbsolute } from \"../../utils/paths.ts\";\nimport type { ExtensionContext, ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { parseConflictBlocks, registerConflictBlocks } from \"./conflict-registry.ts\";\nimport {\n\tbuildDirectoryTree,\n\tbuildDirectoryTreeFromOperations,\n\ttype DirectoryTreeEntry,\n\ttype DirectoryTreeResult,\n} from \"./directory-tree.ts\";\nimport { isReadableUrlPath } from \"./fetch-url.ts\";\nimport { FileToolAbortedError } from \"./file-tool-errors.ts\";\nimport { isNotebookPath, readEditableNotebookText } from \"./notebook.ts\";\nimport { resolveReadPathAsync, resolveToCwd } from \"./path-utils.ts\";\nimport { applyReadLineSelection, extractDocumentMarkdown, isDocumentPath } from \"./read-document-extract.ts\";\nimport {\n\ttype ReadLinePlan,\n\treadLocalFileChunks,\n\ttype SelectedReadLines,\n\tselectReadLinesFromChunks,\n\tselectReadLinesFromList,\n} from \"./read-line-stream.ts\";\nimport {\n\tformatSelectedLines,\n\tisReadResourceSelector,\n\ttype ReadLineSelector,\n\tselectExactReadRanges,\n\tselectReadRanges,\n\tsplitReadLineSelector,\n} from \"./read-selectors.ts\";\nimport { readUrlBranch } from \"./read-url.ts\";\nimport { getTextOutput, invalidArgText, replaceTabs, shortenPath, str } from \"./render-utils.ts\";\nimport {\n\ttype InternalResourceContext,\n\tisInternalUrl,\n\tparseArchiveSelector,\n\treadArchiveSelector,\n\treadInternalSelector,\n\treadSqliteSelector,\n\tresolveArchiveSelector,\n\tresolveInternalSelector,\n\tsqliteSelectorForPath,\n} from \"./resource-selectors.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, type TruncationResult, truncateHead } from \"./truncate.ts\";\n\nconst readSchema = Type.Object(\n\t{\n\t\tpath: Type.String({\n\t\t\tdescription:\n\t\t\t\t\"File, directory, archive member, SQLite selector, internal resource (skill://, local://, artifact://, conflict://, history://), image, document, or URL to read. Append selectors such as :raw, :conflicts, :N, :A-B, :A+C, or :A-B,C-D to scope output.\",\n\t\t}),\n\t},\n\t{ additionalProperties: false },\n);\nexport const readToolSystemPromptContribution = Object.freeze({\n\tsnippet: \"Read a path selector.\",\n\tguidelines: Object.freeze([\n\t\t\"Use read to inspect file and resource contents; use path selectors for line ranges, raw output, and conflict views.\",\n\t] as const),\n} as const);\nexport type ReadToolInput = Static<typeof readSchema>;\n\nconst readOutputSchema = Type.Union([\n\tType.String(),\n\tType.Object({ type: Type.Literal(\"image\"), data: Type.String(), mimeType: Type.String(), note: Type.String() }),\n]);\nexport type ReadToolOutput = Static<typeof readOutputSchema>;\nconst READ_TOOL_MAX_RESULT_CHARS = 50_000;\nexport interface OversizedReadDetails {\n\tblocked: true;\n\tpath: string;\n\tchars: number;\n\tmaxChars: number;\n\tstartLine: number;\n\trequestedLimit?: number;\n\ttotalFileLines: number;\n\tfirstLineBytes: number;\n\tbyteGuidance: boolean;\n}\nexport interface ReadToolDetails {\n\tisDirectory?: boolean;\n\tresolvedPath?: string;\n\ttruncation?: TruncationResult;\n\toversizedRead?: OversizedReadDetails;\n\timageUnsupportedByModel?: string;\n\tmeta?: {\n\t\tsource?: string;\n\t\tsourcePath?: string;\n\t\tartifactId?: string;\n\t\ttruncation?: TruncationResult;\n\t\tlimits?: Record<string, number>;\n\t};\n}\ninterface CompactReadClassification {\n\tkind: \"docs\" | \"resource\" | \"skill\";\n\tlabel: string;\n}\nconst COMPACT_RESOURCE_FILE_NAMES = new Set([\"AGENTS.override.md\", \"AGENTS.md\", \"AGENTS.MD\", \"CLAUDE.md\", \"CLAUDE.MD\"]);\nexport interface ReadOperations {\n\treadFile: (absolutePath: string) => Promise<Buffer>;\n\taccess: (absolutePath: string) => Promise<void>;\n\tstat?: (absolutePath: string) => Promise<{ isFile: boolean; isDirectory: boolean } | undefined>;\n\tlistDir?: (absolutePath: string) => Promise<DirectoryTreeEntry[] | undefined>;\n\tdetectImageMimeType?: (absolutePath: string) => Promise<string | null | undefined>;\n\t/**\n\t * Stream file contents in chunks. When present, text files are read through it and only the lines a read shows\n\t * are kept in memory; otherwise `readFile` loads the whole file. Stop reading when the signal aborts; `read` also\n\t * stops consuming the stream then.\n\t */\n\tcreateReadStream?: (absolutePath: string, options: { signal?: AbortSignal }) => AsyncIterable<Uint8Array>;\n}\nconst defaultReadOperations: ReadOperations = {\n\treadFile: (path) => fsReadFile(path),\n\tcreateReadStream: readLocalFileChunks,\n\taccess: (path) => fsAccess(path, constants.R_OK),\n\tdetectImageMimeType: detectSupportedImageMimeTypeFromFile,\n};\nasync function* readWholeFile(ops: ReadOperations, absolutePath: string): AsyncGenerator<Uint8Array> {\n\tyield await ops.readFile(absolutePath);\n}\nexport interface ReadToolOptions {\n\t/** Whether to auto-resize images. Default: true */\n\tautoResizeImages?: boolean;\n\t/** Fallback resize profile when the execution context has no model metadata. */\n\tresizeOptions?: ModelImageResizeOptions;\n\toperations?: ReadOperations;\n}\ntype ReadRenderArgs = { path?: string };\nfunction formatReadLineRange(_args: ReadRenderArgs | undefined, _theme: Theme): string {\n\treturn \"\";\n}\nfunction formatReadCall(args: ReadRenderArgs | undefined, theme: Theme): string {\n\tconst rawPath = str(args?.path);\n\tconst path = rawPath !== null ? shortenPath(rawPath) : null;\n\tconst invalidArg = invalidArgText(theme);\n\tconst pathDisplay = path === null ? invalidArg : path ? theme.fg(\"accent\", path) : theme.fg(\"toolOutput\", \"...\");\n\treturn `${theme.fg(\"toolTitle\", theme.bold(\"read\"))} ${pathDisplay}${formatReadLineRange(args, theme)}`;\n}\nfunction trimTrailingEmptyLines(lines: string[]): string[] {\n\tlet end = lines.length;\n\twhile (end > 0 && lines[end - 1] === \"\") end--;\n\treturn lines.slice(0, end);\n}\nfunction toReadOutput(content: (TextContent | ImageContent)[]): ReadToolOutput {\n\tconst text = content.find((block) => block.type === \"text\")?.text ?? \"\";\n\tconst image = content.find((block) => block.type === \"image\");\n\treturn image ? { type: \"image\", data: image.data, mimeType: image.mimeType, note: text } : text;\n}\nfunction toPosixPath(filePath: string): string {\n\treturn filePath.split(sep).join(\"/\");\n}\nfunction formatCount(count: number): string {\n\treturn count.toLocaleString(\"en-US\");\n}\nfunction shellQuote(value: string): string {\n\treturn `'${value.replace(/'/g, `'\\\\''`)}'`;\n}\nfunction buildOversizedReadMessage(details: OversizedReadDetails): string {\n\tconst pathForExample = JSON.stringify(details.path);\n\tconst rangePathForExample = JSON.stringify(`${details.path}:${details.startLine}+200`);\n\tconst shellPathForExample = shellQuote(details.path);\n\tconst requestedLimitLine =\n\t\tdetails.requestedLimit !== undefined ? [`Requested line limit: ${formatCount(details.requestedLimit)}`] : [];\n\tif (details.byteGuidance) {\n\t\treturn [\n\t\t\t`File read blocked: requested selected range is too large (${formatCount(details.chars)} chars; threshold: ${formatCount(details.maxChars)} chars).`,\n\t\t\t`Path: ${details.path}`,\n\t\t\t...requestedLimitLine,\n\t\t\t\"\",\n\t\t\t\"The selected content starts with a single oversized line, so line pagination is not useful. Read byte slices instead. Examples:\",\n\t\t\t`- Inspect the start of line ${details.startLine}: sed -n '${details.startLine}p' ${shellPathForExample} | head -c ${DEFAULT_MAX_BYTES}`,\n\t\t\t`- Inspect a later byte window: sed -n '${details.startLine}p' ${shellPathForExample} | tail -c +${DEFAULT_MAX_BYTES + 1} | head -c ${DEFAULT_MAX_BYTES}`,\n\t\t\t`- Search for relevant text first: search({ \"pattern\": \"functionName\", \"paths\": ${pathForExample} })`,\n\t\t].join(\"\\n\");\n\t}\n\tconst targetedSnippetOffset = Math.max(details.startLine, 120);\n\tconst snippetPathForExample = JSON.stringify(`${details.path}:${targetedSnippetOffset}+80`);\n\treturn [\n\t\t`File read blocked: requested selected range is too large (${formatCount(details.chars)} chars; threshold: ${formatCount(details.maxChars)} chars).`,\n\t\t`Path: ${details.path}`,\n\t\t...requestedLimitLine,\n\t\t\"\",\n\t\t\"Read only the needed context incrementally. Examples:\",\n\t\t`- Search for relevant symbols first: search({ \"pattern\": \"functionName\", \"paths\": ${pathForExample} })`,\n\t\t`- Read a smaller line range: read({ \"path\": ${rangePathForExample} })`,\n\t\t`- Read a targeted snippet around a match: read({ \"path\": ${snippetPathForExample} })`,\n\t].join(\"\\n\");\n}\nfunction readSourceMeta(source: string): ReadToolDetails {\n\treturn { meta: { source, sourcePath: source } };\n}\nfunction oversizedReadResult(details: OversizedReadDetails): { content: TextContent[]; details: ReadToolDetails } {\n\treturn {\n\t\tcontent: [{ type: \"text\", text: buildOversizedReadMessage(details) }],\n\t\tdetails: {\n\t\t\toversizedRead: details,\n\t\t\tmeta: { source: details.path, sourcePath: details.path, limits: { maxChars: details.maxChars } },\n\t\t},\n\t};\n}\nfunction getPiDocsClassification(absolutePath: string): CompactReadClassification | undefined {\n\tconst packageRoot = dirname(getReadmePath());\n\tconst relativePath = relative(resolvePath(packageRoot), resolvePath(absolutePath));\n\tif (\n\t\trelativePath === \"\" ||\n\t\trelativePath === \"..\" ||\n\t\trelativePath.startsWith(`..${sep}`) ||\n\t\tisAbsolute(relativePath)\n\t) {\n\t\treturn undefined;\n\t}\n\tconst label = toPosixPath(relativePath);\n\tif (label === \"README.md\" || label.startsWith(\"docs/\") || label.startsWith(\"examples/\")) {\n\t\treturn { kind: \"docs\", label };\n\t}\n\treturn undefined;\n}\nfunction getCompactReadClassification(\n\targs: ReadRenderArgs | undefined,\n\tcwd: string,\n): CompactReadClassification | undefined {\n\tconst rawPath = str(args?.path);\n\tif (!rawPath) return undefined;\n\tconst absolutePath = resolveToCwd(rawPath, cwd);\n\tconst fileName = basename(absolutePath);\n\tif (fileName === \"SKILL.md\") {\n\t\treturn { kind: \"skill\", label: basename(dirname(absolutePath)) || fileName };\n\t}\n\tconst docsClassification = getPiDocsClassification(absolutePath);\n\tif (docsClassification) return docsClassification;\n\tif (COMPACT_RESOURCE_FILE_NAMES.has(fileName)) {\n\t\treturn { kind: \"resource\", label: formatPathRelativeToCwdOrAbsolute(absolutePath, cwd) };\n\t}\n\treturn undefined;\n}\nfunction formatCompactReadCall(\n\tclassification: CompactReadClassification,\n\targs: ReadRenderArgs | undefined,\n\ttheme: Theme,\n): string {\n\tconst hint = parenthesizedKeyHint(\"app.tools.expand\", \"Expand\");\n\tconst expandHint = hint ? ` ${hint}` : \"\";\n\tif (classification.kind === \"skill\") {\n\t\treturn (\n\t\t\ttheme.fg(\"customMessageLabel\", `\\x1b[1m[skill]\\x1b[22m `) +\n\t\t\ttheme.fg(\"customMessageText\", classification.label) +\n\t\t\tformatReadLineRange(args, theme) +\n\t\t\texpandHint\n\t\t);\n\t}\n\treturn (\n\t\ttheme.fg(\"toolTitle\", theme.bold(`read ${classification.kind}`)) +\n\t\t\" \" +\n\t\ttheme.fg(\"accent\", classification.label) +\n\t\tformatReadLineRange(args, theme) +\n\t\texpandHint\n\t);\n}\nfunction formatReadResult(\n\targs: ReadRenderArgs | undefined,\n\tresult: { content: (TextContent | ImageContent)[]; details?: ReadToolDetails },\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tshowImages: boolean,\n\t_cwd: string,\n\tisError: boolean,\n): string {\n\tconst unsupportedBy = result.details?.imageUnsupportedByModel;\n\tconst imageWarning = unsupportedBy\n\t\t? `\\n${theme.fg(\"warning\", `[${unsupportedBy} does not support images; it saw a placeholder instead]`)}`\n\t\t: \"\";\n\tconst oversizedRead = result.details?.oversizedRead;\n\tconst oversizedReadBlocked = oversizedRead?.blocked === true;\n\tif (!options.expanded && !isError && !oversizedReadBlocked) {\n\t\treturn imageWarning;\n\t}\n\tconst rawPath = str(args?.path);\n\tconst output = oversizedRead ? buildOversizedReadMessage(oversizedRead) : getTextOutput(result, showImages);\n\tconst lang = !isError && rawPath && !oversizedReadBlocked ? getLanguageFromPath(rawPath) : undefined;\n\tconst renderedLines = lang ? highlightCode(replaceTabs(output), lang) : output.split(\"\\n\");\n\tconst lines = trimTrailingEmptyLines(renderedLines);\n\tconst maxLines = options.expanded ? lines.length : 10;\n\tconst displayLines = lines.slice(0, maxLines);\n\tconst remaining = lines.length - maxLines;\n\tlet text = `\\n${displayLines.map((line) => (lang ? replaceTabs(line) : theme.fg(\"toolOutput\", replaceTabs(line)))).join(\"\\n\")}`;\n\tif (remaining > 0) {\n\t\ttext +=\n\t\t\ttheme.fg(\"muted\", \"\\n... \") + parenthesizedKeyHint(\"app.tools.expand\", \"Expand\", `${remaining} more lines`);\n\t}\n\tconst truncation = result.details?.truncation;\n\tif (truncation?.truncated) {\n\t\tif (truncation.firstLineExceedsLimit) {\n\t\t\ttext += `\\n${theme.fg(\"warning\", `[First line exceeds ${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit]`)}`;\n\t\t} else if (truncation.truncatedBy === \"lines\") {\n\t\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: showing ${truncation.outputLines} of ${truncation.totalLines} lines (${truncation.maxLines ?? DEFAULT_MAX_LINES} line limit)]`)}`;\n\t\t} else {\n\t\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: ${truncation.outputLines} lines shown (${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit)]`)}`;\n\t\t}\n\t}\n\treturn text + imageWarning;\n}\nfunction archiveSelectorMemberExists(pathValue: string, cwd: string): boolean {\n\tconst archive = parseArchiveSelector(pathValue);\n\tif (!archive?.memberPath) return false;\n\ttry {\n\t\treadArchiveSelector(resolveArchiveSelector(archive, cwd));\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\nfunction appendReadSelectors(pathValue: string, selector: ReadLineSelector): string {\n\tconst range =\n\t\tselector.ranges\n\t\t\t?.map((item) => (item.end === undefined ? `${item.start}` : `${item.start}-${item.end}`))\n\t\t\t.join(\",\") ?? (selector.offset ? `${selector.offset}` : \"\");\n\treturn `${pathValue}${range ? `:${range}` : \"\"}${selector.conflicts ? \":conflicts\" : \"\"}${selector.raw ? \":raw\" : \"\"}`;\n}\nexport function createReadToolDefinition(\n\tcwd: string,\n\toptions?: ReadToolOptions,\n): ToolDefinition<typeof readSchema, ReadToolDetails | undefined> {\n\tconst autoResizeImages = options?.autoResizeImages ?? true;\n\tconst fallbackResizeOptions = options?.resizeOptions;\n\tconst ops = options?.operations ?? defaultReadOperations;\n\treturn {\n\t\tname: \"read\",\n\t\tlabel: \"read\",\n\t\tdescription:\n\t\t\t\"Read files, directories, archives, SQLite databases, internal resources (including history:// for past sessions and workflow runs), images, documents, and URLs through one path string.\",\n\t\tpromptSnippet: readToolSystemPromptContribution.snippet,\n\t\tpromptGuidelines: [...readToolSystemPromptContribution.guidelines],\n\t\tconstrainedSampling: { type: \"json_schema\", strict: \"prefer\" },\n\t\tparameters: readSchema,\n\t\toutputSchema: readOutputSchema,\n\t\tmaxResultSizeChars: Infinity,\n\t\tasync execute(_toolCallId, { path }: ReadToolInput, signal?: AbortSignal, _onUpdate?, ctx?: ExtensionContext) {\n\t\t\tconst resourceCtx = ctx as InternalResourceContext | undefined;\n\t\t\tconst executionCwd = ctx?.cwd || cwd;\n\t\t\tconst splitSelector = splitReadLineSelector(path),\n\t\t\t\tmarkerless = path.replace(/:raw(?=(:|$))/g, \"\").replace(/:conflicts(?=(:|$))/g, \"\"),\n\t\t\t\tsqliteOriginal = sqliteSelectorForPath(markerless, executionCwd),\n\t\t\t\tsqliteDirect = sqliteSelectorForPath(path, executionCwd);\n\t\t\tconst selector = archiveSelectorMemberExists(path, executionCwd)\n\t\t\t\t? { path }\n\t\t\t\t: sqliteDirect && (sqliteDirect.table === \"raw\" || sqliteDirect.table === \"conflicts\")\n\t\t\t\t\t? { path }\n\t\t\t\t\t: sqliteOriginal?.rowId && splitSelector.path !== markerless\n\t\t\t\t\t\t? { path: markerless, raw: splitSelector.raw, conflicts: splitSelector.conflicts }\n\t\t\t\t\t\t: sqliteOriginal && splitSelector.path === markerless && markerless !== path\n\t\t\t\t\t\t\t? { path: markerless, raw: splitSelector.raw, conflicts: splitSelector.conflicts }\n\t\t\t\t\t\t\t: splitSelector.path === path && sqliteDirect\n\t\t\t\t\t\t\t\t? { path }\n\t\t\t\t\t\t\t\t: splitSelector;\n\t\t\tconst effectivePath = selector.path;\n\t\t\tconst effectiveOffset = selector.offset;\n\t\t\tconst effectiveLimit = selector.limit;\n\t\t\tconst effectiveRanges = selector.ranges;\n\t\t\tconst rawOutput = selector.raw;\n\t\t\tconst conflictsOnly = selector.conflicts;\n\t\t\treturn new Promise<{ content: (TextContent | ImageContent)[]; details: ReadToolDetails | undefined }>(\n\t\t\t\t(resolve, reject) => {\n\t\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\t\treject(new FileToolAbortedError(signal.reason));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tlet aborted = false;\n\t\t\t\t\tconst onAbort = () => {\n\t\t\t\t\t\taborted = true;\n\t\t\t\t\t\treject(new FileToolAbortedError(signal?.reason));\n\t\t\t\t\t};\n\t\t\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t\t(async () => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst archive = parseArchiveSelector(effectivePath);\n\t\t\t\t\t\t\tconst sqlite = sqliteSelectorForPath(effectivePath, executionCwd);\n\t\t\t\t\t\t\tif (isReadableUrlPath(effectivePath)) {\n\t\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t\tawait readUrlBranch({\n\t\t\t\t\t\t\t\t\t\teffectivePath,\n\t\t\t\t\t\t\t\t\t\trawOutput: rawOutput === true,\n\t\t\t\t\t\t\t\t\t\teffectiveRanges,\n\t\t\t\t\t\t\t\t\t\teffectiveOffset,\n\t\t\t\t\t\t\t\t\t\teffectiveLimit,\n\t\t\t\t\t\t\t\t\t\tcwd: executionCwd,\n\t\t\t\t\t\t\t\t\t\tctx,\n\t\t\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t\t\t\tmaxChars: READ_TOOL_MAX_RESULT_CHARS,\n\t\t\t\t\t\t\t\t\t\tmaxBytes: DEFAULT_MAX_BYTES,\n\t\t\t\t\t\t\t\t\t\toversized: oversizedReadResult,\n\t\t\t\t\t\t\t\t\t\tsourceMeta: readSourceMeta,\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 (sqlite) {\n\t\t\t\t\t\t\t\tconst textContent = readSqliteSelector(sqlite),\n\t\t\t\t\t\t\t\t\tselection = applyReadLineSelection(\n\t\t\t\t\t\t\t\t\t\ttextContent.split(\"\\n\"),\n\t\t\t\t\t\t\t\t\t\teffectiveRanges,\n\t\t\t\t\t\t\t\t\t\teffectiveOffset,\n\t\t\t\t\t\t\t\t\t\teffectiveLimit,\n\t\t\t\t\t\t\t\t\t\trawOutput,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tselectedText = selection.lines.join(\"\\n\");\n\t\t\t\t\t\t\t\tif ((effectiveRanges || effectiveOffset) && selection.lines.length === 0) {\n\t\t\t\t\t\t\t\t\tconst requested = effectiveRanges?.[0]?.start ?? effectiveOffset ?? 1;\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: `Requested line ${requested} is beyond end of resource (${textContent.split(\"\\n\").length} lines total).`,\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: undefined,\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\tif (\n\t\t\t\t\t\t\t\t\tselectedText.length > READ_TOOL_MAX_RESULT_CHARS ||\n\t\t\t\t\t\t\t\t\tBuffer.byteLength(selectedText, \"utf8\") > DEFAULT_MAX_BYTES\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t\t\toversizedReadResult({\n\t\t\t\t\t\t\t\t\t\t\tblocked: true,\n\t\t\t\t\t\t\t\t\t\t\tpath: effectivePath,\n\t\t\t\t\t\t\t\t\t\t\tchars: selectedText.length,\n\t\t\t\t\t\t\t\t\t\t\tmaxChars: READ_TOOL_MAX_RESULT_CHARS,\n\t\t\t\t\t\t\t\t\t\t\tstartLine: selection.firstLine,\n\t\t\t\t\t\t\t\t\t\t\ttotalFileLines: textContent.split(\"\\n\").length,\n\t\t\t\t\t\t\t\t\t\t\tfirstLineBytes: Buffer.byteLength(selection.lines[0] ?? \"\", \"utf8\"),\n\t\t\t\t\t\t\t\t\t\t\tbyteGuidance: false,\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\tresolve({\n\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: selectedText }],\n\t\t\t\t\t\t\t\t\tdetails: readSourceMeta(effectivePath),\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 (archive) {\n\t\t\t\t\t\t\t\tconst resolvedArchive = resolveArchiveSelector(archive, executionCwd);\n\t\t\t\t\t\t\t\tconst textContent = readArchiveSelector(resolvedArchive);\n\t\t\t\t\t\t\t\tlet allLines = textContent.split(\"\\n\");\n\t\t\t\t\t\t\t\tif (conflictsOnly) {\n\t\t\t\t\t\t\t\t\tlet inConflict = false;\n\t\t\t\t\t\t\t\t\tconst conflictLines = allLines.filter((line) => {\n\t\t\t\t\t\t\t\t\t\tif (line.startsWith(\"<<<<<<<\")) inConflict = true;\n\t\t\t\t\t\t\t\t\t\tconst keep = inConflict;\n\t\t\t\t\t\t\t\t\t\tif (line.startsWith(\">>>>>>>\")) inConflict = false;\n\t\t\t\t\t\t\t\t\t\treturn keep;\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tif (conflictLines.length === 0) {\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: \"No conflict markers 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\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tallLines = conflictLines;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst rangeSelection = (rawOutput ? selectExactReadRanges : selectReadRanges)(\n\t\t\t\t\t\t\t\t\tallLines,\n\t\t\t\t\t\t\t\t\teffectiveRanges,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tconst startLine = rangeSelection\n\t\t\t\t\t\t\t\t\t? rangeSelection.firstLine - 1\n\t\t\t\t\t\t\t\t\t: effectiveOffset\n\t\t\t\t\t\t\t\t\t\t? Math.max(0, effectiveOffset - 1)\n\t\t\t\t\t\t\t\t\t\t: 0;\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tstartLine >= allLines.length ||\n\t\t\t\t\t\t\t\t\t(effectiveRanges && rangeSelection?.selectedLines.length === 0)\n\t\t\t\t\t\t\t\t) {\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: `Requested line ${startLine + 1} is beyond end of resource (${allLines.length} lines total).`,\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: undefined,\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 endLine =\n\t\t\t\t\t\t\t\t\teffectiveLimit !== undefined\n\t\t\t\t\t\t\t\t\t\t? Math.min(startLine + effectiveLimit, allLines.length)\n\t\t\t\t\t\t\t\t\t\t: allLines.length;\n\t\t\t\t\t\t\t\tconst selectedLines = rangeSelection?.selectedLines ?? allLines.slice(startLine, endLine);\n\t\t\t\t\t\t\t\tconst selectedText = selectedLines.join(\"\\n\");\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tselectedText.length > READ_TOOL_MAX_RESULT_CHARS ||\n\t\t\t\t\t\t\t\t\tBuffer.byteLength(selectedText, \"utf8\") > DEFAULT_MAX_BYTES\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t\t\toversizedReadResult({\n\t\t\t\t\t\t\t\t\t\t\tblocked: true,\n\t\t\t\t\t\t\t\t\t\t\tpath: `${resolvedArchive.archivePath}:${resolvedArchive.memberPath}`,\n\t\t\t\t\t\t\t\t\t\t\tchars: selectedText.length,\n\t\t\t\t\t\t\t\t\t\t\tmaxChars: READ_TOOL_MAX_RESULT_CHARS,\n\t\t\t\t\t\t\t\t\t\t\tstartLine: startLine + 1,\n\t\t\t\t\t\t\t\t\t\t\ttotalFileLines: allLines.length,\n\t\t\t\t\t\t\t\t\t\t\tfirstLineBytes: Buffer.byteLength(selectedLines[0] ?? \"\", \"utf8\"),\n\t\t\t\t\t\t\t\t\t\t\tbyteGuidance: false,\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\tresolve({\n\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: selectedText }],\n\t\t\t\t\t\t\t\t\tdetails: readSourceMeta(`${resolvedArchive.archivePath}:${resolvedArchive.memberPath}`),\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 (isInternalUrl(effectivePath)) {\n\t\t\t\t\t\t\t\tconst sourcePath = effectivePath.startsWith(\"local://\")\n\t\t\t\t\t\t\t\t\t? resolveInternalSelector(effectivePath, executionCwd)\n\t\t\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\t\t\tif (sourcePath) {\n\t\t\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t\t\tawait createReadToolDefinition(executionCwd, options).execute(\n\t\t\t\t\t\t\t\t\t\t\t_toolCallId,\n\t\t\t\t\t\t\t\t\t\t\t{ path: appendReadSelectors(sourcePath, selector) },\n\t\t\t\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t\t\t\t\t_onUpdate,\n\t\t\t\t\t\t\t\t\t\t\tctx as never,\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 allLines = (await readInternalSelector(effectivePath, executionCwd, resourceCtx)).split(\n\t\t\t\t\t\t\t\t\t\"\\n\",\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tconst rangeSelection = (rawOutput ? selectExactReadRanges : selectReadRanges)(\n\t\t\t\t\t\t\t\t\tallLines,\n\t\t\t\t\t\t\t\t\teffectiveRanges,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tconst startLine = rangeSelection\n\t\t\t\t\t\t\t\t\t? rangeSelection.firstLine - 1\n\t\t\t\t\t\t\t\t\t: effectiveOffset\n\t\t\t\t\t\t\t\t\t\t? Math.max(0, effectiveOffset - 1)\n\t\t\t\t\t\t\t\t\t\t: 0;\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tstartLine >= allLines.length ||\n\t\t\t\t\t\t\t\t\t(effectiveRanges && rangeSelection?.selectedLines.length === 0)\n\t\t\t\t\t\t\t\t) {\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: `Requested line ${startLine + 1} is beyond end of resource (${allLines.length} lines total).`,\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: undefined,\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 endLine =\n\t\t\t\t\t\t\t\t\teffectiveLimit !== undefined\n\t\t\t\t\t\t\t\t\t\t? Math.min(startLine + effectiveLimit, allLines.length)\n\t\t\t\t\t\t\t\t\t\t: allLines.length;\n\t\t\t\t\t\t\t\tconst selectedLines = rangeSelection?.selectedLines ?? allLines.slice(startLine, endLine);\n\t\t\t\t\t\t\t\tconst selectedText = selectedLines.join(\"\\n\");\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tselectedText.length > READ_TOOL_MAX_RESULT_CHARS ||\n\t\t\t\t\t\t\t\t\tBuffer.byteLength(selectedText, \"utf8\") > DEFAULT_MAX_BYTES\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t\t\toversizedReadResult({\n\t\t\t\t\t\t\t\t\t\t\tblocked: true,\n\t\t\t\t\t\t\t\t\t\t\tpath: effectivePath,\n\t\t\t\t\t\t\t\t\t\t\tchars: selectedText.length,\n\t\t\t\t\t\t\t\t\t\t\tmaxChars: READ_TOOL_MAX_RESULT_CHARS,\n\t\t\t\t\t\t\t\t\t\t\tstartLine: startLine + 1,\n\t\t\t\t\t\t\t\t\t\t\ttotalFileLines: allLines.length,\n\t\t\t\t\t\t\t\t\t\t\tfirstLineBytes: Buffer.byteLength(selectedLines[0] ?? \"\", \"utf8\"),\n\t\t\t\t\t\t\t\t\t\t\tbyteGuidance: false,\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\tresolve({\n\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: selectedText }],\n\t\t\t\t\t\t\t\t\tdetails: readSourceMeta(effectivePath),\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 (isReadResourceSelector(effectivePath))\n\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t`Read resource selectors are not supported by this filesystem backend: ${path}`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst absolutePath = await resolveReadPathAsync(effectivePath, executionCwd);\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\tlet content: (TextContent | ImageContent)[];\n\t\t\t\t\t\t\tlet details: ReadToolDetails | undefined;\n\t\t\t\t\t\t\tawait ops.access(absolutePath);\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\tif (isDocumentPath(absolutePath) && !rawOutput && !isNotebookPath(absolutePath)) {\n\t\t\t\t\t\t\t\tconst buffer = await ops.readFile(absolutePath);\n\t\t\t\t\t\t\t\tconst textContent = await extractDocumentMarkdown(buffer, absolutePath);\n\t\t\t\t\t\t\t\tconst selection = applyReadLineSelection(\n\t\t\t\t\t\t\t\t\ttextContent.split(\"\\n\"),\n\t\t\t\t\t\t\t\t\teffectiveRanges,\n\t\t\t\t\t\t\t\t\teffectiveOffset,\n\t\t\t\t\t\t\t\t\teffectiveLimit,\n\t\t\t\t\t\t\t\t\trawOutput,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (selection.lines.length === 0) {\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: `Requested line ${selection.firstLine} is beyond end of document (${textContent.split(\"\\n\").length} lines total).`,\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: undefined,\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 selectedText = selection.lines.join(\"\\n\");\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tselectedText.length > READ_TOOL_MAX_RESULT_CHARS ||\n\t\t\t\t\t\t\t\t\tBuffer.byteLength(selectedText, \"utf8\") > DEFAULT_MAX_BYTES\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t\t\toversizedReadResult({\n\t\t\t\t\t\t\t\t\t\t\tblocked: true,\n\t\t\t\t\t\t\t\t\t\t\tpath: absolutePath,\n\t\t\t\t\t\t\t\t\t\t\tchars: selectedText.length,\n\t\t\t\t\t\t\t\t\t\t\tmaxChars: READ_TOOL_MAX_RESULT_CHARS,\n\t\t\t\t\t\t\t\t\t\t\tstartLine: selection.firstLine,\n\t\t\t\t\t\t\t\t\t\t\ttotalFileLines: textContent.split(\"\\n\").length,\n\t\t\t\t\t\t\t\t\t\t\tfirstLineBytes: Buffer.byteLength(selection.lines[0] ?? \"\", \"utf8\"),\n\t\t\t\t\t\t\t\t\t\t\tbyteGuidance: false,\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\tcontent = [{ type: \"text\", text: selectedText }];\n\t\t\t\t\t\t\t\tresolve({ content, details: readSourceMeta(absolutePath) });\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tlet tree: DirectoryTreeResult | undefined;\n\t\t\t\t\t\t\tif (ops.stat && ops.listDir) {\n\t\t\t\t\t\t\t\tconst stat = await ops.stat(absolutePath);\n\t\t\t\t\t\t\t\tif (stat?.isDirectory)\n\t\t\t\t\t\t\t\t\ttree = await buildDirectoryTreeFromOperations(\n\t\t\t\t\t\t\t\t\t\tabsolutePath,\n\t\t\t\t\t\t\t\t\t\t{ listDir: ops.listDir },\n\t\t\t\t\t\t\t\t\t\t{ maxDepth: 2, perDirLimit: 12, rootLimit: null },\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else if (!options?.operations && (await fsStat(absolutePath)).isDirectory()) {\n\t\t\t\t\t\t\t\ttree = await buildDirectoryTree(absolutePath, {\n\t\t\t\t\t\t\t\t\tmaxDepth: 2,\n\t\t\t\t\t\t\t\t\tperDirLimit: 12,\n\t\t\t\t\t\t\t\t\trootLimit: null,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (tree) {\n\t\t\t\t\t\t\t\tconst allLines = tree.rendered.split(\"\\n\"),\n\t\t\t\t\t\t\t\t\trangeSelection = (rawOutput ? selectExactReadRanges : selectReadRanges)(\n\t\t\t\t\t\t\t\t\t\tallLines,\n\t\t\t\t\t\t\t\t\t\teffectiveRanges,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tstartLine = rangeSelection\n\t\t\t\t\t\t\t\t\t\t? rangeSelection.firstLine - 1\n\t\t\t\t\t\t\t\t\t\t: effectiveOffset\n\t\t\t\t\t\t\t\t\t\t\t? Math.max(0, effectiveOffset - 1)\n\t\t\t\t\t\t\t\t\t\t\t: 0;\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tstartLine >= allLines.length ||\n\t\t\t\t\t\t\t\t\t(effectiveRanges && rangeSelection?.selectedLines.length === 0)\n\t\t\t\t\t\t\t\t) {\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: `Requested line ${startLine + 1} is beyond end of directory (${allLines.length} lines total).`,\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: undefined,\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 endLine =\n\t\t\t\t\t\t\t\t\t\teffectiveLimit !== undefined\n\t\t\t\t\t\t\t\t\t\t\t? Math.min(startLine + effectiveLimit, allLines.length)\n\t\t\t\t\t\t\t\t\t\t\t: allLines.length,\n\t\t\t\t\t\t\t\t\tselectedLines = rangeSelection?.selectedLines ?? allLines.slice(startLine, endLine);\n\t\t\t\t\t\t\t\tcontent = [{ type: \"text\", text: selectedLines.join(\"\\n\") }];\n\t\t\t\t\t\t\t\tconst meta = {\n\t\t\t\t\t\t\t\t\t...readSourceMeta(absolutePath).meta,\n\t\t\t\t\t\t\t\t\t...(tree.truncated ? { limits: { perDirLimit: 12, totalLines: tree.totalLines } } : {}),\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tresolve({ content, details: { isDirectory: true, resolvedPath: absolutePath, meta } });\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst mimeType = ops.detectImageMimeType ? await ops.detectImageMimeType(absolutePath) : undefined;\n\t\t\t\t\t\t\tif (mimeType) {\n\t\t\t\t\t\t\t\tconst buffer = await ops.readFile(absolutePath);\n\t\t\t\t\t\t\t\tconst processed = await processImage(buffer, mimeType, {\n\t\t\t\t\t\t\t\t\tautoResizeImages,\n\t\t\t\t\t\t\t\t\tresizeOptions: ctx?.model?.inputLimits?.images?.resize ?? fallbackResizeOptions,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (!processed.ok) {\n\t\t\t\t\t\t\t\t\tconst textNote = `Read image file [${mimeType}]\\n${processed.message}`;\n\t\t\t\t\t\t\t\t\tcontent = [{ type: \"text\", text: textNote }];\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tlet textNote = `Read image file [${processed.mimeType}]`;\n\t\t\t\t\t\t\t\t\tif (processed.hints.length > 0) textNote += `\\n${processed.hints.join(\"\\n\")}`;\n\t\t\t\t\t\t\t\t\tcontent = [\n\t\t\t\t\t\t\t\t\t\t{ type: \"text\", text: textNote },\n\t\t\t\t\t\t\t\t\t\t{ type: \"image\", data: processed.data, mimeType: processed.mimeType },\n\t\t\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\t\t\tif (ctx?.model && !ctx.model.input.includes(\"image\")) {\n\t\t\t\t\t\t\t\t\t\tdetails = {\n\t\t\t\t\t\t\t\t\t\t\t...readSourceMeta(absolutePath),\n\t\t\t\t\t\t\t\t\t\t\timageUnsupportedByModel: ctx.model.id,\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}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconst offsetStartLine = effectiveOffset ? Math.max(0, effectiveOffset - 1) : 0;\n\t\t\t\t\t\t\t\tconst plan: ReadLinePlan = effectiveRanges?.length\n\t\t\t\t\t\t\t\t\t? { ranges: effectiveRanges, exact: rawOutput === true }\n\t\t\t\t\t\t\t\t\t: { firstLine: offsetStartLine + 1 };\n\t\t\t\t\t\t\t\tconst notebookView = isNotebookPath(absolutePath) && !rawOutput;\n\t\t\t\t\t\t\t\tlet selection: SelectedReadLines;\n\t\t\t\t\t\t\t\tif (conflictsOnly || notebookView) {\n\t\t\t\t\t\t\t\t\tconst buffer = await ops.readFile(absolutePath);\n\t\t\t\t\t\t\t\t\tconst textContent = notebookView\n\t\t\t\t\t\t\t\t\t\t? readEditableNotebookText(absolutePath, effectivePath)\n\t\t\t\t\t\t\t\t\t\t: buffer.toString(\"utf-8\");\n\t\t\t\t\t\t\t\t\t// Formatted output reads LF-normalized lines. Keep raw reads on the source bytes so\n\t\t\t\t\t\t\t\t\t// :raw preserves CRLF and terminal-newline bytes exactly.\n\t\t\t\t\t\t\t\t\tconst lineTextContent = rawOutput ? textContent : textContent.replace(/\\r\\n/g, \"\\n\");\n\t\t\t\t\t\t\t\t\tconst sourceLines = lineTextContent.split(\"\\n\");\n\t\t\t\t\t\t\t\t\t// A terminal newline separates real lines; omit only its synthetic split item.\n\t\t\t\t\t\t\t\t\tlet allLines =\n\t\t\t\t\t\t\t\t\t\trawOutput || !lineTextContent.endsWith(\"\\n\") ? sourceLines : sourceLines.slice(0, -1);\n\t\t\t\t\t\t\t\t\tif (conflictsOnly) {\n\t\t\t\t\t\t\t\t\t\tregisterConflictBlocks(executionCwd, parseConflictBlocks(absolutePath, textContent));\n\t\t\t\t\t\t\t\t\t\tconst conflictLines: string[] = [];\n\t\t\t\t\t\t\t\t\t\tlet inConflict = false;\n\t\t\t\t\t\t\t\t\t\tfor (const line of allLines) {\n\t\t\t\t\t\t\t\t\t\t\tif (line.startsWith(\"<<<<<<<\")) inConflict = true;\n\t\t\t\t\t\t\t\t\t\t\tif (inConflict) conflictLines.push(line);\n\t\t\t\t\t\t\t\t\t\t\tif (line.startsWith(\">>>>>>>\")) inConflict = false;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tif (conflictLines.length > 0) allLines = conflictLines;\n\t\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: \"No conflict markers found\" }],\n\t\t\t\t\t\t\t\t\t\t\t\tdetails: undefined,\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\treturn;\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\tselection = selectReadLinesFromList(allLines, plan, READ_TOOL_MAX_RESULT_CHARS);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// Stream plain text: only the selected lines are kept, so memory does not grow with the file.\n\t\t\t\t\t\t\t\t\tselection = await selectReadLinesFromChunks(\n\t\t\t\t\t\t\t\t\t\tops.createReadStream?.(absolutePath, { signal }) ?? readWholeFile(ops, absolutePath),\n\t\t\t\t\t\t\t\t\t\tplan,\n\t\t\t\t\t\t\t\t\t\t{ raw: rawOutput === true, maxChars: READ_TOOL_MAX_RESULT_CHARS, signal },\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\tconst totalFileLines = selection.totalLines;\n\t\t\t\t\t\t\t\tconst startLine = \"ranges\" in plan ? selection.firstLineNumber - 1 : offsetStartLine;\n\t\t\t\t\t\t\t\tconst startLineDisplay = startLine + 1;\n\t\t\t\t\t\t\t\tif (startLine >= totalFileLines || (\"ranges\" in plan && selection.count === 0)) {\n\t\t\t\t\t\t\t\t\tconst requested = effectiveRanges?.[0]?.start ?? startLineDisplay;\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: `Requested line ${requested} is beyond end of file (${totalFileLines} lines total). Use ${effectivePath}:${Math.max(1, totalFileLines)} to read the final line.`,\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: undefined,\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 selectedLines = selection.lines;\n\t\t\t\t\t\t\t\tif (selection.chars > READ_TOOL_MAX_RESULT_CHARS) {\n\t\t\t\t\t\t\t\t\tconst firstLineBytes = selection.firstLineBytes;\n\t\t\t\t\t\t\t\t\tconst byteGuidance =\n\t\t\t\t\t\t\t\t\t\tselection.countBeforeTrailingEmpty <= 1 || firstLineBytes > DEFAULT_MAX_BYTES;\n\t\t\t\t\t\t\t\t\tconst oversizedRead: OversizedReadDetails = {\n\t\t\t\t\t\t\t\t\t\tblocked: true,\n\t\t\t\t\t\t\t\t\t\tpath: absolutePath,\n\t\t\t\t\t\t\t\t\t\tchars: selection.chars,\n\t\t\t\t\t\t\t\t\t\tmaxChars: READ_TOOL_MAX_RESULT_CHARS,\n\t\t\t\t\t\t\t\t\t\tstartLine: startLineDisplay,\n\t\t\t\t\t\t\t\t\t\ttotalFileLines,\n\t\t\t\t\t\t\t\t\t\tfirstLineBytes,\n\t\t\t\t\t\t\t\t\t\tbyteGuidance,\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\tdetails = { oversizedRead, meta: readSourceMeta(absolutePath).meta };\n\t\t\t\t\t\t\t\t\tcontent = [{ type: \"text\", text: buildOversizedReadMessage(oversizedRead) }];\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tconst truncation = truncateHead(selectedLines.join(\"\\n\"));\n\t\t\t\t\t\t\t\t\tconst shownLines = truncation.truncated ? truncation.outputLines : selectedLines.length;\n\t\t\t\t\t\t\t\t\tconst shownLineNumbers =\n\t\t\t\t\t\t\t\t\t\t\"ranges\" in plan ? selection.lineNumbers.slice(0, shownLines) : undefined;\n\t\t\t\t\t\t\t\t\tconst lastShownLine = shownLineNumbers?.at(-1) ?? startLine + shownLines;\n\t\t\t\t\t\t\t\t\tlet outputText =\n\t\t\t\t\t\t\t\t\t\tshownLineNumbers && !rawOutput\n\t\t\t\t\t\t\t\t\t\t\t? formatSelectedLines(\n\t\t\t\t\t\t\t\t\t\t\t\t\tselectedLines.slice(0, shownLines),\n\t\t\t\t\t\t\t\t\t\t\t\t\tshownLineNumbers,\n\t\t\t\t\t\t\t\t\t\t\t\t\ttotalFileLines,\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t: truncation.content;\n\t\t\t\t\t\t\t\t\tif (truncation.firstLineExceedsLimit) {\n\t\t\t\t\t\t\t\t\t\tconst firstLineSize = formatSize(selection.firstLineBytes);\n\t\t\t\t\t\t\t\t\t\toutputText = `[Line ${startLineDisplay} is ${firstLineSize}, exceeds ${formatSize(DEFAULT_MAX_BYTES)} limit. Use bash: sed -n '${startLineDisplay}p' ${effectivePath} | head -c ${DEFAULT_MAX_BYTES}]`;\n\t\t\t\t\t\t\t\t\t\tdetails = {\n\t\t\t\t\t\t\t\t\t\t\ttruncation,\n\t\t\t\t\t\t\t\t\t\t\tmeta: { source: absolutePath, sourcePath: absolutePath, truncation },\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t} else if (truncation.truncated) {\n\t\t\t\t\t\t\t\t\t\tconst nextOffset = lastShownLine + 1;\n\t\t\t\t\t\t\t\t\t\toutputText +=\n\t\t\t\t\t\t\t\t\t\t\ttruncation.truncatedBy === \"lines\"\n\t\t\t\t\t\t\t\t\t\t\t\t? `\\n\\n[Showing lines ${startLineDisplay}-${lastShownLine} of ${totalFileLines}. Continue with path selector :${nextOffset}.]`\n\t\t\t\t\t\t\t\t\t\t\t\t: `\\n\\n[Showing lines ${startLineDisplay}-${lastShownLine} of ${totalFileLines} (${formatSize(DEFAULT_MAX_BYTES)} limit). Continue with path selector :${nextOffset}.]`;\n\t\t\t\t\t\t\t\t\t\tdetails = {\n\t\t\t\t\t\t\t\t\t\t\ttruncation,\n\t\t\t\t\t\t\t\t\t\t\tmeta: { source: absolutePath, sourcePath: absolutePath, truncation },\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t} else if (!rawOutput && lastShownLine < totalFileLines) {\n\t\t\t\t\t\t\t\t\t\tconst remaining = totalFileLines - lastShownLine;\n\t\t\t\t\t\t\t\t\t\toutputText += `\\n\\n[${remaining} more lines in file. Continue with path selector :${lastShownLine + 1}.]`;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcontent = [{ type: \"text\", text: outputText }];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\tresolve({ content, details: details ?? readSourceMeta(absolutePath) });\n\t\t\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\tif (!aborted) reject(error);\n\t\t\t\t\t\t}\n\t\t\t\t\t})();\n\t\t\t\t},\n\t\t\t).then((result) =>\n\t\t\t\tresult.details?.oversizedRead?.blocked\n\t\t\t\t\t? { ...result, isError: true }\n\t\t\t\t\t: { ...result, structuredContent: toReadOutput(result.content) },\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\tconst classification = !context.expanded ? getCompactReadClassification(args, context.cwd) : undefined;\n\t\t\ttext.setText(\n\t\t\t\tclassification ? formatCompactReadCall(classification, args, theme) : formatReadCall(args, theme),\n\t\t\t);\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(\n\t\t\t\tformatReadResult(context.args, result, options, theme, context.showImages, context.cwd, context.isError),\n\t\t\t);\n\t\t\treturn text;\n\t\t},\n\t};\n}\nexport function createReadTool(cwd: string, options?: ReadToolOptions): AgentTool<typeof readSchema> {\n\treturn wrapToolDefinition(createReadToolDefinition(cwd, options));\n}\n"]}
@@ -7,7 +7,7 @@ export { type GitExecutable, type GitExecutableResolver, setWorktreeSnapshotGit
7
7
  export { isHeadOnlyAdvance } from "./head-advance.ts";
8
8
  export { canonicalizeWorktreePath } from "./paths.ts";
9
9
  export { SNAPSHOT_DENY_PATTERNS, SNAPSHOT_IGNORE_FILE, SNAPSHOT_KEY_FILE_PATTERNS } from "./policy.ts";
10
- export { defaultWorktreeSnapshotStoreDir, type RestoredWorktree, type RestoreWorktreeSnapshotOptions, removeRestoredWorktree, restoreWorktree, restoreWorktreeSnapshot, type VerifyWorktreeOptions, verifyWorktree, } from "./restore.ts";
10
+ export { type DegradedWorktree, defaultWorktreeSnapshotStoreDir, isDegradableRestoreFailure, type RestoreDegradedWorktreeOptions, type RestoredWorktree, type RestoreWorktreeSnapshotOptions, removeRestoredWorktree, restoreDegradedWorktree, restoreWorktree, restoreWorktreeSnapshot, type VerifyWorktreeOptions, verifyWorktree, } from "./restore.ts";
11
11
  export { DEFAULT_WORKTREE_SNAPSHOT_SETTINGS, resolveWorktreeSnapshotSettings, type WorktreeSnapshotSettingsInput, } from "./settings.ts";
12
- export type { SnapshotBlob, SnapshotBlobStore, WorkspaceBinding, WorktreeRestoreWarning, WorktreeRootMapping, WorktreeSnapshot, WorktreeSnapshotBundle, WorktreeSnapshotChainLink, WorktreeSnapshotFilters, WorktreeSnapshotOmission, WorktreeSnapshotOmissionReason, WorktreeSnapshotPathOmissionReason, WorktreeSnapshotSettings, WorktreeSnapshotSizeOmissionReason, } from "./types.ts";
12
+ export type { SnapshotBlob, SnapshotBlobStore, WorkspaceBinding, WorktreeDegradedRestore, WorktreeDegradedRestoreBasis, WorktreeRestoreWarning, WorktreeRootMapping, WorktreeSnapshot, WorktreeSnapshotBundle, WorktreeSnapshotChainLink, WorktreeSnapshotFilters, WorktreeSnapshotOmission, WorktreeSnapshotOmissionReason, WorktreeSnapshotPathOmissionReason, WorktreeSnapshotSettings, WorktreeSnapshotSizeOmissionReason, WorktreeUnrestored, } from "./types.ts";
13
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/worktree-snapshot/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,uBAAuB,EACvB,yBAAyB,EACzB,KAAK,mBAAmB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,SAAS,EACT,KAAK,8BAA8B,EACnC,uBAAuB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,iCAAiC,GACtC,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC9F,OAAO,EACN,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,uBAAuB,EAC5B,iBAAiB,EACjB,KAAK,qBAAqB,EAC1B,qBAAqB,EACrB,yBAAyB,EACzB,0BAA0B,EAC1B,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,uBAAuB,EACvB,wBAAwB,EACxB,KAAK,4BAA4B,EACjC,KAAK,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A8B,EAC9B,kCAAkC,EAClC,wBAAwB,EACxB,kCAAkC,GAClC,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/worktree-snapshot/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,uBAAuB,EACvB,yBAAyB,EACzB,KAAK,mBAAmB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,SAAS,EACT,KAAK,8BAA8B,EACnC,uBAAuB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,iCAAiC,GACtC,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC9F,OAAO,EACN,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,uBAAuB,EAC5B,iBAAiB,EACjB,KAAK,qBAAqB,EAC1B,qBAAqB,EACrB,yBAAyB,EACzB,0BAA0B,EAC1B,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,uBAAuB,EACvB,wBAAwB,EACxB,KAAK,4BAA4B,EACjC,KAAK,8BAA8B,EACnC,oBAAoB,EACpB,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,mBAAmB,EACnB,KAAK,uBAAuB,EAC5B,KAAK,yBAAyB,EAC9B,cAAc,EACd,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,iBAAiB,EACjB,KAAK,qBAAqB,EAC1B,qBAAqB,EACrB,KAAK,yBAAyB,EAC9B,KAAK,2BAA2B,EAChC,sBAAsB,EACtB,KAAK,0BAA0B,GAC/B,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,KAAK,6BAA6B,EAClC,sBAAsB,EACtB,0BAA0B,EAC1B,yBAAyB,EACzB,KAAK,iCAAiC,EACtC,KAAK,yBAAyB,EAC9B,KAAK,4BAA4B,EACjC,0BAA0B,GAC1B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACvG,OAAO,EACN,KAAK,gBAAgB,EACrB,+BAA+B,EAC/B,0BAA0B,EAC1B,KAAK,8BAA8B,EACnC,KAAK,gBAAgB,EACrB,KAAK,8BAA8B,EACnC,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,EACf,uBAAuB,EACvB,KAAK,qBAAqB,EAC1B,cAAc,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EACN,kCAAkC,EAClC,+BAA+B,EAC/B,KAAK,6BAA6B,GAClC,MAAM,eAAe,CAAC;AACvB,YAAY,EACX,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACvB,4BAA4B,EAC5B,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,EACxB,8BAA8B,EAC9B,kCAAkC,EAClC,wBAAwB,EACxB,kCAAkC,EAClC,kBAAkB,GAClB,MAAM,YAAY,CAAC"}
@@ -7,6 +7,6 @@ export { setWorktreeSnapshotGit } from "./git.js";
7
7
  export { isHeadOnlyAdvance } from "./head-advance.js";
8
8
  export { canonicalizeWorktreePath } from "./paths.js";
9
9
  export { SNAPSHOT_DENY_PATTERNS, SNAPSHOT_IGNORE_FILE, SNAPSHOT_KEY_FILE_PATTERNS } from "./policy.js";
10
- export { defaultWorktreeSnapshotStoreDir, removeRestoredWorktree, restoreWorktree, restoreWorktreeSnapshot, verifyWorktree, } from "./restore.js";
10
+ export { defaultWorktreeSnapshotStoreDir, isDegradableRestoreFailure, removeRestoredWorktree, restoreDegradedWorktree, restoreWorktree, restoreWorktreeSnapshot, verifyWorktree, } from "./restore.js";
11
11
  export { DEFAULT_WORKTREE_SNAPSHOT_SETTINGS, resolveWorktreeSnapshotSettings, } from "./settings.js";
12
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/worktree-snapshot/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,uBAAuB,EACvB,yBAAyB,EAEzB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,SAAS,EAET,uBAAuB,GAGvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC9F,OAAO,EACN,kBAAkB,EAClB,mBAAmB,EAEnB,iBAAiB,EAEjB,qBAAqB,EACrB,yBAAyB,EACzB,0BAA0B,EAC1B,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,EAGvB,uBAAuB,EACvB,wBAAwB,EAGxB,oBAAoB,EAGpB,mBAAmB,EAGnB,cAAc,EAKd,iBAAiB,EAEjB,qBAAqB,EAGrB,sBAAsB,GAEtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAEN,sBAAsB,EACtB,0BAA0B,EAC1B,yBAAyB,EAIzB,0BAA0B,GAC1B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAkD,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACvG,OAAO,EACN,+BAA+B,EAG/B,sBAAsB,EACtB,eAAe,EACf,uBAAuB,EAEvB,cAAc,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EACN,kCAAkC,EAClC,+BAA+B,GAE/B,MAAM,eAAe,CAAC","sourcesContent":["export {\n\tMemorySnapshotBlobStore,\n\tSNAPSHOT_COLLECTION_BATCH,\n\ttype SnapshotIndexTables,\n\tSqlSnapshotBlobStore,\n\tsnapshotBlobHashes,\n\tsnapshotIndexTables,\n} from \"./blob-store.ts\";\nexport {\n\tbindingOf,\n\ttype CaptureWorktreeSnapshotOptions,\n\tcaptureWorktreeSnapshot,\n\ttype WorktreeSnapshotCapture,\n\ttype WorktreeSnapshotUnavailableReason,\n} from \"./capture.ts\";\nexport { computeEnvironmentHash, ENVIRONMENT_INPUT_FILES, snapshotBlob } from \"./env-hash.ts\";\nexport {\n\tfindWorkspaceError,\n\tGitUnavailableError,\n\ttype GitUnavailableErrorCode,\n\tgitInstallCommand,\n\ttype InvalidSnapshotReason,\n\tisGitUnavailableError,\n\tisRetryableWorkspaceError,\n\tisWorkspaceCollectionError,\n\tisWorkspaceConfigError,\n\tisWorkspaceDriftError,\n\tisWorkspaceError,\n\tisWorkspaceGitError,\n\tisWorkspaceRestoreError,\n\tisWorkspaceSnapshotError,\n\trehydrateWorkspaceError,\n\ttype SerializedWorkspaceError,\n\ttype SnapshotCollectionPhase,\n\tserializeWorkspaceError,\n\tWorkspaceCollectionError,\n\ttype WorkspaceCollectionErrorCode,\n\ttype WorkspaceCollectionErrorFields,\n\tWorkspaceConfigError,\n\ttype WorkspaceConfigErrorCode,\n\ttype WorkspaceConfigSource,\n\tWorkspaceDriftError,\n\ttype WorkspaceDriftErrorCode,\n\ttype WorkspaceDriftErrorFields,\n\tWorkspaceError,\n\ttype WorkspaceErrorCode,\n\ttype WorkspaceErrorFields,\n\ttype WorkspaceErrorFieldValue,\n\ttype WorkspaceErrorName,\n\tWorkspaceGitError,\n\ttype WorkspaceGitErrorCode,\n\tWorkspaceRestoreError,\n\ttype WorkspaceRestoreErrorCode,\n\ttype WorkspaceRestoreErrorFields,\n\tWorkspaceSnapshotError,\n\ttype WorkspaceSnapshotErrorCode,\n} from \"./errors.ts\";\nexport {\n\ttype CollectSnapshotGarbageOptions,\n\tcollectSnapshotGarbage,\n\tDEFAULT_BLOB_GRACE_SECONDS,\n\trunningSnapshotCollection,\n\ttype ScheduleSnapshotCollectionOptions,\n\ttype SnapshotCollectionOutcome,\n\ttype SnapshotCollectionSkipReason,\n\tscheduleSnapshotCollection,\n} from \"./garbage.ts\";\nexport { type GitExecutable, type GitExecutableResolver, setWorktreeSnapshotGit } from \"./git.ts\";\nexport { isHeadOnlyAdvance } from \"./head-advance.ts\";\nexport { canonicalizeWorktreePath } from \"./paths.ts\";\nexport { SNAPSHOT_DENY_PATTERNS, SNAPSHOT_IGNORE_FILE, SNAPSHOT_KEY_FILE_PATTERNS } from \"./policy.ts\";\nexport {\n\tdefaultWorktreeSnapshotStoreDir,\n\ttype RestoredWorktree,\n\ttype RestoreWorktreeSnapshotOptions,\n\tremoveRestoredWorktree,\n\trestoreWorktree,\n\trestoreWorktreeSnapshot,\n\ttype VerifyWorktreeOptions,\n\tverifyWorktree,\n} from \"./restore.ts\";\nexport {\n\tDEFAULT_WORKTREE_SNAPSHOT_SETTINGS,\n\tresolveWorktreeSnapshotSettings,\n\ttype WorktreeSnapshotSettingsInput,\n} from \"./settings.ts\";\nexport type {\n\tSnapshotBlob,\n\tSnapshotBlobStore,\n\tWorkspaceBinding,\n\tWorktreeRestoreWarning,\n\tWorktreeRootMapping,\n\tWorktreeSnapshot,\n\tWorktreeSnapshotBundle,\n\tWorktreeSnapshotChainLink,\n\tWorktreeSnapshotFilters,\n\tWorktreeSnapshotOmission,\n\tWorktreeSnapshotOmissionReason,\n\tWorktreeSnapshotPathOmissionReason,\n\tWorktreeSnapshotSettings,\n\tWorktreeSnapshotSizeOmissionReason,\n} from \"./types.ts\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/worktree-snapshot/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,uBAAuB,EACvB,yBAAyB,EAEzB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,SAAS,EAET,uBAAuB,GAGvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC9F,OAAO,EACN,kBAAkB,EAClB,mBAAmB,EAEnB,iBAAiB,EAEjB,qBAAqB,EACrB,yBAAyB,EACzB,0BAA0B,EAC1B,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,EAGvB,uBAAuB,EACvB,wBAAwB,EAGxB,oBAAoB,EAGpB,mBAAmB,EAGnB,cAAc,EAKd,iBAAiB,EAEjB,qBAAqB,EAGrB,sBAAsB,GAEtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAEN,sBAAsB,EACtB,0BAA0B,EAC1B,yBAAyB,EAIzB,0BAA0B,GAC1B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAkD,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACvG,OAAO,EAEN,+BAA+B,EAC/B,0BAA0B,EAI1B,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,EACf,uBAAuB,EAEvB,cAAc,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EACN,kCAAkC,EAClC,+BAA+B,GAE/B,MAAM,eAAe,CAAC","sourcesContent":["export {\n\tMemorySnapshotBlobStore,\n\tSNAPSHOT_COLLECTION_BATCH,\n\ttype SnapshotIndexTables,\n\tSqlSnapshotBlobStore,\n\tsnapshotBlobHashes,\n\tsnapshotIndexTables,\n} from \"./blob-store.ts\";\nexport {\n\tbindingOf,\n\ttype CaptureWorktreeSnapshotOptions,\n\tcaptureWorktreeSnapshot,\n\ttype WorktreeSnapshotCapture,\n\ttype WorktreeSnapshotUnavailableReason,\n} from \"./capture.ts\";\nexport { computeEnvironmentHash, ENVIRONMENT_INPUT_FILES, snapshotBlob } from \"./env-hash.ts\";\nexport {\n\tfindWorkspaceError,\n\tGitUnavailableError,\n\ttype GitUnavailableErrorCode,\n\tgitInstallCommand,\n\ttype InvalidSnapshotReason,\n\tisGitUnavailableError,\n\tisRetryableWorkspaceError,\n\tisWorkspaceCollectionError,\n\tisWorkspaceConfigError,\n\tisWorkspaceDriftError,\n\tisWorkspaceError,\n\tisWorkspaceGitError,\n\tisWorkspaceRestoreError,\n\tisWorkspaceSnapshotError,\n\trehydrateWorkspaceError,\n\ttype SerializedWorkspaceError,\n\ttype SnapshotCollectionPhase,\n\tserializeWorkspaceError,\n\tWorkspaceCollectionError,\n\ttype WorkspaceCollectionErrorCode,\n\ttype WorkspaceCollectionErrorFields,\n\tWorkspaceConfigError,\n\ttype WorkspaceConfigErrorCode,\n\ttype WorkspaceConfigSource,\n\tWorkspaceDriftError,\n\ttype WorkspaceDriftErrorCode,\n\ttype WorkspaceDriftErrorFields,\n\tWorkspaceError,\n\ttype WorkspaceErrorCode,\n\ttype WorkspaceErrorFields,\n\ttype WorkspaceErrorFieldValue,\n\ttype WorkspaceErrorName,\n\tWorkspaceGitError,\n\ttype WorkspaceGitErrorCode,\n\tWorkspaceRestoreError,\n\ttype WorkspaceRestoreErrorCode,\n\ttype WorkspaceRestoreErrorFields,\n\tWorkspaceSnapshotError,\n\ttype WorkspaceSnapshotErrorCode,\n} from \"./errors.ts\";\nexport {\n\ttype CollectSnapshotGarbageOptions,\n\tcollectSnapshotGarbage,\n\tDEFAULT_BLOB_GRACE_SECONDS,\n\trunningSnapshotCollection,\n\ttype ScheduleSnapshotCollectionOptions,\n\ttype SnapshotCollectionOutcome,\n\ttype SnapshotCollectionSkipReason,\n\tscheduleSnapshotCollection,\n} from \"./garbage.ts\";\nexport { type GitExecutable, type GitExecutableResolver, setWorktreeSnapshotGit } from \"./git.ts\";\nexport { isHeadOnlyAdvance } from \"./head-advance.ts\";\nexport { canonicalizeWorktreePath } from \"./paths.ts\";\nexport { SNAPSHOT_DENY_PATTERNS, SNAPSHOT_IGNORE_FILE, SNAPSHOT_KEY_FILE_PATTERNS } from \"./policy.ts\";\nexport {\n\ttype DegradedWorktree,\n\tdefaultWorktreeSnapshotStoreDir,\n\tisDegradableRestoreFailure,\n\ttype RestoreDegradedWorktreeOptions,\n\ttype RestoredWorktree,\n\ttype RestoreWorktreeSnapshotOptions,\n\tremoveRestoredWorktree,\n\trestoreDegradedWorktree,\n\trestoreWorktree,\n\trestoreWorktreeSnapshot,\n\ttype VerifyWorktreeOptions,\n\tverifyWorktree,\n} from \"./restore.ts\";\nexport {\n\tDEFAULT_WORKTREE_SNAPSHOT_SETTINGS,\n\tresolveWorktreeSnapshotSettings,\n\ttype WorktreeSnapshotSettingsInput,\n} from \"./settings.ts\";\nexport type {\n\tSnapshotBlob,\n\tSnapshotBlobStore,\n\tWorkspaceBinding,\n\tWorktreeDegradedRestore,\n\tWorktreeDegradedRestoreBasis,\n\tWorktreeRestoreWarning,\n\tWorktreeRootMapping,\n\tWorktreeSnapshot,\n\tWorktreeSnapshotBundle,\n\tWorktreeSnapshotChainLink,\n\tWorktreeSnapshotFilters,\n\tWorktreeSnapshotOmission,\n\tWorktreeSnapshotOmissionReason,\n\tWorktreeSnapshotPathOmissionReason,\n\tWorktreeSnapshotSettings,\n\tWorktreeSnapshotSizeOmissionReason,\n\tWorktreeUnrestored,\n} from \"./types.ts\";\n"]}
@@ -5,6 +5,12 @@ export interface SnapshotRecordProblem {
5
5
  readonly field: string;
6
6
  readonly reason: InvalidSnapshotReason;
7
7
  }
8
+ /**
9
+ * Whether `remote` is a remote Atomic fetches from and configures: never an option or a control character, without
10
+ * credentials, and a local path, an scp-like `host:path`, or a URL of an allowed transport. A Git remote helper
11
+ * (`ext::`, `<name>::`) or any other scheme is not.
12
+ */
13
+ export declare function isAllowedRemote(remote: string): boolean;
8
14
  /** The first unsafe remote or malformed object id of a binding, or undefined when every value is safe to use. */
9
15
  export declare function bindingRecordProblem(binding: Pick<WorktreeSnapshot, "remotes" | "head" | "tree">): SnapshotRecordProblem | undefined;
10
16
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../../src/core/worktree-snapshot/records.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,qBAAqB,EAAyB,MAAM,aAAa,CAAC;AAChF,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAOrE,4GAA4G;AAC5G,MAAM,WAAW,qBAAqB;IACrC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;CACvC;AAqBD,iHAAiH;AACjH,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC,GAC1D,qBAAqB,GAAG,SAAS,CAMnC;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,qBAAqB,GAAG,SAAS,CA2BnG;AAUD;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,gBAAgB,GAAG,IAAI,GAAG,IAAI,CAG7G;AAED,oGAAoG;AACpG,wBAAgB,+BAA+B,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAGjH"}
1
+ {"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../../src/core/worktree-snapshot/records.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,qBAAqB,EAAyB,MAAM,aAAa,CAAC;AAEhF,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAOrE,4GAA4G;AAC5G,MAAM,WAAW,qBAAqB;IACrC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;CACvC;AAaD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAMvD;AAQD,iHAAiH;AACjH,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC,GAC1D,qBAAqB,GAAG,SAAS,CAMnC;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,qBAAqB,GAAG,SAAS,CA2BnG;AAUD;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,gBAAgB,GAAG,IAAI,GAAG,IAAI,CAG7G;AAED,oGAAoG;AACpG,wBAAgB,+BAA+B,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAGjH"}
@@ -1,4 +1,5 @@
1
1
  import { WorkspaceRestoreError } from "./errors.js";
2
+ import { redactUrlCredentials } from "./git.js";
2
3
  const OBJECT_ID = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;
3
4
  const BLOB_HASH = /^[0-9a-f]{64}$/;
4
5
  const SNAPSHOT_ID = /^[0-9a-f]{1,64}$/;
@@ -9,9 +10,22 @@ function isObjectId(value) {
9
10
  function isBlobHash(value) {
10
11
  return typeof value === "string" && BLOB_HASH.test(value);
11
12
  }
12
- /** Whether `remote` can be passed to `git fetch` as a repository: never an option, never a control character. */
13
- function isSafeRemote(remote) {
14
- return remote.length > 0 && !remote.startsWith("-") && !CONTROL_CHARACTER.test(remote);
13
+ /** The transports a restore fetches over, and a restored worktree's repository may name as a remote. */
14
+ const REMOTE_SCHEMES = new Set(["https", "http", "ssh", "git", "file"]);
15
+ /**
16
+ * Whether `remote` is a remote Atomic fetches from and configures: never an option or a control character, without
17
+ * credentials, and a local path, an scp-like `host:path`, or a URL of an allowed transport. A Git remote helper
18
+ * (`ext::`, `<name>::`) or any other scheme is not.
19
+ */
20
+ export function isAllowedRemote(remote) {
21
+ if (remote.length === 0 || remote.startsWith("-") || CONTROL_CHARACTER.test(remote))
22
+ return false;
23
+ if (redactUrlCredentials(remote) !== remote)
24
+ return false;
25
+ if (/^[A-Za-z][A-Za-z0-9+.-]*::/.test(remote))
26
+ return false;
27
+ const scheme = /^([A-Za-z][A-Za-z0-9+.-]*):\/\//.exec(remote)?.[1];
28
+ return scheme === undefined || REMOTE_SCHEMES.has(scheme.toLowerCase());
15
29
  }
16
30
  function firstObjectIdProblem(values, field) {
17
31
  if (!Array.isArray(values))
@@ -21,7 +35,7 @@ function firstObjectIdProblem(values, field) {
21
35
  }
22
36
  /** The first unsafe remote or malformed object id of a binding, or undefined when every value is safe to use. */
23
37
  export function bindingRecordProblem(binding) {
24
- const remote = binding.remotes.findIndex((value) => !isSafeRemote(value));
38
+ const remote = binding.remotes.findIndex((value) => !isAllowedRemote(value));
25
39
  if (remote >= 0)
26
40
  return { field: `remotes[${remote}]`, reason: "unsafe-remote" };
27
41
  if (!isObjectId(binding.head))
@@ -1 +1 @@
1
- {"version":3,"file":"records.js","sourceRoot":"","sources":["../../../src/core/worktree-snapshot/records.ts"],"names":[],"mappings":"AAAA,OAA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AK,IAAI,IAAI,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI;QACnF,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM,EAAE,OAAO,CAAC,MAAM;KACtB,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAC,OAAyB,EAAE,QAAiC;IACtG,MAAM,OAAO,GAAG,oBAAoB,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC,CAAC;IACnH,IAAI,OAAO,KAAK,SAAS;QAAE,MAAM,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,IAAI,IAAI,CAAC,CAAC;AACjF,CAAC;AAED,oGAAoG;AACpG,MAAM,UAAU,+BAA+B,CAAC,aAAgC,EAAE,UAAyB;IAC1G,MAAM,OAAO,GAAG,oBAAoB,CAAC,aAAa,EAAE,sBAAsB,CAAC,CAAC;IAC5E,IAAI,OAAO,KAAK,SAAS;QAAE,MAAM,eAAe,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import { type InvalidSnapshotReason, WorkspaceRestoreError } from \"./errors.ts\";\nimport type { WorkspaceBinding, WorktreeSnapshot } from \"./types.ts\";\n\nconst OBJECT_ID = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;\nconst BLOB_HASH = /^[0-9a-f]{64}$/;\nconst SNAPSHOT_ID = /^[0-9a-f]{1,64}$/;\nconst CONTROL_CHARACTER = /[\\u0000-\\u001f\\u007f]/;\n\n/** The first field of a snapshot or binding record that Git or the filesystem must not receive, and why. */\nexport interface SnapshotRecordProblem {\n\treadonly field: string;\n\treadonly reason: InvalidSnapshotReason;\n}\n\nfunction isObjectId(value: unknown): boolean {\n\treturn typeof value === \"string\" && OBJECT_ID.test(value);\n}\n\nfunction isBlobHash(value: unknown): boolean {\n\treturn typeof value === \"string\" && BLOB_HASH.test(value);\n}\n\n/** Whether `remote` can be passed to `git fetch` as a repository: never an option, never a control character. */\nfunction isSafeRemote(remote: string): boolean {\n\treturn remote.length > 0 && !remote.startsWith(\"-\") && !CONTROL_CHARACTER.test(remote);\n}\n\nfunction firstObjectIdProblem(values: unknown, field: string): SnapshotRecordProblem | undefined {\n\tif (!Array.isArray(values)) return { field, reason: \"invalid-object-id\" };\n\tconst index = values.findIndex((value) => !isObjectId(value));\n\treturn index < 0 ? undefined : { field: `${field}[${index}]`, reason: \"invalid-object-id\" };\n}\n\n/** The first unsafe remote or malformed object id of a binding, or undefined when every value is safe to use. */\nexport function bindingRecordProblem(\n\tbinding: Pick<WorktreeSnapshot, \"remotes\" | \"head\" | \"tree\">,\n): SnapshotRecordProblem | undefined {\n\tconst remote = binding.remotes.findIndex((value) => !isSafeRemote(value));\n\tif (remote >= 0) return { field: `remotes[${remote}]`, reason: \"unsafe-remote\" };\n\tif (!isObjectId(binding.head)) return { field: \"head\", reason: \"invalid-object-id\" };\n\tif (!isObjectId(binding.tree)) return { field: \"tree\", reason: \"invalid-object-id\" };\n\treturn undefined;\n}\n\n/**\n * The first field of a recorded snapshot that is not what Atomic writes: a hex id, safe remotes, Git object ids for\n * every commit and tree, and SHA-256 hashes for every blob. Records come from storage and imports, so they are checked\n * before any value reaches Git or a path.\n */\nexport function snapshotRecordProblem(snapshot: WorktreeSnapshot): SnapshotRecordProblem | undefined {\n\tif (!SNAPSHOT_ID.test(snapshot.id)) return { field: \"id\", reason: \"invalid-snapshot-id\" };\n\tconst binding = bindingRecordProblem(snapshot);\n\tif (binding) return binding;\n\tfor (const [index, link] of snapshot.chain.entries()) {\n\t\tconst entry = (typeof link === \"object\" && link !== null ? link : {}) as { tree?: unknown; patch?: unknown };\n\t\tif (!isObjectId(entry.tree)) return { field: `chain[${index}].tree`, reason: \"invalid-object-id\" };\n\t\tif (entry.patch !== null && !isBlobHash(entry.patch)) {\n\t\t\treturn { field: `chain[${index}].patch`, reason: \"invalid-blob-hash\" };\n\t\t}\n\t}\n\tif (snapshot.bundle !== null) {\n\t\tconst bundle = (typeof snapshot.bundle === \"object\" ? snapshot.bundle : {}) as {\n\t\t\tblob?: unknown;\n\t\t\tcommits?: unknown;\n\t\t};\n\t\tif (!isBlobHash(bundle.blob)) return { field: \"bundle.blob\", reason: \"invalid-blob-hash\" };\n\t\tconst commits = firstObjectIdProblem(bundle.commits, \"bundle.commits\");\n\t\tif (commits) return commits;\n\t}\n\tfor (const [index, omission] of (Array.isArray(snapshot.omitted) ? snapshot.omitted : []).entries()) {\n\t\tif (typeof omission === \"object\" && omission !== null && \"commits\" in omission) {\n\t\t\tconst commits = firstObjectIdProblem(omission.commits, `omitted[${index}].commits`);\n\t\t\tif (commits) return commits;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nfunction invalidSnapshot(problem: SnapshotRecordProblem, snapshotId: string | null): WorkspaceRestoreError {\n\treturn new WorkspaceRestoreError(\"invalid-snapshot\", {\n\t\tsnapshotId: snapshotId !== null && SNAPSHOT_ID.test(snapshotId) ? snapshotId : null,\n\t\tfield: problem.field,\n\t\treason: problem.reason,\n\t});\n}\n\n/**\n * Throws `invalid-snapshot` naming the first unusable field of `binding` or of the `snapshot` it resolves to, before\n * any Git or filesystem work. The offending value is never echoed: it comes from storage and may hold escape codes.\n */\nexport function assertUsableSnapshotRecord(binding: WorkspaceBinding, snapshot: WorktreeSnapshot | null): void {\n\tconst problem = bindingRecordProblem(binding) ?? (snapshot === null ? undefined : snapshotRecordProblem(snapshot));\n\tif (problem !== undefined) throw invalidSnapshot(problem, snapshot?.id ?? null);\n}\n\n/** Throws `invalid-snapshot` unless every prerequisite a bundle header lists is a Git object id. */\nexport function assertUsableBundlePrerequisites(prerequisites: readonly string[], snapshotId: string | null): void {\n\tconst problem = firstObjectIdProblem(prerequisites, \"bundle.prerequisites\");\n\tif (problem !== undefined) throw invalidS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AAU,+BAA+B,CAAC,aAAgC,EAAE,UAAyB;IAC1G,MAAM,OAAO,GAAG,oBAAoB,CAAC,aAAa,EAAE,sBAAsB,CAAC,CAAC;IAC5E,IAAI,OAAO,KAAK,SAAS;QAAE,MAAM,eAAe,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import { type InvalidSnapshotReason, WorkspaceRestoreError } from \"./errors.ts\";\nimport { redactUrlCredentials } from \"./git.ts\";\nimport type { WorkspaceBinding, WorktreeSnapshot } from \"./types.ts\";\n\nconst OBJECT_ID = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;\nconst BLOB_HASH = /^[0-9a-f]{64}$/;\nconst SNAPSHOT_ID = /^[0-9a-f]{1,64}$/;\nconst CONTROL_CHARACTER = /[\\u0000-\\u001f\\u007f]/;\n\n/** The first field of a snapshot or binding record that Git or the filesystem must not receive, and why. */\nexport interface SnapshotRecordProblem {\n\treadonly field: string;\n\treadonly reason: InvalidSnapshotReason;\n}\n\nfunction isObjectId(value: unknown): boolean {\n\treturn typeof value === \"string\" && OBJECT_ID.test(value);\n}\n\nfunction isBlobHash(value: unknown): boolean {\n\treturn typeof value === \"string\" && BLOB_HASH.test(value);\n}\n\n/** The transports a restore fetches over, and a restored worktree's repository may name as a remote. */\nconst REMOTE_SCHEMES = new Set([\"https\", \"http\", \"ssh\", \"git\", \"file\"]);\n\n/**\n * Whether `remote` is a remote Atomic fetches from and configures: never an option or a control character, without\n * credentials, and a local path, an scp-like `host:path`, or a URL of an allowed transport. A Git remote helper\n * (`ext::`, `<name>::`) or any other scheme is not.\n */\nexport function isAllowedRemote(remote: string): boolean {\n\tif (remote.length === 0 || remote.startsWith(\"-\") || CONTROL_CHARACTER.test(remote)) return false;\n\tif (redactUrlCredentials(remote) !== remote) return false;\n\tif (/^[A-Za-z][A-Za-z0-9+.-]*::/.test(remote)) return false;\n\tconst scheme = /^([A-Za-z][A-Za-z0-9+.-]*):\\/\\//.exec(remote)?.[1];\n\treturn scheme === undefined || REMOTE_SCHEMES.has(scheme.toLowerCase());\n}\n\nfunction firstObjectIdProblem(values: unknown, field: string): SnapshotRecordProblem | undefined {\n\tif (!Array.isArray(values)) return { field, reason: \"invalid-object-id\" };\n\tconst index = values.findIndex((value) => !isObjectId(value));\n\treturn index < 0 ? undefined : { field: `${field}[${index}]`, reason: \"invalid-object-id\" };\n}\n\n/** The first unsafe remote or malformed object id of a binding, or undefined when every value is safe to use. */\nexport function bindingRecordProblem(\n\tbinding: Pick<WorktreeSnapshot, \"remotes\" | \"head\" | \"tree\">,\n): SnapshotRecordProblem | undefined {\n\tconst remote = binding.remotes.findIndex((value) => !isAllowedRemote(value));\n\tif (remote >= 0) return { field: `remotes[${remote}]`, reason: \"unsafe-remote\" };\n\tif (!isObjectId(binding.head)) return { field: \"head\", reason: \"invalid-object-id\" };\n\tif (!isObjectId(binding.tree)) return { field: \"tree\", reason: \"invalid-object-id\" };\n\treturn undefined;\n}\n\n/**\n * The first field of a recorded snapshot that is not what Atomic writes: a hex id, safe remotes, Git object ids for\n * every commit and tree, and SHA-256 hashes for every blob. Records come from storage and imports, so they are checked\n * before any value reaches Git or a path.\n */\nexport function snapshotRecordProblem(snapshot: WorktreeSnapshot): SnapshotRecordProblem | undefined {\n\tif (!SNAPSHOT_ID.test(snapshot.id)) return { field: \"id\", reason: \"invalid-snapshot-id\" };\n\tconst binding = bindingRecordProblem(snapshot);\n\tif (binding) return binding;\n\tfor (const [index, link] of snapshot.chain.entries()) {\n\t\tconst entry = (typeof link === \"object\" && link !== null ? link : {}) as { tree?: unknown; patch?: unknown };\n\t\tif (!isObjectId(entry.tree)) return { field: `chain[${index}].tree`, reason: \"invalid-object-id\" };\n\t\tif (entry.patch !== null && !isBlobHash(entry.patch)) {\n\t\t\treturn { field: `chain[${index}].patch`, reason: \"invalid-blob-hash\" };\n\t\t}\n\t}\n\tif (snapshot.bundle !== null) {\n\t\tconst bundle = (typeof snapshot.bundle === \"object\" ? snapshot.bundle : {}) as {\n\t\t\tblob?: unknown;\n\t\t\tcommits?: unknown;\n\t\t};\n\t\tif (!isBlobHash(bundle.blob)) return { field: \"bundle.blob\", reason: \"invalid-blob-hash\" };\n\t\tconst commits = firstObjectIdProblem(bundle.commits, \"bundle.commits\");\n\t\tif (commits) return commits;\n\t}\n\tfor (const [index, omission] of (Array.isArray(snapshot.omitted) ? snapshot.omitted : []).entries()) {\n\t\tif (typeof omission === \"object\" && omission !== null && \"commits\" in omission) {\n\t\t\tconst commits = firstObjectIdProblem(omission.commits, `omitted[${index}].commits`);\n\t\t\tif (commits) return commits;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nfunction invalidSnapshot(problem: SnapshotRecordProblem, snapshotId: string | null): WorkspaceRestoreError {\n\treturn new WorkspaceRestoreError(\"invalid-snapshot\", {\n\t\tsnapshotId: snapshotId !== null && SNAPSHOT_ID.test(snapshotId) ? snapshotId : null,\n\t\tfield: problem.field,\n\t\treason: problem.reason,\n\t});\n}\n\n/**\n * Throws `invalid-snapshot` naming the first unusable field of `binding` or of the `snapshot` it resolves to, before\n * any Git or filesystem work. The offending value is never echoed: it comes from storage and may hold escape codes.\n */\nexport function assertUsableSnapshotRecord(binding: WorkspaceBinding, snapshot: WorktreeSnapshot | null): void {\n\tconst problem = bindingRecordProblem(binding) ?? (snapshot === null ? undefined : snapshotRecordProblem(snapshot));\n\tif (problem !== undefined) throw invalidSnapshot(problem, snapshot?.id ?? null);\n}\n\n/** Throws `invalid-snapshot` unless every prerequisite a bundle header lists is a Git object id. */\nexport function assertUsableBundlePrerequisites(prerequisites: readonly string[], snapshotId: string | null): void {\n\tconst problem = firstObjectIdProblem(prerequisites, \"bundle.prerequisites\");\n\tif (problem !== undefined) throw invalidSnapshot(problem, snapshotId);\n}\n"]}
@@ -1,6 +1,7 @@
1
+ import { WorkspaceRestoreError } from "./errors.ts";
1
2
  import { type GitExecutable } from "./git.ts";
2
3
  import { type WorktreeSnapshotSettingsInput } from "./settings.ts";
3
- import type { SnapshotBlobStore, WorkspaceBinding, WorktreeRestoreWarning, WorktreeSnapshot } from "./types.ts";
4
+ import type { SnapshotBlobStore, WorkspaceBinding, WorktreeDegradedRestore, WorktreeRestoreWarning, WorktreeSnapshot } from "./types.ts";
4
5
  export interface RestoreWorktreeSnapshotOptions {
5
6
  /** New or empty directory for the restored worktree. Default: a new directory under `storeDir`/worktrees. */
6
7
  readonly into?: string;
@@ -34,6 +35,28 @@ export declare function defaultWorktreeSnapshotStoreDir(): string;
34
35
  * command of the restore runs that executable.
35
36
  */
36
37
  export declare function restoreWorktree(target: WorkspaceBinding | WorktreeSnapshot, options?: RestoreWorktreeSnapshotOptions): Promise<RestoredWorktree>;
38
+ /** Whether a degraded restore can follow `error`, the failure of an exact restore. */
39
+ export declare function isDegradableRestoreFailure(error: unknown): error is WorkspaceRestoreError;
40
+ export interface RestoreDegradedWorktreeOptions extends Omit<RestoreWorktreeSnapshotOptions, "into" | "snapshots"> {
41
+ /**
42
+ * Commits close to the snapshot's `HEAD` to try, nearest first, after its pushed base and before its branch tip:
43
+ * the `HEAD`s of the checkout's earlier snapshots, for example.
44
+ */
45
+ readonly candidates?: readonly string[];
46
+ }
47
+ export interface DegradedWorktree {
48
+ readonly path: string;
49
+ readonly degraded: WorktreeDegradedRestore;
50
+ readonly warnings: readonly WorktreeRestoreWarning[];
51
+ }
52
+ /**
53
+ * Restores the best state of `snapshot` that this host can reach after an exact restore failed with `failure` (#4733),
54
+ * into a new worktree: the recorded `HEAD` with the change sets of the patch chain that apply, each whole or not at
55
+ * all, up to the first that cannot; else the closest commit it can fetch from the recorded remotes, trying the
56
+ * snapshot's pushed base, then `candidates`, then the recorded branch's tip. Rejects with `failure` when no commit is
57
+ * reachable, and with `invalid-snapshot` for a record that fails the security checks, before any Git work.
58
+ */
59
+ export declare function restoreDegradedWorktree(snapshot: WorktreeSnapshot, failure: WorkspaceRestoreError, options?: RestoreDegradedWorktreeOptions): Promise<DegradedWorktree>;
37
60
  /**
38
61
  * Removes a worktree that a restore created, for callers that roll back a multi-checkout restore; a path that no
39
62
  * longer exists is already removed. Refuses, with `unsafe-target` (reason `not-restored`), any path that is not a
@@ -1 +1 @@
1
- {"version":3,"file":"restore.d.ts","sourceRoot":"","sources":["../../../src/core/worktree-snapshot/restore.ts"],"names":[],"mappings":"AAyBA,OAAO,EACN,KAAK,aAAa,EAOlB,MAAM,UAAU,CAAC;AAGlB,OAAO,EAGN,KAAK,6BAA6B,EAClC,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEhH,MAAM,WAAW,8BAA8B;IAC9C,6GAA6G;IAC7G,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,kGAAkG;IAClG,QAAQ,CAAC,KAAK,CAAC,EAAE,iBAAiB,CAAC;IACnC,6DAA6D;IAC7D,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACjD,oIAAoI;IACpI,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,sBAAsB,KAAK,IAAI,CAAC;IAC/D,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,aAAa,CAAC;CAC7B;AAED,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC3C,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,SAAS,sBAAsB,EAAE,CAAC;CACrD;AAED,oHAAoH;AACpH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,sBAAsB,E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