open-multi-agent-kit 0.90.9 → 0.91.0

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 (80) hide show
  1. package/CHANGELOG.md +22 -3
  2. package/README.md +14 -1
  3. package/dist/core/agent-session.d.ts +27 -0
  4. package/dist/core/agent-session.d.ts.map +1 -1
  5. package/dist/core/agent-session.js +188 -25
  6. package/dist/core/agent-session.js.map +1 -1
  7. package/dist/core/command-safety.d.ts.map +1 -1
  8. package/dist/core/command-safety.js +0 -8
  9. package/dist/core/command-safety.js.map +1 -1
  10. package/dist/core/footer-data-provider.d.ts +7 -1
  11. package/dist/core/footer-data-provider.d.ts.map +1 -1
  12. package/dist/core/footer-data-provider.js +12 -0
  13. package/dist/core/footer-data-provider.js.map +1 -1
  14. package/dist/core/index.d.ts +1 -0
  15. package/dist/core/index.d.ts.map +1 -1
  16. package/dist/core/index.js +1 -0
  17. package/dist/core/index.js.map +1 -1
  18. package/dist/core/metrics-sampler.d.ts +20 -0
  19. package/dist/core/metrics-sampler.d.ts.map +1 -1
  20. package/dist/core/metrics-sampler.js +52 -0
  21. package/dist/core/metrics-sampler.js.map +1 -1
  22. package/dist/core/model-registry.d.ts.map +1 -1
  23. package/dist/core/model-registry.js +4 -1
  24. package/dist/core/model-registry.js.map +1 -1
  25. package/dist/core/model-resolver.d.ts.map +1 -1
  26. package/dist/core/model-resolver.js +15 -6
  27. package/dist/core/model-resolver.js.map +1 -1
  28. package/dist/core/provider-resilience.d.ts +51 -0
  29. package/dist/core/provider-resilience.d.ts.map +1 -0
  30. package/dist/core/provider-resilience.js +86 -0
  31. package/dist/core/provider-resilience.js.map +1 -0
  32. package/dist/core/run-journal.d.ts.map +1 -1
  33. package/dist/core/run-journal.js +14 -22
  34. package/dist/core/run-journal.js.map +1 -1
  35. package/dist/core/session-termination.d.ts +8 -2
  36. package/dist/core/session-termination.d.ts.map +1 -1
  37. package/dist/core/session-termination.js +45 -3
  38. package/dist/core/session-termination.js.map +1 -1
  39. package/dist/core/settings-manager.d.ts +30 -0
  40. package/dist/core/settings-manager.d.ts.map +1 -1
  41. package/dist/core/settings-manager.js +17 -0
  42. package/dist/core/settings-manager.js.map +1 -1
  43. package/dist/core/tools/grep.d.ts.map +1 -1
  44. package/dist/core/tools/grep.js +47 -0
  45. package/dist/core/tools/grep.js.map +1 -1
  46. package/dist/core/tools/omp-pure-seams.d.ts +41 -0
  47. package/dist/core/tools/omp-pure-seams.d.ts.map +1 -0
  48. package/dist/core/tools/omp-pure-seams.js +142 -0
  49. package/dist/core/tools/omp-pure-seams.js.map +1 -0
  50. package/dist/core/tools/omp-seam-runtime.d.ts +100 -0
  51. package/dist/core/tools/omp-seam-runtime.d.ts.map +1 -0
  52. package/dist/core/tools/omp-seam-runtime.js +40 -0
  53. package/dist/core/tools/omp-seam-runtime.js.map +1 -0
  54. package/dist/core/tools/read.d.ts.map +1 -1
  55. package/dist/core/tools/read.js +34 -1
  56. package/dist/core/tools/read.js.map +1 -1
  57. package/dist/modes/interactive/components/footer.d.ts +1 -1
  58. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  59. package/dist/modes/interactive/components/footer.js +11 -8
  60. package/dist/modes/interactive/components/footer.js.map +1 -1
  61. package/dist/modes/interactive/theme/omk-aurora-dark.json +80 -0
  62. package/dist/modes/interactive/theme/omk-aurora-light.json +80 -0
  63. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  64. package/dist/modes/interactive/theme/theme.js +5 -0
  65. package/dist/modes/interactive/theme/theme.js.map +1 -1
  66. package/docs/adaptorch-preview.md +1 -1
  67. package/docs/provider-resilience.md +87 -0
  68. package/docs/settings.md +30 -0
  69. package/docs/themes.md +2 -0
  70. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  71. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  72. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  73. package/examples/extensions/gondolin/package-lock.json +2 -2
  74. package/examples/extensions/gondolin/package.json +1 -1
  75. package/examples/extensions/sandbox/package-lock.json +2 -2
  76. package/examples/extensions/sandbox/package.json +1 -1
  77. package/examples/extensions/with-deps/package-lock.json +2 -2
  78. package/examples/extensions/with-deps/package.json +1 -1
  79. package/npm-shrinkwrap.json +22 -13
  80. package/package.json +6 -5
