@code-yeongyu/senpi-agent-core 2026.9.29-3 → 2026.9.29-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -3
- package/dist/agent-loop.d.ts.map +0 -1
- package/dist/agent-loop.js.map +0 -1
- package/dist/agent.d.ts.map +0 -1
- package/dist/agent.js.map +0 -1
- package/dist/assistant-terminal-state.d.ts.map +0 -1
- package/dist/assistant-terminal-state.js.map +0 -1
- package/dist/empty-assistant-recovery.d.ts.map +0 -1
- package/dist/empty-assistant-recovery.js.map +0 -1
- package/dist/harness/agent-harness.d.ts.map +0 -1
- package/dist/harness/agent-harness.js.map +0 -1
- package/dist/harness/compaction/branch-summarization.d.ts.map +0 -1
- package/dist/harness/compaction/branch-summarization.js.map +0 -1
- package/dist/harness/compaction/compaction.d.ts.map +0 -1
- package/dist/harness/compaction/compaction.js.map +0 -1
- package/dist/harness/compaction/utils.d.ts.map +0 -1
- package/dist/harness/compaction/utils.js.map +0 -1
- package/dist/harness/config.d.ts.map +0 -1
- package/dist/harness/config.js.map +0 -1
- package/dist/harness/context.d.ts.map +0 -1
- package/dist/harness/context.js.map +0 -1
- package/dist/harness/env/nodejs.d.ts.map +0 -1
- package/dist/harness/env/nodejs.js.map +0 -1
- package/dist/harness/events.d.ts.map +0 -1
- package/dist/harness/events.js.map +0 -1
- package/dist/harness/execution/assistant.d.ts.map +0 -1
- package/dist/harness/execution/assistant.js.map +0 -1
- package/dist/harness/execution/effect-gate.d.ts.map +0 -1
- package/dist/harness/execution/effect-gate.js.map +0 -1
- package/dist/harness/execution/tools.d.ts.map +0 -1
- package/dist/harness/execution/tools.js.map +0 -1
- package/dist/harness/hooks.d.ts.map +0 -1
- package/dist/harness/hooks.js.map +0 -1
- package/dist/harness/messages.d.ts.map +0 -1
- package/dist/harness/messages.js.map +0 -1
- package/dist/harness/prompt-templates.d.ts.map +0 -1
- package/dist/harness/prompt-templates.js.map +0 -1
- package/dist/harness/result.d.ts.map +0 -1
- package/dist/harness/result.js.map +0 -1
- package/dist/harness/runtime/drive/boundary.d.ts.map +0 -1
- package/dist/harness/runtime/drive/boundary.js.map +0 -1
- package/dist/harness/runtime/drive/checkpoint.d.ts.map +0 -1
- package/dist/harness/runtime/drive/checkpoint.js.map +0 -1
- package/dist/harness/runtime/drive/deferred.d.ts.map +0 -1
- package/dist/harness/runtime/drive/deferred.js.map +0 -1
- package/dist/harness/runtime/drive/generation.d.ts.map +0 -1
- package/dist/harness/runtime/drive/generation.js.map +0 -1
- package/dist/harness/runtime/drive/reconcile.d.ts.map +0 -1
- package/dist/harness/runtime/drive/reconcile.js.map +0 -1
- package/dist/harness/runtime/drive/recovery.d.ts.map +0 -1
- package/dist/harness/runtime/drive/recovery.js.map +0 -1
- package/dist/harness/runtime/drive/response.d.ts.map +0 -1
- package/dist/harness/runtime/drive/response.js.map +0 -1
- package/dist/harness/runtime/drive/retry.d.ts.map +0 -1
- package/dist/harness/runtime/drive/retry.js.map +0 -1
- package/dist/harness/runtime/drive/structural.d.ts.map +0 -1
- package/dist/harness/runtime/drive/structural.js.map +0 -1
- package/dist/harness/runtime/drive/terminal.d.ts.map +0 -1
- package/dist/harness/runtime/drive/terminal.js.map +0 -1
- package/dist/harness/runtime/drive/tool-placement.d.ts.map +0 -1
- package/dist/harness/runtime/drive/tool-placement.js.map +0 -1
- package/dist/harness/runtime/drive/tools.d.ts.map +0 -1
- package/dist/harness/runtime/drive/tools.js.map +0 -1
- package/dist/harness/runtime/drive.d.ts.map +0 -1
- package/dist/harness/runtime/drive.js.map +0 -1
- package/dist/harness/runtime/harness.d.ts.map +0 -1
- package/dist/harness/runtime/harness.js.map +0 -1
- package/dist/harness/runtime/index.d.ts.map +0 -1
- package/dist/harness/runtime/index.js.map +0 -1
- package/dist/harness/runtime/lane.d.ts.map +0 -1
- package/dist/harness/runtime/lane.js.map +0 -1
- package/dist/harness/runtime/progress.d.ts.map +0 -1
- package/dist/harness/runtime/progress.js.map +0 -1
- package/dist/harness/runtime/reducer.d.ts.map +0 -1
- package/dist/harness/runtime/reducer.js.map +0 -1
- package/dist/harness/runtime/restore.d.ts.map +0 -1
- package/dist/harness/runtime/restore.js.map +0 -1
- package/dist/harness/runtime/transcript.d.ts.map +0 -1
- package/dist/harness/runtime/transcript.js.map +0 -1
- package/dist/harness/runtime/types.d.ts.map +0 -1
- package/dist/harness/runtime/types.js.map +0 -1
- package/dist/harness/session/commit.d.ts.map +0 -1
- package/dist/harness/session/commit.js.map +0 -1
- package/dist/harness/session/context.d.ts.map +0 -1
- package/dist/harness/session/context.js.map +0 -1
- package/dist/harness/session/fork-policy.d.ts.map +0 -1
- package/dist/harness/session/fork-policy.js.map +0 -1
- package/dist/harness/session/fork.d.ts.map +0 -1
- package/dist/harness/session/fork.js.map +0 -1
- package/dist/harness/session/in-memory-storage-state.d.ts.map +0 -1
- package/dist/harness/session/in-memory-storage-state.js.map +0 -1
- package/dist/harness/session/index.d.ts.map +0 -1
- package/dist/harness/session/index.js.map +0 -1
- package/dist/harness/session/jsonl/codec.d.ts.map +0 -1
- package/dist/harness/session/jsonl/codec.js.map +0 -1
- package/dist/harness/session/jsonl/fork.d.ts.map +0 -1
- package/dist/harness/session/jsonl/fork.js.map +0 -1
- package/dist/harness/session/jsonl/index.d.ts.map +0 -1
- package/dist/harness/session/jsonl/index.js.map +0 -1
- package/dist/harness/session/jsonl/io.d.ts.map +0 -1
- package/dist/harness/session/jsonl/io.js.map +0 -1
- package/dist/harness/session/jsonl/legacy-v3.d.ts.map +0 -1
- package/dist/harness/session/jsonl/legacy-v3.js.map +0 -1
- package/dist/harness/session/jsonl/repo.d.ts.map +0 -1
- package/dist/harness/session/jsonl/repo.js.map +0 -1
- package/dist/harness/session/jsonl/storage.d.ts.map +0 -1
- package/dist/harness/session/jsonl/storage.js.map +0 -1
- package/dist/harness/session/jsonl/types.d.ts.map +0 -1
- package/dist/harness/session/jsonl/types.js.map +0 -1
- package/dist/harness/session/memory.d.ts.map +0 -1
- package/dist/harness/session/memory.js.map +0 -1
- package/dist/harness/session/mutation-line.d.ts.map +0 -1
- package/dist/harness/session/mutation-line.js.map +0 -1
- package/dist/harness/session/session.d.ts.map +0 -1
- package/dist/harness/session/session.js.map +0 -1
- package/dist/harness/session/testing/benchmark/datasets.d.ts.map +0 -1
- package/dist/harness/session/testing/benchmark/datasets.js.map +0 -1
- package/dist/harness/session/testing/benchmark/session-repo.d.ts.map +0 -1
- package/dist/harness/session/testing/benchmark/session-repo.js.map +0 -1
- package/dist/harness/session/testing/benchmark/storage.d.ts.map +0 -1
- package/dist/harness/session/testing/benchmark/storage.js.map +0 -1
- package/dist/harness/session/testing/conformance/session-repo.d.ts.map +0 -1
- package/dist/harness/session/testing/conformance/session-repo.js.map +0 -1
- package/dist/harness/session/testing/conformance/storage.d.ts.map +0 -1
- package/dist/harness/session/testing/conformance/storage.js.map +0 -1
- package/dist/harness/session/testing/gating-storage.d.ts.map +0 -1
- package/dist/harness/session/testing/gating-storage.js.map +0 -1
- package/dist/harness/session/testing/index.d.ts.map +0 -1
- package/dist/harness/session/testing/index.js.map +0 -1
- package/dist/harness/session/testing/instrumented-storage.d.ts.map +0 -1
- package/dist/harness/session/testing/instrumented-storage.js.map +0 -1
- package/dist/harness/session/testing/storage-decorator.d.ts.map +0 -1
- package/dist/harness/session/testing/storage-decorator.js.map +0 -1
- package/dist/harness/session/testing/types.d.ts.map +0 -1
- package/dist/harness/session/testing/types.js.map +0 -1
- package/dist/harness/session/types.d.ts.map +0 -1
- package/dist/harness/session/types.js.map +0 -1
- package/dist/harness/session/values.d.ts.map +0 -1
- package/dist/harness/session/values.js.map +0 -1
- package/dist/harness/skills.d.ts.map +0 -1
- package/dist/harness/skills.js.map +0 -1
- package/dist/harness/system-prompt.d.ts.map +0 -1
- package/dist/harness/system-prompt.js.map +0 -1
- package/dist/harness/telemetry.d.ts.map +0 -1
- package/dist/harness/telemetry.js.map +0 -1
- package/dist/harness/tools/bash.d.ts.map +0 -1
- package/dist/harness/tools/bash.js.map +0 -1
- package/dist/harness/tools/edit-diff.d.ts.map +0 -1
- package/dist/harness/tools/edit-diff.js.map +0 -1
- package/dist/harness/tools/edit.d.ts.map +0 -1
- package/dist/harness/tools/edit.js.map +0 -1
- package/dist/harness/tools/file-mutation-queue.d.ts.map +0 -1
- package/dist/harness/tools/file-mutation-queue.js.map +0 -1
- package/dist/harness/tools/image.d.ts.map +0 -1
- package/dist/harness/tools/image.js.map +0 -1
- package/dist/harness/tools/index.d.ts.map +0 -1
- package/dist/harness/tools/index.js.map +0 -1
- package/dist/harness/tools/path-utils.d.ts.map +0 -1
- package/dist/harness/tools/path-utils.js.map +0 -1
- package/dist/harness/tools/post-mutate.d.ts.map +0 -1
- package/dist/harness/tools/post-mutate.js.map +0 -1
- package/dist/harness/tools/read.d.ts.map +0 -1
- package/dist/harness/tools/read.js.map +0 -1
- package/dist/harness/tools/tool-context.d.ts.map +0 -1
- package/dist/harness/tools/tool-context.js.map +0 -1
- package/dist/harness/tools/write.d.ts.map +0 -1
- package/dist/harness/tools/write.js.map +0 -1
- package/dist/harness/types.d.ts.map +0 -1
- package/dist/harness/types.js.map +0 -1
- package/dist/harness/utils/adaptive-publisher.d.ts.map +0 -1
- package/dist/harness/utils/adaptive-publisher.js.map +0 -1
- package/dist/harness/utils/output-capture.d.ts.map +0 -1
- package/dist/harness/utils/output-capture.js.map +0 -1
- package/dist/harness/utils/read-folders/brace-scanner.d.ts.map +0 -1
- package/dist/harness/utils/read-folders/brace-scanner.js.map +0 -1
- package/dist/harness/utils/read-folders/compose.d.ts.map +0 -1
- package/dist/harness/utils/read-folders/compose.js.map +0 -1
- package/dist/harness/utils/read-folders/header-protection.d.ts.map +0 -1
- package/dist/harness/utils/read-folders/header-protection.js.map +0 -1
- package/dist/harness/utils/read-folders/index.d.ts.map +0 -1
- package/dist/harness/utils/read-folders/index.js.map +0 -1
- package/dist/harness/utils/read-folders/lexical-context.d.ts.map +0 -1
- package/dist/harness/utils/read-folders/lexical-context.js.map +0 -1
- package/dist/harness/utils/read-folders/lexical-spans.d.ts.map +0 -1
- package/dist/harness/utils/read-folders/lexical-spans.js.map +0 -1
- package/dist/harness/utils/read-folders/prepare.d.ts.map +0 -1
- package/dist/harness/utils/read-folders/prepare.js.map +0 -1
- package/dist/harness/utils/read-folders/tree-sitter/engine.d.ts.map +0 -1
- package/dist/harness/utils/read-folders/tree-sitter/engine.js.map +0 -1
- package/dist/harness/utils/read-folders/tree-sitter/grammar-assets.d.ts.map +0 -1
- package/dist/harness/utils/read-folders/tree-sitter/grammar-assets.js.map +0 -1
- package/dist/harness/utils/read-folders/tree-sitter/syntax.d.ts.map +0 -1
- package/dist/harness/utils/read-folders/tree-sitter/syntax.js.map +0 -1
- package/dist/harness/utils/read-folders/types.d.ts.map +0 -1
- package/dist/harness/utils/read-folders/types.js.map +0 -1
- package/dist/harness/utils/segmented-read-view.d.ts.map +0 -1
- package/dist/harness/utils/segmented-read-view.js.map +0 -1
- package/dist/harness/utils/shell-output.d.ts.map +0 -1
- package/dist/harness/utils/shell-output.js.map +0 -1
- package/dist/harness/utils/truncate.d.ts.map +0 -1
- package/dist/harness/utils/truncate.js.map +0 -1
- package/dist/harness/utils/usage.d.ts.map +0 -1
- package/dist/harness/utils/usage.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/node.d.ts.map +0 -1
- package/dist/node.js.map +0 -1
- package/dist/proxy.d.ts.map +0 -1
- package/dist/proxy.js.map +0 -1
- package/dist/search/index.d.ts.map +0 -1
- package/dist/search/index.js.map +0 -1
- package/dist/stream-fn.d.ts.map +0 -1
- package/dist/stream-fn.js.map +0 -1
- package/dist/tool-arguments.d.ts.map +0 -1
- package/dist/tool-arguments.js.map +0 -1
- package/dist/tool-name-alias.d.ts.map +0 -1
- package/dist/tool-name-alias.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
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BACjC,OAAO,EAAE;wBACR,IAAI,EAAE,UAAU,CAAC,IAAI;wBACrB,KAAK,EAAE,oBAAoB,CAAC,IAAI,EAAE,WAAW,EAAE,gBAAgB,CAAC;wBAChE,gBAAgB,EAAE,UAAU,CAAC,gBAAgB;qBAC7C;iBACD,CAAC;YACH,CAAC,EACD,OAAO,CACP,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport type { AgentHarnessTool, FileError } from \"../types.ts\";\nimport {\n\tapplyEditsToNormalizedContent,\n\tdetectLineEnding,\n\ttype Edit,\n\tgenerateDiffString,\n\tgenerateUnifiedPatch,\n\tnormalizeToLF,\n\trestoreLineEndings,\n\tstripBom,\n} from \"./edit-diff.ts\";\nimport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nimport { resolveToolPath } from \"./path-utils.ts\";\nimport { appendPostMutateNote, runPostMutate } from \"./post-mutate.ts\";\nimport type { ExecutionToolContext } from \"./tool-context.ts\";\n\nconst replaceEditSchema = Type.Object(\n\t{\n\t\toldText: Type.String({\n\t\t\tdescription:\n\t\t\t\t\"Exact text for one targeted replacement. It must be unique in the original file and must not overlap with any other edits[].oldText in the same call.\",\n\t\t}),\n\t\tnewText: Type.String({ description: \"Replacement text for this targeted edit.\" }),\n\t},\n\t{},\n);\n\nconst editSchema = Type.Object(\n\t{\n\t\tpath: Type.String({ description: \"Path to the file to edit (relative or absolute)\" }),\n\t\tedits: Type.Array(replaceEditSchema, {\n\t\t\tdescription:\n\t\t\t\t\"One or more targeted replacements. Each edit is matched against the original file, not incrementally. Do not include overlapping or nested edits. If two changes touch the same block or nearby lines, merge them into one edit instead.\",\n\t\t}),\n\t},\n\t{},\n);\n\nexport type EditToolInput = Static<typeof editSchema>;\ntype LegacyEditToolInput = EditToolInput & { oldText?: unknown; newText?: unknown };\ntype SingleEditInput = { oldText: string; newText: string };\n\nfunction isSingleEditInput(value: unknown): value is SingleEditInput {\n\tif (!value || typeof value !== \"object\" || Array.isArray(value)) return false;\n\tconst edit = value as Record<string, unknown>;\n\treturn typeof edit.oldText === \"string\" && typeof edit.newText === \"string\";\n}\n\nexport interface EditToolDetails {\n\tdiff: string;\n\tpatch: string;\n\tfirstChangedLine?: number;\n}\n\nfunction prepareEditArguments(input: unknown): EditToolInput {\n\tif (!input || typeof input !== \"object\") return input as EditToolInput;\n\tconst args = input as Record<string, unknown>;\n\tif (typeof args.edits === \"string\") {\n\t\ttry {\n\t\t\tconst parsed: unknown = JSON.parse(args.edits);\n\t\t\tif (Array.isArray(parsed)) {\n\t\t\t\targs.edits = parsed;\n\t\t\t} else if (isSingleEditInput(parsed)) {\n\t\t\t\targs.edits = [parsed];\n\t\t\t}\n\t\t} catch {}\n\t} else if (isSingleEditInput(args.edits)) {\n\t\targs.edits = [args.edits];\n\t}\n\n\tconst legacy = args as LegacyEditToolInput;\n\tif (typeof legacy.oldText !== \"string\" || typeof legacy.newText !== \"string\") return args as EditToolInput;\n\tconst edits = Array.isArray(legacy.edits) ? [...legacy.edits] : [];\n\tedits.push({ oldText: legacy.oldText, newText: legacy.newText });\n\tconst { oldText: _oldText, newText: _newText, ...rest } = legacy;\n\treturn { ...rest, edits } as EditToolInput;\n}\n\nfunction validateEditInput(input: EditToolInput): { path: string; edits: Edit[] } {\n\tif (!Array.isArray(input.edits) || input.edits.length === 0) {\n\t\tthrow new Error(\"Edit tool input is invalid. edits must contain at least one replacement.\");\n\t}\n\treturn { path: input.path, edits: input.edits };\n}\n\nfunction editAccessError(path: string, error: FileError): Error {\n\treturn new Error(`Could not edit file: ${path}. Error code: ${error.code}.`, { cause: error });\n}\n\nexport function createEditTool<TContext extends ExecutionToolContext = ExecutionToolContext>(): AgentHarnessTool<\n\tTContext,\n\ttypeof editSchema,\n\tEditToolDetails | undefined\n> {\n\treturn {\n\t\tname: \"edit\",\n\t\tlabel: \"edit\",\n\t\tdescription:\n\t\t\t\"Edit a single file using exact text replacement. Every edits[].oldText must match a unique, non-overlapping region of the original file. If two changes affect the same block or nearby lines, merge them into one edit instead of emitting overlapping edits. Do not include large unchanged regions just to connect distant changes.\",\n\t\tparameters: editSchema,\n\t\tprepareArguments: prepareEditArguments,\n\t\tasync execute(_toolCallId, input, _onUpdate, { env, postMutate }, _invocation, context) {\n\t\t\tconst { path, edits } = validateEditInput(input);\n\t\t\tconst absolutePath = await resolveToolPath(env, path, context);\n\t\t\treturn withFileMutationQueue(\n\t\t\t\tenv,\n\t\t\t\tabsolutePath,\n\t\t\t\tasync () => {\n\t\t\t\t\tif (context.abortSignal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\t\t\tconst info = await env.fileInfo(absolutePath, context);\n\t\t\t\t\tif (!info.ok) throw editAccessError(path, info.error);\n\t\t\t\t\tif (info.value.kind !== \"file\" && info.value.kind !== \"symlink\") {\n\t\t\t\t\t\tthrow new Error(`Could not edit file: ${path}. Path is not a file.`);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst readResult = await env.readTextFile(absolutePath, context);\n\t\t\t\t\tif (!readResult.ok) throw editAccessError(path, readResult.error);\n\t\t\t\t\tif (context.abortSignal?.aborted) throw new Error(\"Operation aborted\");\n\n\t\t\t\t\tconst { bom, text: content } = stripBom(readResult.value);\n\t\t\t\t\tconst originalEnding = detectLineEnding(content);\n\t\t\t\t\tconst normalizedContent = normalizeToLF(content);\n\t\t\t\t\tconst { baseContent, newContent } = applyEditsToNormalizedContent(normalizedContent, edits, path);\n\t\t\t\t\tif (context.abortSignal?.aborted) throw new Error(\"Operation aborted\");\n\n\t\t\t\t\tconst finalContent = bom + restoreLineEndings(newContent, originalEnding);\n\t\t\t\t\tconst writeResult = await env.writeFile(absolutePath, finalContent, context);\n\t\t\t\t\tif (!writeResult.ok) throw editAccessError(path, writeResult.error);\n\t\t\t\t\tif (context.abortSignal?.aborted) throw new Error(\"Operation aborted\");\n\n\t\t\t\t\tconst outcome = await runPostMutate(postMutate, {\n\t\t\t\t\t\ttool: \"edit\",\n\t\t\t\t\t\tpath: absolutePath,\n\t\t\t\t\t\tsignal: context.abortSignal,\n\t\t\t\t\t});\n\t\t\t\t\tif (context.abortSignal?.aborted) throw new Error(\"Operation aborted\");\n\n\t\t\t\t\tlet committedContent = newContent;\n\t\t\t\t\tlet rereadNote: string | undefined;\n\t\t\t\t\tif (outcome.fileMayHaveChanged) {\n\t\t\t\t\t\tconst postMutateRead = await env.readTextFile(absolutePath, context);\n\t\t\t\t\t\t// The edit itself already landed, so an unreadable file is the hook's doing, not a\n\t\t\t\t\t\t// failed edit. Report it as a note rather than an error that misattributes the failure.\n\t\t\t\t\t\tif (postMutateRead.ok) committedContent = normalizeToLF(stripBom(postMutateRead.value).text);\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\trereadNote = `postMutate left the file unreadable: ${postMutateRead.error.code}. Reported diff describes the edit before the hook ran.`;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst diffResult = generateDiffString(baseContent, committedContent);\n\t\t\t\t\tconst text = appendPostMutateNote(\n\t\t\t\t\t\t`Successfully replaced ${edits.length} block(s) in ${path}.`,\n\t\t\t\t\t\toutcome.note,\n\t\t\t\t\t\trereadNote,\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\", text }],\n\t\t\t\t\t\tdetails: {\n\t\t\t\t\t\t\tdiff: diffResult.diff,\n\t\t\t\t\t\t\tpatch: generateUnifiedPatch(path, baseContent, committedContent),\n\t\t\t\t\t\t\tfirstChangedLine: diffResult.firstChangedLine,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\tcontext,\n\t\t\t);\n\t\t},\n\t};\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-mutation-queue.d.ts","sourceRoot":"","sources":["../../../src/harness/tools/file-mutation-queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,YA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AC;YAAS,CAAC;QACV,WAAW,EAAE,CAAC;QACd,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,YAAY;YAAE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACtE,CAAC;AACF,CAAC","sourcesContent":["import type { Context } from \"../context.ts\";\nimport type { ExecutionEnv } from \"../types.ts\";\nimport { getOrThrow } from \"../types.ts\";\n\ntype MutationQueueState = {\n\tqueues: Map<string, Promise<void>>;\n\tregistration: Promise<void>;\n};\n\nconst states = new WeakMap<ExecutionEnv, MutationQueueState>();\n\nfunction getState(env: ExecutionEnv): MutationQueueState {\n\tlet state = states.get(env);\n\tif (!state) {\n\t\tstate = { queues: new Map(), registration: Promise.resolve() };\n\t\tstates.set(env, state);\n\t}\n\treturn state;\n}\n\nasync function getMutationQueueKey(env: ExecutionEnv, path: string, context: Context): Promise<string> {\n\tconst absolutePath = getOrThrow(await env.absolutePath(path, context));\n\tconst canonicalPath = await env.canonicalPath(absolutePath, context);\n\tif (canonicalPath.ok) return canonicalPath.value;\n\tif (canonicalPath.error.code === \"not_found\" || canonicalPath.error.code === \"not_supported\") return absolutePath;\n\tthrow canonicalPath.error;\n}\n\n/** Serialize file mutations targeting the same environment and canonical path. */\nexport async function withFileMutationQueue<T>(\n\tenv: ExecutionEnv,\n\tpath: string,\n\tfn: () => Promise<T>,\n\tcontext: Context,\n): Promise<T> {\n\tconst state = getState(env);\n\tconst registration = state.registration.then(async () => {\n\t\tconst key = await getMutationQueueKey(env, path, context);\n\t\tconst currentQueue = state.queues.get(key) ?? Promise.resolve();\n\n\t\tlet releaseNext = () => {};\n\t\tconst nextQueue = new Promise<void>((resolve) => {\n\t\t\treleaseNext = resolve;\n\t\t});\n\t\tconst chainedQueue = currentQueue.then(() => nextQueue);\n\t\tstate.queues.set(key, chainedQueue);\n\t\treturn { key, currentQueue, chainedQueue, releaseNext };\n\t});\n\tstate.registration = registration.then(\n\t\t() => undefined,\n\t\t() => undefined,\n\t);\n\n\tconst { key, currentQueue, chainedQueue, releaseNext } = await registration;\n\tawait currentQueue;\n\ttry {\n\t\treturn await fn();\n\t} finally {\n\t\treleaseNext();\n\t\tif (state.queues.get(key) === chainedQueue) state.queues.delete(key);\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/harness/tools/image.ts"],"names":[],"mappings":"AAEA,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAOnF;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAatD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"image.js","sourceRoot":"","sources":["../../../src/harness/tools/image.ts"],"names":[],"mappings":"AAAA,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAEvE,MAAM,UAAU,4BAA4B,CAAC,MAAkB;IAC9D,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAAE,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC;IACjG,IAAI,UAAU,CAAC,MAAM,EAAE,aAAa,CAAC;QAAE,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;IAChH,IAAI,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC;QAAE,OAAO,WAAW,CAAC;IAC1D,IAAI,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,IAAI,eAAe,CA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U,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;IACrE,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["const PNG_SIGNATURE = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];\n\nexport function detectSupportedImageMimeType(buffer: Uint8Array): string | undefined {\n\tif (startsWith(buffer, [0xff, 0xd8, 0xff])) return buffer[3] === 0xf7 ? undefined : \"image/jpeg\";\n\tif (startsWith(buffer, PNG_SIGNATURE)) return isPng(buffer) && !isAnimatedPng(buffer) ? \"image/png\" : undefined;\n\tif (startsWithAscii(buffer, 0, \"GIF\")) return \"image/gif\";\n\tif (startsWithAscii(buffer, 0, \"RIFF\") && startsWithAscii(buffer, 8, \"WEBP\")) return \"image/webp\";\n\tif (startsWithAscii(buffer, 0, \"BM\") && isBmp(buffer)) return \"image/bmp\";\n\treturn undefined;\n}\n\nexport function encodeBase64(bytes: Uint8Array): string {\n\tconst alphabet = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\tlet output = \"\";\n\tfor (let index = 0; index < bytes.length; index += 3) {\n\t\tconst first = bytes[index] ?? 0;\n\t\tconst second = bytes[index + 1];\n\t\tconst third = bytes[index + 2];\n\t\toutput += alphabet[first >> 2];\n\t\toutput += alphabet[((first & 0x03) << 4) | ((second ?? 0) >> 4)];\n\t\toutput += second === undefined ? \"=\" : alphabet[((second & 0x0f) << 2) | ((third ?? 0) >> 6)];\n\t\toutput += third === undefined ? \"=\" : alphabet[third & 0x3f];\n\t}\n\treturn output;\n}\n\nfunction isPng(buffer: Uint8Array): boolean {\n\treturn (\n\t\tbuffer.length >= 16 && readUint32BE(buffer, PNG_SIGNATURE.length) === 13 && startsWithAscii(buffer, 12, \"IHDR\")\n\t);\n}\n\nfunction isAnimatedPng(buffer: Uint8Array): boolean {\n\tlet offset = PNG_SIGNATURE.length;\n\twhile (offset + 8 <= buffer.length) {\n\t\tconst chunkLength = readUint32BE(buffer, offset);\n\t\tconst chunkTypeOffset = offset + 4;\n\t\tif (startsWithAscii(buffer, chunkTypeOffset, \"acTL\")) return true;\n\t\tif (startsWithAscii(buffer, chunkTypeOffset, \"IDAT\")) return false;\n\t\tconst nextOffset = offset + 8 + chunkLength + 4;\n\t\tif (nextOffset <= offset || nextOffset > buffer.length) return false;\n\t\toffset = nextOffset;\n\t}\n\treturn false;\n}\n\nfunction isBmp(buffer: Uint8Array): boolean {\n\tif (buffer.length < 26) return false;\n\tconst declaredFileSize = readUint32LE(buffer, 2);\n\tconst pixelDataOffset = readUint32LE(buffer, 10);\n\tconst dibHeaderSize = readUint32LE(buffer, 14);\n\tif (declaredFileSize !== 0 && declaredFileSize < 26) return false;\n\tif (pixelDataOffset < 14 + dibHeaderSize) return false;\n\tif (declaredFileSize !== 0 && pixelDataOffset >= declaredFileSize) return false;\n\n\tlet colorPlanes: number;\n\tlet bitsPerPixel: number;\n\tif (dibHeaderSize === 12) {\n\t\tcolorPlanes = readUint16LE(buffer, 22);\n\t\tbitsPerPixel = readUint16LE(buffer, 24);\n\t} else if (dibHeaderSize >= 40 && dibHeaderSize <= 124) {\n\t\tif (buffer.length < 30) return false;\n\t\tcolorPlanes = readUint16LE(buffer, 26);\n\t\tbitsPerPixel = readUint16LE(buffer, 28);\n\t} else {\n\t\treturn false;\n\t}\n\treturn colorPlanes === 1 && [1, 4, 8, 16, 24, 32].includes(bitsPerPixel);\n}\n\nfunction readUint16LE(buffer: Uint8Array, offset: number): number {\n\treturn (buffer[offset] ?? 0) + ((buffer[offset + 1] ?? 0) << 8);\n}\n\nfunction readUint32BE(buffer: Uint8Array, offset: number): number {\n\treturn (\n\t\t(buffer[offset] ?? 0) * 0x1000000 +\n\t\t((buffer[offset + 1] ?? 0) << 16) +\n\t\t((buffer[offset + 2] ?? 0) << 8) +\n\t\t(buffer[offset + 3] ?? 0)\n\t);\n}\n\nfunction readUint32LE(buffer: Uint8Array, offset: number): number {\n\treturn (\n\t\t(buffer[offset] ?? 0) +\n\t\t((buffer[offset + 1] ?? 0) << 8) +\n\t\t((buffer[offset + 2] ?? 0) << 16) +\n\t\t(buffer[offset + 3] ?? 0) * 0x1000000\n\t);\n}\n\nfunction startsWith(buffer: Uint8Array, bytes: number[]): boolean {\n\tif (buffer.length < bytes.length) return false;\n\treturn bytes.every((byte, index) => buffer[index] === byte);\n}\n\nfunction startsWithAscii(buffer: Uint8Array, offset: number, text: string): boolean {\n\tif (buffer.length < offset + text.length) return false;\n\tfor (let index = 0; index < text.length; index++) {\n\t\tif (buffer[offset + index] !== text.charCodeAt(index)) return false;\n\t}\n\treturn true;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/harness/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,cAAc,GACd,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,aAAa,GAClB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AACnB,YAAY,EACX,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/harness/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAMN,cAAc,GACd,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,GAGd,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,GAMd,MAAM,WAAW,CAAC;AAOnB,OAAO,EAAE,eAAe,EAAuB,MAAM,YAAY,CAAC","sourcesContent":["export {\n\ttype BashExecution,\n\ttype BashPrepare,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n} from \"./bash.ts\";\nexport {\n\tcreateEditTool,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n} from \"./edit.ts\";\nexport {\n\tcreateReadTool,\n\ttype ReadImageProcessor,\n\ttype ReadImageProcessorResult,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport type {\n\tExecutionToolContext,\n\tPostMutateContext,\n\tPostMutateHook,\n\tPostMutateResult,\n} from \"./tool-context.ts\";\nexport { createWriteTool, type WriteToolInput } from \"./write.ts\";\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"path-utils.d.ts","sourceRoot":"","sources":["../../../src/harness/tools/path-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAWhD,wBAAsB,eAAe,CAAC,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAExG;AAED,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAc5G"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"path-utils.js","sourceRoot":"","sources":["../../../src/harness/tools/path-utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,cAAc,GAAG,0CAA0C,CA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{ ExecutionEnv } from \"../types.ts\";\nimport { getOrThrow } from \"../types.ts\";\n\nconst UNICODE_SPACES = /[\\u00A0\\u2000-\\u200A\\u202F\\u205F\\u3000]/g;\nconst NARROW_NO_BREAK_SPACE = \"\\u202F\";\n\nfunction normalizeToolPath(path: string): string {\n\tconst normalized = path.replace(UNICODE_SPACES, \" \");\n\treturn normalized.startsWith(\"@\") ? normalized.slice(1) : normalized;\n}\n\nexport async function resolveToolPath(env: ExecutionEnv, path: string, context: Context): Promise<string> {\n\treturn getOrThrow(await env.absolutePath(normalizeToolPath(path), context));\n}\n\nexport async function resolveReadToolPath(env: ExecutionEnv, path: string, context: Context): Promise<string> {\n\tconst resolved = await resolveToolPath(env, path, context);\n\tconst variants = [\n\t\tresolved,\n\t\tresolved.replace(/ (AM|PM)\\./gi, `${NARROW_NO_BREAK_SPACE}$1.`),\n\t\tresolved.normalize(\"NFD\"),\n\t\tresolved.replace(/'/g, \"\\u2019\"),\n\t\tresolved.normalize(\"NFD\").replace(/'/g, \"\\u2019\"),\n\t];\n\n\tfor (const variant of new Set(variants)) {\n\t\tif (getOrThrow(await env.exists(variant, context))) return variant;\n\t}\n\treturn resolved;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"post-mutate.d.ts","sourceRoot":"","sources":["../../../src/harness/tools/post-mutate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAoB,MAAM,mBAAmB,CAAC;AAE7F,4FAA4F;AAC5F,MAAM,WAAW,iBAAiB;IACjC;;;;OAIG;IACH,kBAAkB,EAAE,OAAO,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAID;;;;;GAKG;AACH,wBAAsB,aAAa,CAClC,IAAI,EAAE,cAAc,GAAG,SAAS,EAChC,KAAK,EAAE,iBAAiB,GACtB,OAAO,CAAC,iBAAiB,CAAC,CAS5B;AAED,6FAA6F;AAC7F,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,CAE9F"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"post-mutate.js","sourceRoot":"","sources":["../../../src/harness/tools/post-mutate.ts"],"names":[],"mappings":"AAaA,MAAM,SAAS,GAAsB,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC;AAEnE;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAClC,IAAgC,EAChC,KAAwB;IAExB,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAC5B,IAAI,MAAwB,CAAC;IAC7B,IAAI,CAAC;QACJ,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,IAAI,EAAE,2BAA2B,YAAY,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;IAC7F,CAAC;IACD,OAAO,EAAE,kBAAkB,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;AAClE,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,oBAAoB,CAAC,IAAY,EAAE,GAAG,KAAgC;IACrF,OAAO,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzE,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IACnC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC/D,CAAC","sourcesContent":["import type { PostMutateContext, PostMutateHook, PostMutateResult } from \"./tool-context.ts\";\n\n/** Result of running a `postMutate` hook, with hook failures degraded to a warning note. */\nexport interface PostMutateOutcome {\n\t/**\n\t * Whether the file may differ from the bytes the tool itself wrote. True when the hook reported\n\t * a change, and also when the hook rejected — a hook that fails midway can leave the file\n\t * partially rewritten, so callers must re-read rather than trust their own bytes.\n\t */\n\tfileMayHaveChanged: boolean;\n\tnote?: string;\n}\n\nconst NO_CHANGE: PostMutateOutcome = { fileMayHaveChanged: false };\n\n/**\n * Run a `postMutate` hook after a write has already landed on disk.\n *\n * The write is committed by the time the hook runs, so a rejecting hook must not fail the tool\n * call and lose that result. Hook failures are reported as an appended warning note instead.\n */\nexport async function runPostMutate(\n\thook: PostMutateHook | undefined,\n\tinput: PostMutateContext,\n): Promise<PostMutateOutcome> {\n\tif (!hook) return NO_CHANGE;\n\tlet result: PostMutateResult;\n\ttry {\n\t\tresult = await hook(input);\n\t} catch (error) {\n\t\treturn { fileMayHaveChanged: true, note: `postMutate hook failed: ${errorMessage(error)}` };\n\t}\n\treturn { fileMayHaveChanged: result.changed, note: result.note };\n}\n\n/** Append any `postMutate` notes to tool result text, one per line, skipping absent ones. */\nexport function appendPostMutateNote(text: string, ...notes: Array<string | undefined>): string {\n\treturn [text, ...notes.filter((note) => note !== undefined)].join(\"\\n\");\n}\n\nfunction errorMessage(error: unknown): string {\n\treturn error instanceof Error ? error.message : String(error);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../../src/harness/tools/read.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,OAAO,EAAE,KAAK,UAAU,EAAsB,MAAM,gCAAgC,CAAC;AAGrF,OAAO,EAIN,KAAK,gBAAgB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UAAU,GAAG,cAAc,GAAG,CAAC,CAAC;gBACtC,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC;gBAChC,IAAI,UAAU,CAAC,WAAW,KAAK,OAAO,EAAE,CAAC;oBACxC,UAAU,IAAI,sBAAsB,gBAAgB,IAAI,cAAc,OAAO,cAAc,gBAAgB,UAAU,gBAAgB,CAAC;gBACvI,CAAC;qBAAM,CAAC;oBACP,UAAU,IAAI,sBAAsB,gBAAgB,IAAI,cAAc,OAAO,cAAc,KAAK,UAAU,CAAC,iBAAiB,CAAC,uBAAuB,UAAU,gBAAgB,CAAC;gBAChL,CAAC;gBACD,OAAO,GAAG,EAAE,UAAU,EAAE,CAAC;YAC1B,CAAC;iBAAM,IAAI,gBAAgB,KAAK,SAAS,IAAI,SAAS,GAAG,gBAAgB,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC;gBAC7F,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,SAAS,GAAG,gBAAgB,CAAC,CAAC;gBACnE,MAAM,UAAU,GAAG,SAAS,GAAG,gBAAgB,GAAG,CAAC,CAAC;gBACpD,UAAU,GAAG,GAAG,UAAU,CAAC,OAAO,QAAQ,SAAS,mCAAmC,UAAU,gBAAgB,CAAC;YAClH,CAAC;iBAAM,CAAC;gBACP,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC;YACjC,CAAC;YAED,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC;QACnE,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import type { ImageContent, TextContent } from \"@earendil-works/pi-ai\";\nimport { type Static, Type } from \"typebox\";\nimport type { Context } from \"../context.ts\";\nimport type { AgentHarnessTool } from \"../types.ts\";\nimport { FileError, getOrThrow } from \"../types.ts\";\nimport { type ReadFolder, selectedReadFolder } from \"../utils/read-folders/index.ts\";\nimport { prepareReadFolder } from \"../utils/read-folders/prepare.ts\";\nimport { createDefaultReadSummary } from \"../utils/segmented-read-view.ts\";\nimport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationResult,\n\ttruncateHead,\n} from \"../utils/truncate.ts\";\nimport { detectSupportedImageMimeType, encodeBase64 } from \"./image.ts\";\nimport { resolveReadToolPath } from \"./path-utils.ts\";\nimport type { ExecutionToolContext } from \"./tool-context.ts\";\n\nconst readSchema = Type.Object({\n\tpath: Type.String({ description: \"Path to the file to read (relative or absolute)\" }),\n\toffset: Type.Optional(Type.Number({ description: \"Line number to start reading from (1-indexed)\" })),\n\tlimit: Type.Optional(Type.Number({ description: \"Maximum number of lines to read\" })),\n});\n\nexport type ReadToolInput = Static<typeof readSchema>;\n\nexport interface ReadToolDetails {\n\ttruncation?: TruncationResult;\n}\n\nexport type ReadImageProcessorResult =\n\t| { ok: true; data: string; mimeType: string; hints: string[] }\n\t| { ok: false; message: string };\n\nexport type ReadImageProcessor = (\n\tbytes: Uint8Array,\n\tmimeType: string,\n\toptions: { autoResizeImages: boolean },\n\tcontext: Context,\n) => Promise<ReadImageProcessorResult>;\n\nexport interface ReadToolOptions {\n\t/** Whether an injected image processor should resize images. Default: true. */\n\tautoResizeImages?: boolean;\n\t/** Optional image conversion/resizing implementation. */\n\timageProcessor?: ReadImageProcessor;\n\t/** Structural folder. Default options select the measured folder; omit here for verbatim reads. */\n\tfolder?: ReadFolder;\n}\n\nexport function createReadTool<TContext extends ExecutionToolContext = ExecutionToolContext>(\n\toptions: ReadToolOptions = { folder: selectedReadFolder },\n): AgentHarnessTool<TContext, typeof readSchema, ReadToolDetails | undefined> {\n\treturn {\n\t\tname: \"read\",\n\t\tlabel: \"read\",\n\t\tdescription: `Read the contents of a file. Supports text files and images (jpg, png, gif, webp, bmp). Images are sent as attachments. For text files, output is truncated to ${DEFAULT_MAX_LINES} lines or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). Use offset/limit for large files. When you need the full file, continue with offset until complete.`,\n\t\tparameters: readSchema,\n\t\tasync execute(_toolCallId, { path, offset, limit }, _onUpdate, { env }, _invocation, context) {\n\t\t\tconst absolutePath = await resolveReadToolPath(env, path, context);\n\t\t\tconst bytes = getOrThrow(await env.readBinaryFile(absolutePath, context));\n\t\t\tif (context.abortSignal?.aborted) throw new FileError(\"aborted\", \"Operation aborted\", absolutePath);\n\t\t\tconst mimeType = detectSupportedImageMimeType(bytes);\n\t\t\tif (mimeType) {\n\t\t\t\tif (options?.imageProcessor) {\n\t\t\t\t\tconst processed = await options.imageProcessor(\n\t\t\t\t\t\tbytes,\n\t\t\t\t\t\tmimeType,\n\t\t\t\t\t\t{ autoResizeImages: options.autoResizeImages ?? true },\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t);\n\t\t\t\t\tif (!processed.ok) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: `Read image file [${mimeType}]\\n${processed.message}` }],\n\t\t\t\t\t\t\tdetails: undefined,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tconst hints = processed.hints.length > 0 ? `\\n${processed.hints.join(\"\\n\")}` : \"\";\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t{ type: \"text\", text: `Read image file [${processed.mimeType}]${hints}` },\n\t\t\t\t\t\t\t{ type: \"image\", data: processed.data, mimeType: processed.mimeType },\n\t\t\t\t\t\t] satisfies Array<TextContent | ImageContent>,\n\t\t\t\t\t\tdetails: undefined,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif (mimeType === \"image/bmp\") {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\t\ttext: \"Read image file [image/bmp]\\n[Image omitted: configure an imageProcessor to convert BMP images.]\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdetails: undefined,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{ type: \"text\", text: `Read image file [${mimeType}]` },\n\t\t\t\t\t\t{ type: \"image\", data: encodeBase64(bytes), mimeType },\n\t\t\t\t\t] satisfies Array<TextContent | ImageContent>,\n\t\t\t\t\tdetails: undefined,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst textContent = new TextDecoder().decode(bytes);\n\t\t\tconst allLines = textContent.split(\"\\n\");\n\t\t\tconst totalFileLines = allLines.length;\n\t\t\tconst startLine = offset ? Math.max(0, offset - 1) : 0;\n\t\t\tconst startLineDisplay = startLine + 1;\n\t\t\tif (startLine >= allLines.length) {\n\t\t\t\tthrow new Error(`Offset ${offset} is beyond end of file (${allLines.length} lines total)`);\n\t\t\t}\n\n\t\t\tlet selectedContent: string;\n\t\t\tlet userLimitedLines: number | undefined;\n\t\t\tif (limit !== undefined) {\n\t\t\t\tconst endLine = Math.min(startLine + limit, allLines.length);\n\t\t\t\tselectedContent = allLines.slice(startLine, endLine).join(\"\\n\");\n\t\t\t\tuserLimitedLines = endLine - startLine;\n\t\t\t} else {\n\t\t\t\tselectedContent = allLines.slice(startLine).join(\"\\n\");\n\t\t\t}\n\n\t\t\tconst truncation = truncateHead(selectedContent);\n\t\t\t// A selected grammar loads lazily here, on the first structural read for its language.\n\t\t\tconst folder = await prepareReadFolder(absolutePath, options.folder);\n\t\t\tconst summary = createDefaultReadSummary({\n\t\t\t\tpath: absolutePath,\n\t\t\t\ttext: textContent,\n\t\t\t\toffset,\n\t\t\t\tlimit,\n\t\t\t\tfolder,\n\t\t\t\ttruncated: truncation.truncated,\n\t\t\t});\n\t\t\tlet outputText: string;\n\t\t\tlet details: ReadToolDetails | undefined;\n\t\t\tif (summary) {\n\t\t\t\toutputText = summary.text;\n\t\t\t} else if (truncation.firstLineExceedsLimit) {\n\t\t\t\tconst firstLineSize = formatSize(new TextEncoder().encode(allLines[startLine]).byteLength);\n\t\t\t\toutputText = `[Line ${startLineDisplay} is ${firstLineSize}, exceeds ${formatSize(DEFAULT_MAX_BYTES)} limit. Use bash: sed -n '${startLineDisplay}p' ${path} | head -c ${DEFAULT_MAX_BYTES}]`;\n\t\t\t\tdetails = { truncation };\n\t\t\t} else if (truncation.truncated) {\n\t\t\t\tconst endLineDisplay = startLineDisplay + truncation.outputLines - 1;\n\t\t\t\tconst nextOffset = endLineDisplay + 1;\n\t\t\t\toutputText = truncation.content;\n\t\t\t\tif (truncation.truncatedBy === \"lines\") {\n\t\t\t\t\toutputText += `\\n\\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalFileLines}. Use offset=${nextOffset} to continue.]`;\n\t\t\t\t} else {\n\t\t\t\t\toutputText += `\\n\\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalFileLines} (${formatSize(DEFAULT_MAX_BYTES)} limit). Use offset=${nextOffset} to continue.]`;\n\t\t\t\t}\n\t\t\t\tdetails = { truncation };\n\t\t\t} else if (userLimitedLines !== undefined && startLine + userLimitedLines < allLines.length) {\n\t\t\t\tconst remaining = allLines.length - (startLine + userLimitedLines);\n\t\t\t\tconst nextOffset = startLine + userLimitedLines + 1;\n\t\t\t\toutputText = `${truncation.content}\\n\\n[${remaining} more lines in file. Use offset=${nextOffset} to continue.]`;\n\t\t\t} else {\n\t\t\t\toutputText = truncation.content;\n\t\t\t}\n\n\t\t\treturn { content: [{ type: \"text\", text: outputText }], details };\n\t\t},\n\t};\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-context.d.ts","sourceRoot":"","sources":["../../../src/harness/tools/tool-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,uDAAuD;AACvD,MAAM,WAAW,iBAAiB;IACjC,wCAAwC;IACxC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;IACvB,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,+EAA+E;IAC/E,MAAM,CAAC,EAAE,WAAW,CAAC;CACrB;AAED,+CAA+C;AAC/C,MAAM,WAAW,gBAAgB;IAChC,kFAAkF;IAClF,OAAO,EAAE,OAAO,CAAC;IACjB,yDAAyD;IACzD,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,4FAA4F;AAC5F,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,iBAAiB,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAErF,6EAA6E;AAC7E,MAAM,WAAW,oBAAoB;IACpC,GAAG,EAAE,YAAY,CAAC;IAClB;;;;OAIG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;CAC5B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-context.js","sourceRoot":"","sources":["../../../src/harness/tools/tool-context.ts"],"names":[],"mappings":"","sourcesContent":["import type { ExecutionEnv } from \"../types.ts\";\n\n/** Mutation that triggered a `postMutate` hook run. */\nexport interface PostMutateContext {\n\t/** Tool that performed the mutation. */\n\ttool: \"write\" | \"edit\";\n\t/** Absolute path of the file that was just written. */\n\tpath: string;\n\t/** Abort signal of the originating tool call, when the caller supplied one. */\n\tsignal?: AbortSignal;\n}\n\n/** Outcome reported by a `postMutate` hook. */\nexport interface PostMutateResult {\n\t/** Whether the hook itself rewrote the file after the tool's own write landed. */\n\tchanged: boolean;\n\t/** Single-line note appended to the tool result text. */\n\tnote?: string;\n}\n\n/** Hook invoked inside the file mutation queue, immediately after a tool write succeeds. */\nexport type PostMutateHook = (input: PostMutateContext) => Promise<PostMutateResult>;\n\n/** Filesystem and shell context required by the built-in execution tools. */\nexport interface ExecutionToolContext {\n\tenv: ExecutionEnv;\n\t/**\n\t * Optional post-write hook (formatting, codegen, normalization). It runs inside the same\n\t * mutation-queue slot as the write it follows, so the file cannot be mutated in between.\n\t * A rejecting hook never discards the landed write; the tool appends a warning note instead.\n\t */\n\tpostMutate?: PostMutateHook;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../../src/harness/tools/write.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAKpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,QAAA,MAAM,WAAW;;;EAGf,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAC;AAExD,wBAAgB,eAAe,CAAC,QAAQ,SAAS,oBAAoB,GAAG,oBAAoB,KAAK,gBAAgB,CAChH,QAAQ,EACR,OAAO,WAAW,EAClB,SAAS,CACT,CAgCA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"write.js","sourceRoot":"","sources":["../../../src/harness/tools/write.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGvE,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,kDAAkD,EAAE,CAAC;IACtF,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC;CACrE,CAAC,CAAC;AAIH,MAAM,UAAU,eAAe;IAK9B,OAAO;QACN,IAAI,EAAE,OAAO;Q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type { AgentHarnessTool } from \"../types.ts\";\nimport { getOrThrow } from \"../types.ts\";\nimport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nimport { resolveToolPath } from \"./path-utils.ts\";\nimport { appendPostMutateNote, runPostMutate } from \"./post-mutate.ts\";\nimport type { ExecutionToolContext } from \"./tool-context.ts\";\n\nconst writeSchema = Type.Object({\n\tpath: Type.String({ description: \"Path to the file to write (relative or absolute)\" }),\n\tcontent: Type.String({ description: \"Content to write to the file\" }),\n});\n\nexport type WriteToolInput = Static<typeof writeSchema>;\n\nexport function createWriteTool<TContext extends ExecutionToolContext = ExecutionToolContext>(): AgentHarnessTool<\n\tTContext,\n\ttypeof writeSchema,\n\tundefined\n> {\n\treturn {\n\t\tname: \"write\",\n\t\tlabel: \"write\",\n\t\tdescription:\n\t\t\t\"Write content to a file. Creates the file if it doesn't exist, overwrites if it does. Automatically creates parent directories.\",\n\t\tparameters: writeSchema,\n\t\tasync execute(_toolCallId, { path, content }, _onUpdate, { env, postMutate }, _invocation, context) {\n\t\t\tconst absolutePath = await resolveToolPath(env, path, context);\n\t\t\treturn withFileMutationQueue(\n\t\t\t\tenv,\n\t\t\t\tabsolutePath,\n\t\t\t\tasync () => {\n\t\t\t\t\tif (context.abortSignal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\t\t\tgetOrThrow(await env.writeFile(absolutePath, content, context));\n\t\t\t\t\tif (context.abortSignal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\t\t\tconst outcome = await runPostMutate(postMutate, {\n\t\t\t\t\t\ttool: \"write\",\n\t\t\t\t\t\tpath: absolutePath,\n\t\t\t\t\t\tsignal: context.abortSignal,\n\t\t\t\t\t});\n\t\t\t\t\tif (context.abortSignal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\t\t\tconst text = appendPostMutateNote(`Successfully wrote to ${path}`, outcome.note);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\", text }],\n\t\t\t\t\t\tdetails: undefined,\n\t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C,YAAY,IAAyB,EAAE,OAAe,EAAE,KAAa;QACpE,KAAK,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,KAAK,KAAK,SAAS;YAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IAC7C,CAAC;CACD;AAKD,sDAAsD;AACtD,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAI5C,YAAY,IAA4B,EAAE,OAAe,EAAE,KAAa;QACvE,KAAK,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;CACD","sourcesContent":["import type { SimpleStreamOptions, Transport } from \"@earendil-works/pi-ai\";\nimport type { Static, TSchema } from \"typebox\";\nimport type { AgentTool, AgentToolResult } from \"../types.ts\";\nimport type { Context } from \"./context.ts\";\nimport type { JsonValue } from \"./session/types.ts\";\nimport type { TruncationResult } from \"./utils/truncate.ts\";\n\n/** Result of a fallible operation. Expected failures are returned as `ok: false` instead of thrown. */\nexport type Result<TValue, TError> = { ok: true; value: TValue } | { ok: false; error: TError };\n\n/** Create a successful {@link Result}. */\nexport function ok<TValue, TError>(value: TValue): Result<TValue, TError> {\n\treturn { ok: true, value };\n}\n\n/** Create a failed {@link Result}. */\nexport function err<TValue, TError>(error: TError): Result<TValue, TError> {\n\treturn { ok: false, error };\n}\n\n/** Return the success value or throw the failure error. Intended for tests and explicit adapter boundaries. */\nexport function getOrThrow<TValue, TError>(result: Result<TValue, TError>): TValue {\n\tif (!result.ok) throw result.error;\n\treturn result.value;\n}\n\n/** Normalize nullable values to optional values. */\nexport function getOrUndefined<T>(value: T | null | undefined): T | undefined {\n\treturn value ?? undefined;\n}\n\n/** Normalize unknown thrown values into Error instances before using them as typed error causes. */\nexport function toError(error: unknown): Error {\n\tif (error instanceof Error) return error;\n\tif (typeof error === \"string\") return new Error(error);\n\ttry {\n\t\treturn new Error(JSON.stringify(error));\n\t} catch {\n\t\treturn new Error(String(error));\n\t}\n}\n\n/**\n * Skill loaded from a `SKILL.md` file or provided by an application.\n *\n * `name`, `description`, and `filePath` are inserted into the system prompt in an XML-formatted block as suggested by agentskills.io.\n * Use {@link formatSkillsForSystemPrompt} to generate the spec-compatible system prompt block.\n */\nexport interface Skill {\n\t/** Stable skill name used for lookup and model-visible listings. */\n\tname: string;\n\t/** Short model-visible description of when to use the skill. */\n\tdescription: string;\n\t/** Full skill instructions. */\n\tcontent: string;\n\t/** Absolute path to the skill file. Used for model-visible location and resolving relative references. */\n\tfilePath: string;\n\t/** Exclude this skill from model-visible skill lists while still allowing explicit application invocation. */\n\tdisableModelInvocation?: boolean;\n}\n\n/** Prompt template that can be formatted into a prompt for explicit invocation. */\nexport interface PromptTemplate {\n\t/** Stable template name used for lookup or application command routing. */\n\tname: string;\n\t/** Optional description for command lists or autocomplete. */\n\tdescription?: string;\n\t/** Template content. Argument placeholders are formatted by `formatPromptTemplateInvocation`. */\n\tcontent: string;\n}\n\n/** Resources made available to explicit invocation methods and system-prompt callbacks. */\nexport interface AgentHarnessResources<\n\tTSkill extends Skill = Skill,\n\tTPromptTemplate extends PromptTemplate = PromptTemplate,\n> {\n\t/** Prompt templates available for explicit invocation. */\n\tpromptTemplates?: TPromptTemplate[];\n\t/** Skills available to the model and explicit skill invocation. */\n\tskills?: TSkill[];\n}\n\n/** Options for one live harness tool progress update. */\nexport interface AgentHarnessToolUpdateOptions {\n\t/** Request replacement of this invocation's durable recovery checkpoint. */\n\tcheckpoint?: true;\n}\n\n/** Synchronous full-snapshot progress callback supplied to harness-native tools. */\nexport type AgentHarnessToolUpdateCallback<TDetails> = (\n\tpartialResult: AgentToolResult<TDetails>,\n\toptions?: AgentHarnessToolUpdateOptions,\n) => void;\n\n/** Stable harness identity for one logical tool call, unchanged during safe replay. */\nexport interface AgentHarnessToolInvocation {\n\t/** Opaque session-unique id equal to the call's reserved result-entry id. */\n\treadonly invocationId: string;\n\treadonly operationId: string;\n\treadonly turnId: string;\n\t/** Read one invocation-scoped durable replay memo. */\n\tgetMemo(name: string): Promise<JsonValue | undefined>;\n\t/** Set or delete one invocation-scoped durable replay memo. */\n\tsetMemo(name: string, value: JsonValue | undefined): Promise<void>;\n}\n\n/** Tool definition executed by an {@link AgentHarness} with an application-defined context. */\nexport type AgentHarnessTool<\n\tTContext extends object | undefined,\n\tTParameters extends TSchema = TSchema,\n\tTDetails = unknown,\n> = Omit<AgentTool<TParameters, TDetails>, \"execute\"> & {\n\t/** Execute the tool call with the context resolved for the current turn snapshot. */\n\texecute(\n\t\ttoolCallId: string,\n\t\tparams: Static<TParameters>,\n\t\tonUpdate: AgentHarnessToolUpdateCallback<TDetails>,\n\t\ttoolContext: TContext,\n\t\tinvocation: AgentHarnessToolInvocation,\n\t\tcontext: Context,\n\t): Promise<AgentToolResult<TDetails>>;\n};\n\n/** Static tool context or provider resolved for each turn snapshot. */\nexport type AgentHarnessToolContextSource<TContext extends object | undefined> =\n\t| TContext\n\t| ((context: Context) => TContext | Promise<TContext>);\n\n/** Curated provider request options owned by the harness and snapshotted per turn. */\nexport interface AgentHarnessStreamOptions {\n\t/** Preferred transport forwarded to the stream function. */\n\ttransport?: Transport;\n\t/** Provider request timeout in milliseconds. */\n\ttimeoutMs?: number;\n\t/** Maximum provider retry attempts. */\n\tmaxRetries?: number;\n\t/** Optional cap for provider-requested retry delays. */\n\tmaxRetryDelayMs?: number;\n\t/** Additional request headers merged with auth and lifecycle headers. */\n\theaders?: Record<string, string>;\n\t/** Provider metadata forwarded with requests. */\n\tmetadata?: SimpleStreamOptions[\"metadata\"];\n\t/** Provider cache retention hint. */\n\tcacheRetention?: SimpleStreamOptions[\"cacheRetention\"];\n\t/** Ask a capable provider to continue generation asynchronously. */\n\tdeferred?: boolean | { window?: \"15m\" | \"1h\" | \"24h\" };\n}\n\n/** Per-request stream option patch returned by provider hooks. */\nexport interface AgentHarnessStreamOptionsPatch\n\textends Omit<Partial<AgentHarnessStreamOptions>, \"headers\" | \"metadata\"> {\n\t/** Header patch. `undefined` values delete keys; explicit `headers: undefined` clears all headers. */\n\theaders?: Record<string, string | undefined>;\n\t/** Metadata patch. `undefined` values delete keys; explicit `metadata: undefined` clears all metadata. */\n\tmetadata?: Record<string, unknown | undefined>;\n}\n\n/** Kind of filesystem object as addressed by a {@link FileSystem}. Symlinks are not followed automatically. */\nexport type FileKind = \"file\" | \"directory\" | \"symlink\";\n\n/** Stable, backend-independent file error codes returned by {@link FileSystem} file operations. */\nexport type FileErrorCode =\n\t| \"aborted\"\n\t| \"not_found\"\n\t| \"permission_denied\"\n\t| \"not_directory\"\n\t| \"is_directory\"\n\t| \"invalid\"\n\t| \"not_supported\"\n\t| \"unknown\";\n\n/** Error returned by {@link FileSystem} file operations. */\nexport class FileError extends Error {\n\treadonly cause?: unknown;\n\t/** Backend-independent error code. */\n\tpublic code: FileErrorCode;\n\t/** Absolute addressed path associated with the failure, when available. */\n\tpublic path?: string;\n\n\tconstructor(code: FileErrorCode, message: string, path?: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"FileError\";\n\t\tthis.code = code;\n\t\tthis.path = path;\n\t\tif (cause !== undefined) this.cause = cause;\n\t}\n}\n\n/** Stable, backend-independent execution error codes returned by {@link ExecutionEnv.exec}. */\nexport type ExecutionErrorCode =\n\t| \"aborted\"\n\t| \"timeout\"\n\t| \"shell_unavailable\"\n\t| \"spawn_error\"\n\t| \"callback_error\"\n\t| \"unknown\";\n\n/** Error returned by {@link ExecutionEnv.exec}. */\nexport class ExecutionError extends Error {\n\treadonly cause?: unknown;\n\t/** Backend-independent error code. */\n\tpublic code: ExecutionErrorCode;\n\n\tconstructor(code: ExecutionErrorCode, message: string, cause?: unknown) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"ExecutionError\";\n\t\tthis.code = code;\n\t\tif (cause !== undefined) this.cause = cause;\n\t}\n}\n\n/** Stable compaction error codes returned by compaction helpers. */\nexport type CompactionErrorCode = \"aborted\" | \"summarization_failed\";\n\n/** Error returned by compaction helpers. */\nexport class CompactionError extends Error {\n\treadonly cause?: unknown;\n\t/** Backend-independent error code. */\n\tpublic code: CompactionErrorCode;\n\n\tconstructor(code: CompactionErrorCode, message: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"CompactionError\";\n\t\tthis.code = code;\n\t\tif (cause !== undefined) this.cause = cause;\n\t}\n}\n\n/** Stable branch-summary error codes returned by branch summarization helpers. */\nexport type BranchSummaryErrorCode = \"aborted\" | \"summarization_failed\";\n\n/** Error returned by branch summarization helpers. */\nexport class BranchSummaryError extends Error {\n\t/** Backend-independent error code. */\n\tpublic code: BranchSummaryErrorCode;\n\n\tconstructor(code: BranchSummaryErrorCode, message: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"BranchSummaryError\";\n\t\tthis.code = code;\n\t}\n}\n\n/** Metadata for one filesystem object in a {@link FileSystem}. */\nexport interface FileInfo {\n\t/** Basename of {@link path}. */\n\tname: string;\n\t/** Absolute, syntactically normalized addressed path in the execution environment. Symlinks are not followed. */\n\tpath: string;\n\t/** Object kind. Symlink targets are not followed; use {@link FileSystem.canonicalPath} explicitly. */\n\tkind: FileKind;\n\t/** Size in bytes for the addressed filesystem object. */\n\tsize: number;\n\t/** Modification time as milliseconds since Unix epoch. */\n\tmtimeMs: number;\n}\n\n/** One UTF-8 line read from a text file. */\nexport interface TextLine {\n\ttext: string;\n\t/** Whether the line ended with `\\n`; callers use this to discard a torn final record. */\n\tterminated: boolean;\n}\n\n/** Pull-based UTF-8 line reader that preserves final-line termination. */\nexport interface TextLineReader {\n\treadLine(context: Context): Promise<Result<TextLine | undefined, FileError>>;\n\t/** Release the open file. Must be best-effort and must not throw or reject. */\n\tclose(context: Context): Promise<void>;\n}\n\n/**\n * Filesystem capability used by the harness.\n *\n * Paths passed to methods may be absolute or relative to {@link cwd}. Paths returned by file operations are addressed paths\n * in the filesystem namespace, but are not canonicalized through symlinks unless returned by {@link canonicalPath}.\n *\n * Operation methods must never throw or reject. All filesystem failures, including unexpected backend failures, must be\n * encoded in the returned {@link Result}. Implementations must preserve this invariant.\n */\nexport interface FileSystem {\n\t/** Current working directory for relative paths. */\n\tcwd: string;\n\n\t/** Return an absolute addressed path without requiring it to exist and without resolving symlinks. */\n\tabsolutePath(path: string, context: Context): Promise<Result<string, FileError>>;\n\t/** Join path segments in the filesystem namespace without requiring the result to exist. */\n\tjoinPath(parts: string[], context: Context): Promise<Result<string, FileError>>;\n\t/** Read a UTF-8 text file. */\n\treadTextFile(path: string, context: Context): Promise<Result<string, FileError>>;\n\t/** Open a UTF-8 text file for pull-based line reading. */\n\topenTextLineReader(path: string, context: Context): Promise<Result<TextLineReader, FileError>>;\n\t/** Read UTF-8 text lines. Implementations should stop once `maxLines` lines have been read. */\n\treadTextLines(\n\t\tpath: string,\n\t\toptions: { maxLines?: number } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<string[], FileError>>;\n\t/** Read a binary file. */\n\treadBinaryFile(path: string, context: Context): Promise<Result<Uint8Array, FileError>>;\n\t/** Create or overwrite a file, creating parent directories when supported. */\n\twriteFile(path: string, content: string | Uint8Array, context: Context): Promise<Result<void, FileError>>;\n\t/** Create or append to a file, creating parent directories when supported. */\n\tappendFile(path: string, content: string | Uint8Array, context: Context): Promise<Result<void, FileError>>;\n\t/** Atomically rename a file, replacing the destination when it exists. Does not copy across filesystems. */\n\trenameFile(sourcePath: string, destinationPath: string, context: Context): Promise<Result<void, FileError>>;\n\t/** Return metadata for the addressed path without following symlinks. */\n\tfileInfo(path: string, context: Context): Promise<Result<FileInfo, FileError>>;\n\t/** List direct children of a directory without following symlinks. */\n\tlistDir(path: string, context: Context): Promise<Result<FileInfo[], FileError>>;\n\t/** Return the canonical path for an existing path, resolving symlinks where supported. */\n\tcanonicalPath(path: string, context: Context): Promise<Result<string, FileError>>;\n\t/** Return false for missing paths. Other errors, such as permission failures, return a {@link FileError}. */\n\texists(path: string, context: Context): Promise<Result<boolean, FileError>>;\n\t/** Create a directory. Defaults to `recursive: true`. */\n\tcreateDir(\n\t\tpath: string,\n\t\toptions: { recursive?: boolean } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<void, FileError>>;\n\t/** Remove a file or directory. Defaults to `recursive: false` and `force: false`. */\n\tremove(\n\t\tpath: string,\n\t\toptions: { recursive?: boolean; force?: boolean } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<void, FileError>>;\n\t/** Create a temporary directory and return its absolute path. Defaults to `prefix: \"tmp-\"`. */\n\tcreateTempDir(prefix: string | undefined, context: Context): Promise<Result<string, FileError>>;\n\t/** Create a temporary file and return its absolute path. Defaults to `prefix: \"\"` and `suffix: \"\"`. */\n\tcreateTempFile(\n\t\toptions: { prefix?: string; suffix?: string } | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<string, FileError>>;\n\n\t/** Release filesystem resources. Must be best-effort and must not throw or reject. */\n\tcleanup(context: Context): Promise<void>;\n}\n\n/** Which portion of bounded output survives after the limit is crossed. */\nexport type ShellOutputRetention = \"head\" | \"tail\";\n\n/** Source-side limits for one combined shell output view. */\nexport interface ShellOutputLimits {\n\tmaxBytes: number;\n\tmaxLines: number;\n\t/** Defaults to `\"tail\"`. */\n\tretain?: ShellOutputRetention;\n}\n\n/** Bounded shell capture requested by the caller. */\nexport interface ShellOutputCaptureOptions {\n\tlimits: ShellOutputLimits;\n\t/** Preserve complete output in an execution-environment-local file after the limits are crossed. */\n\tspill?: boolean;\n}\n\n/** Truncation metadata without a duplicate copy of the retained text. */\nexport type ShellOutputTruncation = Omit<TruncationResult, \"content\">;\n\n/** Metadata accompanying a bounded shell output view. */\nexport interface ShellOutputMetadata {\n\ttruncation: ShellOutputTruncation;\n\tspillPath?: string;\n\tlastLineBytes?: number;\n}\n\n/** Complete bounded shell output view. */\nexport interface ShellOutputView extends ShellOutputMetadata {\n\ttext: string;\n}\n\n/** Incremental source-side change to one bounded shell output view. */\nexport type ShellOutputUpdate =\n\t| { kind: \"replace\"; output: ShellOutputView }\n\t| { kind: \"append\"; text: string; metadata: ShellOutputMetadata }\n\t| { kind: \"slide\"; drop: number; text: string; metadata: ShellOutputMetadata }\n\t| { kind: \"metadata\"; metadata: ShellOutputMetadata };\n\n/** Bounded shell completion. Output text is delivered through {@link ShellExecOptions.onUpdate}. */\nexport interface ShellExecResult extends ShellOutputMetadata {\n\texitCode: number;\n}\n\n/** Options for {@link Shell.exec}. */\nexport interface ShellExecOptions {\n\t/** Working directory for the command. Relative paths are resolved against {@link ExecutionEnv.cwd}. Defaults to {@link ExecutionEnv.cwd}. */\n\tcwd?: string;\n\t/** Environment variables for the command. Values override inherited defaults when `inheritEnv` is true. */\n\tenv?: Record<string, string>;\n\t/** Whether to inherit the execution environment's default variables. Defaults to true. */\n\tinheritEnv?: boolean;\n\t/** Timeout in seconds. Implementations should return a timeout error when the command exceeds this duration. Defaults to no timeout. */\n\ttimeout?: number;\n\t/** Source-side bounded capture. Output is discarded when this and `onUpdate` are both absent. */\n\tcapture?: ShellOutputCaptureOptions;\n\t/**\n\t * Called with bounded output changes.\n\t *\n\t * A returned promise is awaited before the execution result settles: an observer that rejects\n\t * fails the execution with a `callback_error` whose `cause` is the value it rejected with,\n\t * instead of surfacing as an unhandled rejection.\n\t */\n\tonUpdate?: (update: ShellOutputUpdate, context: Context) => void | PromiseLike<void>;\n}\n\n/** Shell execution capability used by the harness. */\nexport interface Shell {\n\t/** Execute a shell command in {@link FileSystem.cwd} unless `options.cwd` is provided. */\n\texec(\n\t\tcommand: string,\n\t\toptions: ShellExecOptions | undefined,\n\t\tcontext: Context,\n\t): Promise<Result<ShellExecResult, ExecutionError>>;\n\t/** Release shell resources. Must be best-effort and must not throw or reject. */\n\tcleanup(context: Context): Promise<void>;\n}\n\n/** Filesystem and process execution environment used by the harness. */\nexport interface ExecutionEnv extends FileSystem, Shell {}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adaptive-publisher.d.ts","sourceRoot":"","sources":["../../../src/harness/utils/adaptive-publisher.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,wBAAwB,CAAC,MAAM,EAAE,OAAO;IACxD,QAAQ,IAAI,MAAM,CAAC;IACnB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IAC3E,OAAO,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC;IACjC,OAAO,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/B,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;GAMG;AACH,qBAAa,iBAAiB,CAAC,MAAM,EAAE,OAAO;;IAU7C,YAAY,OAAO,EAAE,wBAAwB,CAAC,MAAM,EAAE,OAAO,CAAC,EAI7D;IAED,SAAS,IAAI,IAAI,CAShB;IAED,KAAK,CAAC,KAAK,UAAQ,GAAG,IAAI,CAuBzB;IAED,OAAO,IAAI,IAAI,CAId;CAaD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adaptive-publisher.js","sourceRoot":"","sources":["../../../src/harness/utils/adaptive-publisher.ts"],"names":[],"mappings":"AAUA;;;;;;GAMG;AACH,MAAM,OAAO,iBAAiB;IACpB,QAAQ,CAA4C;IACpD,cAAc,CAAS;IACvB,q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AC,EAAE,IAAI,CAAC,CAAC;IACV,CAAC;CACD","sourcesContent":["export interface AdaptivePublisherOptions<TValue, TUpdate> {\n\tsnapshot(): TValue;\n\tupdate(previous: TValue | undefined, current: TValue): TUpdate | undefined;\n\tmeasure(update: TUpdate): number;\n\tpublish(update: TUpdate): void;\n\tonError(error: unknown): void;\n\tminIntervalMs?: number;\n\ttargetBytesPerSecond?: number;\n}\n\n/**\n * Publishes the latest state without queuing intermediate mutations.\n *\n * The first dirty state after idle is immediate. Each publication then buys a\n * delay proportional to its encoded size, with a minimum interval that also\n * bounds event count. A single trailing timer guarantees eventual publication.\n */\nexport class AdaptivePublisher<TValue, TUpdate> {\n\treadonly #options: AdaptivePublisherOptions<TValue, TUpdate>;\n\treadonly #minIntervalMs: number;\n\treadonly #targetBytesPerSecond: number;\n\t#published: TValue | undefined;\n\t#dirty = false;\n\t#nextEmitAt = 0;\n\t#timer: ReturnType<typeof setTimeout> | undefined;\n\t#disposed = false;\n\n\tconstructor(options: AdaptivePublisherOptions<TValue, TUpdate>) {\n\t\tthis.#options = options;\n\t\tthis.#minIntervalMs = options.minIntervalMs ?? 100;\n\t\tthis.#targetBytesPerSecond = options.targetBytesPerSecond ?? 100 * 1024;\n\t}\n\n\tmarkDirty(): void {\n\t\tif (this.#disposed) return;\n\t\tthis.#dirty = true;\n\t\tconst wait = this.#nextEmitAt - Date.now();\n\t\tif (wait <= 0) {\n\t\t\tthis.flush();\n\t\t\treturn;\n\t\t}\n\t\tthis.#armTimer(wait);\n\t}\n\n\tflush(force = false): void {\n\t\tif (this.#disposed || !this.#dirty) return;\n\t\tconst now = Date.now();\n\t\tif (!force && now < this.#nextEmitAt) {\n\t\t\tthis.#armTimer(this.#nextEmitAt - now);\n\t\t\treturn;\n\t\t}\n\t\tif (this.#timer !== undefined) clearTimeout(this.#timer);\n\t\tthis.#timer = undefined;\n\t\tconst current = this.#options.snapshot();\n\t\tconst update = this.#options.update(this.#published, current);\n\t\tif (update === undefined) {\n\t\t\tthis.#published = current;\n\t\t\tthis.#dirty = false;\n\t\t\treturn;\n\t\t}\n\t\tconst encodedBytes = this.#options.measure(update);\n\t\tthis.#published = current;\n\t\tthis.#dirty = false;\n\t\tthis.#nextEmitAt = now + Math.max(this.#minIntervalMs, (encodedBytes * 1000) / this.#targetBytesPerSecond);\n\t\t// Commit before delivery. A consumer may apply the update and then throw or\n\t\t// reenter the producer; retaining the old baseline would duplicate that delta.\n\t\tthis.#options.publish(update);\n\t}\n\n\tdispose(): void {\n\t\tif (this.#timer !== undefined) clearTimeout(this.#timer);\n\t\tthis.#timer = undefined;\n\t\tthis.#disposed = true;\n\t}\n\n\t#armTimer(wait: number): void {\n\t\tif (this.#timer !== undefined) return;\n\t\tthis.#timer = setTimeout(() => {\n\t\t\tthis.#timer = undefined;\n\t\t\ttry {\n\t\t\t\tthis.flush();\n\t\t\t} catch (error) {\n\t\t\t\tthis.#options.onError(error);\n\t\t\t}\n\t\t}, wait);\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"output-capture.d.ts","sourceRoot":"","sources":["../../../src/harness/utils/output-capture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,yBAAyB,EAAuB,iBAAiB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAItH,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAC/C,eAAO,MAAM,8BAA8B,QAAa,CAAC;AAMzD,UAAU,qBAAqB;IAC9B,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACjE,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;CAC9B;AAED;;;;;;;GAOG;AACH,qBAAa,aAAa;;IAkBzB,YAAY,OAAO,EAAE,yBAAyB,GAAG,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,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\nimport type { ShellOutputCaptureOptions, ShellOutputMetadata, ShellOutputUpdate, ShellOutputView } from \"../types.ts\";\nimport { AdaptivePublisher } from \"./adaptive-publisher.ts\";\nimport { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, truncateHead, truncateTail, utf8ByteLength } from \"./truncate.ts\";\n\nexport const OUTPUT_MIN_EMIT_INTERVAL_MS = 100;\nexport const OUTPUT_TARGET_BYTES_PER_SECOND = 100 * 1024;\n\nconst INVALID_SHELL_OUTPUT = /[\\x00-\\x08\\x0b-\\x1f\\ufff9-\\ufffb]/g;\nconst textEncoder = new TextEncoder();\nconst textDecoder = new TextDecoder();\n\ninterface OutputCaptureHandlers {\n\tonUpdate?: (update: ShellOutputUpdate, context: Context) => void;\n\tonError(error: unknown): void;\n}\n\n/**\n * Maintains and publishes one bounded shell-output view.\n *\n * Writes received while publication is rate-limited collapse into the latest\n * view. Small changes remain responsive; complete window turnovers purchase a\n * proportionally longer delay. The first update after idle and an explicit\n * final flush are immediate.\n */\nexport class OutputCapture {\n\treadonly #maxBytes: number;\n\treadonly #maxLines: number;\n\treadonly #retain: \"head\" | \"tail\";\n\treadonly #context: Context;\n\treadonly #onUpdate: OutputCaptureHandlers[\"onUpdate\"];\n\n\treadonly #decoder = new TextDecoder();\n\t#buffer = \"\";\n\t#bufferBytes = 0;\n\t#totalBytes = 0;\n\t#newlines = 0;\n\t#endsWithNewline = true;\n\t#currentLineBytes = 0;\n\t#spillPath: string | undefined;\n\t#disposed = false;\n\treadonly #publisher: AdaptivePublisher<ShellOutputView, ShellOutputUpdate>;\n\n\tconstructor(options: ShellOutputCaptureOptions | undefined, context: Context, handlers: OutputCaptureHandlers) {\n\t\tthis.#maxBytes = options?.limits.maxBytes ?? DEFAULT_MAX_BYTES;\n\t\tthis.#maxLines = options?.limits.maxLines ?? DEFAULT_MAX_LINES;\n\t\tthis.#retain = options?.limits.retain ?? \"tail\";\n\t\tthis.#context = context;\n\t\tthis.#onUpdate = handlers.onUpdate;\n\t\tif (!Number.isFinite(this.#maxBytes) || this.#maxBytes <= 0) {\n\t\t\tthrow new TypeError(\"Output maxBytes must be a positive finite number\");\n\t\t}\n\t\tif (!Number.isInteger(this.#maxLines) || this.#maxLines <= 0) {\n\t\t\tthrow new TypeError(\"Output maxLines must be a positive integer\");\n\t\t}\n\t\tthis.#publisher = new AdaptivePublisher({\n\t\t\tsnapshot: () => this.snapshot(),\n\t\t\tupdate: updateFrom,\n\t\t\tmeasure: (update) => utf8ByteLength(JSON.stringify(update)),\n\t\t\tpublish: (update) => this.#onUpdate?.(update, this.#context),\n\t\t\tonError: handlers.onError,\n\t\t\tminIntervalMs: OUTPUT_MIN_EMIT_INTERVAL_MS,\n\t\t\ttargetBytesPerSecond: OUTPUT_TARGET_BYTES_PER_SECOND,\n\t\t});\n\t}\n\n\tget truncated(): boolean {\n\t\treturn this.#totalBytes > this.#maxBytes || this.#totalLines() > this.#maxLines;\n\t}\n\n\tpush(chunk: string | Uint8Array): void {\n\t\tif (this.#disposed) return;\n\t\tif (typeof chunk === \"string\") {\n\t\t\tthis.#appendText(this.#decoder.decode());\n\t\t\tthis.#appendText(chunk);\n\t\t\treturn;\n\t\t}\n\t\tthis.#appendText(this.#decoder.decode(chunk, { stream: true }));\n\t}\n\n\tfinish(): void {\n\t\tif (this.#disposed) return;\n\t\tthis.#appendText(this.#decoder.decode());\n\t}\n\n\tsetSpillPath(path: string): void {\n\t\tif (this.#disposed || this.#spillPath === path) return;\n\t\tthis.#spillPath = path;\n\t\tthis.#publisher.markDirty();\n\t\tthis.flush();\n\t}\n\n\tsnapshot(): ShellOutputView {\n\t\tconst retained =\n\t\t\tthis.#retain === \"head\"\n\t\t\t\t? truncateHead(this.#buffer, { maxBytes: this.#maxBytes, maxLines: this.#maxLines })\n\t\t\t\t: truncateTail(this.#buffer, { maxBytes: this.#maxBytes, maxLines: this.#maxLines });\n\t\tconst totalLines = this.#totalLines();\n\t\tconst truncated = this.truncated;\n\t\tconst { content, ...truncation } = retained;\n\t\treturn {\n\t\t\ttext: sanitizeShellOutput(content),\n\t\t\ttruncation: {\n\t\t\t\t...truncation,\n\t\t\t\ttruncated,\n\t\t\t\ttruncatedBy: truncated ? (totalLines > this.#maxLines ? \"lines\" : \"bytes\") : null,\n\t\t\t\ttotalBytes: this.#totalBytes,\n\t\t\t\ttotalLines,\n\t\t\t},\n\t\t\t...(this.#spillPath === undefined ? {} : { spillPath: this.#spillPath }),\n\t\t\t...(retained.lastLinePartial ? { lastLineBytes: this.#currentLineBytes } : {}),\n\t\t};\n\t}\n\n\tflush(): void {\n\t\tif (this.#disposed) return;\n\t\tthis.#publisher.flush(true);\n\t}\n\n\tdispose(): void {\n\t\tthis.#publisher.dispose();\n\t\tthis.#disposed = true;\n\t}\n\n\t#appendText(text: string): void {\n\t\tif (text === \"\") return;\n\t\tconst textBytes = utf8ByteLength(text);\n\t\tthis.#totalBytes += textBytes;\n\t\tthis.#newlines += countNewlines(text);\n\t\tthis.#endsWithNewline = text.endsWith(\"\\n\");\n\t\tconst lastNewline = text.lastIndexOf(\"\\n\");\n\t\tthis.#currentLineBytes =\n\t\t\tlastNewline === -1 ? this.#currentLineBytes + textBytes : utf8ByteLength(text.slice(lastNewline + 1));\n\t\tthis.#buffer += text;\n\t\tthis.#bufferBytes += textBytes;\n\n\t\tconst guard = this.#maxBytes * 2;\n\t\tif (this.#bufferBytes > guard * 2) {\n\t\t\tthis.#buffer =\n\t\t\t\tthis.#retain === \"tail\"\n\t\t\t\t\t? trimToLastUtf8Bytes(this.#buffer, guard)\n\t\t\t\t\t: trimToFirstUtf8Bytes(this.#buffer, guard);\n\t\t\tthis.#bufferBytes = utf8ByteLength(this.#buffer);\n\t\t}\n\t\tthis.#publisher.markDirty();\n\t}\n\n\t#totalLines(): number {\n\t\treturn this.#newlines + (this.#endsWithNewline || this.#totalBytes === 0 ? 0 : 1);\n\t}\n}\n\nexport function applyShellOutputUpdate(\n\tcurrent: ShellOutputView | undefined,\n\tupdate: ShellOutputUpdate,\n): ShellOutputView {\n\tswitch (update.kind) {\n\t\tcase \"replace\":\n\t\t\treturn update.output;\n\t\tcase \"append\":\n\t\t\treturn { text: `${current?.text ?? \"\"}${update.text}`, ...update.metadata };\n\t\tcase \"slide\":\n\t\t\treturn { text: `${current?.text.slice(update.drop) ?? \"\"}${update.text}`, ...update.metadata };\n\t\tcase \"metadata\":\n\t\t\treturn { text: current?.text ?? \"\", ...update.metadata };\n\t}\n}\n\nfunction updateFrom(previous: ShellOutputView | undefined, current: ShellOutputView): ShellOutputUpdate {\n\tif (previous === undefined) return { kind: \"replace\", output: current };\n\tconst metadata: ShellOutputMetadata = {\n\t\ttruncation: current.truncation,\n\t\t...(current.spillPath === undefined ? {} : { spillPath: current.spillPath }),\n\t\t...(current.lastLineBytes === undefined ? {} : { lastLineBytes: current.lastLineBytes }),\n\t};\n\tif (current.text === previous.text) return { kind: \"metadata\", metadata };\n\tif (current.text.length > previous.text.length && current.text.slice(0, previous.text.length) === previous.text) {\n\t\treturn { kind: \"append\", text: current.text.slice(previous.text.length), metadata };\n\t}\n\tconst shared = suffixPrefixOverlap(\n\t\tprevious.text,\n\t\tcurrent.text,\n\t\tMath.min(previous.text.length, current.text.length, current.truncation.maxBytes * 2),\n\t);\n\tif (shared > 0) {\n\t\treturn {\n\t\t\tkind: \"slide\",\n\t\t\tdrop: previous.text.length - shared,\n\t\t\ttext: current.text.slice(shared),\n\t\t\tmetadata,\n\t\t};\n\t}\n\treturn { kind: \"replace\", output: current };\n}\n\nfunction suffixPrefixOverlap(before: string, after: string, scan: number): number {\n\tif (before.length === 0 || after.length === 0 || scan === 0) return 0;\n\tconst tail = before.length > scan ? before.slice(before.length - scan) : before;\n\tfor (const probeLength of [Math.min(64, after.length), 1]) {\n\t\tconst probe = after.slice(0, probeLength);\n\t\tlet candidates = 0;\n\t\tfor (let index = tail.indexOf(probe); index !== -1; index = tail.indexOf(probe, index + 1)) {\n\t\t\tif (++candidates > 8) break;\n\t\t\tconst overlapLength = tail.length - index;\n\t\t\tif (overlapLength <= after.length && tail.slice(index) === after.slice(0, overlapLength)) {\n\t\t\t\treturn overlapLength;\n\t\t\t}\n\t\t}\n\t\tif (probeLength === 1) break;\n\t}\n\treturn 0;\n}\n\nexport function sanitizeShellOutput(text: string): string {\n\treturn text.replace(INVALID_SHELL_OUTPUT, \"\");\n}\n\nfunction countNewlines(text: string): number {\n\tlet count = 0;\n\tfor (let index = text.indexOf(\"\\n\"); index !== -1; index = text.indexOf(\"\\n\", index + 1)) count++;\n\treturn count;\n}\n\nfunction trimToLastUtf8Bytes(text: string, maxBytes: number): string {\n\tconst bytes = textEncoder.encode(text);\n\tif (bytes.length <= maxBytes) return text;\n\tlet start = bytes.length - maxBytes;\n\twhile (start < bytes.length && ((bytes[start] ?? 0) & 0xc0) === 0x80) start++;\n\treturn textDecoder.decode(bytes.subarray(start));\n}\n\nfunction trimToFirstUtf8Bytes(text: string, maxBytes: number): string {\n\tconst bytes = textEncoder.encode(text);\n\tif (bytes.length <= maxBytes) return text;\n\tlet end = maxBytes;\n\twhile (end > 0 && ((bytes[end] ?? 0) & 0xc0) === 0x80) end--;\n\treturn textDecoder.decode(bytes.subarray(0, end));\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"brace-scanner.d.ts","sourceRoot":"","sources":["../../../../src/harness/utils/read-folders/brace-scanner.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAiB,MAAM,YAAY,CAAC;AAEjF,+EAA+E;AAC/E,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,GAAG,IAAI,GAAG,MAAM,EAAE,QAAQ,EAAE,gBAAgB,GAAG,aAAa,CAqPpH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"brace-scanner.js","sourceRoot":"","sources":["../../../../src/harness/utils/read-folders/brace-scanner.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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AC;YAClB,YAAY,GAAG,KAAK,CAAC;YACrB,oBAAoB,GAAG,KAAK,CAAC;YAC7B,IAAI,mBAAmB,KAAK,KAAK,CAAC,MAAM;gBAAE,mBAAmB,GAAG,SAAS,CAAC;QAC3E,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC;YACvF,OAAO,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAChC,UAAU,GAAG,UAAU,IAAI,QAAQ,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,CAAC;QAC5E,QAAQ,GAAG,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;QACtD,CAAC,IAAI,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/B,aAAa,GAAG,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IAC7C,CAAC;IACD,OAAO,QAAQ,IAAI,aAAa,IAAI,KAAK,CAAC,MAAM,IAAI,OAAO,CAAC,UAAU;QACrE,CAAC,CAAC,IAAI,CAAC,+BAA+B,CAAC;QACvC,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;AACzD,CAAC","sourcesContent":["import { HeaderProtection } from \"./header-protection.ts\";\nimport { controls, expressionKeywords, isCallCallee, type Open, signatureDeclarations } from \"./lexical-context.ts\";\nimport { commentSpan, lineCommentEnd, regexSpan, stringSpan, typeArgumentsSpan } from \"./lexical-spans.ts\";\nimport type { ReadBraceScan, ReadFoldSettings, ReadLineRange } from \"./types.ts\";\n\n/** Measured row-17 brace lexer, restricted to the three selected languages. */\nexport function scanBraces(source: string, language: \"ts\" | \"js\" | \"json\", settings: ReadFoldSettings): ReadBraceScan {\n\tconst ranges: ReadLineRange[] = [];\n\tconst stack: Open[] = [];\n\tconst headers = new HeaderProtection();\n\tconst fail = (reason: string): ReadBraceScan => ({ status: \"parse_failure\", reason });\n\tlet line = 1;\n\tlet i = 0;\n\tlet template = false;\n\tlet templateDepth = 0;\n\tlet previous = \"\";\n\tlet beforeWord = \"\";\n\tlet wordLine = 1;\n\tlet valueArrow = false;\n\tlet expressionEnd: boolean | null = false;\n\tlet importClause = false;\n\tlet ambiguousAngleDepth: number | undefined;\n\tlet signatureDeclaration = false;\n\tif (source.startsWith(\"#!\")) {\n\t\tconst end = source.indexOf(\"\\n\");\n\t\ti = end < 0 ? source.length : end;\n\t}\n\twhile (i < source.length) {\n\t\tconst char = source[i];\n\t\tconst next = source[i + 1];\n\t\tif (char === \"\\n\") line++;\n\t\tif (template) {\n\t\t\tif (char === \"\\\\\") {\n\t\t\t\tif (next === \"\\n\") line++;\n\t\t\t\ti += 2;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (char === \"`\") {\n\t\t\t\ttemplate = false;\n\t\t\t\ttemplateDepth--;\n\t\t\t\texpressionEnd = true;\n\t\t\t\tprevious = \"literal\";\n\t\t\t} else if (char === \"$\" && next === \"{\") {\n\t\t\t\tstack.push({\n\t\t\t\t\tchar: \"{\",\n\t\t\t\t\tline,\n\t\t\t\t\tfoldable: false,\n\t\t\t\t\tprotected: true,\n\t\t\t\t\tsignature: false,\n\t\t\t\t\tinterpolation: true,\n\t\t\t\t\tcontrol: false,\n\t\t\t\t\tcall: false,\n\t\t\t\t\tvalueParameters: false,\n\t\t\t\t\tdeclaration: false,\n\t\t\t\t});\n\t\t\t\ttemplate = false;\n\t\t\t\texpressionEnd = false;\n\t\t\t\tprevious = \"{\";\n\t\t\t\ti += 2;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (/\\s/.test(char)) {\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"/\" && next === \"/\") {\n\t\t\ti = lineCommentEnd(source, i);\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"/\" && next === \"*\") {\n\t\t\tconst span = commentSpan(source, i + 2);\n\t\t\tif (!span) return fail(\"unterminated_comment\");\n\t\t\t// Keep declaration docs and every delimiter line with the source signature.\n\t\t\tif (\n\t\t\t\tspan.newlines + 1 >= settings.minCommentLines &&\n\t\t\t\ttemplateDepth === 0 &&\n\t\t\t\t!stack.some((open) => open.protected) &&\n\t\t\t\t!source.startsWith(\"/**\", i) &&\n\t\t\t\t!source.startsWith(\"/*!\", i)\n\t\t\t) {\n\t\t\t\tranges.push({ startLine: line + 1, endLine: line + span.newlines - 1 });\n\t\t\t}\n\t\t\tif (source.startsWith(\"/**\", i) || source.startsWith(\"/*!\", i)) headers.protect(line, line + span.newlines);\n\t\t\tline += span.newlines;\n\t\t\ti = span.end;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '\"' || char === \"'\") {\n\t\t\tconst span = stringSpan(source, i + 1, char);\n\t\t\tif (!span) return fail(\"unterminated_string\");\n\t\t\tline += span.newlines;\n\t\t\ti = span.end;\n\t\t\tprevious = \"literal\";\n\t\t\texpressionEnd = true;\n\t\t\tif (!stack.length) importClause = false;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"`\") {\n\t\t\ttemplate = true;\n\t\t\ttemplateDepth++;\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"/\") {\n\t\t\tif (expressionEnd === null) return fail(\"ambiguous_regex_literal\");\n\t\t\tif (!expressionEnd) {\n\t\t\t\tconst span = regexSpan(source, i + 1);\n\t\t\t\tif (!span) return fail(\"ambiguous_or_unterminated_regex\");\n\t\t\t\ti = span.end;\n\t\t\t\tprevious = \"literal\";\n\t\t\t\texpressionEnd = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\ti += next === \"=\" ? 2 : 1;\n\t\t\texpressionEnd = false;\n\t\t\tprevious = \"/\";\n\t\t\tcontinue;\n\t\t}\n\t\tif (/[A-Za-z_$]/.test(char)) {\n\t\t\tconst start = i++;\n\t\t\twhile (/[A-Za-z_$0-9]/.test(source[i] ?? \"\")) i++;\n\t\t\tbeforeWord = previous;\n\t\t\tprevious = source.slice(start, i);\n\t\t\twordLine = line;\n\t\t\tif (!headers.word(previous, beforeWord, stack.length, line, language === \"ts\")) return fail(\"unproved_header\");\n\t\t\texpressionEnd = !expressionKeywords.has(previous);\n\t\t\tif (language === \"ts\" && signatureDeclarations.has(previous)) signatureDeclaration = true;\n\t\t\tif (previous === \"import\") importClause = true;\n\t\t\tif (previous === \"from\") importClause = false;\n\t\t\tcontinue;\n\t\t}\n\t\tif (/[0-9]/.test(char)) {\n\t\t\ti++;\n\t\t\twhile (/[A-Za-z_0-9.]/.test(source[i] ?? \"\")) i++;\n\t\t\texpressionEnd = true;\n\t\t\tprevious = \"number\";\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"{\" || char === \"[\" || char === \"(\") {\n\t\t\tif (char === \"{\" && ambiguousAngleDepth !== undefined) return fail(\"ambiguous_angle_syntax\");\n\t\t\tif (\n\t\t\t\tlanguage !== \"json\" &&\n\t\t\t\tchar !== \"(\" &&\n\t\t\t\tprevious === \",\" &&\n\t\t\t\t!stack.some((open) => open.protected) &&\n\t\t\t\tstack.at(-1)?.char !== \"[\" &&\n\t\t\t\t!stack.at(-1)?.call\n\t\t\t)\n\t\t\t\treturn fail(\"ambiguous_binding\");\n\t\t\tconst classBody = headers.open(char, stack.length, previous, line);\n\t\t\tif (!headers.punctuation(char, stack.length, line)) return fail(\"unproved_header\");\n\t\t\tconst call = char === \"(\" && isCallCallee(previous, beforeWord);\n\t\t\tconst declaration = signatureDeclaration && !stack.some((open) => open.declaration);\n\t\t\tconst signature =\n\t\t\t\tdeclaration ||\n\t\t\t\theaders.active ||\n\t\t\t\tstack.some((open) => open.signature) ||\n\t\t\t\t(language !== \"json\" && char === \"[\" && stack.at(-1)?.char === \"{\") ||\n\t\t\t\timportClause ||\n\t\t\t\t[\"const\", \"let\", \"var\", \"export\", \"type\", \"#\", \"!\"].includes(previous) ||\n\t\t\t\t(language !== \"json\" && [\":\", \"<\", \"&\", \"|\"].includes(previous)) ||\n\t\t\t\t(language === \"ts\" && previous === \"=>\" && !valueArrow);\n\t\t\tconst protectedRange =\n\t\t\t\tsignature ||\n\t\t\t\t(char === \"(\" && !call && !(previous === \"=>\" && valueArrow)) ||\n\t\t\t\tstack.some((open) => open.protected);\n\t\t\tconst foldable =\n\t\t\t\ttemplateDepth === 0 &&\n\t\t\t\tchar !== \"(\" &&\n\t\t\t\t!classBody &&\n\t\t\t\t!protectedRange &&\n\t\t\t\t(char === \"{\" || !expressionEnd || language === \"json\");\n\t\t\tstack.push({\n\t\t\t\tchar,\n\t\t\t\tline,\n\t\t\t\theaderLine: char === \"(\" ? wordLine : line,\n\t\t\t\ttarget: char !== \"(\" && !expressionEnd,\n\t\t\t\tfoldable,\n\t\t\t\tprotected: protectedRange,\n\t\t\t\tsignature,\n\t\t\t\tinterpolation: false,\n\t\t\t\tcontrol: char === \"(\" && controls.has(previous),\n\t\t\t\tcall,\n\t\t\t\tvalueParameters: char === \"(\" && stack.at(-1)?.call === true && [\"(\", \",\"].includes(previous),\n\t\t\t\tdeclaration,\n\t\t\t});\n\t\t\tvalueArrow = false;\n\t\t\texpressionEnd = false;\n\t\t\tprevious = char;\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"}\" || char === \"]\" || char === \")\") {\n\t\t\tconst open = stack.pop();\n\t\t\tif (ambiguousAngleDepth !== undefined && stack.length < ambiguousAngleDepth) ambiguousAngleDepth = undefined;\n\t\t\tif (!open || { \"{\": \"}\", \"[\": \"]\", \"(\": \")\" }[open.char] !== char) return fail(\"unbalanced_delimiters\");\n\t\t\tif (open.interpolation) {\n\t\t\t\ttemplate = true;\n\t\t\t\ti++;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\theaders.close(open, stack.length, line);\n\t\t\tif (open.foldable && line - open.line - 1 >= settings.minBodyLines)\n\t\t\t\tranges.push({ startLine: open.line + 1, endLine: line - 1 });\n\t\t\tvalueArrow = open.valueParameters;\n\t\t\tif (open.declaration) signatureDeclaration = false;\n\t\t\texpressionEnd = open.control ? false : char === \"}\" ? null : true;\n\t\t\tif (char === \"}\") importClause = false;\n\t\t\tprevious = char;\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\t\tif ((char === \"+\" || char === \"-\") && next === char) {\n\t\t\tprevious = char + char;\n\t\t\ti += 2;\n\t\t\tcontinue;\n\t\t}\n\t\t// JSX, escaped identifiers and unknown lexical tokens cannot establish safe delimiters.\n\t\tif (char === \"<\" && language === \"ts\" && expressionEnd) {\n\t\t\tconst span = typeArgumentsSpan(source, i + 1);\n\t\t\tif (span) {\n\t\t\t\tline += span.newlines;\n\t\t\t\ti = span.end;\n\t\t\t\tprevious = \">\";\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// A comparison can finish at its enclosing delimiter; an unresolved generic\n\t\t\t// reaching a brace must fail rather than fold constraint/signature members.\n\t\t\tif (!/^\\s*\\{/.test(source.slice(i + 1))) ambiguousAngleDepth = stack.length;\n\t\t}\n\t\tif (char === \"<\" && !expressionEnd && /^<\\/?[A-Za-z]/.test(source.slice(i)))\n\t\t\treturn fail(\"ambiguous_angle_syntax\");\n\t\tif (!\";:,.?=><!~+-*%&|^\".includes(char)) return fail(\"unknown_token\");\n\t\tif (char === \";\") {\n\t\t\timportClause = false;\n\t\t\tsignatureDeclaration = false;\n\t\t\tif (ambiguousAngleDepth === stack.length) ambiguousAngleDepth = undefined;\n\t\t}\n\t\tif (!headers.punctuation(char === \"=\" && next === \">\" ? \"=>\" : char, stack.length, line))\n\t\t\treturn fail(\"unproved_header\");\n\t\tvalueArrow = valueArrow && previous === \")\" && char === \"=\" && next === \">\";\n\t\tprevious = char === \"=\" && next === \">\" ? \"=>\" : char;\n\t\ti += previous === \"=>\" ? 2 : 1;\n\t\texpressionEnd = char === \".\" ? null : false;\n\t}\n\treturn template || templateDepth || stack.length || headers.unfinished\n\t\t? fail(\"unbalanced_or_unproved_header\")\n\t\t: { status: \"parsed\", ranges: headers.filter(ranges) };\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../../../src/harness/utils/read-folders/compose.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhG,0GAA0G;AAC1G,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,aAAa,EAAE,GAAG,SAAS,aAAa,EAAE,GAAG,SAAS,CAehG;AAED,kFAAkF;AAClF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,gBAAgB,CAarF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compose.js","sourceRoot":"","sources":["../../../../src/harness/utils/read-folders/compose.ts"],"names":[],"mappings":"AAEA,0GAA0G;AAC1G,MAAM,UAAU,SAAS,CAAC,MAAgC;IAGzD,MAAM,KAAK,GAAW,EAAE,CAAC;IACzB,MAAM,KAAK,GAAW,EAAE,CAAC;IACzB,KAAK,MAAM,KAAK,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;QACpG,OAAO,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,SAAS,GAAG,KAAK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esContent":["import type { ReadBraceScan, ReadFolderResult, ReadFoldRange, ReadLineRange } from \"./types.ts\";\n\n/** Hierarchical omitted interiors from a flat scan. Ambiguous nesting is a parse failure, not a guess. */\nexport function hierarchy(ranges: readonly ReadLineRange[]): readonly ReadFoldRange[] | undefined {\n\t// Builder-owned arrays; no caller-owned ranges are sorted or mutated.\n\ttype Node = ReadLineRange & { readonly children: Node[] };\n\tconst roots: Node[] = [];\n\tconst stack: Node[] = [];\n\tfor (const range of [...ranges].sort((a, b) => a.startLine - b.startLine || b.endLine - a.endLine)) {\n\t\twhile (stack.length && range.startLine > stack[stack.length - 1].endLine) stack.pop();\n\t\tconst parent = stack[stack.length - 1];\n\t\tif (parent && range.startLine === parent.startLine && range.endLine === parent.endLine) continue;\n\t\tif (parent && (range.startLine <= parent.startLine || range.endLine >= parent.endLine)) return undefined;\n\t\tconst node: Node = { ...range, children: [] };\n\t\t(parent ? parent.children : roots).push(node);\n\t\tstack.push(node);\n\t}\n\treturn roots;\n}\n\n/** The single scan-to-result composition shared by every fold-boundary engine. */\nexport function composeFoldResult(text: string, scan: ReadBraceScan): ReadFolderResult {\n\tswitch (scan.status) {\n\t\tcase \"parse_failure\":\n\t\t\treturn scan;\n\t\tcase \"parsed\": {\n\t\t\tconst ranges = hierarchy(scan.ranges);\n\t\t\treturn ranges\n\t\t\t\t? { status: \"parsed\", text, ranges }\n\t\t\t\t: { status: \"parse_failure\", reason: \"ambiguous_line_boundaries\" };\n\t\t}\n\t\tdefault:\n\t\t\treturn scan satisfies never;\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"header-protection.d.ts","sourceRoot":"","sources":["../../../../src/harness/utils/read-folders/header-protection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAIhD,6FAA6F;AAC7F,qBAAa,gBAAgB;IAC5B,QAAQ,CAAC,SAAS,EAAE,aAAa,EAAE,CAAM;IACzC,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,UAAU,CAAqE;IAEvF,IAAI,MAAM,IAAI,OAAO,CAEpB;IACD,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAG,OAAO,CAU9F;IAED,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAQzE;IAED,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAMnD;IAED,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAY/D;IAED,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAEhD;IAED,MAAM,CAAC,MAAM,EAAE,SAAS,aAAa,EAAE,GAAG,aAAa,EAAE,CAKxD;CACD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"header-protection.js","sourceRoot":"","sources":["../../../../src/harness/utils/read-folders/header-protection.ts"],"names":[],"mappings":"AAKA,6FAA6F;AAC7F,MAAM,OAAO,gBAAgB;IAA7B;QACU,cAAS,GAAoB,EAAE,CAAC;IAkE1C,CAAC;IA7DA,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC;IACnC,CAAC;IACD,IAAI,UAAU;QACb,OAAO,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC;IACnC,CAAC;IAED,IA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,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QACxF,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,CAAC,SAAiB,EAAE,OAAe;QACzC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,CAAC,MAAgC;QACtC,OAAO,MAAM,CAAC,MAAM,CACnB,CAAC,KAAK,EAAE,EAAE,CACT,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,IAAI,MAAM,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,IAAI,MAAM,CAAC,SAAS,CAAC,CACzG,CAAC;IACH,CAAC;CACD","sourcesContent":["import type { Open } from \"./lexical-context.ts\";\nimport type { ReadLineRange } from \"./types.ts\";\n\ntype Header = { readonly kind: \"class\" | \"function\"; readonly depth: number; readonly startLine: number };\n\n/** A lexical proof only: ambiguous headers invalidate the whole parse, not just one fold. */\nexport class HeaderProtection {\n\treadonly intervals: ReadLineRange[] = [];\n\tprivate pending: Header | undefined;\n\tprivate target: number | undefined;\n\tprivate parameters: { readonly depth: number; readonly startLine: number } | undefined;\n\n\tget active(): boolean {\n\t\treturn this.pending !== undefined;\n\t}\n\tget unfinished(): boolean {\n\t\treturn this.pending !== undefined;\n\t}\n\n\tword(word: string, previous: string, depth: number, line: number, typescript: boolean): boolean {\n\t\tthis.target = undefined;\n\t\t// These operators can hide an arbitrarily shaped type before a real body.\n\t\t// No TypeScript grammar is installed: do not infer a boundary from the next brace.\n\t\tif (typescript && [\"keyof\", \"typeof\", \"infer\", \"readonly\", \"satisfies\", \"as\"].includes(word)) return false;\n\t\tif ((word === \"class\" || word === \"function\") && previous !== \".\") {\n\t\t\tif (this.pending) return false; // e.g. a nested class expression in heritage\n\t\t\tthis.pending = { kind: word, depth, startLine: line };\n\t\t}\n\t\treturn true;\n\t}\n\n\topen(char: string, depth: number, previous: string, line: number): boolean {\n\t\tconst header = this.pending;\n\t\tif (char !== \"{\" || header?.depth !== depth) return false;\n\t\tif (header.kind === \"function\" && previous !== \")\") return false;\n\t\tthis.protect(header.startLine, line);\n\t\tthis.pending = undefined;\n\t\tthis.parameters = undefined;\n\t\treturn header.kind === \"class\";\n\t}\n\n\tclose(open: Open, depth: number, line: number): void {\n\t\tthis.target = open.target ? open.line : undefined;\n\t\tconst startLine = open.headerLine ?? open.line;\n\t\t// Every protected member context, not only a proven signature, must survive enclosing folds.\n\t\tif (open.protected && (open.signature || open.char !== \"(\")) this.protect(startLine, line);\n\t\tif (open.char === \"(\" && !open.call && !open.control) this.parameters = { depth, startLine };\n\t}\n\n\tpunctuation(token: string, depth: number, line: number): boolean {\n\t\t// A value-position array/object reaching '=' is a destructuring assignment target.\n\t\t// Protecting it retrospectively rejects both its members and any enclosing body.\n\t\tconst target = this.target;\n\t\tthis.target = undefined;\n\t\tif (token === \"=\" && target !== undefined) this.protect(target, line);\n\t\tif (token === \":\" && this.parameters?.depth === depth) return false;\n\t\tif ((token === \"{\" || token === \"=>\") && this.parameters?.depth === depth) {\n\t\t\tthis.protect(this.parameters.startLine, line);\n\t\t\tthis.parameters = undefined;\n\t\t} else if (token === \";\" || token === \"=\" || token === \",\") this.parameters = undefined;\n\t\treturn true;\n\t}\n\n\tprotect(startLine: number, endLine: number): void {\n\t\tthis.intervals.push({ startLine, endLine });\n\t}\n\n\tfilter(ranges: readonly ReadLineRange[]): ReadLineRange[] {\n\t\treturn ranges.filter(\n\t\t\t(range) =>\n\t\t\t\t!this.intervals.some((header) => range.startLine <= header.endLine && range.endLine >= header.startLine),\n\t\t);\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/harness/utils/read-folders/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAqC,MAAM,YAAY,CAAC;AAEhF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;QACzB,IAAI,CAAC;YACJ,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,KAAK,YAAY,WAAW;gBAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;YAC7F,MAAM,KAAK,CAAC;QACb,CAAC;IACF,CAAC;IACD,OAAO,iBAAiB,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAe,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,gBAAgB,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC","sourcesContent":["import { scanBraces } from \"./brace-scanner.ts\";\nimport { composeFoldResult } from \"./compose.ts\";\nimport type { ReadFolder, ReadFolderInput, ReadFolderResult } from \"./types.ts\";\n\nexport * from \"./types.ts\";\n\n/** Frozen measured selection, not a runtime registry that can enable unmeasured grammars. */\nexport const READ_FOLDER_SELECTION = Object.freeze({\n\thead: \"ec63eb5ee999da83b9e5d3e37b83d1998707f44c\",\n\tselectionSha256: \"07388b6a393cc05c78533fa701d536d5e617a38e2293b10c0a281a55395cc8a3\",\n\twasm: true,\n\trawReasons: Object.freeze({\n\t\tts: \"wasm_candidate_below_threshold\",\n\t\ttsx: \"wasm_candidate_below_threshold\",\n\t} as const),\n\tlanguages: Object.freeze({\n\t\tts: \"raw\",\n\t\tjs: \"wasm\",\n\t\tjson: \"heuristic\",\n\t\ttsx: \"raw\",\n\t\tpython: \"unsupported\",\n\t\trust: \"unsupported\",\n\t\tgo: \"unsupported\",\n\t\tmarkdown: \"prose_exempt\",\n\t\ttxt: \"prose_exempt\",\n\t} as const),\n} as const);\n\nexport type ReadSummaryLanguage = keyof typeof READ_FOLDER_SELECTION.languages;\n/** Every engine a frozen selection may name, independent of which ones the current receipt uses. */\nexport type ReadSummaryEngine = \"raw\" | \"heuristic\" | \"wasm\" | \"unsupported\" | \"prose_exempt\";\nexport function languageForPath(path: string): ReadSummaryLanguage | undefined {\n\tconst name = path.split(/[\\\\/]/).pop()?.toLowerCase() ?? \"\";\n\tif (!name.includes(\".\")) return undefined;\n\tswitch (name.slice(name.lastIndexOf(\".\") + 1)) {\n\t\tcase \"ts\":\n\t\t\treturn \"ts\";\n\t\tcase \"js\":\n\t\t\treturn \"js\";\n\t\tcase \"json\":\n\t\t\treturn \"json\";\n\t\tcase \"tsx\":\n\t\t\treturn \"tsx\";\n\t\tcase \"py\":\n\t\t\treturn \"python\";\n\t\tcase \"rs\":\n\t\t\treturn \"rust\";\n\t\tcase \"go\":\n\t\t\treturn \"go\";\n\t\tcase \"md\":\n\t\tcase \"markdown\":\n\t\tcase \"mdown\":\n\t\tcase \"mkd\":\n\t\tcase \"mkdn\":\n\t\t\treturn \"markdown\";\n\t\tcase \"txt\":\n\t\t\treturn \"txt\";\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\n/** The frozen engine for a path's language, independent of which folder object a caller supplies. */\nexport function readSummaryEngineForPath(path: string): ReadSummaryEngine | undefined {\n\tconst language = languageForPath(path);\n\tif (language === undefined) return undefined;\n\tconst engine: ReadSummaryEngine = READ_FOLDER_SELECTION.languages[language];\n\treturn engine;\n}\n\n/** Reader eligibility stays bound to the frozen selection even with a custom folder. */\nexport function isReadSummaryPath(path: string): boolean {\n\tconst engine = readSummaryEngineForPath(path);\n\treturn engine === \"heuristic\" || engine === \"wasm\";\n}\n\nfunction fold({ path, text, settings }: ReadFolderInput): ReadFolderResult {\n\tconst language = languageForPath(path);\n\tif (!language) return { status: \"unsupported\", reason: \"unsupported_language\" };\n\tconst engine: ReadSummaryEngine = READ_FOLDER_SELECTION.languages[language];\n\tswitch (engine) {\n\t\tcase \"unsupported\":\n\t\t\treturn { status: \"unsupported\", reason: \"unsupported_language\" };\n\t\tcase \"prose_exempt\":\n\t\t\treturn { status: \"unsupported\", reason: \"prose_exempt\" };\n\t\tcase \"raw\": // Retain the pure candidate for safety/quality measurement, never default-read eligibility.\n\t\tcase \"heuristic\":\n\t\tcase \"wasm\": // The heuristic scan is the tree-sitter engine's fallback, so it stays callable here.\n\t\t\tbreak;\n\t\tdefault:\n\t\t\treturn engine satisfies never;\n\t}\n\t// Narrow the language independently: the manifest is the sole enablement authority.\n\tif (language !== \"ts\" && language !== \"js\" && language !== \"json\")\n\t\treturn { status: \"unsupported\", reason: \"unsupported_language\" };\n\tif (language === \"json\") {\n\t\ttry {\n\t\t\tJSON.parse(text);\n\t\t} catch (error) {\n\t\t\tif (error instanceof SyntaxError) return { status: \"parse_failure\", reason: \"invalid_json\" };\n\t\t\tthrow error;\n\t\t}\n\t}\n\treturn composeFoldResult(text, scanBraces(text, language, settings));\n}\n\nexport const selectedReadFolder: ReadFolder = Object.freeze({ id: \"measured-brace\", version: \"3\", fold });\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lexical-context.d.ts","sourceRoot":"","sources":["../../../../src/harness/utils/read-folders/lexical-context.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,IAAI,GAAG;IAClB,QAAQ,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,2FAA2F;IAC3F,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,IA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C,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC;QACvB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAC9D,CAAC;AACH,CAAC","sourcesContent":["export type Open = {\n\treadonly char: \"{\" | \"[\" | \"(\";\n\treadonly line: number;\n\treadonly headerLine?: number;\n\t/** Opened where a value may start, so it can still turn out to be an assignment target. */\n\treadonly target?: boolean;\n\treadonly foldable: boolean;\n\treadonly protected: boolean;\n\treadonly signature: boolean;\n\treadonly interpolation: boolean;\n\treadonly control: boolean;\n\treadonly call: boolean;\n\treadonly valueParameters: boolean;\n\treadonly declaration: boolean;\n};\n\nexport const expressionKeywords = new Set([\n\t\"return\",\n\t\"throw\",\n\t\"yield\",\n\t\"await\",\n\t\"case\",\n\t\"typeof\",\n\t\"void\",\n\t\"delete\",\n\t\"in\",\n\t\"of\",\n\t\"instanceof\",\n]);\nexport const controls = new Set([\"if\", \"while\", \"for\", \"switch\", \"catch\", \"with\"]);\nexport const signatureDeclarations = new Set([\"type\", \"interface\", \"enum\", \"namespace\", \"module\", \"declare\"]);\n\n/** Only expression callees release argument values; declarations retain parameter protection. */\nexport function isCallCallee(previous: string, beforeWord: string): boolean {\n\treturn (\n\t\t/^[A-Za-z_$][\\w$]*$/.test(previous) &&\n\t\t![\"function\", \"async\", \"new\"].includes(previous) &&\n\t\t!expressionKeywords.has(previous) &&\n\t\t!controls.has(previous) &&\n\t\t[\".\", \"=\", \":\", \"return\", \"await\", \"new\"].includes(beforeWord)\n\t);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lexical-spans.d.ts","sourceRoot":"","sources":["../../../../src/harness/utils/read-folders/lexical-spans.ts"],"names":[],"mappings":"AAAA,KAAK,IAAI,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,E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IAAI,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,QAAQ;YAC/F,OAAO,SAAS,CAAC;QAClB,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YACxB,IAAI,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;gBAAE,OAAO,SAAS,CAAC;YACrE,CAAC,EAAE,CAAC;YACJ,SAAS;QACV,CAAC;QACD,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG;YAAE,cAAc,GAAG,IAAI,CAAC;QAC7C,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG;YAAE,cAAc,GAAG,KAAK,CAAC;QAC9C,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;YAC1C,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;YAChB,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;gBAAE,GAAG,EAAE,CAAC;YAC/C,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;YACvC,2EAA2E;YAC3E,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,MAAM;gBAAE,OAAO,SAAS,CAAC;YACvF,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;QAC7B,CAAC;IACF,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["type Span = { readonly end: number; readonly newlines: number };\n\n// Selected TS/JS/JSON branches of row 17's measured literal scanner.\n// Offsets are UTF-16 indices; output coordinates always describe whole source lines.\nexport function stringSpan(source: string, start: number, delimiter: string): Span | undefined {\n\tlet newlines = 0;\n\tfor (let i = start; i < source.length; i++) {\n\t\tif (source[i] === delimiter) return { end: i + 1, newlines };\n\t\tif (source[i] === \"\\n\" || source[i] === \"\\r\") return undefined;\n\t\tif (source[i] === \"\\\\\") {\n\t\t\tif (source[i + 1] === \"\\r\" && source[i + 2] === \"\\n\") i++;\n\t\t\tif (source[i + 1] === \"\\n\") newlines++;\n\t\t\ti++;\n\t\t}\n\t}\n\treturn undefined;\n}\n\n/** Skip only brace-free type arguments; constraints/object types still take the protected/raw path. */\nexport function typeArgumentsSpan(source: string, start: number): Span | undefined {\n\tconst delimiters = [\"<\"];\n\tlet newlines = 0;\n\tfor (let i = start; i < source.length; i++) {\n\t\tconst char = source[i];\n\t\tif (char === \"\\n\") newlines++;\n\t\tif (char === '\"' || char === \"'\") {\n\t\t\tconst span = stringSpan(source, i + 1, char);\n\t\t\tif (!span) return undefined;\n\t\t\tnewlines += span.newlines;\n\t\t\ti = span.end - 1;\n\t\t} else if (char === \"<\" || char === \"[\") delimiters.push(char);\n\t\telse if (char === \">\" || char === \"]\") {\n\t\t\tif (delimiters.pop() !== (char === \">\" ? \"<\" : \"[\")) return undefined;\n\t\t\tif (!delimiters.length) return { end: i + 1, newlines };\n\t\t} else if (!/[A-Za-z_$0-9\\s,.?|&]/.test(char)) return undefined;\n\t}\n\treturn undefined;\n}\n\nexport function lineCommentEnd(source: string, start: number): number {\n\tlet end = start;\n\twhile (end < source.length && !/[\\n\\r\\u2028\\u2029]/.test(source[end])) end++;\n\treturn end;\n}\n\nexport function commentSpan(source: string, start: number): Span | undefined {\n\tlet newlines = 0;\n\tfor (let i = start; i < source.length; i++) {\n\t\tif (source[i] === \"\\n\") newlines++;\n\t\tif (source.startsWith(\"*/\", i)) return { end: i + 2, newlines };\n\t}\n\treturn undefined;\n}\n\nexport function regexSpan(source: string, start: number): Span | undefined {\n\tlet characterClass = false;\n\tfor (let i = start; i < source.length; i++) {\n\t\tif (source[i] === \"\\n\" || source[i] === \"\\r\" || source[i] === \"\\u2028\" || source[i] === \"\\u2029\")\n\t\t\treturn undefined;\n\t\tif (source[i] === \"\\\\\") {\n\t\t\tif (/[\\r\\n\\u2028\\u2029]/.test(source[i + 1] ?? \"\")) return undefined;\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (source[i] === \"[\") characterClass = true;\n\t\tif (source[i] === \"]\") characterClass = false;\n\t\tif (source[i] === \"/\" && !characterClass) {\n\t\t\tlet end = i + 1;\n\t\t\twhile (/[a-z]/i.test(source[end] ?? \"\")) end++;\n\t\t\tconst flags = source.slice(i + 1, end);\n\t\t\t// Unicode-set regexes need a different nested-class grammar; do not guess.\n\t\t\tif (/[^dgimsuy]/.test(flags) || new Set(flags).size !== flags.length) return undefined;\n\t\t\treturn { end, newlines: 0 };\n\t\t}\n\t}\n\treturn undefined;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prepare.d.ts","sourceRoot":"","sources":["../../../../src/harness/utils/read-folders/prepare.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAEvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,MAAM,wBAAwB,GAAG,IAAI,CAAC,uBAAuB,EAAE,UAAU,CAAC,CAAC;AAEjF;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACtC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,UAAU,GAAG,SAAS,EAC9B,OAAO,GAAE,wBAA6B,GACpC,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAUjC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prepare.js","sourceRoot":"","sources":["../../../../src/harness/utils/read-folders/prepare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAO3F;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACtC,IAAY,EACZ,MAA8B,EAC9B,OAAO,GAA6B,EAAE;IAEtC,IAAI,CAAC,MAAM,IAAI,MAAM,KAAK,kBAAkB;QAAE,OAAO,MAAM,CAAC;IAC5D,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,CAAC,QAAQ,IAAI,wBAAwB,CAAC,IAAI,CAAC,KAAK,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1E,IAAI,CAAC;QACJ,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,MAAM,CAAC,yBAAyB,CAAC,CAAC;QACzE,OAAO,CAAC,MAAM,oBAAoB,CAAC,QAA8B,EAAE,EAAE,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC;IACjH,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,MAAM,CAAC;IACf,CAAC;AACF,CAAC","sourcesContent":["import { languageForPath, readSummaryEngineForPath, selectedReadFolder } from \"./index.ts\";\nimport type { TreeSitterFolderOptions } from \"./tree-sitter/engine.ts\";\nimport type { TreeSitterLanguage } from \"./tree-sitter/syntax.ts\";\nimport type { ReadFolder } from \"./types.ts\";\n\nexport type PrepareReadFolderOptions = Omit<TreeSitterFolderOptions, \"fallback\">;\n\n/**\n * Resolve the folder a default read must use for this path. Only a language the frozen selection\n * binds to `wasm` loads a grammar, lazily and once; every other language keeps the folder it was\n * given, and a grammar that is absent or unusable keeps it too. A caller that supplies its own\n * folder keeps exactly that folder: the selection decides eligibility, never someone else's engine.\n */\nexport async function prepareReadFolder(\n\tpath: string,\n\tfolder: ReadFolder | undefined,\n\toptions: PrepareReadFolderOptions = {},\n): Promise<ReadFolder | undefined> {\n\tif (!folder || folder !== selectedReadFolder) return folder;\n\tconst language = languageForPath(path);\n\tif (!language || readSummaryEngineForPath(path) !== \"wasm\") return folder;\n\ttry {\n\t\tconst { loadTreeSitterFolder } = await import(\"./tree-sitter/engine.ts\");\n\t\treturn (await loadTreeSitterFolder(language as TreeSitterLanguage, { ...options, fallback: folder })) ?? folder;\n\t} catch {\n\t\treturn folder;\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../../../../src/harness/utils/read-folders/tree-sitter/engine.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAqC,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,KAAK,eAAe,EAA0C,MAAM,qBAAqB,CAAC;AACnG,OAAO,EAAyC,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAE7F,0GAA0G;AAC1G,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAC/C,eAAO,MAAM,qBAAqB,qBAAqB,CAAC;AACxD,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAE9C,MAAM,MAAM,uBAAuB,GAAG;IACrC,0FAA0F;IAC1F,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,cAAc,CAAC,EAAE,eAAe,CAAC;IAC1C,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC5D,mGAAmG;IACnG,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAoEF;;;;GAIG;AACH,wBAAsB,oBAAoB,CACzC,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,EAAE,uBAAuB,GAC9B,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAiBjC;AAED,wFAAwF;AACxF,wBAAgB,uBAAuB,IAAI,IAAI,CAG9C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version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C,IAAI,EAAE,CAAC,KAAsB,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC;KACrF,CAAC,CAAC;AACJ,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,uBAAuB;IACtC,OAAO,GAAG,SAAS,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,CAAC;AAClB,CAAC","sourcesContent":["import type { Language, Parser as ParserType } from \"web-tree-sitter\";\nimport { composeFoldResult } from \"../compose.ts\";\nimport type { ReadFolder, ReadFolderInput, ReadFolderResult } from \"../types.ts\";\nimport { type GrammarResolver, resolveGrammarPath, resolveRuntimePath } from \"./grammar-assets.ts\";\nimport { foldRangesFromSyntax, type SyntaxNode, type TreeSitterLanguage } from \"./syntax.ts\";\n\n/** A structural read must never outlast this budget: an exhausted parse falls back, it does not stall. */\nexport const TREE_SITTER_PARSE_BUDGET_MS = 250;\nexport const TREE_SITTER_FOLDER_ID = \"tree-sitter-wasm\";\nexport const TREE_SITTER_FOLDER_VERSION = \"1\";\n\nexport type TreeSitterFolderOptions = {\n\t/** Used verbatim when a grammar is absent, the parse fails or the budget is exhausted. */\n\treadonly fallback: ReadFolder;\n\treadonly parseBudgetMs?: number;\n\treadonly resolveGrammar?: GrammarResolver;\n\treadonly resolveRuntime?: () => Promise<string | undefined>;\n\t/** Off for tests that inject resolvers; the shipped read path always shares one loaded grammar. */\n\treadonly cache?: boolean;\n};\n\ntype Loaded = { readonly parser: ParserType; readonly language: TreeSitterLanguage };\n\nlet runtime: Promise<typeof import(\"web-tree-sitter\") | undefined> | undefined;\nconst grammars = new Map<TreeSitterLanguage, Promise<Loaded | undefined>>();\n\nasync function loadRuntime(\n\tresolveRuntime: () => Promise<string | undefined>,\n): Promise<typeof import(\"web-tree-sitter\") | undefined> {\n\ttry {\n\t\tconst module = await import(\"web-tree-sitter\");\n\t\tconst wasm = await resolveRuntime();\n\t\tawait module.Parser.init(wasm ? { locateFile: () => wasm } : undefined);\n\t\treturn module;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nasync function loadParser(language: TreeSitterLanguage, options: TreeSitterFolderOptions): Promise<Loaded | undefined> {\n\tconst resolveGrammar = options.resolveGrammar ?? resolveGrammarPath;\n\tconst resolveRuntime = options.resolveRuntime ?? resolveRuntimePath;\n\tconst grammar = await resolveGrammar(language);\n\tif (!grammar) return undefined;\n\tif (options.cache === false) {\n\t\tconst module = await loadRuntime(resolveRuntime);\n\t\treturn module && instantiate(module, grammar, language);\n\t}\n\truntime ??= loadRuntime(resolveRuntime);\n\tconst module = await runtime;\n\treturn module && instantiate(module, grammar, language);\n}\n\nasync function instantiate(\n\tmodule: typeof import(\"web-tree-sitter\"),\n\tgrammar: string,\n\tlanguage: TreeSitterLanguage,\n): Promise<Loaded | undefined> {\n\ttry {\n\t\tconst loaded: Language = await module.Language.load(grammar);\n\t\tconst parser = new module.Parser();\n\t\tparser.setLanguage(loaded);\n\t\treturn { parser, language };\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction foldWith(loaded: Loaded, budgetMs: number, input: ReadFolderInput, fallback: ReadFolder): ReadFolderResult {\n\tconst deadline = performance.now() + budgetMs;\n\tlet tree: ReturnType<ParserType[\"parse\"]> = null;\n\ttry {\n\t\ttree = loaded.parser.parse(input.text, null, { progressCallback: () => performance.now() > deadline });\n\t\tif (!tree) return fallback.fold(input);\n\t\tconst scan = foldRangesFromSyntax(tree.rootNode as unknown as SyntaxNode, input.settings);\n\t\tif (scan.status === \"parse_failure\") return fallback.fold(input);\n\t\treturn composeFoldResult(input.text, scan);\n\t} catch {\n\t\t// A grammar/runtime fault is a fallback condition, never a failed read.\n\t\treturn fallback.fold(input);\n\t} finally {\n\t\ttree?.delete();\n\t\t// Parsing resumes mid-document after a cancelled parse unless the parser is reset.\n\t\tloaded.parser.reset();\n\t}\n}\n\n/**\n * Load the grammar for one language and return a folder that produces the same fold-boundary\n * output the heuristic produces, with the heuristic itself as the fallback. Grammars load lazily,\n * on the first structural read for their language.\n */\nexport async function loadTreeSitterFolder(\n\tlanguage: TreeSitterLanguage,\n\toptions: TreeSitterFolderOptions,\n): Promise<ReadFolder | undefined> {\n\tconst load = () => loadParser(language, options);\n\tconst loaded = await (options.cache === false\n\t\t? load()\n\t\t: (grammars.get(language) ??\n\t\t\t(() => {\n\t\t\t\tconst pending = load();\n\t\t\t\tgrammars.set(language, pending);\n\t\t\t\treturn pending;\n\t\t\t})()));\n\tif (!loaded) return undefined;\n\tconst budgetMs = options.parseBudgetMs ?? TREE_SITTER_PARSE_BUDGET_MS;\n\treturn Object.freeze({\n\t\tid: TREE_SITTER_FOLDER_ID,\n\t\tversion: TREE_SITTER_FOLDER_VERSION,\n\t\tfold: (input: ReadFolderInput) => foldWith(loaded, budgetMs, input, options.fallback),\n\t});\n}\n\n/** Test seam: drop the memoized runtime/grammars so a resolver change is observable. */\nexport function resetTreeSitterGrammars(): void {\n\truntime = undefined;\n\tgrammars.clear();\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"grammar-assets.d.ts","sourceRoot":"","sources":["../../../../../src/harness/utils/read-folders/tree-sitter/grammar-assets.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,8GAA8G;AAC9G,eAAO,MAAM,aAAa;iBACrB,iBAAiB;kBAChB,UAAU;iBACX,iBAAiB;EACkC,CAAC;AASzD,eAAO,MAAM,wBAAwB,yBAAyB,CAAC;AAE/D,uHAAuH;AACvH,eAAO,MAAM,sBAAsB,QAAgF,CAAC;AA+BpH,MAAM,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,kBAAkB,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;AAE5F;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAOlG;AAED,2EAA2E;AAC3E,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAItE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"grammar-assets.js","sourceRoot":"","sources":["../../../../../src/harness/utils/read-folders/tree-sitter/grammar-assets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,8GAA8G;AAC9G,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC;IAC1C,EAAE,EAAE,iBAAiB;IACrB,GAAG,EAAE,UAAU;IACf,EAAE,EAAE,iBAAiB;CACiC,CAAC,CAAC;AAEzD,4EAA4E;AAC5E,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;IACpC,EAAE,EAAE,6BAA6B;IACjC,GAAG,EAAE,sBAAsB;IAC3B,EAAE,EAAE,6BAA6B;CACqB,CAAC,CAAC;AAEzD,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAE/D,uHAAuH;AACvH,MAAM,CAAC,MAAM,sBAAsB,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,oCAAoC,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAEpH;;;GAGG;AACH,MAAM,gBAAgB,GAA4E;IACjG,EAAE,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,mDAAmD,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC;CACjG,CAAC;AACF,MAAM,eAAe,GAAG,GAAG,EAAE,CAC5B,MAAM,CAAC,wDAAwD,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,MA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,CAAC,CAAC;IACxE,IAAI,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,QAAQ,CAAC;IAC1C,OAAO,CAAC,MAAM,YAAY,CAAC,eAAe,CAAC,CAAC,IAAI,aAAa,CAAC,sCAAsC,CAAC,CAAC;AACvG,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { TreeSitterLanguage } from \"./syntax.ts\";\n\n/** Vendored grammar file names, resolved identically from `src`, published `dist` and the compiled binary. */\nexport const GRAMMAR_FILES = Object.freeze({\n\tts: \"typescript.wasm\",\n\ttsx: \"tsx.wasm\",\n\tjs: \"javascript.wasm\",\n} as const satisfies Record<TreeSitterLanguage, string>);\n\n/** Upstream grammar file names inside the pinned measurement dependency. */\nconst UPSTREAM_FILES = Object.freeze({\n\tts: \"tree-sitter-typescript.wasm\",\n\ttsx: \"tree-sitter-tsx.wasm\",\n\tjs: \"tree-sitter-javascript.wasm\",\n} as const satisfies Record<TreeSitterLanguage, string>);\n\nexport const TREE_SITTER_RUNTIME_FILE = \"web-tree-sitter.wasm\";\n\n/** `src/harness/utils/read-folders/tree-sitter` and `dist/harness/utils/read-folders/tree-sitter` share this depth. */\nexport const packagedAssetDirectory = fileURLToPath(new URL(\"../../../../../assets/tree-sitter/\", import.meta.url));\n\n/**\n * Bun's compiler embeds a literal `type: \"file\"` import and hands back an extracted path.\n * Only shipped grammars may appear here: every specifier must resolve at compile time.\n */\nconst embeddedGrammars: Partial<Record<TreeSitterLanguage, () => Promise<{ default: string }>>> = {\n\tjs: () => import(\"../../../../../assets/tree-sitter/javascript.wasm\", { with: { type: \"file\" } }),\n};\nconst embeddedRuntime = () =>\n\timport(\"../../../../../assets/tree-sitter/web-tree-sitter.wasm\", { with: { type: \"file\" } });\n\nasync function embeddedPath(load: (() => Promise<{ default: string }>) | undefined): Promise<string | undefined> {\n\tif (!load || !process.versions.bun) return undefined;\n\ttry {\n\t\tconst module = await load();\n\t\treturn existsSync(module.default) ? module.default : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction installedPath(specifier: string): string | undefined {\n\ttry {\n\t\tconst path = createRequire(import.meta.url).resolve(specifier);\n\t\treturn existsSync(path) ? path : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport type GrammarResolver = (language: TreeSitterLanguage) => Promise<string | undefined>;\n\n/**\n * Packaged grammars ship with the package and the compiled binary; the pinned measurement\n * dependency only backs languages that are evaluated but not shipped. A missing grammar is a\n * normal outcome: the caller keeps the heuristic folder.\n */\nexport async function resolveGrammarPath(language: TreeSitterLanguage): Promise<string | undefined> {\n\tconst packaged = join(packagedAssetDirectory, GRAMMAR_FILES[language]);\n\tif (existsSync(packaged)) return packaged;\n\treturn (\n\t\t(await embeddedPath(embeddedGrammars[language])) ??\n\t\tinstalledPath(`@vscode/tree-sitter-wasm/wasm/${UPSTREAM_FILES[language]}`)\n\t);\n}\n\n/** The emscripten runtime module the grammars are instantiated against. */\nexport async function resolveRuntimePath(): Promise<string | undefined> {\n\tconst packaged = join(packagedAssetDirectory, TREE_SITTER_RUNTIME_FILE);\n\tif (existsSync(packaged)) return packaged;\n\treturn (await embeddedPath(embeddedRuntime)) ?? installedPath(\"web-tree-sitter/web-tree-sitter.wasm\");\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"syntax.d.ts","sourceRoot":"","sources":["../../../../../src/harness/utils/read-folders/tree-sitter/syntax.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAiB,MAAM,aAAa,CAAC;AAElF,sGAAsG;AACtG,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,aAAa,EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACjD,QAAQ,CAAC,WAAW,EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/C,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,UAAU,GAAG,IAAI,CAAC,EAAE,CAAC;IAClD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC;CACpD;AAED,MAAM,MAAM,kBAAkB,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,CAAC;AA8FrD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,gBAAgB,GAAG,aAAa,CA4EhG"}
|