@@ -1 +1 @@
1
- {"version":3,"file":"grep.js","sourceRoot":"","sources":["../../../src/core/tools/grep.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,wDAAwD,CAAC;AAEjF,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EACN,iBAAiB,EACjB,UAAU,EACV,oBAAoB,EAEpB,YAAY,EACZ,YAAY,GACZ,MAAM,eAAe,CAAC;AAEvB,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,0CAA0C,EAAE,CAAC;IACjF,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,0DAA0D,EAAE,C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AAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;6BAC9D,CAAC,CACF,CAAC;wBAAA,CACF,CAAC,CAAC;oBACJ,CAAC;oBAAC,OAAO,GAAG,EAAE,CAAC;wBACd,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,GAAY,CAAC,CAAC,CAAC;oBACpC,CAAC;gBAAA,CACD,CAAC,EAAE,CAAC;YAAA,CACL,CAAC,CAAC;QAAA,CACH;QACD,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE;YAChC,MAAM,IAAI,GAAI,OAAO,CAAC,aAAkC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;YAC1C,OAAO,IAAI,CAAC;QAAA,CACZ;QACD,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;YAC7C,MAAM,IAAI,GAAI,OAAO,CAAC,aAAkC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAa,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;YAClF,OAAO,IAAI,CAAC;QAAA,CACZ;KACD,CAAC;AAAA,CACF;AAED,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAyB,EAAgC;IACpG,OAAO,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AAAA,CAClE","sourcesContent":["import { readFile as fsReadFile, stat as fsStat } from \"node:fs/promises\";\nimport { createInterface } from \"node:readline\";\nimport { spawn } from \"child_process\";\nimport type { AgentTool } from \"omk-agent-core\";\nimport { Text } from \"omk-tui\";\nimport path from \"path\";\nimport { type Static, Type } from \"typebox\";\nimport { keyHint } from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport { ensureTool } from \"../../utils/tools-manager.ts\";\nimport type { ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\nimport { getTextOutput, invalidArgText, shortenPath, str } from \"./render-utils.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport {\n\tDEFAULT_MAX_BYTES,\n\tformatSize,\n\tGREP_MAX_LINE_LENGTH,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n} from \"./truncate.ts\";\n\nconst grepSchema = Type.Object({\n\tpattern: Type.String({ description: \"Search pattern (regex or literal string)\" }),\n\tpath: Type.Optional(Type.String({ description: \"Directory or file to search (default: current directory)\" })),\n\tglob: Type.Optional(Type.String({ description: \"Filter files by glob pattern, e.g. '*.ts' or '**/*.spec.ts'\" })),\n\tignoreCase: Type.Optional(Type.Boolean({ description: \"Case-insensitive search (default: false)\" })),\n\tliteral: Type.Optional(\n\t\tType.Boolean({ description: \"Treat pattern as literal string instead of regex (default: false)\" }),\n\t),\n\tcontext: Type.Optional(\n\t\tType.Number({ description: \"Number of lines to show before and after each match (default: 0)\" }),\n\t),\n\tlimit: Type.Optional(Type.Number({ description: \"Maximum number of matches to return (default: 100)\" })),\n});\n\nexport type GrepToolInput = Static<typeof grepSchema>;\nconst DEFAULT_LIMIT = 100;\n\nexport interface GrepToolDetails {\n\ttruncation?: TruncationResult;\n\tmatchLimitReached?: number;\n\tlinesTruncated?: boolean;\n}\n\n/**\n * Pluggable operations for the grep tool.\n * Override these to delegate search to remote systems (for example SSH).\n */\nexport interface GrepOperations {\n\t/** Check if path is a directory. Throws if path does not exist. */\n\tisDirectory: (absolutePath: string) => Promise<boolean> | boolean;\n\t/** Read file contents for context lines */\n\treadFile: (absolutePath: string) => Promise<string> | string;\n}\n\nconst defaultGrepOperations: GrepOperations = {\n\tisDirectory: async (p) => (await fsStat(p)).isDirectory(),\n\treadFile: (p) => fsReadFile(p, \"utf-8\"),\n};\n\nexport interface GrepToolOptions {\n\t/** Custom operations for grep. Default: local filesystem plus ripgrep */\n\toperations?: GrepOperations;\n}\n\nfunction formatGrepCall(\n\targs: { pattern: string; path?: string; glob?: string; limit?: number } | undefined,\n\ttheme: Theme,\n): string {\n\tconst pattern = str(args?.pattern);\n\tconst rawPath = str(args?.path);\n\tconst path = rawPath !== null ? shortenPath(rawPath || \".\") : null;\n\tconst glob = str(args?.glob);\n\tconst limit = args?.limit;\n\tconst invalidArg = invalidArgText(theme);\n\tlet text =\n\t\ttheme.fg(\"toolTitle\", theme.bold(\"grep\")) +\n\t\t\" \" +\n\t\t(pattern === null ? invalidArg : theme.fg(\"accent\", `/${pattern || \"\"}/`)) +\n\t\ttheme.fg(\"toolOutput\", ` in ${path === null ? invalidArg : path}`);\n\tif (glob) text += theme.fg(\"toolOutput\", ` (${glob})`);\n\tif (limit !== undefined) text += theme.fg(\"toolOutput\", ` limit ${limit}`);\n\treturn text;\n}\n\nfunction formatGrepResult(\n\tresult: {\n\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\tdetails?: GrepToolDetails;\n\t},\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tshowImages: boolean,\n): string {\n\tconst output = getTextOutput(result, showImages).trim();\n\tlet text = \"\";\n\tif (output) {\n\t\tconst lines = output.split(\"\\n\");\n\t\tconst maxLines = options.expanded ? lines.length : 15;\n\t\tconst displayLines = lines.slice(0, maxLines);\n\t\tconst remaining = lines.length - maxLines;\n\t\ttext += `\\n${displayLines.map((line) => theme.fg(\"toolOutput\", line)).join(\"\\n\")}`;\n\t\tif (remaining > 0) {\n\t\t\ttext += `${theme.fg(\"muted\", `\\n... (${remaining} more lines,`)} ${keyHint(\"app.tools.expand\", \"to expand\")})`;\n\t\t}\n\t}\n\n\tconst matchLimit = result.details?.matchLimitReached;\n\tconst truncation = result.details?.truncation;\n\tconst linesTruncated = result.details?.linesTruncated;\n\tif (matchLimit || truncation?.truncated || linesTruncated) {\n\t\tconst warnings: string[] = [];\n\t\tif (matchLimit) warnings.push(`${matchLimit} matches limit`);\n\t\tif (truncation?.truncated) warnings.push(`${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit`);\n\t\tif (linesTruncated) warnings.push(\"some lines truncated\");\n\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: ${warnings.join(\", \")}]`)}`;\n\t}\n\treturn text;\n}\n\nexport function createGrepToolDefinition(\n\tcwd: string,\n\toptions?: GrepToolOptions,\n): ToolDefinition<typeof grepSchema, GrepToolDetails | undefined> {\n\tconst customOps = options?.operations;\n\treturn {\n\t\tname: \"grep\",\n\t\tlabel: \"grep\",\n\t\tdescription: `Search file contents for a pattern. Returns matching lines with file paths and line numbers. Respects .gitignore. Output is truncated to ${DEFAULT_LIMIT} matches or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). Long lines are truncated to ${GREP_MAX_LINE_LENGTH} chars.`,\n\t\tpromptSnippet: \"Search file contents for patterns (respects .gitignore)\",\n\t\tparameters: grepSchema,\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{\n\t\t\t\tpattern,\n\t\t\t\tpath: searchDir,\n\t\t\t\tglob,\n\t\t\t\tignoreCase,\n\t\t\t\tliteral,\n\t\t\t\tcontext,\n\t\t\t\tlimit,\n\t\t\t}: {\n\t\t\t\tpattern: string;\n\t\t\t\tpath?: string;\n\t\t\t\tglob?: string;\n\t\t\t\tignoreCase?: boolean;\n\t\t\t\tliteral?: boolean;\n\t\t\t\tcontext?: number;\n\t\t\t\tlimit?: number;\n\t\t\t},\n\t\t\tsignal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\t_ctx?,\n\t\t) {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet settled = false;\n\t\t\t\tconst settle = (fn: () => void) => {\n\t\t\t\t\tif (!settled) {\n\t\t\t\t\t\tsettled = true;\n\t\t\t\t\t\tfn();\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\t(async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst rgPath = await ensureTool(\"rg\", true);\n\t\t\t\t\t\tif (!rgPath) {\n\t\t\t\t\t\t\tsettle(() => reject(new Error(\"ripgrep (rg) is not available and could not be downloaded\")));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst searchPath = resolveToCwd(searchDir || \".\", cwd);\n\t\t\t\t\t\tconst ops = customOps ?? defaultGrepOperations;\n\t\t\t\t\t\tlet isDirectory: boolean;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tisDirectory = await ops.isDirectory(searchPath);\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\tsettle(() => reject(new Error(`Path not found: ${searchPath}`)));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst contextValue = context && context > 0 ? context : 0;\n\t\t\t\t\t\tconst effectiveLimit = Math.max(1, limit ?? DEFAULT_LIMIT);\n\t\t\t\t\t\tconst formatPath = (filePath: string): string => {\n\t\t\t\t\t\t\tif (isDirectory) {\n\t\t\t\t\t\t\t\tconst relative = path.relative(searchPath, filePath);\n\t\t\t\t\t\t\t\tif (relative && !relative.startsWith(\"..\")) {\n\t\t\t\t\t\t\t\t\treturn relative.replace(/\\\\/g, \"/\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn path.basename(filePath);\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst fileCache = new Map<string, string[]>();\n\t\t\t\t\t\tconst getFileLines = async (filePath: string): Promise<string[]> => {\n\t\t\t\t\t\t\tlet lines = fileCache.get(filePath);\n\t\t\t\t\t\t\tif (!lines) {\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tconst content = await ops.readFile(filePath);\n\t\t\t\t\t\t\t\t\tlines = content.replace(/\\r\\n/g, \"\\n\").replace(/\\r/g, \"\\n\").split(\"\\n\");\n\t\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t\tlines = [];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tfileCache.set(filePath, lines);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn lines;\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst args: string[] = [\"--json\", \"--line-number\", \"--color=never\", \"--hidden\"];\n\t\t\t\t\t\tif (ignoreCase) args.push(\"--ignore-case\");\n\t\t\t\t\t\tif (literal) args.push(\"--fixed-strings\");\n\t\t\t\t\t\tif (glob) args.push(\"--glob\", glob);\n\t\t\t\t\t\targs.push(\"--\", pattern, searchPath);\n\n\t\t\t\t\t\tconst child = spawn(rgPath, args, { stdio: [\"ignore\", \"pipe\", \"pipe\"] });\n\t\t\t\t\t\tconst rl = createInterface({ input: child.stdout });\n\t\t\t\t\t\tlet stderr = \"\";\n\t\t\t\t\t\tlet matchCount = 0;\n\t\t\t\t\t\tlet matchLimitReached = false;\n\t\t\t\t\t\tlet linesTruncated = false;\n\t\t\t\t\t\tlet aborted = false;\n\t\t\t\t\t\tlet killedDueToLimit = false;\n\t\t\t\t\t\tconst outputLines: string[] = [];\n\n\t\t\t\t\t\tconst cleanup = () => {\n\t\t\t\t\t\t\trl.close();\n\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst stopChild = (dueToLimit = false) => {\n\t\t\t\t\t\t\tif (!child.killed) {\n\t\t\t\t\t\t\t\tkilledDueToLimit = dueToLimit;\n\t\t\t\t\t\t\t\tchild.kill();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst onAbort = () => {\n\t\t\t\t\t\t\taborted = true;\n\t\t\t\t\t\t\tstopChild();\n\t\t\t\t\t\t};\n\t\t\t\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t\t\tchild.stderr?.on(\"data\", (chunk) => {\n\t\t\t\t\t\t\tstderr += chunk.toString();\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tconst formatBlock = async (filePath: string, lineNumber: number): Promise<string[]> => {\n\t\t\t\t\t\t\tconst relativePath = formatPath(filePath);\n\t\t\t\t\t\t\tconst lines = await getFileLines(filePath);\n\t\t\t\t\t\t\tif (!lines.length) return [`${relativePath}:${lineNumber}: (unable to read file)`];\n\t\t\t\t\t\t\tconst block: string[] = [];\n\t\t\t\t\t\t\tconst start = contextValue > 0 ? Math.max(1, lineNumber - contextValue) : lineNumber;\n\t\t\t\t\t\t\tconst end = contextValue > 0 ? Math.min(lines.length, lineNumber + contextValue) : lineNumber;\n\t\t\t\t\t\t\tfor (let current = start; current <= end; current++) {\n\t\t\t\t\t\t\t\tconst lineText = lines[current - 1] ?? \"\";\n\t\t\t\t\t\t\t\tconst sanitized = lineText.replace(/\\r/g, \"\");\n\t\t\t\t\t\t\t\tconst isMatchLine = current === lineNumber;\n\t\t\t\t\t\t\t\t// Truncate long lines so grep output stays compact.\n\t\t\t\t\t\t\t\tconst { text: truncatedText, wasTruncated } = truncateLine(sanitized);\n\t\t\t\t\t\t\t\tif (wasTruncated) linesTruncated = true;\n\t\t\t\t\t\t\t\tif (isMatchLine) block.push(`${relativePath}:${current}: ${truncatedText}`);\n\t\t\t\t\t\t\t\telse block.push(`${relativePath}-${current}- ${truncatedText}`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn block;\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\t// Collect matches during streaming, then format them after rg exits.\n\t\t\t\t\t\tconst matches: Array<{ filePath: string; lineNumber: number; lineText?: string }> = [];\n\t\t\t\t\t\trl.on(\"line\", (line) => {\n\t\t\t\t\t\t\tif (!line.trim() || matchCount >= effectiveLimit) return;\n\t\t\t\t\t\t\tlet event: any;\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tevent = JSON.parse(line);\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (event.type === \"match\") {\n\t\t\t\t\t\t\t\tmatchCount++;\n\t\t\t\t\t\t\t\tconst filePath = event.data?.path?.text;\n\t\t\t\t\t\t\t\tconst lineNumber = event.data?.line_number;\n\t\t\t\t\t\t\t\tconst lineText = event.data?.lines?.text;\n\t\t\t\t\t\t\t\tif (filePath && typeof lineNumber === \"number\")\n\t\t\t\t\t\t\t\t\tmatches.push({ filePath, lineNumber, lineText });\n\t\t\t\t\t\t\t\tif (matchCount >= effectiveLimit) {\n\t\t\t\t\t\t\t\t\tmatchLimitReached = true;\n\t\t\t\t\t\t\t\t\tstopChild(true);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tchild.on(\"error\", (error) => {\n\t\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\t\tsettle(() => reject(new Error(`Failed to run ripgrep: ${error.message}`)));\n\t\t\t\t\t\t});\n\t\t\t\t\t\tchild.on(\"close\", async (code) => {\n\t\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\t\tif (aborted) {\n\t\t\t\t\t\t\t\tsettle(() => reject(new Error(\"Operation aborted\")));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!killedDueToLimit && code !== 0 && code !== 1) {\n\t\t\t\t\t\t\t\tconst errorMsg = stderr.trim() || `ripgrep exited with code ${code}`;\n\t\t\t\t\t\t\t\tsettle(() => reject(new Error(errorMsg)));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (matchCount === 0) {\n\t\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\t\tresolve({ content: [{ type: \"text\", text: \"No matches found\" }], details: undefined }),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Format matches after streaming finishes so custom readFile() backends can be async.\n\t\t\t\t\t\t\tfor (const match of matches) {\n\t\t\t\t\t\t\t\tif (contextValue === 0 && match.lineText !== undefined) {\n\t\t\t\t\t\t\t\t\tconst relativePath = formatPath(match.filePath);\n\t\t\t\t\t\t\t\t\tconst sanitized = match.lineText\n\t\t\t\t\t\t\t\t\t\t.replace(/\\r\\n/g, \"\\n\")\n\t\t\t\t\t\t\t\t\t\t.replace(/\\r/g, \"\")\n\t\t\t\t\t\t\t\t\t\t.replace(/\\n$/, \"\");\n\t\t\t\t\t\t\t\t\tconst { text: truncatedText, wasTruncated } = truncateLine(sanitized);\n\t\t\t\t\t\t\t\t\tif (wasTruncated) linesTruncated = true;\n\t\t\t\t\t\t\t\t\toutputLines.push(`${relativePath}:${match.lineNumber}: ${truncatedText}`);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tconst block = await formatBlock(match.filePath, match.lineNumber);\n\t\t\t\t\t\t\t\t\toutputLines.push(...block);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst rawOutput = outputLines.join(\"\\n\");\n\t\t\t\t\t\t\t// Apply byte truncation. There is no line limit here because the match limit already capped rows.\n\t\t\t\t\t\t\tconst truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });\n\t\t\t\t\t\t\tlet output = truncation.content;\n\t\t\t\t\t\t\tconst details: GrepToolDetails = {};\n\t\t\t\t\t\t\t// Build actionable notices for truncation and match limits.\n\t\t\t\t\t\t\tconst notices: string[] = [];\n\t\t\t\t\t\t\tif (matchLimitReached) {\n\t\t\t\t\t\t\t\tnotices.push(\n\t\t\t\t\t\t\t\t\t`${effectiveLimit} matches limit reached. Use limit=${effectiveLimit * 2} for more, or refine pattern`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tdetails.matchLimitReached = effectiveLimit;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (truncation.truncated) {\n\t\t\t\t\t\t\t\tnotices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);\n\t\t\t\t\t\t\t\tdetails.truncation = truncation;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (linesTruncated) {\n\t\t\t\t\t\t\t\tnotices.push(\n\t\t\t\t\t\t\t\t\t`Some lines truncated to ${GREP_MAX_LINE_LENGTH} chars. Use read tool to see full lines`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tdetails.linesTruncated = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (notices.length > 0) output += `\\n\\n[${notices.join(\". \")}]`;\n\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: output }],\n\t\t\t\t\t\t\t\t\tdetails: Object.keys(details).length > 0 ? details : undefined,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tsettle(() => reject(err as Error));\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t});\n\t\t},\n\t\trenderCall(args, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatGrepCall(args, theme));\n\t\t\treturn text;\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatGrepResult(result as any, options, theme, context.showImages));\n\t\t\treturn text;\n\t\t},\n\t};\n}\n\nexport function createGrepTool(cwd: string, options?: GrepToolOptions): AgentTool<typeof grepSchema> {\n\treturn wrapToolDefinition(createGrepToolDefinition(cwd, options));\n}\n"]}
1
+ {"version":3,"file":"grep.js","sourceRoot":"","sources":["../../../src/core/tools/grep.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,wDAAwD,CAAC;AAEjF,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAG1D,OAAO,EACN,eAAe,EACf,WAAW,EAEX,UAAU,IAAI,aAAa,EAC3B,aAAa,IAAI,gBAAgB,GACjC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EACN,iBAAiB,EACjB,UAAU,EACV,oBAAoB,EAEpB,YAAY,EACZ,YAAY,GACZ,MAAM,eAAe,CAAC;AAEvB,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,0CAA0C,EAAE,CAAC;IACjF,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,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ACZ;QACD,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;YAC7C,MAAM,IAAI,GAAI,OAAO,CAAC,aAAkC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAa,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;YAClF,OAAO,IAAI,CAAC;QAAA,CACZ;KACD,CAAC;AAAA,CACF;AAED,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAyB,EAAgC;IACpG,OAAO,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AAAA,CAClE","sourcesContent":["import { readFile as fsReadFile, stat as fsStat } from \"node:fs/promises\";\nimport { createInterface } from \"node:readline\";\nimport { spawn } from \"child_process\";\nimport type { AgentTool } from \"omk-agent-core\";\nimport { Text } from \"omk-tui\";\nimport path from \"path\";\nimport { type Static, Type } from \"typebox\";\nimport { keyHint } from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport { ensureTool } from \"../../utils/tools-manager.ts\";\nimport type { ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport type { OmpPureSeams } from \"./omp-pure-seams.ts\";\nimport {\n\tformatOmpIssues,\n\tgetOmpSeams,\n\ttype OmpSearchPlan,\n\tplanSearch as ompPlanSearch,\n\tpresentSearch as ompPresentSearch,\n} from \"./omp-seam-runtime.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\nimport { getTextOutput, invalidArgText, shortenPath, str } from \"./render-utils.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport {\n\tDEFAULT_MAX_BYTES,\n\tformatSize,\n\tGREP_MAX_LINE_LENGTH,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n} from \"./truncate.ts\";\n\nconst grepSchema = Type.Object({\n\tpattern: Type.String({ description: \"Search pattern (regex or literal string)\" }),\n\tpath: Type.Optional(Type.String({ description: \"Directory or file to search (default: current directory)\" })),\n\tglob: Type.Optional(Type.String({ description: \"Filter files by glob pattern, e.g. '*.ts' or '**/*.spec.ts'\" })),\n\tignoreCase: Type.Optional(Type.Boolean({ description: \"Case-insensitive search (default: false)\" })),\n\tliteral: Type.Optional(\n\t\tType.Boolean({ description: \"Treat pattern as literal string instead of regex (default: false)\" }),\n\t),\n\tcontext: Type.Optional(\n\t\tType.Number({ description: \"Number of lines to show before and after each match (default: 0)\" }),\n\t),\n\tlimit: Type.Optional(Type.Number({ description: \"Maximum number of matches to return (default: 100)\" })),\n});\n\nexport type GrepToolInput = Static<typeof grepSchema>;\nconst DEFAULT_LIMIT = 100;\n\nexport interface GrepToolDetails {\n\ttruncation?: TruncationResult;\n\tmatchLimitReached?: number;\n\tlinesTruncated?: boolean;\n}\n\n/**\n * Pluggable operations for the grep tool.\n * Override these to delegate search to remote systems (for example SSH).\n */\nexport interface GrepOperations {\n\t/** Check if path is a directory. Throws if path does not exist. */\n\tisDirectory: (absolutePath: string) => Promise<boolean> | boolean;\n\t/** Read file contents for context lines */\n\treadFile: (absolutePath: string) => Promise<string> | string;\n}\n\nconst defaultGrepOperations: GrepOperations = {\n\tisDirectory: async (p) => (await fsStat(p)).isDirectory(),\n\treadFile: (p) => fsReadFile(p, \"utf-8\"),\n};\n\nexport interface GrepToolOptions {\n\t/** Custom operations for grep. Default: local filesystem plus ripgrep */\n\toperations?: GrepOperations;\n}\n\nfunction formatGrepCall(\n\targs: { pattern: string; path?: string; glob?: string; limit?: number } | undefined,\n\ttheme: Theme,\n): string {\n\tconst pattern = str(args?.pattern);\n\tconst rawPath = str(args?.path);\n\tconst path = rawPath !== null ? shortenPath(rawPath || \".\") : null;\n\tconst glob = str(args?.glob);\n\tconst limit = args?.limit;\n\tconst invalidArg = invalidArgText(theme);\n\tlet text =\n\t\ttheme.fg(\"toolTitle\", theme.bold(\"grep\")) +\n\t\t\" \" +\n\t\t(pattern === null ? invalidArg : theme.fg(\"accent\", `/${pattern || \"\"}/`)) +\n\t\ttheme.fg(\"toolOutput\", ` in ${path === null ? invalidArg : path}`);\n\tif (glob) text += theme.fg(\"toolOutput\", ` (${glob})`);\n\tif (limit !== undefined) text += theme.fg(\"toolOutput\", ` limit ${limit}`);\n\treturn text;\n}\n\nfunction formatGrepResult(\n\tresult: {\n\t\tcontent: Array<{ type: string; text?: string; data?: string; mimeType?: string }>;\n\t\tdetails?: GrepToolDetails;\n\t},\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tshowImages: boolean,\n): string {\n\tconst output = getTextOutput(result, showImages).trim();\n\tlet text = \"\";\n\tif (output) {\n\t\tconst lines = output.split(\"\\n\");\n\t\tconst maxLines = options.expanded ? lines.length : 15;\n\t\tconst displayLines = lines.slice(0, maxLines);\n\t\tconst remaining = lines.length - maxLines;\n\t\ttext += `\\n${displayLines.map((line) => theme.fg(\"toolOutput\", line)).join(\"\\n\")}`;\n\t\tif (remaining > 0) {\n\t\t\ttext += `${theme.fg(\"muted\", `\\n... (${remaining} more lines,`)} ${keyHint(\"app.tools.expand\", \"to expand\")})`;\n\t\t}\n\t}\n\n\tconst matchLimit = result.details?.matchLimitReached;\n\tconst truncation = result.details?.truncation;\n\tconst linesTruncated = result.details?.linesTruncated;\n\tif (matchLimit || truncation?.truncated || linesTruncated) {\n\t\tconst warnings: string[] = [];\n\t\tif (matchLimit) warnings.push(`${matchLimit} matches limit`);\n\t\tif (truncation?.truncated) warnings.push(`${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit`);\n\t\tif (linesTruncated) warnings.push(\"some lines truncated\");\n\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: ${warnings.join(\", \")}]`)}`;\n\t}\n\treturn text;\n}\n\nexport function createGrepToolDefinition(\n\tcwd: string,\n\toptions?: GrepToolOptions,\n): ToolDefinition<typeof grepSchema, GrepToolDetails | undefined> {\n\tconst customOps = options?.operations;\n\treturn {\n\t\tname: \"grep\",\n\t\tlabel: \"grep\",\n\t\tdescription: `Search file contents for a pattern. Returns matching lines with file paths and line numbers. Respects .gitignore. Output is truncated to ${DEFAULT_LIMIT} matches or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). Long lines are truncated to ${GREP_MAX_LINE_LENGTH} chars.`,\n\t\tpromptSnippet: \"Search file contents for patterns (respects .gitignore)\",\n\t\tparameters: grepSchema,\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{\n\t\t\t\tpattern,\n\t\t\t\tpath: searchDir,\n\t\t\t\tglob,\n\t\t\t\tignoreCase,\n\t\t\t\tliteral,\n\t\t\t\tcontext,\n\t\t\t\tlimit,\n\t\t\t}: {\n\t\t\t\tpattern: string;\n\t\t\t\tpath?: string;\n\t\t\t\tglob?: string;\n\t\t\t\tignoreCase?: boolean;\n\t\t\t\tliteral?: boolean;\n\t\t\t\tcontext?: number;\n\t\t\t\tlimit?: number;\n\t\t\t},\n\t\t\tsignal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\t_ctx?,\n\t\t) {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlet settled = false;\n\t\t\t\tconst settle = (fn: () => void) => {\n\t\t\t\t\tif (!settled) {\n\t\t\t\t\t\tsettled = true;\n\t\t\t\t\t\tfn();\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\t(async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst rgPath = await ensureTool(\"rg\", true);\n\t\t\t\t\t\tif (!rgPath) {\n\t\t\t\t\t\t\tsettle(() => reject(new Error(\"ripgrep (rg) is not available and could not be downloaded\")));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst searchPath = resolveToCwd(searchDir || \".\", cwd);\n\t\t\t\t\t\tconst ops = customOps ?? defaultGrepOperations;\n\t\t\t\t\t\tlet isDirectory: boolean;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tisDirectory = await ops.isDirectory(searchPath);\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\tsettle(() => reject(new Error(`Path not found: ${searchPath}`)));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst ompSeamsPromise = getOmpSeams();\n\t\t\t\t\t\tlet ompSeams: OmpPureSeams | undefined;\n\t\t\t\t\t\tlet ompSearchPlan: OmpSearchPlan | undefined;\n\t\t\t\t\t\tif (ompSeamsPromise) {\n\t\t\t\t\t\t\t// OMP seam path (OMK_OMP_SEAMS=1): validation and presentation are\n\t\t\t\t\t\t\t// delegated to the vendored pure search seam (ADR-OMP-008). The host\n\t\t\t\t\t\t\t// still runs ripgrep and supplies the raw matches.\n\t\t\t\t\t\t\tompSeams = await ompSeamsPromise;\n\t\t\t\t\t\t\tconst planned = ompPlanSearch(ompSeams, {\n\t\t\t\t\t\t\t\tpattern,\n\t\t\t\t\t\t\t\tpath: searchDir,\n\t\t\t\t\t\t\t\tglob,\n\t\t\t\t\t\t\t\tignoreCase,\n\t\t\t\t\t\t\t\tliteral,\n\t\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\t\tlimit,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tif (!planned.ok) {\n\t\t\t\t\t\t\t\tthrow new Error(`Invalid search request: ${formatOmpIssues(planned.issues)}`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tompSearchPlan = planned.plan;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst contextValue = context && context > 0 ? context : 0;\n\t\t\t\t\t\tconst effectiveLimit = Math.max(1, limit ?? DEFAULT_LIMIT);\n\t\t\t\t\t\tconst formatPath = (filePath: string): string => {\n\t\t\t\t\t\t\tif (isDirectory) {\n\t\t\t\t\t\t\t\tconst relative = path.relative(searchPath, filePath);\n\t\t\t\t\t\t\t\tif (relative && !relative.startsWith(\"..\")) {\n\t\t\t\t\t\t\t\t\treturn relative.replace(/\\\\/g, \"/\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn path.basename(filePath);\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst fileCache = new Map<string, string[]>();\n\t\t\t\t\t\tconst getFileLines = async (filePath: string): Promise<string[]> => {\n\t\t\t\t\t\t\tlet lines = fileCache.get(filePath);\n\t\t\t\t\t\t\tif (!lines) {\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tconst content = await ops.readFile(filePath);\n\t\t\t\t\t\t\t\t\tlines = content.replace(/\\r\\n/g, \"\\n\").replace(/\\r/g, \"\\n\").split(\"\\n\");\n\t\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t\tlines = [];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tfileCache.set(filePath, lines);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn lines;\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst args: string[] = [\"--json\", \"--line-number\", \"--color=never\", \"--hidden\"];\n\t\t\t\t\t\tif (ignoreCase) args.push(\"--ignore-case\");\n\t\t\t\t\t\tif (literal) args.push(\"--fixed-strings\");\n\t\t\t\t\t\tif (glob) args.push(\"--glob\", glob);\n\t\t\t\t\t\targs.push(\"--\", pattern, searchPath);\n\n\t\t\t\t\t\tconst child = spawn(rgPath, args, { stdio: [\"ignore\", \"pipe\", \"pipe\"] });\n\t\t\t\t\t\tconst rl = createInterface({ input: child.stdout });\n\t\t\t\t\t\tlet stderr = \"\";\n\t\t\t\t\t\tlet matchCount = 0;\n\t\t\t\t\t\tlet matchLimitReached = false;\n\t\t\t\t\t\tlet linesTruncated = false;\n\t\t\t\t\t\tlet aborted = false;\n\t\t\t\t\t\tlet killedDueToLimit = false;\n\t\t\t\t\t\tconst outputLines: string[] = [];\n\n\t\t\t\t\t\tconst cleanup = () => {\n\t\t\t\t\t\t\trl.close();\n\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst stopChild = (dueToLimit = false) => {\n\t\t\t\t\t\t\tif (!child.killed) {\n\t\t\t\t\t\t\t\tkilledDueToLimit = dueToLimit;\n\t\t\t\t\t\t\t\tchild.kill();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst onAbort = () => {\n\t\t\t\t\t\t\taborted = true;\n\t\t\t\t\t\t\tstopChild();\n\t\t\t\t\t\t};\n\t\t\t\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t\t\tchild.stderr?.on(\"data\", (chunk) => {\n\t\t\t\t\t\t\tstderr += chunk.toString();\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tconst formatBlock = async (filePath: string, lineNumber: number): Promise<string[]> => {\n\t\t\t\t\t\t\tconst relativePath = formatPath(filePath);\n\t\t\t\t\t\t\tconst lines = await getFileLines(filePath);\n\t\t\t\t\t\t\tif (!lines.length) return [`${relativePath}:${lineNumber}: (unable to read file)`];\n\t\t\t\t\t\t\tconst block: string[] = [];\n\t\t\t\t\t\t\tconst start = contextValue > 0 ? Math.max(1, lineNumber - contextValue) : lineNumber;\n\t\t\t\t\t\t\tconst end = contextValue > 0 ? Math.min(lines.length, lineNumber + contextValue) : lineNumber;\n\t\t\t\t\t\t\tfor (let current = start; current <= end; current++) {\n\t\t\t\t\t\t\t\tconst lineText = lines[current - 1] ?? \"\";\n\t\t\t\t\t\t\t\tconst sanitized = lineText.replace(/\\r/g, \"\");\n\t\t\t\t\t\t\t\tconst isMatchLine = current === lineNumber;\n\t\t\t\t\t\t\t\t// Truncate long lines so grep output stays compact.\n\t\t\t\t\t\t\t\tconst { text: truncatedText, wasTruncated } = truncateLine(sanitized);\n\t\t\t\t\t\t\t\tif (wasTruncated) linesTruncated = true;\n\t\t\t\t\t\t\t\tif (isMatchLine) block.push(`${relativePath}:${current}: ${truncatedText}`);\n\t\t\t\t\t\t\t\telse block.push(`${relativePath}-${current}- ${truncatedText}`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn block;\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\t// Collect matches during streaming, then format them after rg exits.\n\t\t\t\t\t\tconst matches: Array<{ filePath: string; lineNumber: number; lineText?: string }> = [];\n\t\t\t\t\t\trl.on(\"line\", (line) => {\n\t\t\t\t\t\t\tif (!line.trim() || matchCount >= effectiveLimit) return;\n\t\t\t\t\t\t\tlet event: any;\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tevent = JSON.parse(line);\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (event.type === \"match\") {\n\t\t\t\t\t\t\t\tmatchCount++;\n\t\t\t\t\t\t\t\tconst filePath = event.data?.path?.text;\n\t\t\t\t\t\t\t\tconst lineNumber = event.data?.line_number;\n\t\t\t\t\t\t\t\tconst lineText = event.data?.lines?.text;\n\t\t\t\t\t\t\t\tif (filePath && typeof lineNumber === \"number\")\n\t\t\t\t\t\t\t\t\tmatches.push({ filePath, lineNumber, lineText });\n\t\t\t\t\t\t\t\tif (matchCount >= effectiveLimit) {\n\t\t\t\t\t\t\t\t\tmatchLimitReached = true;\n\t\t\t\t\t\t\t\t\tstopChild(true);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tchild.on(\"error\", (error) => {\n\t\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\t\tsettle(() => reject(new Error(`Failed to run ripgrep: ${error.message}`)));\n\t\t\t\t\t\t});\n\t\t\t\t\t\tchild.on(\"close\", async (code) => {\n\t\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\t\tif (aborted) {\n\t\t\t\t\t\t\t\tsettle(() => reject(new Error(\"Operation aborted\")));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!killedDueToLimit && code !== 0 && code !== 1) {\n\t\t\t\t\t\t\t\tconst errorMsg = stderr.trim() || `ripgrep exited with code ${code}`;\n\t\t\t\t\t\t\t\tsettle(() => reject(new Error(errorMsg)));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (matchCount === 0) {\n\t\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\t\tresolve({ content: [{ type: \"text\", text: \"No matches found\" }], details: undefined }),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// OMP seam presentation: the seam renders a deterministic grouped\n\t\t\t\t\t\t\t// view of host-supplied matches. Context-line rendering has no seam\n\t\t\t\t\t\t\t// equivalent, so context>0 keeps the OMK formatter (ADR-OMP-008).\n\t\t\t\t\t\t\tif (ompSeams && ompSearchPlan && contextValue === 0) {\n\t\t\t\t\t\t\t\tconst hostMatches = matches.map((match) => ({\n\t\t\t\t\t\t\t\t\tfile: formatPath(match.filePath),\n\t\t\t\t\t\t\t\t\tline: match.lineNumber,\n\t\t\t\t\t\t\t\t\ttext: (match.lineText ?? \"\").replace(/\\r\\n/g, \"\\n\").replace(/\\r/g, \"\").replace(/\\n$/, \"\"),\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t\tconst presented = ompPresentSearch(ompSeams, ompSearchPlan, hostMatches);\n\t\t\t\t\t\t\t\tif (!presented.ok) {\n\t\t\t\t\t\t\t\t\tsettle(() => reject(new Error(\"OMP search presentation failed: conflicting match facts\")));\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\tlet output = presented.presentation.text;\n\t\t\t\t\t\t\t\tif (matchLimitReached) {\n\t\t\t\t\t\t\t\t\toutput += `\\n\\n[${effectiveLimit} matches limit reached. Use limit=${effectiveLimit * 2} for more, or refine pattern]`;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: output }],\n\t\t\t\t\t\t\t\t\t\tdetails: matchLimitReached ? { matchLimitReached: effectiveLimit } : undefined,\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Format matches after streaming finishes so custom readFile() backends can be async.\n\t\t\t\t\t\t\tfor (const match of matches) {\n\t\t\t\t\t\t\t\tif (contextValue === 0 && match.lineText !== undefined) {\n\t\t\t\t\t\t\t\t\tconst relativePath = formatPath(match.filePath);\n\t\t\t\t\t\t\t\t\tconst sanitized = match.lineText\n\t\t\t\t\t\t\t\t\t\t.replace(/\\r\\n/g, \"\\n\")\n\t\t\t\t\t\t\t\t\t\t.replace(/\\r/g, \"\")\n\t\t\t\t\t\t\t\t\t\t.replace(/\\n$/, \"\");\n\t\t\t\t\t\t\t\t\tconst { text: truncatedText, wasTruncated } = truncateLine(sanitized);\n\t\t\t\t\t\t\t\t\tif (wasTruncated) linesTruncated = true;\n\t\t\t\t\t\t\t\t\toutputLines.push(`${relativePath}:${match.lineNumber}: ${truncatedText}`);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tconst block = await formatBlock(match.filePath, match.lineNumber);\n\t\t\t\t\t\t\t\t\toutputLines.push(...block);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst rawOutput = outputLines.join(\"\\n\");\n\t\t\t\t\t\t\t// Apply byte truncation. There is no line limit here because the match limit already capped rows.\n\t\t\t\t\t\t\tconst truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });\n\t\t\t\t\t\t\tlet output = truncation.content;\n\t\t\t\t\t\t\tconst details: GrepToolDetails = {};\n\t\t\t\t\t\t\t// Build actionable notices for truncation and match limits.\n\t\t\t\t\t\t\tconst notices: string[] = [];\n\t\t\t\t\t\t\tif (matchLimitReached) {\n\t\t\t\t\t\t\t\tnotices.push(\n\t\t\t\t\t\t\t\t\t`${effectiveLimit} matches limit reached. Use limit=${effectiveLimit * 2} for more, or refine pattern`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tdetails.matchLimitReached = effectiveLimit;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (truncation.truncated) {\n\t\t\t\t\t\t\t\tnotices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);\n\t\t\t\t\t\t\t\tdetails.truncation = truncation;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (linesTruncated) {\n\t\t\t\t\t\t\t\tnotices.push(\n\t\t\t\t\t\t\t\t\t`Some lines truncated to ${GREP_MAX_LINE_LENGTH} chars. Use read tool to see full lines`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tdetails.linesTruncated = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (notices.length > 0) output += `\\n\\n[${notices.join(\". \")}]`;\n\t\t\t\t\t\t\tsettle(() =>\n\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: output }],\n\t\t\t\t\t\t\t\t\tdetails: Object.keys(details).length > 0 ? details : undefined,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tsettle(() => reject(err as Error));\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t});\n\t\t},\n\t\trenderCall(args, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatGrepCall(args, theme));\n\t\t\treturn text;\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatGrepResult(result as any, options, theme, context.showImages));\n\t\t\treturn text;\n\t\t},\n\t};\n}\n\nexport function createGrepTool(cwd: string, options?: GrepToolOptions): AgentTool<typeof grepSchema> {\n\treturn wrapToolDefinition(createGrepToolDefinition(cwd, options));\n}\n"]}
@@ -0,0 +1,41 @@
1
+ /** Error categories raised by the OMP pure-seam loader. */
2
+ export type OmpSeamsErrorCode = "DISABLED" | "VENDOR_NOT_FOUND" | "INVALID_SEAM";
3
+ /** Typed error thrown by {@link loadOmpPureSeams}. */
4
+ export declare class OmpSeamsError extends Error {
5
+ readonly code: OmpSeamsErrorCode;
6
+ constructor(code: OmpSeamsErrorCode, message: string);
7
+ }
8
+ /** The validated set of pure oh-my-pi seams (data/proposal-only). */
9
+ export interface OmpPureSeams {
10
+ planRead(input: unknown): unknown;
11
+ presentRead(plan: unknown, file: unknown): unknown;
12
+ planSearch(input: unknown): unknown;
13
+ presentSearch(plan: unknown, matches: unknown, sourceDigests?: unknown): unknown;
14
+ parseHashlineProposal(text: string): unknown;
15
+ hashProposalLine(text: string): Promise<string>;
16
+ hashProposalSource(text: string): Promise<string>;
17
+ }
18
+ /**
19
+ * Returns true unless the seams feature is explicitly disabled
20
+ * (OMK_OMP_SEAMS === "0"). Enabled by default per ADR-OMP-009.
21
+ * Reads `process.env` when no record is supplied.
22
+ */
23
+ export declare function isOmpSeamsEnabled(env?: Record<string, string | undefined>): boolean;
24
+ /**
25
+ * Walks up from `startDir` (inclusive) looking for a `vendor/oh-my-pi`
26
+ * directory that contains the pure read seam marker file. Returns the absolute
27
+ * vendor directory path, or `undefined` when none is found within the level cap.
28
+ */
29
+ export declare function resolveOmpVendorDir(startDir: string): string | undefined;
30
+ /**
31
+ * Loads and validates the three pure seam modules from the vendored oh-my-pi
32
+ * tree and returns a frozen {@link OmpPureSeams} record. Throws
33
+ * {@link OmpSeamsError} with code DISABLED when the feature is off,
34
+ * VENDOR_NOT_FOUND when the vendor tree cannot be located, or INVALID_SEAM when
35
+ * any expected export is missing or not a function.
36
+ */
37
+ export declare function loadOmpPureSeams(options?: {
38
+ vendorDir?: string;
39
+ env?: Record<string, string | undefined>;
40
+ }): Promise<OmpPureSeams>;
41
+ //# sourceMappingURL=omp-pure-seams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"omp-pure-seams.d.ts","sourceRoot":"","sources":["../../../src/core/tools/omp-pure-seams.ts"],"names":[],"mappings":"AAiBA,2DAA2D;AAC3D,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,kBAAkB,GAAG,cAAc,CAAC;AAEjF,sDAAsD;AACtD,qBAAa,aAAc,SAAQ,KAAK;IACvC,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IAEjC,YAAY,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,EAInD;CACD;AAED,qEAAqE;AACrE,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC;IAClC,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;IACnD,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC;IACpC,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IACjF,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7C,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAChD,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAClD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,OAAO,CAGnF;AAMD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAWxE;AAwBD;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,CAAC,EAAE;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CACzC,GAAG,OAAO,CAAC,YAAY,CAAC,CAqExB","sourcesContent":["/**\n * Flag-gated loader for the vendored oh-my-pi \"pure\" read/search/hashline seams.\n *\n * These seams are pure data/proposal-only functions (planning + presentation +\n * hashline parsing). They do NOT touch edit/write/file-mutation paths. The\n * loader is enabled by default and opts out via OMK_OMP_SEAMS=0 (ADR-OMP-009);\n * when disabled it throws DISABLED and tool behavior falls back to the\n * pre-seam implementation byte-identically.\n *\n * The file is erasable TypeScript: no `enum`, no parameter properties, no `as`,\n * no non-null assertions, no `any` annotations, and no runtime dependencies\n * beyond the Node.js standard library.\n */\nimport { existsSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, resolve } from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\n\n/** Error categories raised by the OMP pure-seam loader. */\nexport type OmpSeamsErrorCode = \"DISABLED\" | \"VENDOR_NOT_FOUND\" | \"INVALID_SEAM\";\n\n/** Typed error thrown by {@link loadOmpPureSeams}. */\nexport class OmpSeamsError extends Error {\n\treadonly code: OmpSeamsErrorCode;\n\n\tconstructor(code: OmpSeamsErrorCode, message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"OmpSeamsError\";\n\t\tthis.code = code;\n\t}\n}\n\n/** The validated set of pure oh-my-pi seams (data/proposal-only). */\nexport interface OmpPureSeams {\n\tplanRead(input: unknown): unknown;\n\tpresentRead(plan: unknown, file: unknown): unknown;\n\tplanSearch(input: unknown): unknown;\n\tpresentSearch(plan: unknown, matches: unknown, sourceDigests?: unknown): unknown;\n\tparseHashlineProposal(text: string): unknown;\n\thashProposalLine(text: string): Promise<string>;\n\thashProposalSource(text: string): Promise<string>;\n}\n\n/**\n * Returns true unless the seams feature is explicitly disabled\n * (OMK_OMP_SEAMS === \"0\"). Enabled by default per ADR-OMP-009.\n * Reads `process.env` when no record is supplied.\n */\nexport function isOmpSeamsEnabled(env?: Record<string, string | undefined>): boolean {\n\tconst source: Record<string, string | undefined> = env ?? process.env;\n\treturn source.OMK_OMP_SEAMS !== \"0\";\n}\n\nconst VENDOR_SEGMENT = join(\"vendor\", \"oh-my-pi\");\nconst VENDOR_MARKER = join(VENDOR_SEGMENT, \"packages\", \"coding-agent\", \"src\", \"pure\", \"read.ts\");\nconst MAX_WALK_UP_LEVELS = 8;\n\n/**\n * Walks up from `startDir` (inclusive) looking for a `vendor/oh-my-pi`\n * directory that contains the pure read seam marker file. Returns the absolute\n * vendor directory path, or `undefined` when none is found within the level cap.\n */\nexport function resolveOmpVendorDir(startDir: string): string | undefined {\n\tlet dir = isAbsolute(startDir) ? startDir : resolve(startDir);\n\tfor (let level = 0; level <= MAX_WALK_UP_LEVELS; level += 1) {\n\t\tif (existsSync(join(dir, VENDOR_MARKER))) {\n\t\t\treturn join(dir, VENDOR_SEGMENT);\n\t\t}\n\t\tconst parent = dirname(dir);\n\t\tif (parent === dir) break;\n\t\tdir = parent;\n\t}\n\treturn undefined;\n}\n\n// --- internal narrowing helpers (no `as`; type guards carry the signatures) ---\n\ntype SeamFn = (...args: never[]) => unknown;\ntype SeamAsyncStrFn = (...args: never[]) => Promise<string>;\n\nfunction isSeamFn(member: unknown): member is SeamFn {\n\treturn typeof member === \"function\";\n}\n\nfunction isSeamAsyncStrFn(member: unknown): member is SeamAsyncStrFn {\n\treturn typeof member === \"function\";\n}\n\nfunction expectFn<T extends SeamFn>(member: unknown, guard: (m: unknown) => m is T, name: string): T {\n\tif (guard(member)) return member;\n\tthrow new OmpSeamsError(\"INVALID_SEAM\", `OMP seam missing or non-function: ${name}`);\n}\n\nconst READ_SEAM = join(\"packages\", \"coding-agent\", \"src\", \"pure\", \"read.ts\");\nconst SEARCH_SEAM = join(\"packages\", \"coding-agent\", \"src\", \"pure\", \"search.ts\");\nconst PROPOSAL_SEAM = join(\"packages\", \"hashline\", \"src\", \"proposal.ts\");\n\n/**\n * Loads and validates the three pure seam modules from the vendored oh-my-pi\n * tree and returns a frozen {@link OmpPureSeams} record. Throws\n * {@link OmpSeamsError} with code DISABLED when the feature is off,\n * VENDOR_NOT_FOUND when the vendor tree cannot be located, or INVALID_SEAM when\n * any expected export is missing or not a function.\n */\nexport async function loadOmpPureSeams(options?: {\n\tvendorDir?: string;\n\tenv?: Record<string, string | undefined>;\n}): Promise<OmpPureSeams> {\n\tconst env: Record<string, string | undefined> = options?.env ?? process.env;\n\tif (!isOmpSeamsEnabled(env)) {\n\t\tthrow new OmpSeamsError(\n\t\t\t\"DISABLED\",\n\t\t\t\"OMP pure seams are disabled (OMK_OMP_SEAMS=0; unset or set to any other value to enable).\",\n\t\t);\n\t}\n\n\tlet vendorDir: string | undefined = options?.vendorDir ?? env.OMK_OMP_VENDOR_DIR;\n\tif (!vendorDir) {\n\t\tconst moduleUrl = new URL(\".\", import.meta.url);\n\t\tif (moduleUrl.protocol !== \"file:\") {\n\t\t\tthrow new OmpSeamsError(\n\t\t\t\t\"VENDOR_NOT_FOUND\",\n\t\t\t\t\"OMP vendor dir was not provided and the module is not a file URL.\",\n\t\t\t);\n\t\t}\n\t\tconst found = resolveOmpVendorDir(fileURLToPath(moduleUrl));\n\t\tif (!found) {\n\t\t\tthrow new OmpSeamsError(\n\t\t\t\t\"VENDOR_NOT_FOUND\",\n\t\t\t\t\"OMP vendor dir not found by walking up from the module directory.\",\n\t\t\t);\n\t\t}\n\t\tvendorDir = found;\n\t}\n\tif (!existsSync(vendorDir)) {\n\t\tthrow new OmpSeamsError(\"VENDOR_NOT_FOUND\", `OMP vendor dir does not exist: ${vendorDir}`);\n\t}\n\n\tconst readUrl = pathToFileURL(join(vendorDir, READ_SEAM)).href;\n\tconst searchUrl = pathToFileURL(join(vendorDir, SEARCH_SEAM)).href;\n\tconst proposalUrl = pathToFileURL(join(vendorDir, PROPOSAL_SEAM)).href;\n\n\tconst readMod = await import(readUrl);\n\tconst searchMod = await import(searchUrl);\n\tconst proposalMod = await import(proposalUrl);\n\n\t// Validate every expected member up front so the INVALID_SEAM error lists\n\t// ALL missing/non-function exports, not just the first one encountered.\n\tconst expected: ReadonlyArray<readonly [unknown, string]> = [\n\t\t[readMod.planRead, \"planRead\"],\n\t\t[readMod.presentRead, \"presentRead\"],\n\t\t[searchMod.planSearch, \"planSearch\"],\n\t\t[searchMod.presentSearch, \"presentSearch\"],\n\t\t[proposalMod.parseHashlineProposal, \"parseHashlineProposal\"],\n\t\t[proposalMod.hashProposalLine, \"hashProposalLine\"],\n\t\t[proposalMod.hashProposalSource, \"hashProposalSource\"],\n\t];\n\tconst missing: string[] = [];\n\tfor (const [member, name] of expected) {\n\t\tif (typeof member !== \"function\") missing.push(name);\n\t}\n\tif (missing.length > 0) {\n\t\tthrow new OmpSeamsError(\"INVALID_SEAM\", `OMP seams missing or non-function: ${missing.join(\", \")}`);\n\t}\n\n\tconst rec: OmpPureSeams = {\n\t\tplanRead: expectFn(readMod.planRead, isSeamFn, \"planRead\"),\n\t\tpresentRead: expectFn(readMod.presentRead, isSeamFn, \"presentRead\"),\n\t\tplanSearch: expectFn(searchMod.planSearch, isSeamFn, \"planSearch\"),\n\t\tpresentSearch: expectFn(searchMod.presentSearch, isSeamFn, \"presentSearch\"),\n\t\tparseHashlineProposal: expectFn(proposalMod.parseHashlineProposal, isSeamFn, \"parseHashlineProposal\"),\n\t\thashProposalLine: expectFn(proposalMod.hashProposalLine, isSeamAsyncStrFn, \"hashProposalLine\"),\n\t\thashProposalSource: expectFn(proposalMod.hashProposalSource, isSeamAsyncStrFn, \"hashProposalSource\"),\n\t};\n\tObject.freeze(rec);\n\treturn rec;\n}\n"]}
@@ -0,0 +1,142 @@
1
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
2
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
3
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
4
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
5
+ });
6
+ }
7
+ return path;
8
+ };
9
+ /**
10
+ * Flag-gated loader for the vendored oh-my-pi "pure" read/search/hashline seams.
11
+ *
12
+ * These seams are pure data/proposal-only functions (planning + presentation +
13
+ * hashline parsing). They do NOT touch edit/write/file-mutation paths. The
14
+ * loader is enabled by default and opts out via OMK_OMP_SEAMS=0 (ADR-OMP-009);
15
+ * when disabled it throws DISABLED and tool behavior falls back to the
16
+ * pre-seam implementation byte-identically.
17
+ *
18
+ * The file is erasable TypeScript: no `enum`, no parameter properties, no `as`,
19
+ * no non-null assertions, no `any` annotations, and no runtime dependencies
20
+ * beyond the Node.js standard library.
21
+ */
22
+ import { existsSync } from "node:fs";
23
+ import { dirname, isAbsolute, join, resolve } from "node:path";
24
+ import { fileURLToPath, pathToFileURL } from "node:url";
25
+ /** Typed error thrown by {@link loadOmpPureSeams}. */
26
+ export class OmpSeamsError extends Error {
27
+ code;
28
+ constructor(code, message) {
29
+ super(message);
30
+ this.name = "OmpSeamsError";
31
+ this.code = code;
32
+ }
33
+ }
34
+ /**
35
+ * Returns true unless the seams feature is explicitly disabled
36
+ * (OMK_OMP_SEAMS === "0"). Enabled by default per ADR-OMP-009.
37
+ * Reads `process.env` when no record is supplied.
38
+ */
39
+ export function isOmpSeamsEnabled(env) {
40
+ const source = env ?? process.env;
41
+ return source.OMK_OMP_SEAMS !== "0";
42
+ }
43
+ const VENDOR_SEGMENT = join("vendor", "oh-my-pi");
44
+ const VENDOR_MARKER = join(VENDOR_SEGMENT, "packages", "coding-agent", "src", "pure", "read.ts");
45
+ const MAX_WALK_UP_LEVELS = 8;
46
+ /**
47
+ * Walks up from `startDir` (inclusive) looking for a `vendor/oh-my-pi`
48
+ * directory that contains the pure read seam marker file. Returns the absolute
49
+ * vendor directory path, or `undefined` when none is found within the level cap.
50
+ */
51
+ export function resolveOmpVendorDir(startDir) {
52
+ let dir = isAbsolute(startDir) ? startDir : resolve(startDir);
53
+ for (let level = 0; level <= MAX_WALK_UP_LEVELS; level += 1) {
54
+ if (existsSync(join(dir, VENDOR_MARKER))) {
55
+ return join(dir, VENDOR_SEGMENT);
56
+ }
57
+ const parent = dirname(dir);
58
+ if (parent === dir)
59
+ break;
60
+ dir = parent;
61
+ }
62
+ return undefined;
63
+ }
64
+ function isSeamFn(member) {
65
+ return typeof member === "function";
66
+ }
67
+ function isSeamAsyncStrFn(member) {
68
+ return typeof member === "function";
69
+ }
70
+ function expectFn(member, guard, name) {
71
+ if (guard(member))
72
+ return member;
73
+ throw new OmpSeamsError("INVALID_SEAM", `OMP seam missing or non-function: ${name}`);
74
+ }
75
+ const READ_SEAM = join("packages", "coding-agent", "src", "pure", "read.ts");
76
+ const SEARCH_SEAM = join("packages", "coding-agent", "src", "pure", "search.ts");
77
+ const PROPOSAL_SEAM = join("packages", "hashline", "src", "proposal.ts");
78
+ /**
79
+ * Loads and validates the three pure seam modules from the vendored oh-my-pi
80
+ * tree and returns a frozen {@link OmpPureSeams} record. Throws
81
+ * {@link OmpSeamsError} with code DISABLED when the feature is off,
82
+ * VENDOR_NOT_FOUND when the vendor tree cannot be located, or INVALID_SEAM when
83
+ * any expected export is missing or not a function.
84
+ */
85
+ export async function loadOmpPureSeams(options) {
86
+ const env = options?.env ?? process.env;
87
+ if (!isOmpSeamsEnabled(env)) {
88
+ throw new OmpSeamsError("DISABLED", "OMP pure seams are disabled (OMK_OMP_SEAMS=0; unset or set to any other value to enable).");
89
+ }
90
+ let vendorDir = options?.vendorDir ?? env.OMK_OMP_VENDOR_DIR;
91
+ if (!vendorDir) {
92
+ const moduleUrl = new URL(".", import.meta.url);
93
+ if (moduleUrl.protocol !== "file:") {
94
+ throw new OmpSeamsError("VENDOR_NOT_FOUND", "OMP vendor dir was not provided and the module is not a file URL.");
95
+ }
96
+ const found = resolveOmpVendorDir(fileURLToPath(moduleUrl));
97
+ if (!found) {
98
+ throw new OmpSeamsError("VENDOR_NOT_FOUND", "OMP vendor dir not found by walking up from the module directory.");
99
+ }
100
+ vendorDir = found;
101
+ }
102
+ if (!existsSync(vendorDir)) {
103
+ throw new OmpSeamsError("VENDOR_NOT_FOUND", `OMP vendor dir does not exist: ${vendorDir}`);
104
+ }
105
+ const readUrl = pathToFileURL(join(vendorDir, READ_SEAM)).href;
106
+ const searchUrl = pathToFileURL(join(vendorDir, SEARCH_SEAM)).href;
107
+ const proposalUrl = pathToFileURL(join(vendorDir, PROPOSAL_SEAM)).href;
108
+ const readMod = await import(__rewriteRelativeImportExtension(readUrl));
109
+ const searchMod = await import(__rewriteRelativeImportExtension(searchUrl));
110
+ const proposalMod = await import(__rewriteRelativeImportExtension(proposalUrl));
111
+ // Validate every expected member up front so the INVALID_SEAM error lists
112
+ // ALL missing/non-function exports, not just the first one encountered.
113
+ const expected = [
114
+ [readMod.planRead, "planRead"],
115
+ [readMod.presentRead, "presentRead"],
116
+ [searchMod.planSearch, "planSearch"],
117
+ [searchMod.presentSearch, "presentSearch"],
118
+ [proposalMod.parseHashlineProposal, "parseHashlineProposal"],
119
+ [proposalMod.hashProposalLine, "hashProposalLine"],
120
+ [proposalMod.hashProposalSource, "hashProposalSource"],
121
+ ];
122
+ const missing = [];
123
+ for (const [member, name] of expected) {
124
+ if (typeof member !== "function")
125
+ missing.push(name);
126
+ }
127
+ if (missing.length > 0) {
128
+ throw new OmpSeamsError("INVALID_SEAM", `OMP seams missing or non-function: ${missing.join(", ")}`);
129
+ }
130
+ const rec = {
131
+ planRead: expectFn(readMod.planRead, isSeamFn, "planRead"),
132
+ presentRead: expectFn(readMod.presentRead, isSeamFn, "presentRead"),
133
+ planSearch: expectFn(searchMod.planSearch, isSeamFn, "planSearch"),
134
+ presentSearch: expectFn(searchMod.presentSearch, isSeamFn, "presentSearch"),
135
+ parseHashlineProposal: expectFn(proposalMod.parseHashlineProposal, isSeamFn, "parseHashlineProposal"),
136
+ hashProposalLine: expectFn(proposalMod.hashProposalLine, isSeamAsyncStrFn, "hashProposalLine"),
137
+ hashProposalSource: expectFn(proposalMod.hashProposalSource, isSeamAsyncStrFn, "hashProposalSource"),
138
+ };
139
+ Object.freeze(rec);
140
+ return rec;
141
+ }
142
+ //# sourceMappingURL=omp-pure-seams.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"omp-pure-seams.js","sourceRoot":"","sources":["../../../src/core/tools/omp-pure-seams.ts"],"names":[],"mappings":";;;;;;;;AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAKxD,sDAAsD;AACtD,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC9B,IAAI,CAAoB;IAEjC,YAAY,IAAuB,EAAE,OAAe,EAAE;QACrD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAAA,CACjB;CACD;AAaD;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAwC,EAAW;IACpF,MAAM,MAAM,GAAuC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IACtE,OAAO,MAAM,CAAC,aAAa,KAAK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AM,IAAI,aAAa,CAAC,cAAc,EAAE,sCAAsC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACrG,CAAC;IAED,MAAM,GAAG,GAAiB;QACzB,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,CAAC;QAC1D,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,QAAQ,EAAE,aAAa,CAAC;QACnE,UAAU,EAAE,QAAQ,CAAC,SAAS,CAAC,UAAU,EAAE,QAAQ,EAAE,YAAY,CAAC;QAClE,aAAa,EAAE,QAAQ,CAAC,SAAS,CAAC,aAAa,EAAE,QAAQ,EAAE,eAAe,CAAC;QAC3E,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAAC,qBAAqB,EAAE,QAAQ,EAAE,uBAAuB,CAAC;QACrG,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,CAAC;QAC9F,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAAC,kBAAkB,EAAE,gBAAgB,EAAE,oBAAoB,CAAC;KACpG,CAAC;IACF,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,GAAG,CAAC;AAAA,CACX","sourcesContent":["/**\n * Flag-gated loader for the vendored oh-my-pi \"pure\" read/search/hashline seams.\n *\n * These seams are pure data/proposal-only functions (planning + presentation +\n * hashline parsing). They do NOT touch edit/write/file-mutation paths. The\n * loader is enabled by default and opts out via OMK_OMP_SEAMS=0 (ADR-OMP-009);\n * when disabled it throws DISABLED and tool behavior falls back to the\n * pre-seam implementation byte-identically.\n *\n * The file is erasable TypeScript: no `enum`, no parameter properties, no `as`,\n * no non-null assertions, no `any` annotations, and no runtime dependencies\n * beyond the Node.js standard library.\n */\nimport { existsSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, resolve } from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\n\n/** Error categories raised by the OMP pure-seam loader. */\nexport type OmpSeamsErrorCode = \"DISABLED\" | \"VENDOR_NOT_FOUND\" | \"INVALID_SEAM\";\n\n/** Typed error thrown by {@link loadOmpPureSeams}. */\nexport class OmpSeamsError extends Error {\n\treadonly code: OmpSeamsErrorCode;\n\n\tconstructor(code: OmpSeamsErrorCode, message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"OmpSeamsError\";\n\t\tthis.code = code;\n\t}\n}\n\n/** The validated set of pure oh-my-pi seams (data/proposal-only). */\nexport interface OmpPureSeams {\n\tplanRead(input: unknown): unknown;\n\tpresentRead(plan: unknown, file: unknown): unknown;\n\tplanSearch(input: unknown): unknown;\n\tpresentSearch(plan: unknown, matches: unknown, sourceDigests?: unknown): unknown;\n\tparseHashlineProposal(text: string): unknown;\n\thashProposalLine(text: string): Promise<string>;\n\thashProposalSource(text: string): Promise<string>;\n}\n\n/**\n * Returns true unless the seams feature is explicitly disabled\n * (OMK_OMP_SEAMS === \"0\"). Enabled by default per ADR-OMP-009.\n * Reads `process.env` when no record is supplied.\n */\nexport function isOmpSeamsEnabled(env?: Record<string, string | undefined>): boolean {\n\tconst source: Record<string, string | undefined> = env ?? process.env;\n\treturn source.OMK_OMP_SEAMS !== \"0\";\n}\n\nconst VENDOR_SEGMENT = join(\"vendor\", \"oh-my-pi\");\nconst VENDOR_MARKER = join(VENDOR_SEGMENT, \"packages\", \"coding-agent\", \"src\", \"pure\", \"read.ts\");\nconst MAX_WALK_UP_LEVELS = 8;\n\n/**\n * Walks up from `startDir` (inclusive) looking for a `vendor/oh-my-pi`\n * directory that contains the pure read seam marker file. Returns the absolute\n * vendor directory path, or `undefined` when none is found within the level cap.\n */\nexport function resolveOmpVendorDir(startDir: string): string | undefined {\n\tlet dir = isAbsolute(startDir) ? startDir : resolve(startDir);\n\tfor (let level = 0; level <= MAX_WALK_UP_LEVELS; level += 1) {\n\t\tif (existsSync(join(dir, VENDOR_MARKER))) {\n\t\t\treturn join(dir, VENDOR_SEGMENT);\n\t\t}\n\t\tconst parent = dirname(dir);\n\t\tif (parent === dir) break;\n\t\tdir = parent;\n\t}\n\treturn undefined;\n}\n\n// --- internal narrowing helpers (no `as`; type guards carry the signatures) ---\n\ntype SeamFn = (...args: never[]) => unknown;\ntype SeamAsyncStrFn = (...args: never[]) => Promise<string>;\n\nfunction isSeamFn(member: unknown): member is SeamFn {\n\treturn typeof member === \"function\";\n}\n\nfunction isSeamAsyncStrFn(member: unknown): member is SeamAsyncStrFn {\n\treturn typeof member === \"function\";\n}\n\nfunction expectFn<T extends SeamFn>(member: unknown, guard: (m: unknown) => m is T, name: string): T {\n\tif (guard(member)) return member;\n\tthrow new OmpSeamsError(\"INVALID_SEAM\", `OMP seam missing or non-function: ${name}`);\n}\n\nconst READ_SEAM = join(\"packages\", \"coding-agent\", \"src\", \"pure\", \"read.ts\");\nconst SEARCH_SEAM = join(\"packages\", \"coding-agent\", \"src\", \"pure\", \"search.ts\");\nconst PROPOSAL_SEAM = join(\"packages\", \"hashline\", \"src\", \"proposal.ts\");\n\n/**\n * Loads and validates the three pure seam modules from the vendored oh-my-pi\n * tree and returns a frozen {@link OmpPureSeams} record. Throws\n * {@link OmpSeamsError} with code DISABLED when the feature is off,\n * VENDOR_NOT_FOUND when the vendor tree cannot be located, or INVALID_SEAM when\n * any expected export is missing or not a function.\n */\nexport async function loadOmpPureSeams(options?: {\n\tvendorDir?: string;\n\tenv?: Record<string, string | undefined>;\n}): Promise<OmpPureSeams> {\n\tconst env: Record<string, string | undefined> = options?.env ?? process.env;\n\tif (!isOmpSeamsEnabled(env)) {\n\t\tthrow new OmpSeamsError(\n\t\t\t\"DISABLED\",\n\t\t\t\"OMP pure seams are disabled (OMK_OMP_SEAMS=0; unset or set to any other value to enable).\",\n\t\t);\n\t}\n\n\tlet vendorDir: string | undefined = options?.vendorDir ?? env.OMK_OMP_VENDOR_DIR;\n\tif (!vendorDir) {\n\t\tconst moduleUrl = new URL(\".\", import.meta.url);\n\t\tif (moduleUrl.protocol !== \"file:\") {\n\t\t\tthrow new OmpSeamsError(\n\t\t\t\t\"VENDOR_NOT_FOUND\",\n\t\t\t\t\"OMP vendor dir was not provided and the module is not a file URL.\",\n\t\t\t);\n\t\t}\n\t\tconst found = resolveOmpVendorDir(fileURLToPath(moduleUrl));\n\t\tif (!found) {\n\t\t\tthrow new OmpSeamsError(\n\t\t\t\t\"VENDOR_NOT_FOUND\",\n\t\t\t\t\"OMP vendor dir not found by walking up from the module directory.\",\n\t\t\t);\n\t\t}\n\t\tvendorDir = found;\n\t}\n\tif (!existsSync(vendorDir)) {\n\t\tthrow new OmpSeamsError(\"VENDOR_NOT_FOUND\", `OMP vendor dir does not exist: ${vendorDir}`);\n\t}\n\n\tconst readUrl = pathToFileURL(join(vendorDir, READ_SEAM)).href;\n\tconst searchUrl = pathToFileURL(join(vendorDir, SEARCH_SEAM)).href;\n\tconst proposalUrl = pathToFileURL(join(vendorDir, PROPOSAL_SEAM)).href;\n\n\tconst readMod = await import(readUrl);\n\tconst searchMod = await import(searchUrl);\n\tconst proposalMod = await import(proposalUrl);\n\n\t// Validate every expected member up front so the INVALID_SEAM error lists\n\t// ALL missing/non-function exports, not just the first one encountered.\n\tconst expected: ReadonlyArray<readonly [unknown, string]> = [\n\t\t[readMod.planRead, \"planRead\"],\n\t\t[readMod.presentRead, \"presentRead\"],\n\t\t[searchMod.planSearch, \"planSearch\"],\n\t\t[searchMod.presentSearch, \"presentSearch\"],\n\t\t[proposalMod.parseHashlineProposal, \"parseHashlineProposal\"],\n\t\t[proposalMod.hashProposalLine, \"hashProposalLine\"],\n\t\t[proposalMod.hashProposalSource, \"hashProposalSource\"],\n\t];\n\tconst missing: string[] = [];\n\tfor (const [member, name] of expected) {\n\t\tif (typeof member !== \"function\") missing.push(name);\n\t}\n\tif (missing.length > 0) {\n\t\tthrow new OmpSeamsError(\"INVALID_SEAM\", `OMP seams missing or non-function: ${missing.join(\", \")}`);\n\t}\n\n\tconst rec: OmpPureSeams = {\n\t\tplanRead: expectFn(readMod.planRead, isSeamFn, \"planRead\"),\n\t\tpresentRead: expectFn(readMod.presentRead, isSeamFn, \"presentRead\"),\n\t\tplanSearch: expectFn(searchMod.planSearch, isSeamFn, \"planSearch\"),\n\t\tpresentSearch: expectFn(searchMod.presentSearch, isSeamFn, \"presentSearch\"),\n\t\tparseHashlineProposal: expectFn(proposalMod.parseHashlineProposal, isSeamFn, \"parseHashlineProposal\"),\n\t\thashProposalLine: expectFn(proposalMod.hashProposalLine, isSeamAsyncStrFn, \"hashProposalLine\"),\n\t\thashProposalSource: expectFn(proposalMod.hashProposalSource, isSeamAsyncStrFn, \"hashProposalSource\"),\n\t};\n\tObject.freeze(rec);\n\treturn rec;\n}\n"]}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Typed runtime facade over the flag-gated OMP pure-seam loader.
3
+ *
4
+ * Wiring boundary for I2 (ADR-OMP-008/009): the read and grep tools delegate
5
+ * request validation and output presentation to the vendored OMP pure seams.
6
+ * Enabled by default; `OMK_OMP_SEAMS=0` opts out and tool behavior falls back
7
+ * byte-identically to the pre-seam implementation.
8
+ *
9
+ * The loader exposes unknown-in/unknown-out signatures; all structural
10
+ * assertions live in this single file so tool code stays clean.
11
+ */
12
+ import { type OmpPureSeams } from "./omp-pure-seams.ts";
13
+ export interface OmpIssue {
14
+ readonly field: string;
15
+ readonly code: string;
16
+ readonly message: string;
17
+ }
18
+ export interface OmpReadPlan {
19
+ readonly path: string;
20
+ readonly offset: number;
21
+ readonly limit: number;
22
+ }
23
+ export type OmpReadPlanResult = {
24
+ readonly ok: true;
25
+ readonly plan: OmpReadPlan;
26
+ } | {
27
+ readonly ok: false;
28
+ readonly issues: readonly OmpIssue[];
29
+ };
30
+ export interface OmpReadPresentation {
31
+ readonly text: string;
32
+ readonly window: {
33
+ readonly startLine: number;
34
+ readonly endLine: number;
35
+ readonly totalLines: number;
36
+ readonly truncated: boolean;
37
+ };
38
+ }
39
+ export type OmpReadPresentResult = {
40
+ readonly ok: true;
41
+ readonly presentation: OmpReadPresentation;
42
+ } | {
43
+ readonly ok: false;
44
+ readonly conflicts: readonly unknown[];
45
+ };
46
+ export interface OmpSearchPlan {
47
+ readonly pattern: string;
48
+ readonly path: string;
49
+ readonly glob?: string;
50
+ readonly ignoreCase: boolean;
51
+ readonly literal: boolean;
52
+ readonly context: number;
53
+ readonly limit: number;
54
+ }
55
+ export type OmpSearchPlanResult = {
56
+ readonly ok: true;
57
+ readonly plan: OmpSearchPlan;
58
+ } | {
59
+ readonly ok: false;
60
+ readonly issues: readonly OmpIssue[];
61
+ };
62
+ export interface OmpSearchHostMatch {
63
+ readonly file: string;
64
+ readonly line: number;
65
+ readonly column?: number;
66
+ readonly text: string;
67
+ readonly expectedLineHash?: string;
68
+ }
69
+ export interface OmpSearchPresentation {
70
+ readonly text: string;
71
+ readonly totalMatches: number;
72
+ readonly omittedMatches: number;
73
+ readonly truncated: boolean;
74
+ }
75
+ export type OmpSearchPresentResult = {
76
+ readonly ok: true;
77
+ readonly presentation: OmpSearchPresentation;
78
+ } | {
79
+ readonly ok: false;
80
+ readonly conflicts: readonly unknown[];
81
+ };
82
+ /**
83
+ * Returns the memoized seam set unless `OMK_OMP_SEAMS=0`; `undefined` when
84
+ * opted out. Loader errors (VENDOR_NOT_FOUND, INVALID_SEAM) propagate to
85
+ * the caller of the returned promise.
86
+ */
87
+ export declare function getOmpSeams(): Promise<OmpPureSeams> | undefined;
88
+ export declare function planRead(seams: OmpPureSeams, input: unknown): OmpReadPlanResult;
89
+ export declare function presentRead(seams: OmpPureSeams, plan: OmpReadPlan, file: {
90
+ text: string;
91
+ sourceDigest?: string;
92
+ lineDigests?: readonly {
93
+ line: number;
94
+ digest: string;
95
+ }[];
96
+ }): OmpReadPresentResult;
97
+ export declare function planSearch(seams: OmpPureSeams, input: unknown): OmpSearchPlanResult;
98
+ export declare function presentSearch(seams: OmpPureSeams, plan: OmpSearchPlan, matches: readonly OmpSearchHostMatch[]): OmpSearchPresentResult;
99
+ export declare function formatOmpIssues(issues: readonly OmpIssue[]): string;
100
+ //# sourceMappingURL=omp-seam-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"omp-seam-runtime.d.ts","sourceRoot":"","sources":["../../../src/core/tools/omp-seam-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAuC,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAE7F,MAAM,WAAW,QAAQ;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,iBAAiB,GAC1B;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;CAAE,GACjD;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,CAAA;CAAE,CAAC;AAEhE,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE;QAChB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;QAC5B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;KAC5B,CAAC;CACF;AAED,MAAM,MAAM,oBAAoB,GAC7B;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QA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M,sBAAsB,GAC/B;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,YAAY,EAAE,qBAAqB,CAAA;CAAE,GACnE;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,OAAO,EAAE,CAAA;CAAE,CAAC;AAIlE;;;;GAIG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC,GAAG,SAAS,CAI/D;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,GAAG,iBAAiB,CAE/E;AAED,wBAAgB,WAAW,CAC1B,KAAK,EAAE,YAAY,EACnB,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,SAAS;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAAE,GACtG,oBAAoB,CAEtB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,GAAG,mBAAmB,CAEnF;AAED,wBAAgB,aAAa,CAC5B,KAAK,EAAE,YAAY,EACnB,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,SAAS,kBAAkB,EAAE,GACpC,sBAAsB,CAExB;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,GAAG,MAAM,CAEnE","sourcesContent":["/**\n * Typed runtime facade over the flag-gated OMP pure-seam loader.\n *\n * Wiring boundary for I2 (ADR-OMP-008/009): the read and grep tools delegate\n * request validation and output presentation to the vendored OMP pure seams.\n * Enabled by default; `OMK_OMP_SEAMS=0` opts out and tool behavior falls back\n * byte-identically to the pre-seam implementation.\n *\n * The loader exposes unknown-in/unknown-out signatures; all structural\n * assertions live in this single file so tool code stays clean.\n */\nimport { isOmpSeamsEnabled, loadOmpPureSeams, type OmpPureSeams } from \"./omp-pure-seams.ts\";\n\nexport interface OmpIssue {\n\treadonly field: string;\n\treadonly code: string;\n\treadonly message: string;\n}\n\nexport interface OmpReadPlan {\n\treadonly path: string;\n\treadonly offset: number;\n\treadonly limit: number;\n}\n\nexport type OmpReadPlanResult =\n\t| { readonly ok: true; readonly plan: OmpReadPlan }\n\t| { readonly ok: false; readonly issues: readonly OmpIssue[] };\n\nexport interface OmpReadPresentation {\n\treadonly text: string;\n\treadonly window: {\n\t\treadonly startLine: number;\n\t\treadonly endLine: number;\n\t\treadonly totalLines: number;\n\t\treadonly truncated: boolean;\n\t};\n}\n\nexport type OmpReadPresentResult =\n\t| { readonly ok: true; readonly presentation: OmpReadPresentation }\n\t| { readonly ok: false; readonly conflicts: readonly unknown[] };\n\nexport interface OmpSearchPlan {\n\treadonly pattern: string;\n\treadonly path: string;\n\treadonly glob?: string;\n\treadonly ignoreCase: boolean;\n\treadonly literal: boolean;\n\treadonly context: number;\n\treadonly limit: number;\n}\n\nexport type OmpSearchPlanResult =\n\t| { readonly ok: true; readonly plan: OmpSearchPlan }\n\t| { readonly ok: false; readonly issues: readonly OmpIssue[] };\n\nexport interface OmpSearchHostMatch {\n\treadonly file: string;\n\treadonly line: number;\n\treadonly column?: number;\n\treadonly text: string;\n\treadonly expectedLineHash?: string;\n}\n\nexport interface OmpSearchPresentation {\n\treadonly text: string;\n\treadonly totalMatches: number;\n\treadonly omittedMatches: number;\n\treadonly truncated: boolean;\n}\n\nexport type OmpSearchPresentResult =\n\t| { readonly ok: true; readonly presentation: OmpSearchPresentation }\n\t| { readonly ok: false; readonly conflicts: readonly unknown[] };\n\nlet cached: Promise<OmpPureSeams> | undefined;\n\n/**\n * Returns the memoized seam set unless `OMK_OMP_SEAMS=0`; `undefined` when\n * opted out. Loader errors (VENDOR_NOT_FOUND, INVALID_SEAM) propagate to\n * the caller of the returned promise.\n */\nexport function getOmpSeams(): Promise<OmpPureSeams> | undefined {\n\tif (!isOmpSeamsEnabled()) return undefined;\n\tcached ??= loadOmpPureSeams();\n\treturn cached;\n}\n\nexport function planRead(seams: OmpPureSeams, input: unknown): OmpReadPlanResult {\n\treturn seams.planRead(input) as OmpReadPlanResult;\n}\n\nexport function presentRead(\n\tseams: OmpPureSeams,\n\tplan: OmpReadPlan,\n\tfile: { text: string; sourceDigest?: string; lineDigests?: readonly { line: number; digest: string }[] },\n): OmpReadPresentResult {\n\treturn seams.presentRead(plan, file) as OmpReadPresentResult;\n}\n\nexport function planSearch(seams: OmpPureSeams, input: unknown): OmpSearchPlanResult {\n\treturn seams.planSearch(input) as OmpSearchPlanResult;\n}\n\nexport function presentSearch(\n\tseams: OmpPureSeams,\n\tplan: OmpSearchPlan,\n\tmatches: readonly OmpSearchHostMatch[],\n): OmpSearchPresentResult {\n\treturn seams.presentSearch(plan, matches) as OmpSearchPresentResult;\n}\n\nexport function formatOmpIssues(issues: readonly OmpIssue[]): string {\n\treturn issues.map((issue) => `${issue.field}: ${issue.message}`).join(\"; \");\n}\n"]}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Typed runtime facade over the flag-gated OMP pure-seam loader.
3
+ *
4
+ * Wiring boundary for I2 (ADR-OMP-008/009): the read and grep tools delegate
5
+ * request validation and output presentation to the vendored OMP pure seams.
6
+ * Enabled by default; `OMK_OMP_SEAMS=0` opts out and tool behavior falls back
7
+ * byte-identically to the pre-seam implementation.
8
+ *
9
+ * The loader exposes unknown-in/unknown-out signatures; all structural
10
+ * assertions live in this single file so tool code stays clean.
11
+ */
12
+ import { isOmpSeamsEnabled, loadOmpPureSeams } from "./omp-pure-seams.js";
13
+ let cached;
14
+ /**
15
+ * Returns the memoized seam set unless `OMK_OMP_SEAMS=0`; `undefined` when
16
+ * opted out. Loader errors (VENDOR_NOT_FOUND, INVALID_SEAM) propagate to
17
+ * the caller of the returned promise.
18
+ */
19
+ export function getOmpSeams() {
20
+ if (!isOmpSeamsEnabled())
21
+ return undefined;
22
+ cached ??= loadOmpPureSeams();
23
+ return cached;
24
+ }
25
+ export function planRead(seams, input) {
26
+ return seams.planRead(input);
27
+ }
28
+ export function presentRead(seams, plan, file) {
29
+ return seams.presentRead(plan, file);
30
+ }
31
+ export function planSearch(seams, input) {
32
+ return seams.planSearch(input);
33
+ }
34
+ export function presentSearch(seams, plan, matches) {
35
+ return seams.presentSearch(plan, matches);
36
+ }
37
+ export function formatOmpIssues(issues) {
38
+ return issues.map((issue) => `${issue.field}: ${issue.message}`).join("; ");
39
+ }
40
+ //# sourceMappingURL=omp-seam-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"omp-seam-runtime.js","sourceRoot":"","sources":["../../../src/core/tools/omp-seam-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAqB,MAAM,qBAAqB,CAAC;AAiE7F,IAAI,MAAyC,CAAC;AAE9C;;;;GAIG;AACH,MAAM,UAAU,WAAW,GAAsC;IAChE,IAAI,CAAC,iBAAiB,EAAE;QAAE,OAAO,SAAS,CAAC;IAC3C,MAAM,KAAK,gBAAgB,EAAE,CAAC;IAC9B,OAAO,MAAM,CAAC;AAAA,CACd;AAED,MAAM,UAAU,QAAQ,CAAC,KAAmB,EAAE,KAAc,EAAqB;IAChF,OAAO,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAsB,CAAC;AAAA,CAClD;AAED,MAAM,UAAU,WAAW,CAC1B,KAAmB,EACnB,IAAiB,EACjB,IAAwG,EACjF;IACvB,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAyB,CAAC;AAAA,CAC7D;AAED,MAAM,UAAU,UAAU,CAAC,KAAmB,EAAE,KAAc,EAAuB;IACpF,OAAO,KAAK,CAAC,UAAU,CAAC,KAAK,CAAwB,CAAC;AAAA,CACtD;AAED,MAAM,UAAU,aAAa,CAC5B,KAAmB,EACnB,IAAmB,EACnB,OAAsC,EACb;IACzB,OAAO,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAA2B,CAAC;AAAA,CACpE;AAED,MAAM,UAAU,eAAe,CAAC,MAA2B,EAAU;IACpE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAAA,CAC5E","sourcesContent":["/**\n * Typed runtime facade over the flag-gated OMP pure-seam loader.\n *\n * Wiring boundary for I2 (ADR-OMP-008/009): the read and grep tools delegate\n * request validation and output presentation to the vendored OMP pure seams.\n * Enabled by default; `OMK_OMP_SEAMS=0` opts out and tool behavior falls back\n * byte-identically to the pre-seam implementation.\n *\n * The loader exposes unknown-in/unknown-out signatures; all structural\n * assertions live in this single file so tool code stays clean.\n */\nimport { isOmpSeamsEnabled, loadOmpPureSeams, type OmpPureSeams } from \"./omp-pure-seams.ts\";\n\nexport interface OmpIssue {\n\treadonly field: string;\n\treadonly code: string;\n\treadonly message: string;\n}\n\nexport interface OmpReadPlan {\n\treadonly path: string;\n\treadonly offset: number;\n\treadonly limit: number;\n}\n\nexport type OmpReadPlanResult =\n\t| { readonly ok: true; readonly plan: OmpReadPlan }\n\t| { readonly ok: false; readonly issues: readonly OmpIssue[] };\n\nexport interface OmpReadPresentation {\n\treadonly text: string;\n\treadonly window: {\n\t\treadonly startLine: number;\n\t\treadonly endLine: number;\n\t\treadonly totalLines: number;\n\t\treadonly truncated: boolean;\n\t};\n}\n\nexport type OmpReadPresentResult =\n\t| { readonly ok: true; readonly presentation: OmpReadPresentation }\n\t| { readonly ok: false; readonly conflicts: readonly unknown[] };\n\nexport interface OmpSearchPlan {\n\treadonly pattern: string;\n\treadonly path: string;\n\treadonly glob?: string;\n\treadonly ignoreCase: boolean;\n\treadonly literal: boolean;\n\treadonly context: number;\n\treadonly limit: number;\n}\n\nexport type OmpSearchPlanResult =\n\t| { readonly ok: true; readonly plan: OmpSearchPlan }\n\t| { readonly ok: false; readonly issues: readonly OmpIssue[] };\n\nexport interface OmpSearchHostMatch {\n\treadonly file: string;\n\treadonly line: number;\n\treadonly column?: number;\n\treadonly text: string;\n\treadonly expectedLineHash?: string;\n}\n\nexport interface OmpSearchPresentation {\n\treadonly text: string;\n\treadonly totalMatches: number;\n\treadonly omittedMatches: number;\n\treadonly truncated: boolean;\n}\n\nexport type OmpSearchPresentResult =\n\t| { readonly ok: true; readonly presentation: OmpSearchPresentation }\n\t| { readonly ok: false; readonly conflicts: readonly unknown[] };\n\nlet cached: Promise<OmpPureSeams> | undefined;\n\n/**\n * Returns the memoized seam set unless `OMK_OMP_SEAMS=0`; `undefined` when\n * opted out. Loader errors (VENDOR_NOT_FOUND, INVALID_SEAM) propagate to\n * the caller of the returned promise.\n */\nexport function getOmpSeams(): Promise<OmpPureSeams> | undefined {\n\tif (!isOmpSeamsEnabled()) return undefined;\n\tcached ??= loadOmpPureSeams();\n\treturn cached;\n}\n\nexport function planRead(seams: OmpPureSeams, input: unknown): OmpReadPlanResult {\n\treturn seams.planRead(input) as OmpReadPlanResult;\n}\n\nexport function presentRead(\n\tseams: OmpPureSeams,\n\tplan: OmpReadPlan,\n\tfile: { text: string; sourceDigest?: string; lineDigests?: readonly { line: number; digest: string }[] },\n): OmpReadPresentResult {\n\treturn seams.presentRead(plan, file) as OmpReadPresentResult;\n}\n\nexport function planSearch(seams: OmpPureSeams, input: unknown): OmpSearchPlanResult {\n\treturn seams.planSearch(input) as OmpSearchPlanResult;\n}\n\nexport function presentSearch(\n\tseams: OmpPureSeams,\n\tplan: OmpSearchPlan,\n\tmatches: readonly OmpSearchHostMatch[],\n): OmpSearchPresentResult {\n\treturn seams.presentSearch(plan, matches) as OmpSearchPresentResult;\n}\n\nexport function formatOmpIssues(issues: readonly OmpIssue[]): string {\n\treturn issues.map((issue) => `${issue.field}: ${issue.message}`).join(\"; \");\n}\n"]}