@caupulican/pi-adaptative 0.80.29 → 0.80.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"improvement-loop.js","sourceRoot":"","sources":["../../src/core/improvement-loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAuB,MAAM,uBAAuB,CAAC;AAsQxE,MAAM,kBAAkB,GAAG,QAAQ,CAAC;AACpC,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC;AAC/E,MAAM,cAAc,GAAG,aAAY,CAAC;AACpC,MAAM,iBAAiB,GAAG,yDAAyD,CAAC;AAEpF,SAAS,qBAAqB,CAAC,KAAc,EAAiB;IAC7D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACtE,OAAO,KAAK,CAAC;AAAA,CACb;AAED,SAAS,oBAAoB,CAAC,KAAyB,EAAE,QAAgB,EAAU;IAClF,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,QAAQ,CAAC;IACvF,OAAO,KAAK,CAAC;AAAA,CACb;AAED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,CAAC,CAAC;AAAA,CACH","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport { StringEnum } from \"@caupulican/pi-ai\";\nimport { Type } from \"typebox\";\nimport { getAgentDir } from \"../config.ts\";\nimport { defineTool, type ToolDefinition } from \"./extensions/types.ts\";\n\nexport type MetricDirection = \"lower\" | \"higher\";\nexport type ImprovementDecision = \"keep\" | \"discard\" | \"retry\" | \"blocked\";\nexport type ImprovementDecisionReason =\n\t| \"baseline\"\n\t| \"metric_improved\"\n\t| \"checks_failed\"\n\t| \"metric_missing\"\n\t| \"metric_invalid\"\n\t| \"not_better_than_best\"\n\t| \"below_min_delta\"\n\t| \"below_min_relative_delta\"\n\t| \"insufficient_noise_evidence\"\n\t| \"below_confidence\";\nexport type ConfidenceMode = \"none\" | \"mad\";\nexport type LowConfidenceAction = \"retry\" | \"discard\";\n\nexport interface MetricComparison {\n\tcurrent: number;\n\tbest: number | null;\n\tdirection: MetricDirection;\n\tdelta: number;\n\trelativeDelta: number | null;\n\timproved: boolean;\n}\n\nexport interface ConfidenceResult {\n\tmode: ConfidenceMode;\n\tvalue: number | null;\n\tnoiseFloor: number | null;\n\tsampleCount: number;\n}\n\nexport interface ImprovementDecisionInput {\n\tcurrentMetric: number | null | undefined;\n\tbestMetric?: number | null;\n\tbaselineMetric?: number | null;\n\tdirection?: MetricDirection;\n\tchecksPass?: boolean | null;\n\tminDelta?: number;\n\tminRelativeDelta?: number;\n\tconfidenceMode?: ConfidenceMode;\n\tminConfidence?: number;\n\tlowConfidenceAction?: LowConfidenceAction;\n\tnoiseMetrics?: number[];\n}\n\nexport interface ImprovementDecisionResult {\n\tdecision: ImprovementDecision;\n\treason: ImprovementDecisionReason;\n\tcomparison: MetricComparison | null;\n\tconfidence: ConfidenceResult;\n}\n\nexport interface ImprovementRunRecord {\n\trunId: string | number;\n\tobjective?: string;\n\thypothesis?: string;\n\tmetricName: string;\n\tmetricUnit?: string;\n\tdirection: MetricDirection;\n\tmetric: number | null;\n\tsecondaryMetrics?: Record<string, number>;\n\tchecksPass: boolean | null;\n\tdecision: ImprovementDecision;\n\treason: ImprovementDecisionReason;\n\tconfidence?: number | null;\n\tchangedFiles?: string[];\n\tevidenceRef?: string;\n\tnextHint?: string;\n\ttimestamp: number;\n}\n\nexport interface GitStatusEntry {\n\tindex: string;\n\tworkingTree: string;\n\tpath: string;\n\torigPath?: string;\n}\n\nexport interface OwnedDiscardPlanInput {\n\tbeforeStatus: string | GitStatusEntry[];\n\tafterStatus: string | GitStatusEntry[];\n\townedPaths: string[];\n\tpreservePaths?: string[];\n}\n\nexport interface OwnedDiscardPlan {\n\trevertPaths: string[];\n\tpreservePaths: string[];\n\tprotectedUserDirtyPaths: string[];\n\tunownedChangedPaths: string[];\n\tcanDiscardOwnedChanges: boolean;\n}\n\nexport interface ImprovementLoopConfig {\n\tloopId: string;\n\tobjective: string;\n\tmetricName: string;\n\tmetricUnit?: string;\n\tdirection: MetricDirection;\n\tminDelta: number;\n\tminRelativeDelta: number;\n\tconfidenceMode: ConfidenceMode;\n\tminConfidence: number;\n\tlowConfidenceAction: LowConfidenceAction;\n\tcreatedAt: number;\n\tcwd: string;\n}\n\nexport interface ImprovementSandboxRecord {\n\tsandboxId: string;\n\tstatus: \"active\" | \"cleaned\";\n\trepoPath: string;\n\tworktreePath: string;\n\tbaseRef: string;\n\tcreatedAt: number;\n\tcleanedAt?: number;\n\texportedAt?: number;\n\tpatchPath?: string;\n\tpatchBytes?: number;\n\treason?: string;\n}\n\nexport interface ImprovementLoopState {\n\tconfig: ImprovementLoopConfig;\n\truns: ImprovementRunRecord[];\n\tsandboxes: ImprovementSandboxRecord[];\n\tactiveSandbox: ImprovementSandboxRecord | null;\n\tbaselineMetric: number | null;\n\tbestMetric: number | null;\n\tbestRunId: string | number | null;\n\tlastDecision: ImprovementDecisionResult | null;\n\tlogPath: string;\n}\n\nexport interface ImprovementLoopPaths {\n\trootDir: string;\n\tworkspaceDir: string;\n\tlogPath: string;\n\tsandboxDir: string;\n\tartifactDir: string;\n\tworkspaceKey: string;\n\tloopId: string;\n}\n\nexport interface ImprovementLoopInitInput {\n\tcwd: string;\n\tobjective: string;\n\tmetricName: string;\n\tmetricUnit?: string;\n\tdirection?: MetricDirection;\n\tloopId?: string;\n\tminDelta?: number;\n\tminRelativeDelta?: number;\n\tconfidenceMode?: ConfidenceMode;\n\tminConfidence?: number;\n\tlowConfidenceAction?: LowConfidenceAction;\n\tagentDir?: string;\n\treset?: boolean;\n}\n\nexport interface ImprovementLoopRecordInput {\n\tcwd: string;\n\tloopId?: string;\n\trunId?: string | number;\n\tmetric: number | null | undefined;\n\tsecondaryMetrics?: Record<string, number>;\n\tchecksPass?: boolean | null;\n\thypothesis?: string;\n\tchangedFiles?: string[];\n\tevidenceRef?: string;\n\tnextHint?: string;\n\tagentDir?: string;\n}\n\nexport interface ImprovementLoopStatusInput {\n\tcwd: string;\n\tloopId?: string;\n\tagentDir?: string;\n}\n\nexport interface ImprovementSandboxCreateInput extends ImprovementLoopStatusInput {\n\texec: ImprovementLoopExec;\n\tbaseRef?: string;\n\tallowDirtyRepo?: boolean;\n\tsandboxId?: string;\n\tsignal?: AbortSignal;\n}\n\nexport interface ImprovementSandboxCleanupInput extends ImprovementLoopStatusInput {\n\texec: ImprovementLoopExec;\n\tsandboxId?: string;\n\treason?: string;\n\tsignal?: AbortSignal;\n}\n\nexport interface ImprovementSandboxExportInput extends ImprovementLoopStatusInput {\n\texec: ImprovementLoopExec;\n\tsandboxId?: string;\n\tallowEmptyPatch?: boolean;\n\tsignal?: AbortSignal;\n}\n\ntype ImprovementLoopLogEntry =\n\t| ({ type: \"config\" } & ImprovementLoopConfig)\n\t| ({ type: \"run\" } & ImprovementRunRecord)\n\t| ({ type: \"sandbox\" } & ImprovementSandboxRecord);\n\nexport type ImprovementLoopToolAction =\n\t| \"init\"\n\t| \"status\"\n\t| \"record\"\n\t| \"measure\"\n\t| \"sandbox_create\"\n\t| \"sandbox_export\"\n\t| \"sandbox_cleanup\";\n\nexport interface ImprovementMeasurementCommandResult {\n\tstdout: string;\n\tstderr: string;\n\tcode: number;\n\tkilled: boolean;\n\tstdoutTruncated?: boolean;\n\tstderrTruncated?: boolean;\n}\n\nexport interface ImprovementMeasurementResult {\n\tcommand: string;\n\texitCode: number;\n\ttimedOut: boolean;\n\tdurationMs: number;\n\tstdout: string;\n\tstderr: string;\n\tstdoutTruncated: boolean;\n\tstderrTruncated: boolean;\n\tparsedMetrics: Record<string, number>;\n\tprimaryMetric: number | null;\n\tchecksCommand?: string;\n\tchecksExitCode?: number;\n\tchecksTimedOut?: boolean;\n\tchecksPass: boolean;\n\tchecksStdout?: string;\n\tchecksStderr?: string;\n}\n\nexport type ImprovementLoopExec = (\n\tcommand: string,\n\targs: string[],\n\toptions?: { cwd?: string; timeout?: number; signal?: AbortSignal; maxBuffer?: number },\n) => Promise<ImprovementMeasurementCommandResult>;\n\nexport interface ImprovementLoopToolDetails {\n\taction: ImprovementLoopToolAction;\n\tstate: ImprovementLoopState | null;\n\tdecision?: ImprovementDecisionResult;\n\tmeasurement?: ImprovementMeasurementResult;\n\tsandbox?: ImprovementSandboxRecord;\n\tlogPath: string;\n}\n\nconst METRIC_LINE_PREFIX = \"METRIC\";\nconst DENIED_METRIC_NAMES = new Set([\"__proto__\", \"constructor\", \"prototype\"]);\nconst METRIC_NAME_RE = /^[\\w.µ]+$/u;\nconst DECIMAL_NUMBER_RE = /^[+-]?(?:(?:\\d+(?:\\.\\d*)?)|(?:\\.\\d+))(?:[eE][+-]?\\d+)?$/;\n\nfunction normalizeFiniteNumber(value: unknown): number | null {\n\tif (typeof value !== \"number\" || !Number.isFinite(value)) return null;\n\treturn value;\n}\n\nfunction normalizeNonNegative(value: number | undefined, fallback: number): number {\n\tif (typeof value !== \"number\" || !Number.isFinite(value) || value < 0) return fallback;\n\treturn value;\n}\n\nfunction normalizeDirection(direction: MetricDirection | undefined): MetricDirection {\n\treturn direction === \"higher\" ? \"higher\" : \"lower\";\n}\n\nexport function parseMetricLines(output: string): Map<string, number> {\n\tconst metrics = new Map<string, number>();\n\tfor (const line of output.split(/\\r?\\n/)) {\n\t\tconst trimmed = line.trim();\n\t\tif (!trimmed.startsWith(`${METRIC_LINE_PREFIX} `)) continue;\n\t\tconst body = trimmed.slice(METRIC_LINE_PREFIX.length).trim();\n\t\tconst equals = body.indexOf(\"=\");\n\t\tif (equals <= 0) continue;\n\t\tconst name = body.slice(0, equals);\n\t\tconst rawValue = body.slice(equals + 1).trim();\n\t\tif (!METRIC_NAME_RE.test(name) || DENIED_METRIC_NAMES.has(name)) continue;\n\t\tif (!DECIMAL_NUMBER_RE.test(rawValue)) continue;\n\t\tconst value = Number(rawValue);\n\t\tif (Number.isFinite(value)) metrics.set(name, value);\n\t}\n\treturn metrics;\n}\n\nexport function metricMapFromOutput(output: string): Record<string, number> {\n\treturn Object.fromEntries(parseMetricLines(output));\n}\n\nexport function selectPrimaryMetric(\n\tmetrics: Map<string, number> | Record<string, number>,\n\tmetricName: string,\n): number | null {\n\tconst value = metrics instanceof Map ? metrics.get(metricName) : metrics[metricName];\n\treturn normalizeFiniteNumber(value);\n}\n\nexport function compareMetric(\n\tcurrent: number,\n\tbest: number | null | undefined,\n\tdirection: MetricDirection = \"lower\",\n): MetricComparison {\n\tconst normalizedBest = normalizeFiniteNumber(best) ?? null;\n\tif (normalizedBest === null) {\n\t\treturn {\n\t\t\tcurrent,\n\t\t\tbest: null,\n\t\t\tdirection,\n\t\t\tdelta: Number.POSITIVE_INFINITY,\n\t\t\trelativeDelta: null,\n\t\t\timproved: true,\n\t\t};\n\t}\n\n\tconst delta = direction === \"lower\" ? normalizedBest - current : current - normalizedBest;\n\tconst relativeDelta = normalizedBest === 0 ? null : delta / Math.abs(normalizedBest);\n\treturn {\n\t\tcurrent,\n\t\tbest: normalizedBest,\n\t\tdirection,\n\t\tdelta,\n\t\trelativeDelta,\n\t\timproved: delta > 0,\n\t};\n}\n\nexport function median(values: number[]): number | null {\n\tconst finite = values.filter(Number.isFinite).sort((a, b) => a - b);\n\tif (finite.length === 0) return null;\n\tconst mid = Math.floor(finite.length / 2);\n\treturn finite.length % 2 === 0 ? (finite[mid - 1] + finite[mid]) / 2 : finite[mid];\n}\n\nexport function medianAbsoluteDeviation(values: number[]): number | null {\n\tconst m = median(values);\n\tif (m === null) return null;\n\treturn median(values.filter(Number.isFinite).map((value) => Math.abs(value - m)));\n}\n\nexport function computeMadConfidence(improvementDelta: number, samples: number[]): ConfidenceResult {\n\tconst finite = samples.filter(Number.isFinite);\n\tif (finite.length < 3) {\n\t\treturn { mode: \"mad\", value: null, noiseFloor: null, sampleCount: finite.length };\n\t}\n\tconst mad = medianAbsoluteDeviation(finite);\n\tif (mad === null || mad === 0) {\n\t\treturn { mode: \"mad\", value: null, noiseFloor: mad, sampleCount: finite.length };\n\t}\n\treturn {\n\t\tmode: \"mad\",\n\t\tvalue: Math.abs(improvementDelta) / mad,\n\t\tnoiseFloor: mad,\n\t\tsampleCount: finite.length,\n\t};\n}\n\nexport function decideImprovement(input: ImprovementDecisionInput): ImprovementDecisionResult {\n\tconst direction = normalizeDirection(input.direction);\n\tconst minDelta = normalizeNonNegative(input.minDelta, 0);\n\tconst minRelativeDelta = normalizeNonNegative(input.minRelativeDelta, 0);\n\tconst minConfidence = normalizeNonNegative(input.minConfidence, 0);\n\tconst confidenceMode = input.confidenceMode ?? (minConfidence > 0 ? \"mad\" : \"none\");\n\tconst lowConfidenceAction = input.lowConfidenceAction ?? \"retry\";\n\n\tconst emptyConfidence: ConfidenceResult = { mode: confidenceMode, value: null, noiseFloor: null, sampleCount: 0 };\n\n\tif (input.checksPass === false) {\n\t\treturn { decision: \"discard\", reason: \"checks_failed\", comparison: null, confidence: emptyConfidence };\n\t}\n\n\tconst current = normalizeFiniteNumber(input.currentMetric);\n\tif (current === null) {\n\t\treturn {\n\t\t\tdecision: \"blocked\",\n\t\t\treason: input.currentMetric == null ? \"metric_missing\" : \"metric_invalid\",\n\t\t\tcomparison: null,\n\t\t\tconfidence: emptyConfidence,\n\t\t};\n\t}\n\n\tconst best = normalizeFiniteNumber(input.bestMetric) ?? null;\n\tconst comparison = compareMetric(current, best, direction);\n\tif (best === null) {\n\t\treturn { decision: \"keep\", reason: \"baseline\", comparison, confidence: emptyConfidence };\n\t}\n\tif (!comparison.improved) {\n\t\treturn { decision: \"discard\", reason: \"not_better_than_best\", comparison, confidence: emptyConfidence };\n\t}\n\tif (comparison.delta < minDelta) {\n\t\treturn { decision: \"discard\", reason: \"below_min_delta\", comparison, confidence: emptyConfidence };\n\t}\n\tif (comparison.relativeDelta !== null && comparison.relativeDelta < minRelativeDelta) {\n\t\treturn { decision: \"discard\", reason: \"below_min_relative_delta\", comparison, confidence: emptyConfidence };\n\t}\n\n\tif (confidenceMode === \"mad\" && minConfidence > 0) {\n\t\tconst samples = [...(input.noiseMetrics ?? []), current];\n\t\tconst confidence = computeMadConfidence(comparison.delta, samples);\n\t\tif (confidence.value === null) {\n\t\t\treturn {\n\t\t\t\tdecision: lowConfidenceAction,\n\t\t\t\treason: \"insufficient_noise_evidence\",\n\t\t\t\tcomparison,\n\t\t\t\tconfidence,\n\t\t\t};\n\t\t}\n\t\tif (confidence.value < minConfidence) {\n\t\t\treturn {\n\t\t\t\tdecision: lowConfidenceAction,\n\t\t\t\treason: \"below_confidence\",\n\t\t\t\tcomparison,\n\t\t\t\tconfidence,\n\t\t\t};\n\t\t}\n\t\treturn { decision: \"keep\", reason: \"metric_improved\", comparison, confidence };\n\t}\n\n\treturn { decision: \"keep\", reason: \"metric_improved\", comparison, confidence: emptyConfidence };\n}\n\nexport function serializeRunRecord(record: ImprovementRunRecord): string {\n\treturn JSON.stringify(record);\n}\n\nexport async function appendRunRecord(filePath: string, record: ImprovementRunRecord): Promise<void> {\n\tawait mkdir(dirname(filePath), { recursive: true });\n\tawait writeFile(filePath, `${serializeRunRecord(record)}\\n`, { flag: \"a\" });\n}\n\nexport async function readRunRecords(filePath: string): Promise<ImprovementRunRecord[]> {\n\tlet text = \"\";\n\ttry {\n\t\ttext = await readFile(filePath, \"utf8\");\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return [];\n\t\tthrow error;\n\t}\n\tconst records: ImprovementRunRecord[] = [];\n\tfor (const line of text.split(\"\\n\")) {\n\t\tif (!line.trim()) continue;\n\t\tconst parsed = JSON.parse(line) as ImprovementRunRecord;\n\t\trecords.push(parsed);\n\t}\n\treturn records;\n}\n\nfunction normalizeLoopId(loopId: string | undefined): string {\n\tconst normalized = (loopId ?? \"default\")\n\t\t.trim()\n\t\t.replace(/[^a-zA-Z0-9._-]+/g, \"-\")\n\t\t.replace(/^-+|-+$/g, \"\");\n\treturn normalized || \"default\";\n}\n\nfunction workspaceKeyFor(cwd: string): string {\n\treturn createHash(\"sha256\").update(cwd).digest(\"hex\").slice(0, 16);\n}\n\nexport function improvementLoopPaths(input: ImprovementLoopStatusInput): ImprovementLoopPaths {\n\tconst rootDir = join(input.agentDir ?? getAgentDir(), \"improvement-loop\");\n\tconst workspaceKey = workspaceKeyFor(input.cwd);\n\tconst loopId = normalizeLoopId(input.loopId);\n\tconst workspaceDir = join(rootDir, \"workspaces\", workspaceKey);\n\treturn {\n\t\trootDir,\n\t\tworkspaceDir,\n\t\tlogPath: join(workspaceDir, `${loopId}.jsonl`),\n\t\tsandboxDir: join(workspaceDir, \"sandboxes\", loopId),\n\t\tartifactDir: join(workspaceDir, \"artifacts\", loopId),\n\t\tworkspaceKey,\n\t\tloopId,\n\t};\n}\n\nfunction finiteRunMetric(run: ImprovementRunRecord): number | null {\n\treturn normalizeFiniteNumber(run.metric);\n}\n\nfunction betterRun(\n\tcurrent: ImprovementRunRecord,\n\tbest: ImprovementRunRecord | null,\n\tdirection: MetricDirection,\n): ImprovementRunRecord {\n\tif (!best) return current;\n\tconst currentMetric = finiteRunMetric(current);\n\tconst bestMetric = finiteRunMetric(best);\n\tif (currentMetric === null || bestMetric === null) return best;\n\treturn compareMetric(currentMetric, bestMetric, direction).improved ? current : best;\n}\n\nfunction configFromInit(input: ImprovementLoopInitInput, loopId: string): ImprovementLoopConfig {\n\treturn {\n\t\tloopId,\n\t\tobjective: input.objective,\n\t\tmetricName: input.metricName,\n\t\tmetricUnit: input.metricUnit ?? \"\",\n\t\tdirection: normalizeDirection(input.direction),\n\t\tminDelta: normalizeNonNegative(input.minDelta, 0),\n\t\tminRelativeDelta: normalizeNonNegative(input.minRelativeDelta, 0),\n\t\tconfidenceMode: input.confidenceMode ?? (normalizeNonNegative(input.minConfidence, 0) > 0 ? \"mad\" : \"none\"),\n\t\tminConfidence: normalizeNonNegative(input.minConfidence, 0),\n\t\tlowConfidenceAction: input.lowConfidenceAction ?? \"retry\",\n\t\tcreatedAt: Date.now(),\n\t\tcwd: input.cwd,\n\t};\n}\n\nasync function readLoopLogEntries(logPath: string): Promise<ImprovementLoopLogEntry[]> {\n\tlet text = \"\";\n\ttry {\n\t\ttext = await readFile(logPath, \"utf8\");\n\t} catch (error) {\n\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return [];\n\t\tthrow error;\n\t}\n\treturn text\n\t\t.split(\"\\n\")\n\t\t.filter((line) => line.trim().length > 0)\n\t\t.map((line) => JSON.parse(line) as ImprovementLoopLogEntry);\n}\n\nfunction reconstructImprovementLoopState(\n\tentries: ImprovementLoopLogEntry[],\n\tlogPath: string,\n): ImprovementLoopState | null {\n\tlet config: ImprovementLoopConfig | null = null;\n\tlet runs: ImprovementRunRecord[] = [];\n\tconst sandboxById = new Map<string, ImprovementSandboxRecord>();\n\tfor (const entry of entries) {\n\t\tif (entry.type === \"config\") {\n\t\t\tconst { type: _type, ...rest } = entry;\n\t\t\tconfig = rest;\n\t\t\truns = [];\n\t\t\tsandboxById.clear();\n\t\t\tcontinue;\n\t\t}\n\t\tif (entry.type === \"run\") {\n\t\t\tconst { type: _type, ...run } = entry;\n\t\t\truns.push(run);\n\t\t\tcontinue;\n\t\t}\n\t\tif (entry.type === \"sandbox\") {\n\t\t\tconst { type: _type, ...sandbox } = entry;\n\t\t\tsandboxById.set(sandbox.sandboxId, sandbox);\n\t\t}\n\t}\n\tif (!config) return null;\n\n\tconst baselineMetric = finiteRunMetric(runs[0] ?? ({} as ImprovementRunRecord));\n\tlet bestRun: ImprovementRunRecord | null = null;\n\tfor (const run of runs) {\n\t\tif (run.decision !== \"keep\" || finiteRunMetric(run) === null) continue;\n\t\tbestRun = betterRun(run, bestRun, config.direction);\n\t}\n\n\tconst sandboxes = [...sandboxById.values()].sort((a, b) => a.createdAt - b.createdAt);\n\tconst activeSandbox = [...sandboxes].reverse().find((sandbox) => sandbox.status === \"active\") ?? null;\n\treturn {\n\t\tconfig,\n\t\truns,\n\t\tsandboxes,\n\t\tactiveSandbox,\n\t\tbaselineMetric,\n\t\tbestMetric: bestRun ? finiteRunMetric(bestRun) : null,\n\t\tbestRunId: bestRun?.runId ?? null,\n\t\tlastDecision: null,\n\t\tlogPath,\n\t};\n}\n\nexport async function initImprovementLoop(input: ImprovementLoopInitInput): Promise<ImprovementLoopState> {\n\tconst paths = improvementLoopPaths(input);\n\tconst existing = await readLoopLogEntries(paths.logPath);\n\tif (existing.length > 0 && !input.reset) {\n\t\tthrow new Error(\n\t\t\t`Improvement loop already exists at ${paths.logPath}; pass reset=true to replace user-level loop state.`,\n\t\t);\n\t}\n\tconst config = configFromInit(input, paths.loopId);\n\tawait mkdir(dirname(paths.logPath), { recursive: true });\n\tawait writeFile(paths.logPath, `${JSON.stringify({ type: \"config\", ...config })}\\n`);\n\tconst state = reconstructImprovementLoopState([{ type: \"config\", ...config }], paths.logPath);\n\tif (!state) throw new Error(\"Failed to initialize improvement loop state\");\n\treturn state;\n}\n\nexport async function readImprovementLoopState(\n\tinput: ImprovementLoopStatusInput,\n): Promise<ImprovementLoopState | null> {\n\tconst paths = improvementLoopPaths(input);\n\treturn reconstructImprovementLoopState(await readLoopLogEntries(paths.logPath), paths.logPath);\n}\n\nfunction createSandboxId(input: ImprovementSandboxCreateInput): string {\n\tif (input.sandboxId) return normalizeLoopId(input.sandboxId);\n\tconst seed = `${input.cwd}:${input.loopId ?? \"default\"}:${Date.now()}:${Math.random()}`;\n\treturn `${Date.now()}-${createHash(\"sha256\").update(seed).digest(\"hex\").slice(0, 8)}`;\n}\n\nasync function appendSandboxRecord(\n\tinput: ImprovementLoopStatusInput,\n\tsandbox: ImprovementSandboxRecord,\n): Promise<ImprovementLoopState> {\n\tconst paths = improvementLoopPaths(input);\n\tawait mkdir(dirname(paths.logPath), { recursive: true });\n\tawait writeFile(paths.logPath, `${JSON.stringify({ type: \"sandbox\", ...sandbox })}\\n`, { flag: \"a\" });\n\tconst updated = await readImprovementLoopState(input);\n\tif (!updated) throw new Error(\"Failed to read improvement loop after sandbox update\");\n\treturn updated;\n}\n\nasync function runGit(\n\texec: ImprovementLoopExec,\n\tcwd: string,\n\targs: string[],\n\tsignal?: AbortSignal,\n): Promise<ImprovementMeasurementCommandResult> {\n\treturn exec(\"git\", args, { cwd, timeout: 60_000, signal, maxBuffer: 64 * 1024 });\n}\n\nexport async function createImprovementSandbox(input: ImprovementSandboxCreateInput): Promise<ImprovementLoopState> {\n\tconst state = await readImprovementLoopState(input);\n\tif (!state) throw new Error(\"Improvement loop is not initialized; call init first.\");\n\tif (state.activeSandbox) {\n\t\tthrow new Error(\n\t\t\t`Active sandbox already exists at ${state.activeSandbox.worktreePath}; clean it before creating another.`,\n\t\t);\n\t}\n\tconst status = await runGit(input.exec, input.cwd, [\"status\", \"--porcelain\"], input.signal);\n\tif (status.code !== 0) throw new Error(`Cannot inspect git status: ${(status.stderr || status.stdout).trim()}`);\n\tif (status.stdout.trim() && !input.allowDirtyRepo) {\n\t\tthrow new Error(\n\t\t\t\"Refusing to create sandbox from dirty repository; commit/stash changes or pass allowDirtyRepo=true.\",\n\t\t);\n\t}\n\tconst baseRef = input.baseRef?.trim() || \"HEAD\";\n\tconst sandboxId = createSandboxId(input);\n\tconst paths = improvementLoopPaths(input);\n\tconst worktreePath = join(paths.sandboxDir, sandboxId);\n\tawait mkdir(dirname(worktreePath), { recursive: true });\n\tconst add = await runGit(\n\t\tinput.exec,\n\t\tinput.cwd,\n\t\t[\"worktree\", \"add\", \"--detach\", worktreePath, baseRef],\n\t\tinput.signal,\n\t);\n\tif (add.code !== 0) throw new Error(`Failed to create git worktree sandbox: ${(add.stderr || add.stdout).trim()}`);\n\tconst sandbox: ImprovementSandboxRecord = {\n\t\tsandboxId,\n\t\tstatus: \"active\",\n\t\trepoPath: input.cwd,\n\t\tworktreePath,\n\t\tbaseRef,\n\t\tcreatedAt: Date.now(),\n\t};\n\treturn appendSandboxRecord(input, sandbox);\n}\n\nexport async function exportImprovementSandboxPatch(\n\tinput: ImprovementSandboxExportInput,\n): Promise<ImprovementLoopState> {\n\tconst state = await readImprovementLoopState(input);\n\tif (!state) throw new Error(\"Improvement loop is not initialized; call init first.\");\n\tconst sandbox = input.sandboxId\n\t\t? state.sandboxes.find((candidate) => candidate.sandboxId === normalizeLoopId(input.sandboxId))\n\t\t: state.activeSandbox;\n\tif (!sandbox || sandbox.status !== \"active\") throw new Error(\"No active sandbox found to export.\");\n\tconst diff = await runGit(input.exec, sandbox.worktreePath, [\"diff\", \"--binary\", \"HEAD\"], input.signal);\n\tif (diff.code !== 0) throw new Error(`Failed to export sandbox patch: ${(diff.stderr || diff.stdout).trim()}`);\n\tif (!diff.stdout.trim() && !input.allowEmptyPatch) throw new Error(\"Sandbox has no changes to export.\");\n\tconst paths = improvementLoopPaths(input);\n\tawait mkdir(paths.artifactDir, { recursive: true });\n\tconst patchPath = join(paths.artifactDir, `${sandbox.sandboxId}.patch`);\n\tawait writeFile(patchPath, diff.stdout);\n\treturn appendSandboxRecord(input, {\n\t\t...sandbox,\n\t\texportedAt: Date.now(),\n\t\tpatchPath,\n\t\tpatchBytes: Buffer.byteLength(diff.stdout),\n\t});\n}\n\nexport async function cleanupImprovementSandbox(input: ImprovementSandboxCleanupInput): Promise<ImprovementLoopState> {\n\tconst state = await readImprovementLoopState(input);\n\tif (!state) throw new Error(\"Improvement loop is not initialized; call init first.\");\n\tconst sandbox = input.sandboxId\n\t\t? state.sandboxes.find((candidate) => candidate.sandboxId === normalizeLoopId(input.sandboxId))\n\t\t: state.activeSandbox;\n\tif (!sandbox || sandbox.status !== \"active\") throw new Error(\"No active sandbox found to clean up.\");\n\tconst remove = await runGit(\n\t\tinput.exec,\n\t\tsandbox.repoPath,\n\t\t[\"worktree\", \"remove\", \"--force\", sandbox.worktreePath],\n\t\tinput.signal,\n\t);\n\tif (remove.code !== 0)\n\t\tthrow new Error(`Failed to remove git worktree sandbox: ${(remove.stderr || remove.stdout).trim()}`);\n\tawait runGit(input.exec, sandbox.repoPath, [\"worktree\", \"prune\"], input.signal);\n\treturn appendSandboxRecord(input, {\n\t\t...sandbox,\n\t\tstatus: \"cleaned\",\n\t\tcleanedAt: Date.now(),\n\t\treason: input.reason,\n\t});\n}\n\nexport async function recordImprovementRun(input: ImprovementLoopRecordInput): Promise<ImprovementLoopState> {\n\tconst state = await readImprovementLoopState(input);\n\tif (!state) throw new Error(\"Improvement loop is not initialized; call init first.\");\n\tconst runId = input.runId ?? state.runs.length + 1;\n\tconst priorMetrics = state.runs\n\t\t.map((run) => run.metric)\n\t\t.filter((metric): metric is number => Number.isFinite(metric));\n\tconst decision = decideImprovement({\n\t\tcurrentMetric: input.metric,\n\t\tbestMetric: state.bestMetric,\n\t\tdirection: state.config.direction,\n\t\tchecksPass: input.checksPass ?? null,\n\t\tminDelta: state.config.minDelta,\n\t\tminRelativeDelta: state.config.minRelativeDelta,\n\t\tconfidenceMode: state.config.confidenceMode,\n\t\tminConfidence: state.config.minConfidence,\n\t\tlowConfidenceAction: state.config.lowConfidenceAction,\n\t\tnoiseMetrics: priorMetrics,\n\t});\n\tconst record: ImprovementRunRecord = {\n\t\trunId,\n\t\tobjective: state.config.objective,\n\t\thypothesis: input.hypothesis,\n\t\tmetricName: state.config.metricName,\n\t\tmetricUnit: state.config.metricUnit,\n\t\tdirection: state.config.direction,\n\t\tmetric: normalizeFiniteNumber(input.metric),\n\t\tsecondaryMetrics: input.secondaryMetrics,\n\t\tchecksPass: input.checksPass ?? null,\n\t\tdecision: decision.decision,\n\t\treason: decision.reason,\n\t\tconfidence: decision.confidence.value,\n\t\tchangedFiles: input.changedFiles,\n\t\tevidenceRef: input.evidenceRef,\n\t\tnextHint: input.nextHint,\n\t\ttimestamp: Date.now(),\n\t};\n\tawait mkdir(dirname(state.logPath), { recursive: true });\n\tawait writeFile(state.logPath, `${JSON.stringify({ type: \"run\", ...record })}\\n`, { flag: \"a\" });\n\tconst updated = await readImprovementLoopState(input);\n\tif (!updated) throw new Error(\"Failed to read improvement loop after recording run\");\n\treturn { ...updated, lastDecision: decision };\n}\n\nfunction secondaryMetricsFrom(\n\tparsedMetrics: Record<string, number>,\n\tprimaryName: string,\n): Record<string, number> | undefined {\n\tconst secondary = Object.fromEntries(Object.entries(parsedMetrics).filter(([name]) => name !== primaryName));\n\treturn Object.keys(secondary).length > 0 ? secondary : undefined;\n}\n\nexport async function runImprovementMeasurement(input: {\n\texec: ImprovementLoopExec;\n\tcwd: string;\n\tcommand: string;\n\tmetricName: string;\n\tchecksCommand?: string;\n\ttimeoutSeconds?: number;\n\tchecksTimeoutSeconds?: number;\n\tmaxOutputBytes?: number;\n\tsignal?: AbortSignal;\n}): Promise<ImprovementMeasurementResult> {\n\tconst command = input.command.trim();\n\tif (!command) throw new Error(\"command is required\");\n\tconst timeoutMs = Math.max(1, Math.floor(input.timeoutSeconds ?? 600)) * 1000;\n\tconst checksTimeoutMs = Math.max(1, Math.floor(input.checksTimeoutSeconds ?? 300)) * 1000;\n\tconst maxBuffer = Math.max(1024, Math.floor(input.maxOutputBytes ?? 64 * 1024));\n\tconst started = Date.now();\n\tconst result = await input.exec(\"bash\", [\"-c\", command], {\n\t\tcwd: input.cwd,\n\t\ttimeout: timeoutMs,\n\t\tsignal: input.signal,\n\t\tmaxBuffer,\n\t});\n\tconst durationMs = Date.now() - started;\n\tconst output = `${result.stdout}\\n${result.stderr}`;\n\tconst parsedMetrics = metricMapFromOutput(output);\n\tconst primaryMetric = selectPrimaryMetric(parsedMetrics, input.metricName);\n\tlet checksPass = result.code === 0 && !result.killed;\n\tlet checksExitCode: number | undefined;\n\tlet checksTimedOut: boolean | undefined;\n\tlet checksStdout: string | undefined;\n\tlet checksStderr: string | undefined;\n\tconst checksCommand = input.checksCommand?.trim();\n\tif (checksPass && checksCommand) {\n\t\tconst checks = await input.exec(\"bash\", [\"-c\", checksCommand], {\n\t\t\tcwd: input.cwd,\n\t\t\ttimeout: checksTimeoutMs,\n\t\t\tsignal: input.signal,\n\t\t\tmaxBuffer,\n\t\t});\n\t\tchecksExitCode = checks.code;\n\t\tchecksTimedOut = checks.killed;\n\t\tchecksStdout = checks.stdout;\n\t\tchecksStderr = checks.stderr;\n\t\tchecksPass = checks.code === 0 && !checks.killed;\n\t}\n\n\treturn {\n\t\tcommand,\n\t\texitCode: result.code,\n\t\ttimedOut: result.killed,\n\t\tdurationMs,\n\t\tstdout: result.stdout,\n\t\tstderr: result.stderr,\n\t\tstdoutTruncated: !!result.stdoutTruncated,\n\t\tstderrTruncated: !!result.stderrTruncated,\n\t\tparsedMetrics,\n\t\tprimaryMetric,\n\t\tchecksCommand: checksCommand || undefined,\n\t\tchecksExitCode,\n\t\tchecksTimedOut,\n\t\tchecksPass,\n\t\tchecksStdout,\n\t\tchecksStderr,\n\t};\n}\n\nexport function parseGitPorcelainStatus(status: string): GitStatusEntry[] {\n\treturn status\n\t\t.split(\"\\n\")\n\t\t.map((line) => line.trimEnd())\n\t\t.filter(Boolean)\n\t\t.map((line) => {\n\t\t\tconst index = line[0] ?? \" \";\n\t\t\tconst workingTree = line[1] ?? \" \";\n\t\t\tconst rawPath = line.slice(3);\n\t\t\tconst renameParts = rawPath.split(\" -> \");\n\t\t\tif (renameParts.length === 2) {\n\t\t\t\treturn { index, workingTree, origPath: renameParts[0], path: renameParts[1] };\n\t\t\t}\n\t\t\treturn { index, workingTree, path: rawPath };\n\t\t});\n}\n\nfunction entriesFromStatus(status: string | GitStatusEntry[]): GitStatusEntry[] {\n\treturn Array.isArray(status) ? status : parseGitPorcelainStatus(status);\n}\n\nfunction normalizePath(path: string): string {\n\treturn path.replace(/\\\\/g, \"/\").replace(/^\\.\\//, \"\");\n}\n\nfunction pathSet(paths: string[]): Set<string> {\n\treturn new Set(paths.map(normalizePath).filter(Boolean));\n}\n\nfunction entryPaths(entry: GitStatusEntry): string[] {\n\treturn [entry.path, entry.origPath].filter((value): value is string => typeof value === \"string\").map(normalizePath);\n}\n\nfunction statusPathSet(entries: GitStatusEntry[]): Set<string> {\n\tconst paths = new Set<string>();\n\tfor (const entry of entries) {\n\t\tfor (const path of entryPaths(entry)) paths.add(path);\n\t}\n\treturn paths;\n}\n\nfunction isPreserved(path: string, preservePaths: Set<string>): boolean {\n\tfor (const preserve of preservePaths) {\n\t\tif (path === preserve || path.startsWith(`${preserve}/`)) return true;\n\t}\n\treturn false;\n}\n\nexport function planOwnedDiscard(input: OwnedDiscardPlanInput): OwnedDiscardPlan {\n\tconst beforePaths = statusPathSet(entriesFromStatus(input.beforeStatus));\n\tconst afterPaths = statusPathSet(entriesFromStatus(input.afterStatus));\n\tconst ownedPaths = pathSet(input.ownedPaths);\n\tconst preservePaths = pathSet(input.preservePaths ?? []);\n\tconst revertPaths: string[] = [];\n\tconst protectedUserDirtyPaths: string[] = [];\n\tconst unownedChangedPaths: string[] = [];\n\tconst preservedChangedPaths: string[] = [];\n\n\tfor (const path of afterPaths) {\n\t\tif (isPreserved(path, preservePaths)) {\n\t\t\tpreservedChangedPaths.push(path);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!ownedPaths.has(path)) {\n\t\t\tunownedChangedPaths.push(path);\n\t\t\tcontinue;\n\t\t}\n\t\tif (beforePaths.has(path)) {\n\t\t\tprotectedUserDirtyPaths.push(path);\n\t\t\tcontinue;\n\t\t}\n\t\trevertPaths.push(path);\n\t}\n\n\treturn {\n\t\trevertPaths: [...new Set(revertPaths)].sort(),\n\t\tpreservePaths: [...new Set(preservedChangedPaths)].sort(),\n\t\tprotectedUserDirtyPaths: [...new Set(protectedUserDirtyPaths)].sort(),\n\t\tunownedChangedPaths: [...new Set(unownedChangedPaths)].sort(),\n\t\tcanDiscardOwnedChanges: protectedUserDirtyPaths.length === 0,\n\t};\n}\n\nconst DecisionToolParams = Type.Object(\n\t{\n\t\tcurrentMetric: Type.Number({ description: \"Measured primary metric for the candidate run.\" }),\n\t\tbestMetric: Type.Optional(Type.Number({ description: \"Best kept primary metric so far. Omit for baseline.\" })),\n\t\tdirection: StringEnum([\"lower\", \"higher\"] as const, {\n\t\t\tdescription: \"Whether lower or higher metric values are better. Default lower.\",\n\t\t}),\n\t\tchecksPass: Type.Optional(\n\t\t\tType.Boolean({ description: \"Whether correctness checks passed. false forces discard.\" }),\n\t\t),\n\t\tminDelta: Type.Optional(\n\t\t\tType.Number({ description: \"Minimum absolute improvement required to keep. Default 0.\" }),\n\t\t),\n\t\tminRelativeDelta: Type.Optional(\n\t\t\tType.Number({ description: \"Minimum relative improvement required to keep, e.g. 0.01 for 1%. Default 0.\" }),\n\t\t),\n\t\tconfidenceMode: Type.Optional(\n\t\t\tStringEnum([\"none\", \"mad\"] as const, {\n\t\t\t\tdescription: \"Noise/confidence policy. Use mad with minConfidence to reject noisy wins.\",\n\t\t\t}),\n\t\t),\n\t\tminConfidence: Type.Optional(\n\t\t\tType.Number({ description: \"Minimum confidence multiple over MAD noise floor. Default 0.\" }),\n\t\t),\n\t\tlowConfidenceAction: Type.Optional(\n\t\t\tStringEnum([\"retry\", \"discard\"] as const, {\n\t\t\t\tdescription: \"Decision when confidence evidence is missing or too low. Default retry.\",\n\t\t\t}),\n\t\t),\n\t\tnoiseMetrics: Type.Optional(\n\t\t\tType.Array(Type.Number(), { description: \"Previous metric samples for MAD confidence calculation.\" }),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport function createImprovementDecisionTool(): ToolDefinition<typeof DecisionToolParams, ImprovementDecisionResult> {\n\treturn defineTool({\n\t\tname: \"improvement_decision\",\n\t\tlabel: \"Improvement Decision\",\n\t\tdescription:\n\t\t\t\"Deterministically decide keep/discard/retry/blocked for an improvement candidate from metric, direction, thresholds, checks, and optional noise samples. The model proposes; code judges.\",\n\t\tpromptSnippet: \"Decide keep/discard for a measured improvement candidate using deterministic metric gates\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use improvement_decision after measuring a candidate when keep/discard must be based on metric evidence rather than model intuition.\",\n\t\t\t\"Do not claim a candidate is kept unless this tool returns decision=keep or a stronger project-specific validator passes.\",\n\t\t\t\"Correctness failures override metric wins; checksPass=false always discards.\",\n\t\t],\n\t\tparameters: DecisionToolParams,\n\t\tasync execute(_toolCallId, params) {\n\t\t\tconst decision = decideImprovement(params);\n\t\t\tconst comparison = decision.comparison;\n\t\t\tconst confidenceText = decision.confidence.value === null ? \"n/a\" : decision.confidence.value.toFixed(2);\n\t\t\tconst deltaText = comparison ? comparison.delta.toString() : \"n/a\";\n\t\t\treturn {\n\t\t\t\tcontent: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\ttext: `Decision: ${decision.decision} (${decision.reason})\\nDelta: ${deltaText}\\nConfidence: ${confidenceText}`,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdetails: decision,\n\t\t\t};\n\t\t},\n\t});\n}\n\nconst LoopToolParams = Type.Object(\n\t{\n\t\taction: StringEnum(\n\t\t\t[\"init\", \"status\", \"record\", \"measure\", \"sandbox_create\", \"sandbox_export\", \"sandbox_cleanup\"] as const,\n\t\t\t{\n\t\t\t\tdescription:\n\t\t\t\t\t\"init creates user-level loop state, status reads it, record appends a supplied measurement, measure runs and records a bounded command, sandbox_create/export/cleanup manage disposable git worktrees and keep patches.\",\n\t\t\t},\n\t\t),\n\t\tloopId: Type.Optional(Type.String({ description: \"Loop id within the current workspace. Default: default.\" })),\n\t\tobjective: Type.Optional(Type.String({ description: \"Loop objective. Required for action=init.\" })),\n\t\tmetricName: Type.Optional(Type.String({ description: \"Primary metric name. Required for action=init.\" })),\n\t\tmetricUnit: Type.Optional(Type.String({ description: \"Display unit for the primary metric.\" })),\n\t\tdirection: Type.Optional(\n\t\t\tStringEnum([\"lower\", \"higher\"] as const, {\n\t\t\t\tdescription: \"Whether lower or higher metric values are better. Default lower.\",\n\t\t\t}),\n\t\t),\n\t\treset: Type.Optional(\n\t\t\tType.Boolean({\n\t\t\t\tdescription: \"For action=init, replace existing user-level loop state for this workspace/loop id.\",\n\t\t\t}),\n\t\t),\n\t\tminDelta: Type.Optional(\n\t\t\tType.Number({ description: \"Minimum absolute improvement required to keep. Default 0.\" }),\n\t\t),\n\t\tminRelativeDelta: Type.Optional(\n\t\t\tType.Number({ description: \"Minimum relative improvement required to keep. Default 0.\" }),\n\t\t),\n\t\tconfidenceMode: Type.Optional(\n\t\t\tStringEnum([\"none\", \"mad\"] as const, {\n\t\t\t\tdescription: \"Noise/confidence policy. Default none unless minConfidence > 0.\",\n\t\t\t}),\n\t\t),\n\t\tminConfidence: Type.Optional(\n\t\t\tType.Number({ description: \"Minimum confidence multiple over MAD noise floor. Default 0.\" }),\n\t\t),\n\t\tlowConfidenceAction: Type.Optional(\n\t\t\tStringEnum([\"retry\", \"discard\"] as const, {\n\t\t\t\tdescription: \"Decision when confidence evidence is missing or low. Default retry.\",\n\t\t\t}),\n\t\t),\n\t\tcurrentMetric: Type.Optional(Type.Number({ description: \"Measured primary metric for action=record.\" })),\n\t\tchecksPass: Type.Optional(\n\t\t\tType.Boolean({ description: \"Correctness check result for action=record. false forces discard.\" }),\n\t\t),\n\t\thypothesis: Type.Optional(Type.String({ description: \"What this run tried.\" })),\n\t\tsecondaryMetrics: Type.Optional(\n\t\t\tType.Object(\n\t\t\t\t{},\n\t\t\t\t{ additionalProperties: Type.Number(), description: \"Secondary metric map for action=record.\" },\n\t\t\t),\n\t\t),\n\t\tchangedFiles: Type.Optional(Type.Array(Type.String(), { description: \"Files changed by this candidate run.\" })),\n\t\tevidenceRef: Type.Optional(\n\t\t\tType.String({ description: \"Path, command, or artifact reference proving the measurement/check result.\" }),\n\t\t),\n\t\tnextHint: Type.Optional(\n\t\t\tType.String({ description: \"Useful next-step hint for later runs, especially after discard/retry/blocked.\" }),\n\t\t),\n\t\tcommand: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription:\n\t\t\t\t\t\"Measurement command for action=measure. Runs via bash -c in ctx.cwd or active sandbox when useSandbox=true.\",\n\t\t\t}),\n\t\t),\n\t\tchecksCommand: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription:\n\t\t\t\t\t\"Optional correctness command for action=measure. Runs only if the measurement command exits 0.\",\n\t\t\t}),\n\t\t),\n\t\ttimeoutSeconds: Type.Optional(\n\t\t\tType.Number({ description: \"Measurement command timeout in seconds. Default 600.\" }),\n\t\t),\n\t\tchecksTimeoutSeconds: Type.Optional(\n\t\t\tType.Number({ description: \"Checks command timeout in seconds. Default 300.\" }),\n\t\t),\n\t\tmaxOutputBytes: Type.Optional(\n\t\t\tType.Number({ description: \"Maximum stdout/stderr tail retained per command. Default 65536.\" }),\n\t\t),\n\t\tuseSandbox: Type.Optional(\n\t\t\tType.Boolean({\n\t\t\t\tdescription: \"For action=measure, run command/checks inside the active sandbox worktree. Default false.\",\n\t\t\t}),\n\t\t),\n\t\tsandboxId: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription:\n\t\t\t\t\t\"Sandbox id for sandbox_create/sandbox_export/sandbox_cleanup. Defaults to generated id or active sandbox.\",\n\t\t\t}),\n\t\t),\n\t\tbaseRef: Type.Optional(Type.String({ description: \"Git base ref for sandbox_create. Default HEAD.\" })),\n\t\tallowDirtyRepo: Type.Optional(\n\t\t\tType.Boolean({\n\t\t\t\tdescription: \"Allow sandbox_create when the real repo has uncommitted changes. Default false.\",\n\t\t\t}),\n\t\t),\n\t\tcleanupReason: Type.Optional(\n\t\t\tType.String({ description: \"Optional reason recorded when sandbox_cleanup removes a sandbox.\" }),\n\t\t),\n\t\tallowEmptyPatch: Type.Optional(\n\t\t\tType.Boolean({ description: \"For sandbox_export, allow writing an empty patch. Default false.\" }),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nfunction requireString(value: string | undefined, label: string): string {\n\tconst trimmed = value?.trim();\n\tif (!trimmed) throw new Error(`${label} is required`);\n\treturn trimmed;\n}\n\nfunction summarizeLoopState(state: ImprovementLoopState | null): string {\n\tif (!state) return \"Improvement loop is not initialized.\";\n\tconst lines = [\n\t\t`Loop ${state.config.loopId}: ${state.config.objective}`,\n\t\t`Metric: ${state.config.metricName} (${state.config.metricUnit || \"unitless\"}, ${state.config.direction} is better)`,\n\t\t`Runs: ${state.runs.length}`,\n\t\t`Baseline: ${state.baselineMetric ?? \"none\"}`,\n\t\t`Best: ${state.bestMetric ?? \"none\"}${state.bestRunId === null ? \"\" : ` (#${state.bestRunId})`}`,\n\t\t`Log: ${state.logPath}`,\n\t];\n\tconst lastRun = state.runs.at(-1);\n\tif (lastRun) lines.push(`Last: ${lastRun.decision} (${lastRun.reason}) metric=${lastRun.metric ?? \"missing\"}`);\n\tif (state.activeSandbox) lines.push(`Active sandbox: ${state.activeSandbox.worktreePath}`);\n\treturn lines.join(\"\\n\");\n}\n\nexport function createImprovementLoopTool(\n\texec?: ImprovementLoopExec,\n): ToolDefinition<typeof LoopToolParams, ImprovementLoopToolDetails> {\n\treturn defineTool({\n\t\tname: \"improvement_loop\",\n\t\tlabel: \"Improvement Loop\",\n\t\tdescription:\n\t\t\t\"Persist and evaluate a deterministic improvement loop in user-level state: init objective/metric policy, measure bounded commands, record measured runs, manage disposable git worktree sandboxes, and status current baseline/best/decision log. Does not commit/apply/revert real-repo files.\",\n\t\tpromptSnippet: \"Track deterministic improvement-loop state and record measured keep/discard decisions\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use improvement_loop init before iterative optimization that needs metric-based keep/discard state.\",\n\t\t\t\"Use improvement_loop measure to run a bounded measurement command and optional checks command, then record the deterministic decision.\",\n\t\t\t\"Use improvement_loop sandbox_create before risky self-modifying experiments so edits happen in a disposable git worktree, not the real repository.\",\n\t\t\t\"Use improvement_loop sandbox_export to capture the sandbox diff as a user-level patch artifact before cleanup when the decision is keep.\",\n\t\t\t\"Use improvement_loop sandbox_cleanup after discard or after exporting/approving a patch; cleanup removes the disposable worktree record, not the real repository.\",\n\t\t\t\"Use improvement_loop record when measurement already happened elsewhere; code decides keep/discard/retry/blocked from metrics and gates.\",\n\t\t\t\"This tool does not commit/apply/revert real-repo files; keep/discard is a decision record until a later approved executor applies it.\",\n\t\t\t\"Operational state is stored under the user-level agent directory, not in the target repository.\",\n\t\t],\n\t\tparameters: LoopToolParams,\n\t\texecutionMode: \"sequential\",\n\t\tasync execute(_toolCallId, params, signal, _onUpdate, ctx) {\n\t\t\tconst cwd = ctx.cwd;\n\t\t\tif (params.action === \"init\") {\n\t\t\t\tconst state = await initImprovementLoop({\n\t\t\t\t\tcwd,\n\t\t\t\t\tloopId: params.loopId,\n\t\t\t\t\tobjective: requireString(params.objective, \"objective\"),\n\t\t\t\t\tmetricName: requireString(params.metricName, \"metricName\"),\n\t\t\t\t\tmetricUnit: params.metricUnit,\n\t\t\t\t\tdirection: params.direction,\n\t\t\t\t\tminDelta: params.minDelta,\n\t\t\t\t\tminRelativeDelta: params.minRelativeDelta,\n\t\t\t\t\tconfidenceMode: params.confidenceMode,\n\t\t\t\t\tminConfidence: params.minConfidence,\n\t\t\t\t\tlowConfidenceAction: params.lowConfidenceAction,\n\t\t\t\t\treset: params.reset,\n\t\t\t\t});\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: `Initialized improvement loop.\\n${summarizeLoopState(state)}` }],\n\t\t\t\t\tdetails: { action: \"init\", state, logPath: state.logPath },\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (params.action === \"record\") {\n\t\t\t\tconst state = await recordImprovementRun({\n\t\t\t\t\tcwd,\n\t\t\t\t\tloopId: params.loopId,\n\t\t\t\t\tmetric: params.currentMetric,\n\t\t\t\t\tsecondaryMetrics: params.secondaryMetrics as Record<string, number> | undefined,\n\t\t\t\t\tchecksPass: params.checksPass ?? null,\n\t\t\t\t\thypothesis: params.hypothesis,\n\t\t\t\t\tchangedFiles: params.changedFiles,\n\t\t\t\t\tevidenceRef: params.evidenceRef,\n\t\t\t\t\tnextHint: params.nextHint,\n\t\t\t\t});\n\t\t\t\tconst decision = state.lastDecision;\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: `Recorded run: ${decision?.decision ?? \"unknown\"} (${decision?.reason ?? \"unknown\"}).\\n${summarizeLoopState(state)}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: { action: \"record\", state, decision: decision ?? undefined, logPath: state.logPath },\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (params.action === \"measure\") {\n\t\t\t\tif (!exec) throw new Error(\"improvement_loop measure requires createImprovementLoopTool(pi.exec)\");\n\t\t\t\tconst before = await readImprovementLoopState({ cwd, loopId: params.loopId });\n\t\t\t\tif (!before) throw new Error(\"Improvement loop is not initialized; call init first.\");\n\t\t\t\tconst measurementCwd = params.useSandbox\n\t\t\t\t\t? (before.activeSandbox?.worktreePath ??\n\t\t\t\t\t\t(() => {\n\t\t\t\t\t\t\tthrow new Error(\"useSandbox=true requires an active sandbox.\");\n\t\t\t\t\t\t})())\n\t\t\t\t\t: cwd;\n\t\t\t\tconst measurement = await runImprovementMeasurement({\n\t\t\t\t\texec,\n\t\t\t\t\tcwd: measurementCwd,\n\t\t\t\t\tcommand: requireString(params.command, \"command\"),\n\t\t\t\t\tmetricName: before.config.metricName,\n\t\t\t\t\tchecksCommand: params.checksCommand,\n\t\t\t\t\ttimeoutSeconds: params.timeoutSeconds,\n\t\t\t\t\tchecksTimeoutSeconds: params.checksTimeoutSeconds,\n\t\t\t\t\tmaxOutputBytes: params.maxOutputBytes,\n\t\t\t\t\tsignal,\n\t\t\t\t});\n\t\t\t\tconst state = await recordImprovementRun({\n\t\t\t\t\tcwd,\n\t\t\t\t\tloopId: params.loopId,\n\t\t\t\t\tmetric: measurement.primaryMetric,\n\t\t\t\t\tsecondaryMetrics: secondaryMetricsFrom(measurement.parsedMetrics, before.config.metricName),\n\t\t\t\t\tchecksPass: measurement.checksPass,\n\t\t\t\t\thypothesis: params.hypothesis,\n\t\t\t\t\tchangedFiles: params.changedFiles,\n\t\t\t\t\tevidenceRef: params.evidenceRef ?? `command:${measurement.command};cwd:${measurementCwd}`,\n\t\t\t\t\tnextHint: params.nextHint,\n\t\t\t\t});\n\t\t\t\tconst decision = state.lastDecision;\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: `Measured ${before.config.metricName}=${measurement.primaryMetric ?? \"missing\"}; decision: ${decision?.decision ?? \"unknown\"} (${decision?.reason ?? \"unknown\"}).\\n${summarizeLoopState(state)}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\taction: \"measure\",\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\tdecision: decision ?? undefined,\n\t\t\t\t\t\tmeasurement,\n\t\t\t\t\t\tlogPath: state.logPath,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (params.action === \"sandbox_create\") {\n\t\t\t\tif (!exec) throw new Error(\"improvement_loop sandbox_create requires createImprovementLoopTool(pi.exec)\");\n\t\t\t\tconst state = await createImprovementSandbox({\n\t\t\t\t\tcwd,\n\t\t\t\t\tloopId: params.loopId,\n\t\t\t\t\texec,\n\t\t\t\t\tbaseRef: params.baseRef,\n\t\t\t\t\tallowDirtyRepo: params.allowDirtyRepo,\n\t\t\t\t\tsandboxId: params.sandboxId,\n\t\t\t\t\tsignal,\n\t\t\t\t});\n\t\t\t\tconst sandbox = state.activeSandbox ?? undefined;\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: `Created sandbox: ${sandbox?.worktreePath ?? \"unknown\"}\\n${summarizeLoopState(state)}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: { action: \"sandbox_create\", state, sandbox, logPath: state.logPath },\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (params.action === \"sandbox_export\") {\n\t\t\t\tif (!exec) throw new Error(\"improvement_loop sandbox_export requires createImprovementLoopTool(pi.exec)\");\n\t\t\t\tconst state = await exportImprovementSandboxPatch({\n\t\t\t\t\tcwd,\n\t\t\t\t\tloopId: params.loopId,\n\t\t\t\t\texec,\n\t\t\t\t\tsandboxId: params.sandboxId,\n\t\t\t\t\tallowEmptyPatch: params.allowEmptyPatch,\n\t\t\t\t\tsignal,\n\t\t\t\t});\n\t\t\t\tconst sandbox = params.sandboxId\n\t\t\t\t\t? state.sandboxes.find((candidate) => candidate.sandboxId === normalizeLoopId(params.sandboxId))\n\t\t\t\t\t: (state.activeSandbox ?? state.sandboxes.at(-1));\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: `Exported sandbox patch: ${sandbox?.patchPath ?? \"unknown\"}\\n${summarizeLoopState(state)}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: { action: \"sandbox_export\", state, sandbox, logPath: state.logPath },\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (params.action === \"sandbox_cleanup\") {\n\t\t\t\tif (!exec) throw new Error(\"improvement_loop sandbox_cleanup requires createImprovementLoopTool(pi.exec)\");\n\t\t\t\tconst state = await cleanupImprovementSandbox({\n\t\t\t\t\tcwd,\n\t\t\t\t\tloopId: params.loopId,\n\t\t\t\t\texec,\n\t\t\t\t\tsandboxId: params.sandboxId,\n\t\t\t\t\treason: params.cleanupReason,\n\t\t\t\t\tsignal,\n\t\t\t\t});\n\t\t\t\tconst sandbox = params.sandboxId\n\t\t\t\t\t? state.sandboxes.find((candidate) => candidate.sandboxId === normalizeLoopId(params.sandboxId))\n\t\t\t\t\t: state.sandboxes.at(-1);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: `Cleaned sandbox.\\n${summarizeLoopState(state)}` }],\n\t\t\t\t\tdetails: { action: \"sandbox_cleanup\", state, sandbox, logPath: state.logPath },\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst state = await readImprovementLoopState({ cwd, loopId: params.loopId });\n\t\t\tconst paths = improvementLoopPaths({ cwd, loopId: params.loopId });\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: summarizeLoopState(state) }],\n\t\t\t\tdetails: { action: \"status\", state, logPath: state?.logPath ?? paths.logPath },\n\t\t\t};\n\t\t},\n\t});\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAyB,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAEhE,MAAM,WAAW,wBAAwB;IACxC,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oFAAoF;IACpF,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,0DAA0D;IAC1D,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,qFAAqF;IACrF,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,uCAAuC;IACvC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,yBAAyB;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,sDAAsD;IACtD,YAAY,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACzD,4EAA4E;IAC5E,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;CACjB;AAwCD,kEAAkE;AAClE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,MAAM,CAmI3E","sourcesContent":["/**\n * System prompt construction and project context loading\n */\n\nimport { getDocsPath, getExamplesPath, getReadmePath } from \"../config.ts\";\nimport { formatSkillsForPrompt, type Skill } from \"./skills.ts\";\n\nexport interface BuildSystemPromptOptions {\n\t/** Custom system prompt (replaces default). */\n\tcustomPrompt?: string;\n\t/** Tools to include in prompt. Default: [read, bash, edit, write, context_audit] */\n\tselectedTools?: string[];\n\t/** Optional one-line tool snippets keyed by tool name. */\n\ttoolSnippets?: Record<string, string>;\n\t/** Additional guideline bullets appended to the default system prompt guidelines. */\n\tpromptGuidelines?: string[];\n\t/** Text to append to system prompt. */\n\tappendSystemPrompt?: string;\n\t/** Working directory. */\n\tcwd: string;\n\t/** Eagerly loaded project/agent instruction files. */\n\tcontextFiles?: Array<{ path: string; content?: string }>;\n\t/** Discovered skills; startup prompt lists only lazy-loadable locations. */\n\tskills?: Skill[];\n}\n\nconst ADAPTATIVE_PERSONA_SECTION = `\n\nAdaptative Agent Persona:\n- Work as a self-improving engineering agent: clarify the mission, choose the smallest safe action, verify important claims, and preserve user trust.\n- Use a lightweight MAPE loop for adaptive work: monitor source/runtime evidence, analyze it against mission and memory, plan the smallest safe change, execute with scoped edits, then verify and feed back durable learning.\n- Treat harness evolution as a first-class task. Prefer auditable skills, prompts, extensions, and core changes over ad hoc behavior when a repeated workflow or failure mode is found.\n- For self-evolution, inspect the current runtime/source before changing it, make focused changes, reload or renew only after source is auditable, and validate with concrete artifacts.\n- For file-backed extensions and tools, default to current-session or current-tenant state; shared/global files, locks, cleanup, stop, compact, prune, or list operations must be deliberate, documented, and safe for parallel sessions.\n- Before preserving or changing durable behavior, confront Automata/user memory and ask: why is it good for the user, is it unique or should it merge with existing memory/skills/agents, and will it make the agent better.\n- Maintain a clear contract between objective, evidence, and completion. Do not call work done until requirements are mapped to files, commands, or runtime observations.\n- Keep durable learning concise: store stable preferences, rules, fixes, and source pointers; do not preserve transient execution noise.`;\n\nfunction formatContextFilesForPrompt(contextFiles: Array<{ path: string; content?: string }>): string {\n\tif (contextFiles.length === 0) {\n\t\treturn \"\";\n\t}\n\n\tconst lines = [\"\\n\\n<project_context>\", \"\", \"Project-specific instructions and guidelines:\", \"\"];\n\n\tfor (const { path, content } of contextFiles) {\n\t\tlines.push(`<project_instructions path=\"${escapeXml(path)}\">`);\n\t\tlines.push(content ?? \"\");\n\t\tlines.push(\"</project_instructions>\", \"\");\n\t}\n\n\tlines.push(\"</project_context>\");\n\treturn lines.join(\"\\n\");\n}\n\nfunction escapeXml(str: string): string {\n\treturn str\n\t\t.replace(/&/g, \"&amp;\")\n\t\t.replace(/</g, \"&lt;\")\n\t\t.replace(/>/g, \"&gt;\")\n\t\t.replace(/\"/g, \"&quot;\")\n\t\t.replace(/'/g, \"&apos;\");\n}\n\n/** Build the system prompt with tools, guidelines, and context */\nexport function buildSystemPrompt(options: BuildSystemPromptOptions): string {\n\tconst {\n\t\tcustomPrompt,\n\t\tselectedTools,\n\t\ttoolSnippets,\n\t\tpromptGuidelines,\n\t\tappendSystemPrompt,\n\t\tcwd,\n\t\tcontextFiles: providedContextFiles,\n\t\tskills: providedSkills,\n\t} = options;\n\tconst resolvedCwd = cwd;\n\tconst promptCwd = resolvedCwd.replace(/\\\\/g, \"/\");\n\n\tconst now = new Date();\n\tconst year = now.getFullYear();\n\tconst month = String(now.getMonth() + 1).padStart(2, \"0\");\n\tconst day = String(now.getDate()).padStart(2, \"0\");\n\tconst date = `${year}-${month}-${day}`;\n\n\tconst appendSection = appendSystemPrompt ? `\\n\\n${appendSystemPrompt}` : \"\";\n\n\tconst contextFiles = providedContextFiles ?? [];\n\tconst skills = providedSkills ?? [];\n\n\tif (customPrompt) {\n\t\tlet prompt = customPrompt;\n\n\t\tprompt += ADAPTATIVE_PERSONA_SECTION;\n\n\t\tif (appendSection) {\n\t\t\tprompt += appendSection;\n\t\t}\n\n\t\tprompt += formatContextFilesForPrompt(contextFiles);\n\n\t\t// Append skills section (only if read tool is available)\n\t\tconst customPromptHasRead = !selectedTools || selectedTools.includes(\"read\");\n\t\tif (customPromptHasRead && skills.length > 0) {\n\t\t\tprompt += formatSkillsForPrompt(skills);\n\t\t}\n\n\t\t// Add date and working directory last\n\t\tprompt += `\\nCurrent date: ${date}`;\n\t\tprompt += `\\nCurrent working directory: ${promptCwd}`;\n\n\t\treturn prompt;\n\t}\n\n\t// Get absolute paths to documentation and examples\n\tconst readmePath = getReadmePath();\n\tconst docsPath = getDocsPath();\n\tconst examplesPath = getExamplesPath();\n\n\t// Build tools list based on selected tools.\n\t// A tool appears in Available tools only when the caller provides a one-line snippet.\n\tconst tools = selectedTools || [\"read\", \"bash\", \"edit\", \"write\"];\n\tconst visibleTools = tools.filter((name) => !!toolSnippets?.[name]);\n\tconst toolsList =\n\t\tvisibleTools.length > 0 ? visibleTools.map((name) => `- ${name}: ${toolSnippets![name]}`).join(\"\\n\") : \"(none)\";\n\n\t// Build guidelines based on which tools are actually available\n\tconst guidelinesList: string[] = [];\n\tconst guidelinesSet = new Set<string>();\n\tconst addGuideline = (guideline: string): void => {\n\t\tif (guidelinesSet.has(guideline)) {\n\t\t\treturn;\n\t\t}\n\t\tguidelinesSet.add(guideline);\n\t\tguidelinesList.push(guideline);\n\t};\n\n\tconst hasBash = tools.includes(\"bash\");\n\tconst hasGrep = tools.includes(\"grep\");\n\tconst hasFind = tools.includes(\"find\");\n\tconst hasLs = tools.includes(\"ls\");\n\tconst hasRead = tools.includes(\"read\");\n\n\t// File exploration guidelines\n\tif (hasBash && !hasGrep && !hasFind && !hasLs) {\n\t\taddGuideline(\"Use bash for file operations like ls, rg, find\");\n\t}\n\n\tfor (const guideline of promptGuidelines ?? []) {\n\t\tconst normalized = guideline.trim();\n\t\tif (normalized.length > 0) {\n\t\t\taddGuideline(normalized);\n\t\t}\n\t}\n\n\t// Always include these\n\taddGuideline(\"Be concise in your responses\");\n\taddGuideline(\"Show file paths clearly when working with files\");\n\n\tconst guidelines = guidelinesList.map((g) => `- ${g}`).join(\"\\n\");\n\n\tlet prompt = `You are an expert coding assistant operating inside pi, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.\n\nAvailable tools:\n${toolsList}\n\nIn addition to the tools above, you may have access to other custom tools depending on the project.${ADAPTATIVE_PERSONA_SECTION}\n\nGuidelines:\n${guidelines}\n\nPi documentation (read only when the user asks about pi itself, its SDK, extensions, themes, skills, or TUI):\n- Main documentation: ${readmePath}\n- Additional docs: ${docsPath}\n- Examples: ${examplesPath} (extensions, custom tools, SDK)\n- When reading pi docs or examples, resolve docs/... under Additional docs and examples/... under Examples, not the current working directory\n- When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), pi packages (docs/packages.md)\n- When working on pi topics, read the docs and examples, and follow .md cross-references before implementing\n- Always read pi .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`;\n\n\tif (appendSection) {\n\t\tprompt += appendSection;\n\t}\n\n\tprompt += formatContextFilesForPrompt(contextFiles);\n\n\t// Append skills section (only if read tool is available)\n\tif (hasRead && skills.length > 0) {\n\t\tprompt += formatSkillsForPrompt(skills);\n\t}\n\n\t// Add date and working directory last\n\tprompt += `\\nCurrent date: ${date}`;\n\tprompt += `\\nCurrent working directory: ${promptCwd}`;\n\n\treturn prompt;\n}\n"]}
1
+ {"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAyB,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAEhE,MAAM,WAAW,wBAAwB;IACxC,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oFAAoF;IACpF,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,0DAA0D;IAC1D,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,qFAAqF;IACrF,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,uCAAuC;IACvC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,yBAAyB;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,sDAAsD;IACtD,YAAY,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACzD,4EAA4E;IAC5E,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;CACjB;AA6CD,kEAAkE;AAClE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,MAAM,CAmI3E","sourcesContent":["/**\n * System prompt construction and project context loading\n */\n\nimport { getDocsPath, getExamplesPath, getReadmePath } from \"../config.ts\";\nimport { formatSkillsForPrompt, type Skill } from \"./skills.ts\";\n\nexport interface BuildSystemPromptOptions {\n\t/** Custom system prompt (replaces default). */\n\tcustomPrompt?: string;\n\t/** Tools to include in prompt. Default: [read, bash, edit, write, context_audit] */\n\tselectedTools?: string[];\n\t/** Optional one-line tool snippets keyed by tool name. */\n\ttoolSnippets?: Record<string, string>;\n\t/** Additional guideline bullets appended to the default system prompt guidelines. */\n\tpromptGuidelines?: string[];\n\t/** Text to append to system prompt. */\n\tappendSystemPrompt?: string;\n\t/** Working directory. */\n\tcwd: string;\n\t/** Eagerly loaded project/agent instruction files. */\n\tcontextFiles?: Array<{ path: string; content?: string }>;\n\t/** Discovered skills; startup prompt lists only lazy-loadable locations. */\n\tskills?: Skill[];\n}\n\nconst ADAPTATIVE_PERSONA_SECTION = `\n\nAdaptative Agent Persona:\n- Work as a self-improving engineering agent: clarify the mission, choose the smallest safe action, verify important claims, and preserve user trust.\n- Use a lightweight MAPE loop for adaptive work: monitor source/runtime evidence, analyze it against mission and memory, plan the smallest safe change, execute with scoped edits, then verify and feed back durable learning.\n- Treat harness evolution as a first-class task. Prefer auditable skills, prompts, extensions, and core changes over ad hoc behavior when a repeated workflow or failure mode is found.\n- Trigger self-evolution when evidence shows a repeated or user-corrected failure, a harness/tooling gap, a safety/privacy/context/performance/footprint risk, or a generic workflow improvement that will help future tasks; do not evolve durable behavior for one-off project facts or transient execution noise.\n- For self-evolution, inspect the current runtime/source before changing it, make focused changes, reload or renew only after source is auditable, and validate with concrete artifacts.\n- Choose the lowest durable layer that solves the problem: memory for stable facts/preferences, skills or prompts for reusable behavior, extensions/tools for repeatable automation, and core only for generic platform behavior that should ship for every user.\n- Keep generated operational state out of target repositories by default: caches, manifests, logs, snapshots, exports, and temporary artifacts belong in user-level/tool-owned storage unless explicitly intended as source/config/docs deliverables.\n- For file-backed extensions and tools, default to current-session or current-tenant state; shared/global files, locks, cleanup, stop, compact, prune, or list operations must be deliberate, documented, and safe for parallel sessions.\n- Do not bake user-specific provider names, local tools, or personal paths into generic harness behavior; describe capability-based roles in core and leave local bindings to user/project configuration.\n- For risky or harness-changing work, seek independent review when a reviewer tool or worker is available; otherwise run a fresh bounded judge pass with the same active provider/model route when possible. Treat reviewer/judge output as evidence, not authority, and verify findings locally before accepting them.\n- Before preserving or changing durable behavior, confront Automata/user memory and ask: why is it good for the user, is it unique or should it merge with existing memory/skills/agents, and will it make the agent better.\n- Maintain a clear contract between objective, evidence, and completion. Do not call work done until requirements are mapped to files, commands, or runtime observations.\n- Keep durable learning concise: store stable preferences, rules, fixes, and source pointers; do not preserve transient execution noise.`;\n\nfunction formatContextFilesForPrompt(contextFiles: Array<{ path: string; content?: string }>): string {\n\tif (contextFiles.length === 0) {\n\t\treturn \"\";\n\t}\n\n\tconst lines = [\"\\n\\n<project_context>\", \"\", \"Project-specific instructions and guidelines:\", \"\"];\n\n\tfor (const { path, content } of contextFiles) {\n\t\tlines.push(`<project_instructions path=\"${escapeXml(path)}\">`);\n\t\tlines.push(content ?? \"\");\n\t\tlines.push(\"</project_instructions>\", \"\");\n\t}\n\n\tlines.push(\"</project_context>\");\n\treturn lines.join(\"\\n\");\n}\n\nfunction escapeXml(str: string): string {\n\treturn str\n\t\t.replace(/&/g, \"&amp;\")\n\t\t.replace(/</g, \"&lt;\")\n\t\t.replace(/>/g, \"&gt;\")\n\t\t.replace(/\"/g, \"&quot;\")\n\t\t.replace(/'/g, \"&apos;\");\n}\n\n/** Build the system prompt with tools, guidelines, and context */\nexport function buildSystemPrompt(options: BuildSystemPromptOptions): string {\n\tconst {\n\t\tcustomPrompt,\n\t\tselectedTools,\n\t\ttoolSnippets,\n\t\tpromptGuidelines,\n\t\tappendSystemPrompt,\n\t\tcwd,\n\t\tcontextFiles: providedContextFiles,\n\t\tskills: providedSkills,\n\t} = options;\n\tconst resolvedCwd = cwd;\n\tconst promptCwd = resolvedCwd.replace(/\\\\/g, \"/\");\n\n\tconst now = new Date();\n\tconst year = now.getFullYear();\n\tconst month = String(now.getMonth() + 1).padStart(2, \"0\");\n\tconst day = String(now.getDate()).padStart(2, \"0\");\n\tconst date = `${year}-${month}-${day}`;\n\n\tconst appendSection = appendSystemPrompt ? `\\n\\n${appendSystemPrompt}` : \"\";\n\n\tconst contextFiles = providedContextFiles ?? [];\n\tconst skills = providedSkills ?? [];\n\n\tif (customPrompt) {\n\t\tlet prompt = customPrompt;\n\n\t\tprompt += ADAPTATIVE_PERSONA_SECTION;\n\n\t\tif (appendSection) {\n\t\t\tprompt += appendSection;\n\t\t}\n\n\t\tprompt += formatContextFilesForPrompt(contextFiles);\n\n\t\t// Append skills section (only if read tool is available)\n\t\tconst customPromptHasRead = !selectedTools || selectedTools.includes(\"read\");\n\t\tif (customPromptHasRead && skills.length > 0) {\n\t\t\tprompt += formatSkillsForPrompt(skills);\n\t\t}\n\n\t\t// Add date and working directory last\n\t\tprompt += `\\nCurrent date: ${date}`;\n\t\tprompt += `\\nCurrent working directory: ${promptCwd}`;\n\n\t\treturn prompt;\n\t}\n\n\t// Get absolute paths to documentation and examples\n\tconst readmePath = getReadmePath();\n\tconst docsPath = getDocsPath();\n\tconst examplesPath = getExamplesPath();\n\n\t// Build tools list based on selected tools.\n\t// A tool appears in Available tools only when the caller provides a one-line snippet.\n\tconst tools = selectedTools || [\"read\", \"bash\", \"edit\", \"write\"];\n\tconst visibleTools = tools.filter((name) => !!toolSnippets?.[name]);\n\tconst toolsList =\n\t\tvisibleTools.length > 0 ? visibleTools.map((name) => `- ${name}: ${toolSnippets![name]}`).join(\"\\n\") : \"(none)\";\n\n\t// Build guidelines based on which tools are actually available\n\tconst guidelinesList: string[] = [];\n\tconst guidelinesSet = new Set<string>();\n\tconst addGuideline = (guideline: string): void => {\n\t\tif (guidelinesSet.has(guideline)) {\n\t\t\treturn;\n\t\t}\n\t\tguidelinesSet.add(guideline);\n\t\tguidelinesList.push(guideline);\n\t};\n\n\tconst hasBash = tools.includes(\"bash\");\n\tconst hasGrep = tools.includes(\"grep\");\n\tconst hasFind = tools.includes(\"find\");\n\tconst hasLs = tools.includes(\"ls\");\n\tconst hasRead = tools.includes(\"read\");\n\n\t// File exploration guidelines\n\tif (hasBash && !hasGrep && !hasFind && !hasLs) {\n\t\taddGuideline(\"Use bash for file operations like ls, rg, find\");\n\t}\n\n\tfor (const guideline of promptGuidelines ?? []) {\n\t\tconst normalized = guideline.trim();\n\t\tif (normalized.length > 0) {\n\t\t\taddGuideline(normalized);\n\t\t}\n\t}\n\n\t// Always include these\n\taddGuideline(\"Be concise in your responses\");\n\taddGuideline(\"Show file paths clearly when working with files\");\n\n\tconst guidelines = guidelinesList.map((g) => `- ${g}`).join(\"\\n\");\n\n\tlet prompt = `You are an expert coding assistant operating inside pi, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.\n\nAvailable tools:\n${toolsList}\n\nIn addition to the tools above, you may have access to other custom tools depending on the project.${ADAPTATIVE_PERSONA_SECTION}\n\nGuidelines:\n${guidelines}\n\nPi documentation (read only when the user asks about pi itself, its SDK, extensions, themes, skills, or TUI):\n- Main documentation: ${readmePath}\n- Additional docs: ${docsPath}\n- Examples: ${examplesPath} (extensions, custom tools, SDK)\n- When reading pi docs or examples, resolve docs/... under Additional docs and examples/... under Examples, not the current working directory\n- When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), pi packages (docs/packages.md)\n- When working on pi topics, read the docs and examples, and follow .md cross-references before implementing\n- Always read pi .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`;\n\n\tif (appendSection) {\n\t\tprompt += appendSection;\n\t}\n\n\tprompt += formatContextFilesForPrompt(contextFiles);\n\n\t// Append skills section (only if read tool is available)\n\tif (hasRead && skills.length > 0) {\n\t\tprompt += formatSkillsForPrompt(skills);\n\t}\n\n\t// Add date and working directory last\n\tprompt += `\\nCurrent date: ${date}`;\n\tprompt += `\\nCurrent working directory: ${promptCwd}`;\n\n\treturn prompt;\n}\n"]}
@@ -9,8 +9,13 @@ Adaptative Agent Persona:
9
9
  - Work as a self-improving engineering agent: clarify the mission, choose the smallest safe action, verify important claims, and preserve user trust.
10
10
  - Use a lightweight MAPE loop for adaptive work: monitor source/runtime evidence, analyze it against mission and memory, plan the smallest safe change, execute with scoped edits, then verify and feed back durable learning.
11
11
  - Treat harness evolution as a first-class task. Prefer auditable skills, prompts, extensions, and core changes over ad hoc behavior when a repeated workflow or failure mode is found.
12
+ - Trigger self-evolution when evidence shows a repeated or user-corrected failure, a harness/tooling gap, a safety/privacy/context/performance/footprint risk, or a generic workflow improvement that will help future tasks; do not evolve durable behavior for one-off project facts or transient execution noise.
12
13
  - For self-evolution, inspect the current runtime/source before changing it, make focused changes, reload or renew only after source is auditable, and validate with concrete artifacts.
14
+ - Choose the lowest durable layer that solves the problem: memory for stable facts/preferences, skills or prompts for reusable behavior, extensions/tools for repeatable automation, and core only for generic platform behavior that should ship for every user.
15
+ - Keep generated operational state out of target repositories by default: caches, manifests, logs, snapshots, exports, and temporary artifacts belong in user-level/tool-owned storage unless explicitly intended as source/config/docs deliverables.
13
16
  - For file-backed extensions and tools, default to current-session or current-tenant state; shared/global files, locks, cleanup, stop, compact, prune, or list operations must be deliberate, documented, and safe for parallel sessions.
17
+ - Do not bake user-specific provider names, local tools, or personal paths into generic harness behavior; describe capability-based roles in core and leave local bindings to user/project configuration.
18
+ - For risky or harness-changing work, seek independent review when a reviewer tool or worker is available; otherwise run a fresh bounded judge pass with the same active provider/model route when possible. Treat reviewer/judge output as evidence, not authority, and verify findings locally before accepting them.
14
19
  - Before preserving or changing durable behavior, confront Automata/user memory and ask: why is it good for the user, is it unique or should it merge with existing memory/skills/agents, and will it make the agent better.
15
20
  - Maintain a clear contract between objective, evidence, and completion. Do not call work done until requirements are mapped to files, commands, or runtime observations.
16
21
  - Keep durable learning concise: store stable preferences, rules, fixes, and source pointers; do not preserve transient execution noise.`;
@@ -1 +1 @@
1
- {"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAc,MAAM,aAAa,CAAC;AAqBhE,MAAM,0BAA0B,GAAG;;;;;;;;;;yIAUsG,CAAC;AAE1I,SAAS,2BAA2B,CAAC,YAAuD,EAAU;IACrG,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC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C,CAAC;IAEvC,8BAA8B;IAC9B,IAAI,OAAO,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC;QAC/C,YAAY,CAAC,gDAAgD,CAAC,CAAC;IAChE,CAAC;IAED,KAAK,MAAM,SAAS,IAAI,gBAAgB,IAAI,EAAE,EAAE,CAAC;QAChD,MAAM,UAAU,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;QACpC,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,YAAY,CAAC,UAAU,CAAC,CAAC;QAC1B,CAAC;IACF,CAAC;IAED,uBAAuB;IACvB,YAAY,CAAC,8BAA8B,CAAC,CAAC;IAC7C,YAAY,CAAC,iDAAiD,CAAC,CAAC;IAEhE,MAAM,UAAU,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAElE,IAAI,MAAM,GAAG;;;EAGZ,SAAS;;qGAE0F,0BAA0B;;;EAG7H,UAAU;;;wBAGY,UAAU;qBACb,QAAQ;cACf,YAAY;;;;0GAIgF,CAAC;IAE1G,IAAI,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,aAAa,CAAC;IACzB,CAAC;IAED,MAAM,IAAI,2BAA2B,CAAC,YAAY,CAAC,CAAC;IAEpD,yDAAyD;IACzD,IAAI,OAAO,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,sCAAsC;IACtC,MAAM,IAAI,mBAAmB,IAAI,EAAE,CAAC;IACpC,MAAM,IAAI,gCAAgC,SAAS,EAAE,CAAC;IAEtD,OAAO,MAAM,CAAC;AAAA,CACd","sourcesContent":["/**\n * System prompt construction and project context loading\n */\n\nimport { getDocsPath, getExamplesPath, getReadmePath } from \"../config.ts\";\nimport { formatSkillsForPrompt, type Skill } from \"./skills.ts\";\n\nexport interface BuildSystemPromptOptions {\n\t/** Custom system prompt (replaces default). */\n\tcustomPrompt?: string;\n\t/** Tools to include in prompt. Default: [read, bash, edit, write, context_audit] */\n\tselectedTools?: string[];\n\t/** Optional one-line tool snippets keyed by tool name. */\n\ttoolSnippets?: Record<string, string>;\n\t/** Additional guideline bullets appended to the default system prompt guidelines. */\n\tpromptGuidelines?: string[];\n\t/** Text to append to system prompt. */\n\tappendSystemPrompt?: string;\n\t/** Working directory. */\n\tcwd: string;\n\t/** Eagerly loaded project/agent instruction files. */\n\tcontextFiles?: Array<{ path: string; content?: string }>;\n\t/** Discovered skills; startup prompt lists only lazy-loadable locations. */\n\tskills?: Skill[];\n}\n\nconst ADAPTATIVE_PERSONA_SECTION = `\n\nAdaptative Agent Persona:\n- Work as a self-improving engineering agent: clarify the mission, choose the smallest safe action, verify important claims, and preserve user trust.\n- Use a lightweight MAPE loop for adaptive work: monitor source/runtime evidence, analyze it against mission and memory, plan the smallest safe change, execute with scoped edits, then verify and feed back durable learning.\n- Treat harness evolution as a first-class task. Prefer auditable skills, prompts, extensions, and core changes over ad hoc behavior when a repeated workflow or failure mode is found.\n- For self-evolution, inspect the current runtime/source before changing it, make focused changes, reload or renew only after source is auditable, and validate with concrete artifacts.\n- For file-backed extensions and tools, default to current-session or current-tenant state; shared/global files, locks, cleanup, stop, compact, prune, or list operations must be deliberate, documented, and safe for parallel sessions.\n- Before preserving or changing durable behavior, confront Automata/user memory and ask: why is it good for the user, is it unique or should it merge with existing memory/skills/agents, and will it make the agent better.\n- Maintain a clear contract between objective, evidence, and completion. Do not call work done until requirements are mapped to files, commands, or runtime observations.\n- Keep durable learning concise: store stable preferences, rules, fixes, and source pointers; do not preserve transient execution noise.`;\n\nfunction formatContextFilesForPrompt(contextFiles: Array<{ path: string; content?: string }>): string {\n\tif (contextFiles.length === 0) {\n\t\treturn \"\";\n\t}\n\n\tconst lines = [\"\\n\\n<project_context>\", \"\", \"Project-specific instructions and guidelines:\", \"\"];\n\n\tfor (const { path, content } of contextFiles) {\n\t\tlines.push(`<project_instructions path=\"${escapeXml(path)}\">`);\n\t\tlines.push(content ?? \"\");\n\t\tlines.push(\"</project_instructions>\", \"\");\n\t}\n\n\tlines.push(\"</project_context>\");\n\treturn lines.join(\"\\n\");\n}\n\nfunction escapeXml(str: string): string {\n\treturn str\n\t\t.replace(/&/g, \"&amp;\")\n\t\t.replace(/</g, \"&lt;\")\n\t\t.replace(/>/g, \"&gt;\")\n\t\t.replace(/\"/g, \"&quot;\")\n\t\t.replace(/'/g, \"&apos;\");\n}\n\n/** Build the system prompt with tools, guidelines, and context */\nexport function buildSystemPrompt(options: BuildSystemPromptOptions): string {\n\tconst {\n\t\tcustomPrompt,\n\t\tselectedTools,\n\t\ttoolSnippets,\n\t\tpromptGuidelines,\n\t\tappendSystemPrompt,\n\t\tcwd,\n\t\tcontextFiles: providedContextFiles,\n\t\tskills: providedSkills,\n\t} = options;\n\tconst resolvedCwd = cwd;\n\tconst promptCwd = resolvedCwd.replace(/\\\\/g, \"/\");\n\n\tconst now = new Date();\n\tconst year = now.getFullYear();\n\tconst month = String(now.getMonth() + 1).padStart(2, \"0\");\n\tconst day = String(now.getDate()).padStart(2, \"0\");\n\tconst date = `${year}-${month}-${day}`;\n\n\tconst appendSection = appendSystemPrompt ? `\\n\\n${appendSystemPrompt}` : \"\";\n\n\tconst contextFiles = providedContextFiles ?? [];\n\tconst skills = providedSkills ?? [];\n\n\tif (customPrompt) {\n\t\tlet prompt = customPrompt;\n\n\t\tprompt += ADAPTATIVE_PERSONA_SECTION;\n\n\t\tif (appendSection) {\n\t\t\tprompt += appendSection;\n\t\t}\n\n\t\tprompt += formatContextFilesForPrompt(contextFiles);\n\n\t\t// Append skills section (only if read tool is available)\n\t\tconst customPromptHasRead = !selectedTools || selectedTools.includes(\"read\");\n\t\tif (customPromptHasRead && skills.length > 0) {\n\t\t\tprompt += formatSkillsForPrompt(skills);\n\t\t}\n\n\t\t// Add date and working directory last\n\t\tprompt += `\\nCurrent date: ${date}`;\n\t\tprompt += `\\nCurrent working directory: ${promptCwd}`;\n\n\t\treturn prompt;\n\t}\n\n\t// Get absolute paths to documentation and examples\n\tconst readmePath = getReadmePath();\n\tconst docsPath = getDocsPath();\n\tconst examplesPath = getExamplesPath();\n\n\t// Build tools list based on selected tools.\n\t// A tool appears in Available tools only when the caller provides a one-line snippet.\n\tconst tools = selectedTools || [\"read\", \"bash\", \"edit\", \"write\"];\n\tconst visibleTools = tools.filter((name) => !!toolSnippets?.[name]);\n\tconst toolsList =\n\t\tvisibleTools.length > 0 ? visibleTools.map((name) => `- ${name}: ${toolSnippets![name]}`).join(\"\\n\") : \"(none)\";\n\n\t// Build guidelines based on which tools are actually available\n\tconst guidelinesList: string[] = [];\n\tconst guidelinesSet = new Set<string>();\n\tconst addGuideline = (guideline: string): void => {\n\t\tif (guidelinesSet.has(guideline)) {\n\t\t\treturn;\n\t\t}\n\t\tguidelinesSet.add(guideline);\n\t\tguidelinesList.push(guideline);\n\t};\n\n\tconst hasBash = tools.includes(\"bash\");\n\tconst hasGrep = tools.includes(\"grep\");\n\tconst hasFind = tools.includes(\"find\");\n\tconst hasLs = tools.includes(\"ls\");\n\tconst hasRead = tools.includes(\"read\");\n\n\t// File exploration guidelines\n\tif (hasBash && !hasGrep && !hasFind && !hasLs) {\n\t\taddGuideline(\"Use bash for file operations like ls, rg, find\");\n\t}\n\n\tfor (const guideline of promptGuidelines ?? []) {\n\t\tconst normalized = guideline.trim();\n\t\tif (normalized.length > 0) {\n\t\t\taddGuideline(normalized);\n\t\t}\n\t}\n\n\t// Always include these\n\taddGuideline(\"Be concise in your responses\");\n\taddGuideline(\"Show file paths clearly when working with files\");\n\n\tconst guidelines = guidelinesList.map((g) => `- ${g}`).join(\"\\n\");\n\n\tlet prompt = `You are an expert coding assistant operating inside pi, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.\n\nAvailable tools:\n${toolsList}\n\nIn addition to the tools above, you may have access to other custom tools depending on the project.${ADAPTATIVE_PERSONA_SECTION}\n\nGuidelines:\n${guidelines}\n\nPi documentation (read only when the user asks about pi itself, its SDK, extensions, themes, skills, or TUI):\n- Main documentation: ${readmePath}\n- Additional docs: ${docsPath}\n- Examples: ${examplesPath} (extensions, custom tools, SDK)\n- When reading pi docs or examples, resolve docs/... under Additional docs and examples/... under Examples, not the current working directory\n- When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), pi packages (docs/packages.md)\n- When working on pi topics, read the docs and examples, and follow .md cross-references before implementing\n- Always read pi .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`;\n\n\tif (appendSection) {\n\t\tprompt += appendSection;\n\t}\n\n\tprompt += formatContextFilesForPrompt(contextFiles);\n\n\t// Append skills section (only if read tool is available)\n\tif (hasRead && skills.length > 0) {\n\t\tprompt += formatSkillsForPrompt(skills);\n\t}\n\n\t// Add date and working directory last\n\tprompt += `\\nCurrent date: ${date}`;\n\tprompt += `\\nCurrent working directory: ${promptCwd}`;\n\n\treturn prompt;\n}\n"]}
1
+ {"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAc,MAAM,aAAa,CAAC;AAqBhE,MAAM,0BAA0B,GAAG;;;;;;;;;;;;;;;yIAesG,CAAC;AAE1I,SAAS,2BAA2B,CAAC,YAAuD,EAAU;IACrG,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,EAAE,CAAC;IACX,CAAC;IAED,MAAM,KAAK,GAAG,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OAAO,IAAI,CAAC,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC;QAC/C,YAAY,CAAC,gDAAgD,CAAC,CAAC;IAChE,CAAC;IAED,KAAK,MAAM,SAAS,IAAI,gBAAgB,IAAI,EAAE,EAAE,CAAC;QAChD,MAAM,UAAU,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;QACpC,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,YAAY,CAAC,UAAU,CAAC,CAAC;QAC1B,CAAC;IACF,CAAC;IAED,uBAAuB;IACvB,YAAY,CAAC,8BAA8B,CAAC,CAAC;IAC7C,YAAY,CAAC,iDAAiD,CAAC,CAAC;IAEhE,MAAM,UAAU,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAElE,IAAI,MAAM,GAAG;;;EAGZ,SAAS;;qGAE0F,0BAA0B;;;EAG7H,UAAU;;;wBAGY,UAAU;qBACb,QAAQ;cACf,YAAY;;;;0GAIgF,CAAC;IAE1G,IAAI,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,aAAa,CAAC;IACzB,CAAC;IAED,MAAM,IAAI,2BAA2B,CAAC,YAAY,CAAC,CAAC;IAEpD,yDAAyD;IACzD,IAAI,OAAO,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,sCAAsC;IACtC,MAAM,IAAI,mBAAmB,IAAI,EAAE,CAAC;IACpC,MAAM,IAAI,gCAAgC,SAAS,EAAE,CAAC;IAEtD,OAAO,MAAM,CAAC;AAAA,CACd","sourcesContent":["/**\n * System prompt construction and project context loading\n */\n\nimport { getDocsPath, getExamplesPath, getReadmePath } from \"../config.ts\";\nimport { formatSkillsForPrompt, type Skill } from \"./skills.ts\";\n\nexport interface BuildSystemPromptOptions {\n\t/** Custom system prompt (replaces default). */\n\tcustomPrompt?: string;\n\t/** Tools to include in prompt. Default: [read, bash, edit, write, context_audit] */\n\tselectedTools?: string[];\n\t/** Optional one-line tool snippets keyed by tool name. */\n\ttoolSnippets?: Record<string, string>;\n\t/** Additional guideline bullets appended to the default system prompt guidelines. */\n\tpromptGuidelines?: string[];\n\t/** Text to append to system prompt. */\n\tappendSystemPrompt?: string;\n\t/** Working directory. */\n\tcwd: string;\n\t/** Eagerly loaded project/agent instruction files. */\n\tcontextFiles?: Array<{ path: string; content?: string }>;\n\t/** Discovered skills; startup prompt lists only lazy-loadable locations. */\n\tskills?: Skill[];\n}\n\nconst ADAPTATIVE_PERSONA_SECTION = `\n\nAdaptative Agent Persona:\n- Work as a self-improving engineering agent: clarify the mission, choose the smallest safe action, verify important claims, and preserve user trust.\n- Use a lightweight MAPE loop for adaptive work: monitor source/runtime evidence, analyze it against mission and memory, plan the smallest safe change, execute with scoped edits, then verify and feed back durable learning.\n- Treat harness evolution as a first-class task. Prefer auditable skills, prompts, extensions, and core changes over ad hoc behavior when a repeated workflow or failure mode is found.\n- Trigger self-evolution when evidence shows a repeated or user-corrected failure, a harness/tooling gap, a safety/privacy/context/performance/footprint risk, or a generic workflow improvement that will help future tasks; do not evolve durable behavior for one-off project facts or transient execution noise.\n- For self-evolution, inspect the current runtime/source before changing it, make focused changes, reload or renew only after source is auditable, and validate with concrete artifacts.\n- Choose the lowest durable layer that solves the problem: memory for stable facts/preferences, skills or prompts for reusable behavior, extensions/tools for repeatable automation, and core only for generic platform behavior that should ship for every user.\n- Keep generated operational state out of target repositories by default: caches, manifests, logs, snapshots, exports, and temporary artifacts belong in user-level/tool-owned storage unless explicitly intended as source/config/docs deliverables.\n- For file-backed extensions and tools, default to current-session or current-tenant state; shared/global files, locks, cleanup, stop, compact, prune, or list operations must be deliberate, documented, and safe for parallel sessions.\n- Do not bake user-specific provider names, local tools, or personal paths into generic harness behavior; describe capability-based roles in core and leave local bindings to user/project configuration.\n- For risky or harness-changing work, seek independent review when a reviewer tool or worker is available; otherwise run a fresh bounded judge pass with the same active provider/model route when possible. Treat reviewer/judge output as evidence, not authority, and verify findings locally before accepting them.\n- Before preserving or changing durable behavior, confront Automata/user memory and ask: why is it good for the user, is it unique or should it merge with existing memory/skills/agents, and will it make the agent better.\n- Maintain a clear contract between objective, evidence, and completion. Do not call work done until requirements are mapped to files, commands, or runtime observations.\n- Keep durable learning concise: store stable preferences, rules, fixes, and source pointers; do not preserve transient execution noise.`;\n\nfunction formatContextFilesForPrompt(contextFiles: Array<{ path: string; content?: string }>): string {\n\tif (contextFiles.length === 0) {\n\t\treturn \"\";\n\t}\n\n\tconst lines = [\"\\n\\n<project_context>\", \"\", \"Project-specific instructions and guidelines:\", \"\"];\n\n\tfor (const { path, content } of contextFiles) {\n\t\tlines.push(`<project_instructions path=\"${escapeXml(path)}\">`);\n\t\tlines.push(content ?? \"\");\n\t\tlines.push(\"</project_instructions>\", \"\");\n\t}\n\n\tlines.push(\"</project_context>\");\n\treturn lines.join(\"\\n\");\n}\n\nfunction escapeXml(str: string): string {\n\treturn str\n\t\t.replace(/&/g, \"&amp;\")\n\t\t.replace(/</g, \"&lt;\")\n\t\t.replace(/>/g, \"&gt;\")\n\t\t.replace(/\"/g, \"&quot;\")\n\t\t.replace(/'/g, \"&apos;\");\n}\n\n/** Build the system prompt with tools, guidelines, and context */\nexport function buildSystemPrompt(options: BuildSystemPromptOptions): string {\n\tconst {\n\t\tcustomPrompt,\n\t\tselectedTools,\n\t\ttoolSnippets,\n\t\tpromptGuidelines,\n\t\tappendSystemPrompt,\n\t\tcwd,\n\t\tcontextFiles: providedContextFiles,\n\t\tskills: providedSkills,\n\t} = options;\n\tconst resolvedCwd = cwd;\n\tconst promptCwd = resolvedCwd.replace(/\\\\/g, \"/\");\n\n\tconst now = new Date();\n\tconst year = now.getFullYear();\n\tconst month = String(now.getMonth() + 1).padStart(2, \"0\");\n\tconst day = String(now.getDate()).padStart(2, \"0\");\n\tconst date = `${year}-${month}-${day}`;\n\n\tconst appendSection = appendSystemPrompt ? `\\n\\n${appendSystemPrompt}` : \"\";\n\n\tconst contextFiles = providedContextFiles ?? [];\n\tconst skills = providedSkills ?? [];\n\n\tif (customPrompt) {\n\t\tlet prompt = customPrompt;\n\n\t\tprompt += ADAPTATIVE_PERSONA_SECTION;\n\n\t\tif (appendSection) {\n\t\t\tprompt += appendSection;\n\t\t}\n\n\t\tprompt += formatContextFilesForPrompt(contextFiles);\n\n\t\t// Append skills section (only if read tool is available)\n\t\tconst customPromptHasRead = !selectedTools || selectedTools.includes(\"read\");\n\t\tif (customPromptHasRead && skills.length > 0) {\n\t\t\tprompt += formatSkillsForPrompt(skills);\n\t\t}\n\n\t\t// Add date and working directory last\n\t\tprompt += `\\nCurrent date: ${date}`;\n\t\tprompt += `\\nCurrent working directory: ${promptCwd}`;\n\n\t\treturn prompt;\n\t}\n\n\t// Get absolute paths to documentation and examples\n\tconst readmePath = getReadmePath();\n\tconst docsPath = getDocsPath();\n\tconst examplesPath = getExamplesPath();\n\n\t// Build tools list based on selected tools.\n\t// A tool appears in Available tools only when the caller provides a one-line snippet.\n\tconst tools = selectedTools || [\"read\", \"bash\", \"edit\", \"write\"];\n\tconst visibleTools = tools.filter((name) => !!toolSnippets?.[name]);\n\tconst toolsList =\n\t\tvisibleTools.length > 0 ? visibleTools.map((name) => `- ${name}: ${toolSnippets![name]}`).join(\"\\n\") : \"(none)\";\n\n\t// Build guidelines based on which tools are actually available\n\tconst guidelinesList: string[] = [];\n\tconst guidelinesSet = new Set<string>();\n\tconst addGuideline = (guideline: string): void => {\n\t\tif (guidelinesSet.has(guideline)) {\n\t\t\treturn;\n\t\t}\n\t\tguidelinesSet.add(guideline);\n\t\tguidelinesList.push(guideline);\n\t};\n\n\tconst hasBash = tools.includes(\"bash\");\n\tconst hasGrep = tools.includes(\"grep\");\n\tconst hasFind = tools.includes(\"find\");\n\tconst hasLs = tools.includes(\"ls\");\n\tconst hasRead = tools.includes(\"read\");\n\n\t// File exploration guidelines\n\tif (hasBash && !hasGrep && !hasFind && !hasLs) {\n\t\taddGuideline(\"Use bash for file operations like ls, rg, find\");\n\t}\n\n\tfor (const guideline of promptGuidelines ?? []) {\n\t\tconst normalized = guideline.trim();\n\t\tif (normalized.length > 0) {\n\t\t\taddGuideline(normalized);\n\t\t}\n\t}\n\n\t// Always include these\n\taddGuideline(\"Be concise in your responses\");\n\taddGuideline(\"Show file paths clearly when working with files\");\n\n\tconst guidelines = guidelinesList.map((g) => `- ${g}`).join(\"\\n\");\n\n\tlet prompt = `You are an expert coding assistant operating inside pi, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.\n\nAvailable tools:\n${toolsList}\n\nIn addition to the tools above, you may have access to other custom tools depending on the project.${ADAPTATIVE_PERSONA_SECTION}\n\nGuidelines:\n${guidelines}\n\nPi documentation (read only when the user asks about pi itself, its SDK, extensions, themes, skills, or TUI):\n- Main documentation: ${readmePath}\n- Additional docs: ${docsPath}\n- Examples: ${examplesPath} (extensions, custom tools, SDK)\n- When reading pi docs or examples, resolve docs/... under Additional docs and examples/... under Examples, not the current working directory\n- When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), pi packages (docs/packages.md)\n- When working on pi topics, read the docs and examples, and follow .md cross-references before implementing\n- Always read pi .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`;\n\n\tif (appendSection) {\n\t\tprompt += appendSection;\n\t}\n\n\tprompt += formatContextFilesForPrompt(contextFiles);\n\n\t// Append skills section (only if read tool is available)\n\tif (hasRead && skills.length > 0) {\n\t\tprompt += formatSkillsForPrompt(skills);\n\t}\n\n\t// Add date and working directory last\n\tprompt += `\\nCurrent date: ${date}`;\n\tprompt += `\\nCurrent working directory: ${promptCwd}`;\n\n\treturn prompt;\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export { createEventBus, type EventBus, type EventBusController } from "./core/e
7
7
  export type { AgentEndEvent, AgentStartEvent, AgentToolResult, AgentToolUpdateCallback, AppKeybinding, AutocompleteProviderFactory, BashToolCallEvent, BeforeAgentStartEvent, BeforeAgentStartEventResult, BeforeProviderRequestEvent, BeforeProviderRequestEventResult, BuildSystemPromptOptions, CompactOptions, ContextEvent, ContextUsage, CustomToolCallEvent, EditToolCallEvent, ExecOptions, ExecResult, Extension, ExtensionActions, ExtensionAPI, ExtensionCommandContext, ExtensionCommandContextActions, ExtensionContext, ExtensionContextActions, ExtensionError, ExtensionEvent, ExtensionFactory, ExtensionFlag, ExtensionHandler, ExtensionRuntime, ExtensionShortcut, ExtensionUIContext, ExtensionUIDialogOptions, ExtensionWidgetOptions, FindToolCallEvent, GrepToolCallEvent, InputEvent, InputEventResult, InputSource, KeybindingsManager, LoadExtensionsResult, LsToolCallEvent, MessageRenderer, MessageRenderOptions, ProviderConfig, ProviderModelConfig, ReadToolCallEvent, RegisteredCommand, RegisteredTool, ResolvedCommand, SessionBeforeCompactEvent, SessionBeforeForkEvent, SessionBeforeSwitchEvent, SessionBeforeTreeEvent, SessionCompactEvent, SessionShutdownEvent, SessionStartEvent, SessionTreeEvent, SlashCommandInfo, SlashCommandSource, SourceInfo, TerminalInputHandler, ToolCallEvent, ToolCallEventResult, ToolDefinition, ToolExecutionMode, ToolInfo, ToolRenderResultOptions, ToolResultEvent, TurnEndEvent, TurnStartEvent, UserBashEvent, UserBashEventResult, WidgetPlacement, WorkingIndicatorOptions, WriteToolCallEvent, } from "./core/extensions/index.ts";
8
8
  export { createExtensionRuntime, defineTool, discoverAndLoadExtensions, ExtensionRunner, isBashToolResult, isEditToolResult, isFindToolResult, isGrepToolResult, isLsToolResult, isReadToolResult, isToolCallEventType, isWriteToolResult, wrapRegisteredTool, wrapRegisteredTools, } from "./core/extensions/index.ts";
9
9
  export type { ReadonlyFooterDataProvider } from "./core/footer-data-provider.ts";
10
+ export { appendRunRecord, type ConfidenceMode, type ConfidenceResult, cleanupImprovementSandbox, compareMetric, computeMadConfidence, createImprovementDecisionTool, createImprovementLoopTool, createImprovementSandbox, decideImprovement, exportImprovementSandboxPatch, type GitStatusEntry, type ImprovementDecision, type ImprovementDecisionInput, type ImprovementDecisionReason, type ImprovementDecisionResult, type ImprovementLoopConfig, type ImprovementLoopExec, type ImprovementLoopInitInput, type ImprovementLoopPaths, type ImprovementLoopRecordInput, type ImprovementLoopState, type ImprovementLoopStatusInput, type ImprovementLoopToolAction, type ImprovementLoopToolDetails, type ImprovementMeasurementCommandResult, type ImprovementMeasurementResult, type ImprovementRunRecord, type ImprovementSandboxCleanupInput, type ImprovementSandboxCreateInput, type ImprovementSandboxExportInput, type ImprovementSandboxRecord, improvementLoopPaths, initImprovementLoop, type LowConfidenceAction, type MetricComparison, type MetricDirection, median, medianAbsoluteDeviation, metricMapFromOutput, type OwnedDiscardPlan, type OwnedDiscardPlanInput, parseGitPorcelainStatus, parseMetricLines, planOwnedDiscard, readImprovementLoopState, readRunRecords, recordImprovementRun, runImprovementMeasurement, selectPrimaryMetric, serializeRunRecord, } from "./core/improvement-loop.ts";
10
11
  export { convertToLlm } from "./core/messages.ts";
11
12
  export { ModelRegistry } from "./core/model-registry.ts";
12
13
  export type { PackageManager, PathMetadata, ProgressCallback, ProgressEvent, ResolvedPaths, ResolvedResource, } from "./core/package-manager.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,IAAI,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGrD,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EACN,YAAY,EACZ,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,EACr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M,oCAAoC,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,KAAK,YAAY,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE9F,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["// Core session management\n\nexport { type Args, parseArgs } from \"./cli/args.ts\";\n\n// Config paths\nexport { getAgentDir, VERSION } from \"./config.ts\";\nexport {\n\tAgentSession,\n\ttype AgentSessionConfig,\n\ttype AgentSessionEvent,\n\ttype AgentSessionEventListener,\n\ttype ModelCycleResult,\n\ttype ParsedSkillBlock,\n\ttype PromptOptions,\n\tparseSkillBlock,\n\ttype SessionStats,\n} from \"./core/agent-session.ts\";\n// Auth and model registry\nexport {\n\ttype ApiKeyCredential,\n\ttype AuthCredential,\n\ttype AuthStatus,\n\tAuthStorage,\n\ttype AuthStorageBackend,\n\tFileAuthStorageBackend,\n\tInMemoryAuthStorageBackend,\n\ttype OAuthCredential,\n} from \"./core/auth-storage.ts\";\n// Compaction\nexport {\n\ttype BranchPreparation,\n\ttype BranchSummaryResult,\n\ttype CollectEntriesResult,\n\ttype CompactionResult,\n\ttype CutPointResult,\n\tcalculateContextTokens,\n\tcollectEntriesForBranchSummary,\n\tcompact,\n\tDEFAULT_COMPACTION_SETTINGS,\n\testimateTokens,\n\ttype FileOperations,\n\tfindCutPoint,\n\tfindTurnStartIndex,\n\ttype GenerateBranchSummaryOptions,\n\tgenerateBranchSummary,\n\tgenerateSummary,\n\tgetLastAssistantUsage,\n\tprepareBranchEntries,\n\tserializeConversation,\n\tshouldCompact,\n} from \"./core/compaction/index.ts\";\nexport { createEventBus, type EventBus, type EventBusController } from \"./core/event-bus.ts\";\n// Extension system\nexport type {\n\tAgentEndEvent,\n\tAgentStartEvent,\n\tAgentToolResult,\n\tAgentToolUpdateCallback,\n\tAppKeybinding,\n\tAutocompleteProviderFactory,\n\tBashToolCallEvent,\n\tBeforeAgentStartEvent,\n\tBeforeAgentStartEventResult,\n\tBeforeProviderRequestEvent,\n\tBeforeProviderRequestEventResult,\n\tBuildSystemPromptOptions,\n\tCompactOptions,\n\tContextEvent,\n\tContextUsage,\n\tCustomToolCallEvent,\n\tEditToolCallEvent,\n\tExecOptions,\n\tExecResult,\n\tExtension,\n\tExtensionActions,\n\tExtensionAPI,\n\tExtensionCommandContext,\n\tExtensionCommandContextActions,\n\tExtensionContext,\n\tExtensionContextActions,\n\tExtensionError,\n\tExtensionEvent,\n\tExtensionFactory,\n\tExtensionFlag,\n\tExtensionHandler,\n\tExtensionRuntime,\n\tExtensionShortcut,\n\tExtensionUIContext,\n\tExtensionUIDialogOptions,\n\tExtensionWidgetOptions,\n\tFindToolCallEvent,\n\tGrepToolCallEvent,\n\tInputEvent,\n\tInputEventResult,\n\tInputSource,\n\tKeybindingsManager,\n\tLoadExtensionsResult,\n\tLsToolCallEvent,\n\tMessageRenderer,\n\tMessageRenderOptions,\n\tProviderConfig,\n\tProviderModelConfig,\n\tReadToolCallEvent,\n\tRegisteredCommand,\n\tRegisteredTool,\n\tResolvedCommand,\n\tSessionBeforeCompactEvent,\n\tSessionBeforeForkEvent,\n\tSessionBeforeSwitchEvent,\n\tSessionBeforeTreeEvent,\n\tSessionCompactEvent,\n\tSessionShutdownEvent,\n\tSessionStartEvent,\n\tSessionTreeEvent,\n\tSlashCommandInfo,\n\tSlashCommandSource,\n\tSourceInfo,\n\tTerminalInputHandler,\n\tToolCallEvent,\n\tToolCallEventResult,\n\tToolDefinition,\n\tToolExecutionMode,\n\tToolInfo,\n\tToolRenderResultOptions,\n\tToolResultEvent,\n\tTurnEndEvent,\n\tTurnStartEvent,\n\tUserBashEvent,\n\tUserBashEventResult,\n\tWidgetPlacement,\n\tWorkingIndicatorOptions,\n\tWriteToolCallEvent,\n} from \"./core/extensions/index.ts\";\nexport {\n\tcreateExtensionRuntime,\n\tdefineTool,\n\tdiscoverAndLoadExtensions,\n\tExtensionRunner,\n\tisBashToolResult,\n\tisEditToolResult,\n\tisFindToolResult,\n\tisGrepToolResult,\n\tisLsToolResult,\n\tisReadToolResult,\n\tisToolCallEventType,\n\tisWriteToolResult,\n\twrapRegisteredTool,\n\twrapRegisteredTools,\n} from \"./core/extensions/index.ts\";\n// Footer data provider (git branch + extension statuses - data not otherwise available to extensions)\nexport type { ReadonlyFooterDataProvider } from \"./core/footer-data-provider.ts\";\nexport { convertToLlm } from \"./core/messages.ts\";\nexport { ModelRegistry } from \"./core/model-registry.ts\";\nexport type {\n\tPackageManager,\n\tPathMetadata,\n\tProgressCallback,\n\tProgressEvent,\n\tResolvedPaths,\n\tResolvedResource,\n} from \"./core/package-manager.ts\";\nexport { DefaultPackageManager } from \"./core/package-manager.ts\";\nexport {\n\tACTIVE_TURN_TTL_MS,\n\tAUTO_RELOAD_COORDINATOR_TTL_MS,\n\tdescribeReloadSession,\n\tgetPendingReloadBlockers,\n\tisReloadSessionProcessAlive,\n\ttype PendingReloadBlockers,\n\ttype ReloadBlockerOptions,\n\ttype ReloadSessionRecord,\n} from \"./core/reload-blockers.ts\";\nexport type { ResourceCollision, ResourceDiagnostic, ResourceLoader } from \"./core/resource-loader.ts\";\nexport { DefaultResourceLoader, loadProjectContextFiles } from \"./core/resource-loader.ts\";\nexport {\n\tmergeResourceProfileMap,\n\tmergeResourceProfileSettings,\n\tparseResourceProfileBlocks,\n\tparseResourceProfileInput,\n\tparseResourceProfileJson,\n\tstripResourceProfileBlocks,\n} from \"./core/resource-profile-blocks.ts\";\n// SDK for programmatic usage\nexport {\n\tAgentSessionRuntime,\n\ttype AgentSessionRuntimeDiagnostic,\n\ttype AgentSessionServices,\n\ttype CreateAgentSessionFromServicesOptions,\n\ttype CreateAgentSessionOptions,\n\ttype CreateAgentSessionResult,\n\ttype CreateAgentSessionRuntimeFactory,\n\ttype CreateAgentSessionRuntimeResult,\n\ttype CreateAgentSessionServicesOptions,\n\t// Factory\n\tcreateAgentSession,\n\tcreateAgentSessionFromServices,\n\tcreateAgentSessionRuntime,\n\tcreateAgentSessionServices,\n\tcreateBashTool,\n\t// Tool factories (for custom cwd)\n\tcreateCodingTools,\n\tcreateEditTool,\n\tcreateFindTool,\n\tcreateGrepTool,\n\tcreateLsTool,\n\tcreateReadOnlyTools,\n\tcreateReadTool,\n\tcreateWriteTool,\n\ttype PromptTemplate,\n} from \"./core/sdk.ts\";\nexport {\n\ttype BranchSummaryEntry,\n\tbuildSessionContext,\n\ttype CompactionEntry,\n\tCURRENT_SESSION_VERSION,\n\ttype CustomEntry,\n\ttype CustomMessageEntry,\n\ttype FileEntry,\n\tgetLatestCompactionEntry,\n\ttype ModelChangeEntry,\n\tmigrateSessionEntries,\n\ttype NewSessionOptions,\n\tparseSessionEntries,\n\ttype SessionContext,\n\ttype SessionEntry,\n\ttype SessionEntryBase,\n\ttype SessionHeader,\n\ttype SessionInfo,\n\ttype SessionInfoEntry,\n\tSessionManager,\n\ttype SessionMessageEntry,\n\ttype ThinkingLevelChangeEntry,\n} from \"./core/session-manager.ts\";\nexport {\n\ttype CompactionSettings,\n\ttype DirectoryResourceProfileInfo,\n\tgetDirectoryResourceProfileInfo,\n\ttype ImageSettings,\n\tmatchesResourceProfilePattern,\n\ttype PackageSource,\n\ttype ResourceProfileFilterSettings,\n\ttype ResourceProfileKind,\n\ttype ResourceProfileSettings,\n\ttype RetrySettings,\n\tSettingsManager,\n\ttype SettingsManagerCreateOptions,\n} from \"./core/settings-manager.ts\";\n// Skills\nexport {\n\tformatSkillsForPrompt,\n\ttype LoadSkillsFromDirOptions,\n\ttype LoadSkillsResult,\n\tloadSkills,\n\tloadSkillsFromDir,\n\ttype Skill,\n\ttype SkillFrontmatter,\n} from \"./core/skills.ts\";\nexport { createSyntheticSourceInfo } from \"./core/source-info.ts\";\n// Tools\nexport {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashToolDefinition,\n\tcreateEditToolDefinition,\n\tcreateFindToolDefinition,\n\tcreateGrepToolDefinition,\n\tcreateLocalBashOperations,\n\tcreateLsToolDefinition,\n\tcreateReadToolDefinition,\n\tcreateWriteToolDefinition,\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n\tformatSize,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n\ttype ToolsOptions,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n\twithFileMutationQueue,\n} from \"./core/tools/index.ts\";\nexport { hasProjectTrustInputs, type ProjectTrustDecision, ProjectTrustStore } from \"./core/trust-manager.ts\";\n// Main entry point\nexport { type MainOptions, main } from \"./main.ts\";\n// Run modes for programmatic SDK usage\nexport {\n\tInteractiveMode,\n\ttype InteractiveModeOptions,\n\ttype ModelInfo,\n\ttype PrintModeOptions,\n\tRpcClient,\n\ttype RpcClientOptions,\n\ttype RpcCommand,\n\ttype RpcEventListener,\n\ttype RpcResponse,\n\ttype RpcSessionState,\n\trunPrintMode,\n\trunRpcMode,\n} from \"./modes/index.ts\";\n// UI components for extensions\nexport {\n\tArminComponent,\n\tAssistantMessageComponent,\n\tBashExecutionComponent,\n\tBorderedLoader,\n\tBranchSummaryMessageComponent,\n\tCompactionSummaryMessageComponent,\n\tCustomEditor,\n\tCustomMessageComponent,\n\tDynamicBorder,\n\tExtensionEditorComponent,\n\tExtensionInputComponent,\n\tExtensionSelectorComponent,\n\tFooterComponent,\n\tkeyHint,\n\tkeyText,\n\tLoginDialogComponent,\n\tModelSelectorComponent,\n\tOAuthSelectorComponent,\n\ttype RenderDiffOptions,\n\trawKeyHint,\n\trenderDiff,\n\trenderTitleBadge,\n\trenderToolTitle,\n\tSessionSelectorComponent,\n\ttype SettingsCallbacks,\n\ttype SettingsConfig,\n\tSettingsSelectorComponent,\n\tShowImagesSelectorComponent,\n\tSkillInvocationMessageComponent,\n\tThemeSelectorComponent,\n\tThinkingSelectorComponent,\n\tTitleBadgeComponent,\n\ttype TitleBadgeOptions,\n\ttype TitleBadgeSegment,\n\ttype TitleBadgeStatus,\n\tToolExecutionComponent,\n\ttype ToolExecutionOptions,\n\tToolTitleComponent,\n\ttype ToolTitleOptions,\n\ttype ToolTitleSegment,\n\ttype ToolTitleStatus,\n\tTreeSelectorComponent,\n\ttitleBadge,\n\ttoolTitle,\n\ttruncateToVisualLines,\n\tUserMessageComponent,\n\tUserMessageSelectorComponent,\n\ttype VisualTruncateResult,\n} from \"./modes/interactive/components/index.ts\";\n// Theme utilities for custom tools and extensions\nexport {\n\tgetLanguageFromPath,\n\tgetMarkdownTheme,\n\tgetSelectListTheme,\n\tgetSettingsListTheme,\n\thighlightCode,\n\tinitTheme,\n\tTheme,\n\ttype ThemeColor,\n} from \"./modes/interactive/theme/theme.ts\";\n// Clipboard utilities\nexport { copyToClipboard } from \"./utils/clipboard.ts\";\nexport { parseFrontmatter, stripFrontmatter } from \"./utils/frontmatter.ts\";\nexport { convertToPng } from \"./utils/image-convert.ts\";\nexport { formatDimensionNote, type ResizedImage, resizeImage } from \"./utils/image-resize.ts\";\n// Shell utilities\nexport { getShellConfig } from \"./utils/shell.ts\";\n"]}
1
+ {"version":3,"file":"index.d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C;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,KAAK,YAAY,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE9F,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["// Core session management\n\nexport { type Args, parseArgs } from \"./cli/args.ts\";\n\n// Config paths\nexport { getAgentDir, VERSION } from \"./config.ts\";\nexport {\n\tAgentSession,\n\ttype AgentSessionConfig,\n\ttype AgentSessionEvent,\n\ttype AgentSessionEventListener,\n\ttype ModelCycleResult,\n\ttype ParsedSkillBlock,\n\ttype PromptOptions,\n\tparseSkillBlock,\n\ttype SessionStats,\n} from \"./core/agent-session.ts\";\n// Auth and model registry\nexport {\n\ttype ApiKeyCredential,\n\ttype AuthCredential,\n\ttype AuthStatus,\n\tAuthStorage,\n\ttype AuthStorageBackend,\n\tFileAuthStorageBackend,\n\tInMemoryAuthStorageBackend,\n\ttype OAuthCredential,\n} from \"./core/auth-storage.ts\";\n// Compaction\nexport {\n\ttype BranchPreparation,\n\ttype BranchSummaryResult,\n\ttype CollectEntriesResult,\n\ttype CompactionResult,\n\ttype CutPointResult,\n\tcalculateContextTokens,\n\tcollectEntriesForBranchSummary,\n\tcompact,\n\tDEFAULT_COMPACTION_SETTINGS,\n\testimateTokens,\n\ttype FileOperations,\n\tfindCutPoint,\n\tfindTurnStartIndex,\n\ttype GenerateBranchSummaryOptions,\n\tgenerateBranchSummary,\n\tgenerateSummary,\n\tgetLastAssistantUsage,\n\tprepareBranchEntries,\n\tserializeConversation,\n\tshouldCompact,\n} from \"./core/compaction/index.ts\";\nexport { createEventBus, type EventBus, type EventBusController } from \"./core/event-bus.ts\";\n// Extension system\nexport type {\n\tAgentEndEvent,\n\tAgentStartEvent,\n\tAgentToolResult,\n\tAgentToolUpdateCallback,\n\tAppKeybinding,\n\tAutocompleteProviderFactory,\n\tBashToolCallEvent,\n\tBeforeAgentStartEvent,\n\tBeforeAgentStartEventResult,\n\tBeforeProviderRequestEvent,\n\tBeforeProviderRequestEventResult,\n\tBuildSystemPromptOptions,\n\tCompactOptions,\n\tContextEvent,\n\tContextUsage,\n\tCustomToolCallEvent,\n\tEditToolCallEvent,\n\tExecOptions,\n\tExecResult,\n\tExtension,\n\tExtensionActions,\n\tExtensionAPI,\n\tExtensionCommandContext,\n\tExtensionCommandContextActions,\n\tExtensionContext,\n\tExtensionContextActions,\n\tExtensionError,\n\tExtensionEvent,\n\tExtensionFactory,\n\tExtensionFlag,\n\tExtensionHandler,\n\tExtensionRuntime,\n\tExtensionShortcut,\n\tExtensionUIContext,\n\tExtensionUIDialogOptions,\n\tExtensionWidgetOptions,\n\tFindToolCallEvent,\n\tGrepToolCallEvent,\n\tInputEvent,\n\tInputEventResult,\n\tInputSource,\n\tKeybindingsManager,\n\tLoadExtensionsResult,\n\tLsToolCallEvent,\n\tMessageRenderer,\n\tMessageRenderOptions,\n\tProviderConfig,\n\tProviderModelConfig,\n\tReadToolCallEvent,\n\tRegisteredCommand,\n\tRegisteredTool,\n\tResolvedCommand,\n\tSessionBeforeCompactEvent,\n\tSessionBeforeForkEvent,\n\tSessionBeforeSwitchEvent,\n\tSessionBeforeTreeEvent,\n\tSessionCompactEvent,\n\tSessionShutdownEvent,\n\tSessionStartEvent,\n\tSessionTreeEvent,\n\tSlashCommandInfo,\n\tSlashCommandSource,\n\tSourceInfo,\n\tTerminalInputHandler,\n\tToolCallEvent,\n\tToolCallEventResult,\n\tToolDefinition,\n\tToolExecutionMode,\n\tToolInfo,\n\tToolRenderResultOptions,\n\tToolResultEvent,\n\tTurnEndEvent,\n\tTurnStartEvent,\n\tUserBashEvent,\n\tUserBashEventResult,\n\tWidgetPlacement,\n\tWorkingIndicatorOptions,\n\tWriteToolCallEvent,\n} from \"./core/extensions/index.ts\";\nexport {\n\tcreateExtensionRuntime,\n\tdefineTool,\n\tdiscoverAndLoadExtensions,\n\tExtensionRunner,\n\tisBashToolResult,\n\tisEditToolResult,\n\tisFindToolResult,\n\tisGrepToolResult,\n\tisLsToolResult,\n\tisReadToolResult,\n\tisToolCallEventType,\n\tisWriteToolResult,\n\twrapRegisteredTool,\n\twrapRegisteredTools,\n} from \"./core/extensions/index.ts\";\n// Footer data provider (git branch + extension statuses - data not otherwise available to extensions)\nexport type { ReadonlyFooterDataProvider } from \"./core/footer-data-provider.ts\";\nexport {\n\tappendRunRecord,\n\ttype ConfidenceMode,\n\ttype ConfidenceResult,\n\tcleanupImprovementSandbox,\n\tcompareMetric,\n\tcomputeMadConfidence,\n\tcreateImprovementDecisionTool,\n\tcreateImprovementLoopTool,\n\tcreateImprovementSandbox,\n\tdecideImprovement,\n\texportImprovementSandboxPatch,\n\ttype GitStatusEntry,\n\ttype ImprovementDecision,\n\ttype ImprovementDecisionInput,\n\ttype ImprovementDecisionReason,\n\ttype ImprovementDecisionResult,\n\ttype ImprovementLoopConfig,\n\ttype ImprovementLoopExec,\n\ttype ImprovementLoopInitInput,\n\ttype ImprovementLoopPaths,\n\ttype ImprovementLoopRecordInput,\n\ttype ImprovementLoopState,\n\ttype ImprovementLoopStatusInput,\n\ttype ImprovementLoopToolAction,\n\ttype ImprovementLoopToolDetails,\n\ttype ImprovementMeasurementCommandResult,\n\ttype ImprovementMeasurementResult,\n\ttype ImprovementRunRecord,\n\ttype ImprovementSandboxCleanupInput,\n\ttype ImprovementSandboxCreateInput,\n\ttype ImprovementSandboxExportInput,\n\ttype ImprovementSandboxRecord,\n\timprovementLoopPaths,\n\tinitImprovementLoop,\n\ttype LowConfidenceAction,\n\ttype MetricComparison,\n\ttype MetricDirection,\n\tmedian,\n\tmedianAbsoluteDeviation,\n\tmetricMapFromOutput,\n\ttype OwnedDiscardPlan,\n\ttype OwnedDiscardPlanInput,\n\tparseGitPorcelainStatus,\n\tparseMetricLines,\n\tplanOwnedDiscard,\n\treadImprovementLoopState,\n\treadRunRecords,\n\trecordImprovementRun,\n\trunImprovementMeasurement,\n\tselectPrimaryMetric,\n\tserializeRunRecord,\n} from \"./core/improvement-loop.ts\";\nexport { convertToLlm } from \"./core/messages.ts\";\nexport { ModelRegistry } from \"./core/model-registry.ts\";\nexport type {\n\tPackageManager,\n\tPathMetadata,\n\tProgressCallback,\n\tProgressEvent,\n\tResolvedPaths,\n\tResolvedResource,\n} from \"./core/package-manager.ts\";\nexport { DefaultPackageManager } from \"./core/package-manager.ts\";\nexport {\n\tACTIVE_TURN_TTL_MS,\n\tAUTO_RELOAD_COORDINATOR_TTL_MS,\n\tdescribeReloadSession,\n\tgetPendingReloadBlockers,\n\tisReloadSessionProcessAlive,\n\ttype PendingReloadBlockers,\n\ttype ReloadBlockerOptions,\n\ttype ReloadSessionRecord,\n} from \"./core/reload-blockers.ts\";\nexport type { ResourceCollision, ResourceDiagnostic, ResourceLoader } from \"./core/resource-loader.ts\";\nexport { DefaultResourceLoader, loadProjectContextFiles } from \"./core/resource-loader.ts\";\nexport {\n\tmergeResourceProfileMap,\n\tmergeResourceProfileSettings,\n\tparseResourceProfileBlocks,\n\tparseResourceProfileInput,\n\tparseResourceProfileJson,\n\tstripResourceProfileBlocks,\n} from \"./core/resource-profile-blocks.ts\";\n// SDK for programmatic usage\nexport {\n\tAgentSessionRuntime,\n\ttype AgentSessionRuntimeDiagnostic,\n\ttype AgentSessionServices,\n\ttype CreateAgentSessionFromServicesOptions,\n\ttype CreateAgentSessionOptions,\n\ttype CreateAgentSessionResult,\n\ttype CreateAgentSessionRuntimeFactory,\n\ttype CreateAgentSessionRuntimeResult,\n\ttype CreateAgentSessionServicesOptions,\n\t// Factory\n\tcreateAgentSession,\n\tcreateAgentSessionFromServices,\n\tcreateAgentSessionRuntime,\n\tcreateAgentSessionServices,\n\tcreateBashTool,\n\t// Tool factories (for custom cwd)\n\tcreateCodingTools,\n\tcreateEditTool,\n\tcreateFindTool,\n\tcreateGrepTool,\n\tcreateLsTool,\n\tcreateReadOnlyTools,\n\tcreateReadTool,\n\tcreateWriteTool,\n\ttype PromptTemplate,\n} from \"./core/sdk.ts\";\nexport {\n\ttype BranchSummaryEntry,\n\tbuildSessionContext,\n\ttype CompactionEntry,\n\tCURRENT_SESSION_VERSION,\n\ttype CustomEntry,\n\ttype CustomMessageEntry,\n\ttype FileEntry,\n\tgetLatestCompactionEntry,\n\ttype ModelChangeEntry,\n\tmigrateSessionEntries,\n\ttype NewSessionOptions,\n\tparseSessionEntries,\n\ttype SessionContext,\n\ttype SessionEntry,\n\ttype SessionEntryBase,\n\ttype SessionHeader,\n\ttype SessionInfo,\n\ttype SessionInfoEntry,\n\tSessionManager,\n\ttype SessionMessageEntry,\n\ttype ThinkingLevelChangeEntry,\n} from \"./core/session-manager.ts\";\nexport {\n\ttype CompactionSettings,\n\ttype DirectoryResourceProfileInfo,\n\tgetDirectoryResourceProfileInfo,\n\ttype ImageSettings,\n\tmatchesResourceProfilePattern,\n\ttype PackageSource,\n\ttype ResourceProfileFilterSettings,\n\ttype ResourceProfileKind,\n\ttype ResourceProfileSettings,\n\ttype RetrySettings,\n\tSettingsManager,\n\ttype SettingsManagerCreateOptions,\n} from \"./core/settings-manager.ts\";\n// Skills\nexport {\n\tformatSkillsForPrompt,\n\ttype LoadSkillsFromDirOptions,\n\ttype LoadSkillsResult,\n\tloadSkills,\n\tloadSkillsFromDir,\n\ttype Skill,\n\ttype SkillFrontmatter,\n} from \"./core/skills.ts\";\nexport { createSyntheticSourceInfo } from \"./core/source-info.ts\";\n// Tools\nexport {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashToolDefinition,\n\tcreateEditToolDefinition,\n\tcreateFindToolDefinition,\n\tcreateGrepToolDefinition,\n\tcreateLocalBashOperations,\n\tcreateLsToolDefinition,\n\tcreateReadToolDefinition,\n\tcreateWriteToolDefinition,\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n\tformatSize,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n\ttype ToolsOptions,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n\twithFileMutationQueue,\n} from \"./core/tools/index.ts\";\nexport { hasProjectTrustInputs, type ProjectTrustDecision, ProjectTrustStore } from \"./core/trust-manager.ts\";\n// Main entry point\nexport { type MainOptions, main } from \"./main.ts\";\n// Run modes for programmatic SDK usage\nexport {\n\tInteractiveMode,\n\ttype InteractiveModeOptions,\n\ttype ModelInfo,\n\ttype PrintModeOptions,\n\tRpcClient,\n\ttype RpcClientOptions,\n\ttype RpcCommand,\n\ttype RpcEventListener,\n\ttype RpcResponse,\n\ttype RpcSessionState,\n\trunPrintMode,\n\trunRpcMode,\n} from \"./modes/index.ts\";\n// UI components for extensions\nexport {\n\tArminComponent,\n\tAssistantMessageComponent,\n\tBashExecutionComponent,\n\tBorderedLoader,\n\tBranchSummaryMessageComponent,\n\tCompactionSummaryMessageComponent,\n\tCustomEditor,\n\tCustomMessageComponent,\n\tDynamicBorder,\n\tExtensionEditorComponent,\n\tExtensionInputComponent,\n\tExtensionSelectorComponent,\n\tFooterComponent,\n\tkeyHint,\n\tkeyText,\n\tLoginDialogComponent,\n\tModelSelectorComponent,\n\tOAuthSelectorComponent,\n\ttype RenderDiffOptions,\n\trawKeyHint,\n\trenderDiff,\n\trenderTitleBadge,\n\trenderToolTitle,\n\tSessionSelectorComponent,\n\ttype SettingsCallbacks,\n\ttype SettingsConfig,\n\tSettingsSelectorComponent,\n\tShowImagesSelectorComponent,\n\tSkillInvocationMessageComponent,\n\tThemeSelectorComponent,\n\tThinkingSelectorComponent,\n\tTitleBadgeComponent,\n\ttype TitleBadgeOptions,\n\ttype TitleBadgeSegment,\n\ttype TitleBadgeStatus,\n\tToolExecutionComponent,\n\ttype ToolExecutionOptions,\n\tToolTitleComponent,\n\ttype ToolTitleOptions,\n\ttype ToolTitleSegment,\n\ttype ToolTitleStatus,\n\tTreeSelectorComponent,\n\ttitleBadge,\n\ttoolTitle,\n\ttruncateToVisualLines,\n\tUserMessageComponent,\n\tUserMessageSelectorComponent,\n\ttype VisualTruncateResult,\n} from \"./modes/interactive/components/index.ts\";\n// Theme utilities for custom tools and extensions\nexport {\n\tgetLanguageFromPath,\n\tgetMarkdownTheme,\n\tgetSelectListTheme,\n\tgetSettingsListTheme,\n\thighlightCode,\n\tinitTheme,\n\tTheme,\n\ttype ThemeColor,\n} from \"./modes/interactive/theme/theme.ts\";\n// Clipboard utilities\nexport { copyToClipboard } from \"./utils/clipboard.ts\";\nexport { parseFrontmatter, stripFrontmatter } from \"./utils/frontmatter.ts\";\nexport { convertToPng } from \"./utils/image-convert.ts\";\nexport { formatDimensionNote, type ResizedImage, resizeImage } from \"./utils/image-resize.ts\";\n// Shell utilities\nexport { getShellConfig } from \"./utils/shell.ts\";\n"]}
package/dist/index.js CHANGED
@@ -9,6 +9,7 @@ export { AuthStorage, FileAuthStorageBackend, InMemoryAuthStorageBackend, } from
9
9
  export { calculateContextTokens, collectEntriesForBranchSummary, compact, DEFAULT_COMPACTION_SETTINGS, estimateTokens, findCutPoint, findTurnStartIndex, generateBranchSummary, generateSummary, getLastAssistantUsage, prepareBranchEntries, serializeConversation, shouldCompact, } from "./core/compaction/index.js";
10
10
  export { createEventBus } from "./core/event-bus.js";
11
11
  export { createExtensionRuntime, defineTool, discoverAndLoadExtensions, ExtensionRunner, isBashToolResult, isEditToolResult, isFindToolResult, isGrepToolResult, isLsToolResult, isReadToolResult, isToolCallEventType, isWriteToolResult, wrapRegisteredTool, wrapRegisteredTools, } from "./core/extensions/index.js";
12
+ export { appendRunRecord, cleanupImprovementSandbox, compareMetric, computeMadConfidence, createImprovementDecisionTool, createImprovementLoopTool, createImprovementSandbox, decideImprovement, exportImprovementSandboxPatch, improvementLoopPaths, initImprovementLoop, median, medianAbsoluteDeviation, metricMapFromOutput, parseGitPorcelainStatus, parseMetricLines, planOwnedDiscard, readImprovementLoopState, readRunRecords, recordImprovementRun, runImprovementMeasurement, selectPrimaryMetric, serializeRunRecord, } from "./core/improvement-loop.js";
12
13
  export { convertToLlm } from "./core/messages.js";
13
14
  export { ModelRegistry } from "./core/model-registry.js";
14
15
  export { DefaultPackageManager } from "./core/package-manager.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAE1B,OAAO,EAAa,SAAS,EAAE,MAAM,eAAe,CAAC;AAErD,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EACN,YAAY,EAOZ,eAAe,GAEf,MAAM,yBAAyB,CAAC;AACjC,0BAA0B;AAC1B,OAAO,EAIN,WAAW,EAEX,sBAAsB,EACtB,0BAA0B,GAE1B,MAAM,wBAAwB,CAAC;AAChC,aAAa;AACb,OAAO,EAMN,sBAAsB,EACtB,8BAA8B,EAC9B,OAAO,EACP,2BAA2B,EAC3B,cAAc,EAEd,YAAY,EACZ,kBAAkB,EAElB,qBAAqB,EACrB,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,aAAa,GACb,MAAM,4BAA4B,CAAC;A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B,kBAAkB,EAClB,oBAAoB,EACpB,aAAa,EACb,SAAS,EACT,KAAK,GAEL,MAAM,oCAAoC,CAAC;AAC5C,sBAAsB;AACtB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAqB,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC9F,kBAAkB;AAClB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["// Core session management\n\nexport { type Args, parseArgs } from \"./cli/args.ts\";\n\n// Config paths\nexport { getAgentDir, VERSION } from \"./config.ts\";\nexport {\n\tAgentSession,\n\ttype AgentSessionConfig,\n\ttype AgentSessionEvent,\n\ttype AgentSessionEventListener,\n\ttype ModelCycleResult,\n\ttype ParsedSkillBlock,\n\ttype PromptOptions,\n\tparseSkillBlock,\n\ttype SessionStats,\n} from \"./core/agent-session.ts\";\n// Auth and model registry\nexport {\n\ttype ApiKeyCredential,\n\ttype AuthCredential,\n\ttype AuthStatus,\n\tAuthStorage,\n\ttype AuthStorageBackend,\n\tFileAuthStorageBackend,\n\tInMemoryAuthStorageBackend,\n\ttype OAuthCredential,\n} from \"./core/auth-storage.ts\";\n// Compaction\nexport {\n\ttype BranchPreparation,\n\ttype BranchSummaryResult,\n\ttype CollectEntriesResult,\n\ttype CompactionResult,\n\ttype CutPointResult,\n\tcalculateContextTokens,\n\tcollectEntriesForBranchSummary,\n\tcompact,\n\tDEFAULT_COMPACTION_SETTINGS,\n\testimateTokens,\n\ttype FileOperations,\n\tfindCutPoint,\n\tfindTurnStartIndex,\n\ttype GenerateBranchSummaryOptions,\n\tgenerateBranchSummary,\n\tgenerateSummary,\n\tgetLastAssistantUsage,\n\tprepareBranchEntries,\n\tserializeConversation,\n\tshouldCompact,\n} from \"./core/compaction/index.ts\";\nexport { createEventBus, type EventBus, type EventBusController } from \"./core/event-bus.ts\";\n// Extension system\nexport type {\n\tAgentEndEvent,\n\tAgentStartEvent,\n\tAgentToolResult,\n\tAgentToolUpdateCallback,\n\tAppKeybinding,\n\tAutocompleteProviderFactory,\n\tBashToolCallEvent,\n\tBeforeAgentStartEvent,\n\tBeforeAgentStartEventResult,\n\tBeforeProviderRequestEvent,\n\tBeforeProviderRequestEventResult,\n\tBuildSystemPromptOptions,\n\tCompactOptions,\n\tContextEvent,\n\tContextUsage,\n\tCustomToolCallEvent,\n\tEditToolCallEvent,\n\tExecOptions,\n\tExecResult,\n\tExtension,\n\tExtensionActions,\n\tExtensionAPI,\n\tExtensionCommandContext,\n\tExtensionCommandContextActions,\n\tExtensionContext,\n\tExtensionContextActions,\n\tExtensionError,\n\tExtensionEvent,\n\tExtensionFactory,\n\tExtensionFlag,\n\tExtensionHandler,\n\tExtensionRuntime,\n\tExtensionShortcut,\n\tExtensionUIContext,\n\tExtensionUIDialogOptions,\n\tExtensionWidgetOptions,\n\tFindToolCallEvent,\n\tGrepToolCallEvent,\n\tInputEvent,\n\tInputEventResult,\n\tInputSource,\n\tKeybindingsManager,\n\tLoadExtensionsResult,\n\tLsToolCallEvent,\n\tMessageRenderer,\n\tMessageRenderOptions,\n\tProviderConfig,\n\tProviderModelConfig,\n\tReadToolCallEvent,\n\tRegisteredCommand,\n\tRegisteredTool,\n\tResolvedCommand,\n\tSessionBeforeCompactEvent,\n\tSessionBeforeForkEvent,\n\tSessionBeforeSwitchEvent,\n\tSessionBeforeTreeEvent,\n\tSessionCompactEvent,\n\tSessionShutdownEvent,\n\tSessionStartEvent,\n\tSessionTreeEvent,\n\tSlashCommandInfo,\n\tSlashCommandSource,\n\tSourceInfo,\n\tTerminalInputHandler,\n\tToolCallEvent,\n\tToolCallEventResult,\n\tToolDefinition,\n\tToolExecutionMode,\n\tToolInfo,\n\tToolRenderResultOptions,\n\tToolResultEvent,\n\tTurnEndEvent,\n\tTurnStartEvent,\n\tUserBashEvent,\n\tUserBashEventResult,\n\tWidgetPlacement,\n\tWorkingIndicatorOptions,\n\tWriteToolCallEvent,\n} from \"./core/extensions/index.ts\";\nexport {\n\tcreateExtensionRuntime,\n\tdefineTool,\n\tdiscoverAndLoadExtensions,\n\tExtensionRunner,\n\tisBashToolResult,\n\tisEditToolResult,\n\tisFindToolResult,\n\tisGrepToolResult,\n\tisLsToolResult,\n\tisReadToolResult,\n\tisToolCallEventType,\n\tisWriteToolResult,\n\twrapRegisteredTool,\n\twrapRegisteredTools,\n} from \"./core/extensions/index.ts\";\n// Footer data provider (git branch + extension statuses - data not otherwise available to extensions)\nexport type { ReadonlyFooterDataProvider } from \"./core/footer-data-provider.ts\";\nexport { convertToLlm } from \"./core/messages.ts\";\nexport { ModelRegistry } from \"./core/model-registry.ts\";\nexport type {\n\tPackageManager,\n\tPathMetadata,\n\tProgressCallback,\n\tProgressEvent,\n\tResolvedPaths,\n\tResolvedResource,\n} from \"./core/package-manager.ts\";\nexport { DefaultPackageManager } from \"./core/package-manager.ts\";\nexport {\n\tACTIVE_TURN_TTL_MS,\n\tAUTO_RELOAD_COORDINATOR_TTL_MS,\n\tdescribeReloadSession,\n\tgetPendingReloadBlockers,\n\tisReloadSessionProcessAlive,\n\ttype PendingReloadBlockers,\n\ttype ReloadBlockerOptions,\n\ttype ReloadSessionRecord,\n} from \"./core/reload-blockers.ts\";\nexport type { ResourceCollision, ResourceDiagnostic, ResourceLoader } from \"./core/resource-loader.ts\";\nexport { DefaultResourceLoader, loadProjectContextFiles } from \"./core/resource-loader.ts\";\nexport {\n\tmergeResourceProfileMap,\n\tmergeResourceProfileSettings,\n\tparseResourceProfileBlocks,\n\tparseResourceProfileInput,\n\tparseResourceProfileJson,\n\tstripResourceProfileBlocks,\n} from \"./core/resource-profile-blocks.ts\";\n// SDK for programmatic usage\nexport {\n\tAgentSessionRuntime,\n\ttype AgentSessionRuntimeDiagnostic,\n\ttype AgentSessionServices,\n\ttype CreateAgentSessionFromServicesOptions,\n\ttype CreateAgentSessionOptions,\n\ttype CreateAgentSessionResult,\n\ttype CreateAgentSessionRuntimeFactory,\n\ttype CreateAgentSessionRuntimeResult,\n\ttype CreateAgentSessionServicesOptions,\n\t// Factory\n\tcreateAgentSession,\n\tcreateAgentSessionFromServices,\n\tcreateAgentSessionRuntime,\n\tcreateAgentSessionServices,\n\tcreateBashTool,\n\t// Tool factories (for custom cwd)\n\tcreateCodingTools,\n\tcreateEditTool,\n\tcreateFindTool,\n\tcreateGrepTool,\n\tcreateLsTool,\n\tcreateReadOnlyTools,\n\tcreateReadTool,\n\tcreateWriteTool,\n\ttype PromptTemplate,\n} from \"./core/sdk.ts\";\nexport {\n\ttype BranchSummaryEntry,\n\tbuildSessionContext,\n\ttype CompactionEntry,\n\tCURRENT_SESSION_VERSION,\n\ttype CustomEntry,\n\ttype CustomMessageEntry,\n\ttype FileEntry,\n\tgetLatestCompactionEntry,\n\ttype ModelChangeEntry,\n\tmigrateSessionEntries,\n\ttype NewSessionOptions,\n\tparseSessionEntries,\n\ttype SessionContext,\n\ttype SessionEntry,\n\ttype SessionEntryBase,\n\ttype SessionHeader,\n\ttype SessionInfo,\n\ttype SessionInfoEntry,\n\tSessionManager,\n\ttype SessionMessageEntry,\n\ttype ThinkingLevelChangeEntry,\n} from \"./core/session-manager.ts\";\nexport {\n\ttype CompactionSettings,\n\ttype DirectoryResourceProfileInfo,\n\tgetDirectoryResourceProfileInfo,\n\ttype ImageSettings,\n\tmatchesResourceProfilePattern,\n\ttype PackageSource,\n\ttype ResourceProfileFilterSettings,\n\ttype ResourceProfileKind,\n\ttype ResourceProfileSettings,\n\ttype RetrySettings,\n\tSettingsManager,\n\ttype SettingsManagerCreateOptions,\n} from \"./core/settings-manager.ts\";\n// Skills\nexport {\n\tformatSkillsForPrompt,\n\ttype LoadSkillsFromDirOptions,\n\ttype LoadSkillsResult,\n\tloadSkills,\n\tloadSkillsFromDir,\n\ttype Skill,\n\ttype SkillFrontmatter,\n} from \"./core/skills.ts\";\nexport { createSyntheticSourceInfo } from \"./core/source-info.ts\";\n// Tools\nexport {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashToolDefinition,\n\tcreateEditToolDefinition,\n\tcreateFindToolDefinition,\n\tcreateGrepToolDefinition,\n\tcreateLocalBashOperations,\n\tcreateLsToolDefinition,\n\tcreateReadToolDefinition,\n\tcreateWriteToolDefinition,\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n\tformatSize,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n\ttype ToolsOptions,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n\twithFileMutationQueue,\n} from \"./core/tools/index.ts\";\nexport { hasProjectTrustInputs, type ProjectTrustDecision, ProjectTrustStore } from \"./core/trust-manager.ts\";\n// Main entry point\nexport { type MainOptions, main } from \"./main.ts\";\n// Run modes for programmatic SDK usage\nexport {\n\tInteractiveMode,\n\ttype InteractiveModeOptions,\n\ttype ModelInfo,\n\ttype PrintModeOptions,\n\tRpcClient,\n\ttype RpcClientOptions,\n\ttype RpcCommand,\n\ttype RpcEventListener,\n\ttype RpcResponse,\n\ttype RpcSessionState,\n\trunPrintMode,\n\trunRpcMode,\n} from \"./modes/index.ts\";\n// UI components for extensions\nexport {\n\tArminComponent,\n\tAssistantMessageComponent,\n\tBashExecutionComponent,\n\tBorderedLoader,\n\tBranchSummaryMessageComponent,\n\tCompactionSummaryMessageComponent,\n\tCustomEditor,\n\tCustomMessageComponent,\n\tDynamicBorder,\n\tExtensionEditorComponent,\n\tExtensionInputComponent,\n\tExtensionSelectorComponent,\n\tFooterComponent,\n\tkeyHint,\n\tkeyText,\n\tLoginDialogComponent,\n\tModelSelectorComponent,\n\tOAuthSelectorComponent,\n\ttype RenderDiffOptions,\n\trawKeyHint,\n\trenderDiff,\n\trenderTitleBadge,\n\trenderToolTitle,\n\tSessionSelectorComponent,\n\ttype SettingsCallbacks,\n\ttype SettingsConfig,\n\tSettingsSelectorComponent,\n\tShowImagesSelectorComponent,\n\tSkillInvocationMessageComponent,\n\tThemeSelectorComponent,\n\tThinkingSelectorComponent,\n\tTitleBadgeComponent,\n\ttype TitleBadgeOptions,\n\ttype TitleBadgeSegment,\n\ttype TitleBadgeStatus,\n\tToolExecutionComponent,\n\ttype ToolExecutionOptions,\n\tToolTitleComponent,\n\ttype ToolTitleOptions,\n\ttype ToolTitleSegment,\n\ttype ToolTitleStatus,\n\tTreeSelectorComponent,\n\ttitleBadge,\n\ttoolTitle,\n\ttruncateToVisualLines,\n\tUserMessageComponent,\n\tUserMessageSelectorComponent,\n\ttype VisualTruncateResult,\n} from \"./modes/interactive/components/index.ts\";\n// Theme utilities for custom tools and extensions\nexport {\n\tgetLanguageFromPath,\n\tgetMarkdownTheme,\n\tgetSelectListTheme,\n\tgetSettingsListTheme,\n\thighlightCode,\n\tinitTheme,\n\tTheme,\n\ttype ThemeColor,\n} from \"./modes/interactive/theme/theme.ts\";\n// Clipboard utilities\nexport { copyToClipboard } from \"./utils/clipboard.ts\";\nexport { parseFrontmatter, stripFrontmatter } from \"./utils/frontmatter.ts\";\nexport { convertToPng } from \"./utils/image-convert.ts\";\nexport { formatDimensionNote, type ResizedImage, resizeImage } from \"./utils/image-resize.ts\";\n// Shell utilities\nexport { getShellConfig } from \"./utils/shell.ts\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAE1B,OAAO,EAAa,SAAS,EAAE,MAAM,eAAe,CAAC;AAErD,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EACN,YAAY,EAOZ,eAAe,GAEf,MAAM,yBAAyB,CAAC;AACjC,0BAA0B;AAC1B,OAAO,EAIN,WAAW,EAEX,sBAAsB,EACtB,0BAA0B,GAE1B,MAAM,wBAAwB,CAAC;AAChC,aAAa;AACb,OAAO,EAMN,sBAAsB,EACtB,8BAA8B,EAC9B,OAAO,EACP,2BAA2B,EAC3B,cAAc,EAEd,YAAY,EACZ,kBAAkB,EAElB,qBAAqB,EACrB,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,aAAa,GACb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAA0C,MAAM,qBAAqB,CAAC;AAkF7F,OAAO,EACN,sBAAsB,EACtB,UAAU,EACV,yBAAyB,EACzB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,GACnB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACN,eAAe,EAGf,yBAAyB,EACzB,aAAa,EACb,oBAAoB,EACpB,6BAA6B,EAC7B,yBAAyB,EACzB,wBAAwB,EACxB,iBAAiB,EACjB,6BAA6B,EAsB7B,oBAAoB,EACpB,mBAAmB,EAInB,MAAM,EACN,uBAAuB,EACvB,mBAAmB,EAGnB,uBAAuB,EACvB,gBAAgB,EAChB,gBAAgB,EAChB,wBAAwB,EACxB,cAAc,EACd,oBAAoB,EACpB,yBAAyB,EACz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,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAqB,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC9F,kBAAkB;AAClB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["// Core session management\n\nexport { type Args, parseArgs } from \"./cli/args.ts\";\n\n// Config paths\nexport { getAgentDir, VERSION } from \"./config.ts\";\nexport {\n\tAgentSession,\n\ttype AgentSessionConfig,\n\ttype AgentSessionEvent,\n\ttype AgentSessionEventListener,\n\ttype ModelCycleResult,\n\ttype ParsedSkillBlock,\n\ttype PromptOptions,\n\tparseSkillBlock,\n\ttype SessionStats,\n} from \"./core/agent-session.ts\";\n// Auth and model registry\nexport {\n\ttype ApiKeyCredential,\n\ttype AuthCredential,\n\ttype AuthStatus,\n\tAuthStorage,\n\ttype AuthStorageBackend,\n\tFileAuthStorageBackend,\n\tInMemoryAuthStorageBackend,\n\ttype OAuthCredential,\n} from \"./core/auth-storage.ts\";\n// Compaction\nexport {\n\ttype BranchPreparation,\n\ttype BranchSummaryResult,\n\ttype CollectEntriesResult,\n\ttype CompactionResult,\n\ttype CutPointResult,\n\tcalculateContextTokens,\n\tcollectEntriesForBranchSummary,\n\tcompact,\n\tDEFAULT_COMPACTION_SETTINGS,\n\testimateTokens,\n\ttype FileOperations,\n\tfindCutPoint,\n\tfindTurnStartIndex,\n\ttype GenerateBranchSummaryOptions,\n\tgenerateBranchSummary,\n\tgenerateSummary,\n\tgetLastAssistantUsage,\n\tprepareBranchEntries,\n\tserializeConversation,\n\tshouldCompact,\n} from \"./core/compaction/index.ts\";\nexport { createEventBus, type EventBus, type EventBusController } from \"./core/event-bus.ts\";\n// Extension system\nexport type {\n\tAgentEndEvent,\n\tAgentStartEvent,\n\tAgentToolResult,\n\tAgentToolUpdateCallback,\n\tAppKeybinding,\n\tAutocompleteProviderFactory,\n\tBashToolCallEvent,\n\tBeforeAgentStartEvent,\n\tBeforeAgentStartEventResult,\n\tBeforeProviderRequestEvent,\n\tBeforeProviderRequestEventResult,\n\tBuildSystemPromptOptions,\n\tCompactOptions,\n\tContextEvent,\n\tContextUsage,\n\tCustomToolCallEvent,\n\tEditToolCallEvent,\n\tExecOptions,\n\tExecResult,\n\tExtension,\n\tExtensionActions,\n\tExtensionAPI,\n\tExtensionCommandContext,\n\tExtensionCommandContextActions,\n\tExtensionContext,\n\tExtensionContextActions,\n\tExtensionError,\n\tExtensionEvent,\n\tExtensionFactory,\n\tExtensionFlag,\n\tExtensionHandler,\n\tExtensionRuntime,\n\tExtensionShortcut,\n\tExtensionUIContext,\n\tExtensionUIDialogOptions,\n\tExtensionWidgetOptions,\n\tFindToolCallEvent,\n\tGrepToolCallEvent,\n\tInputEvent,\n\tInputEventResult,\n\tInputSource,\n\tKeybindingsManager,\n\tLoadExtensionsResult,\n\tLsToolCallEvent,\n\tMessageRenderer,\n\tMessageRenderOptions,\n\tProviderConfig,\n\tProviderModelConfig,\n\tReadToolCallEvent,\n\tRegisteredCommand,\n\tRegisteredTool,\n\tResolvedCommand,\n\tSessionBeforeCompactEvent,\n\tSessionBeforeForkEvent,\n\tSessionBeforeSwitchEvent,\n\tSessionBeforeTreeEvent,\n\tSessionCompactEvent,\n\tSessionShutdownEvent,\n\tSessionStartEvent,\n\tSessionTreeEvent,\n\tSlashCommandInfo,\n\tSlashCommandSource,\n\tSourceInfo,\n\tTerminalInputHandler,\n\tToolCallEvent,\n\tToolCallEventResult,\n\tToolDefinition,\n\tToolExecutionMode,\n\tToolInfo,\n\tToolRenderResultOptions,\n\tToolResultEvent,\n\tTurnEndEvent,\n\tTurnStartEvent,\n\tUserBashEvent,\n\tUserBashEventResult,\n\tWidgetPlacement,\n\tWorkingIndicatorOptions,\n\tWriteToolCallEvent,\n} from \"./core/extensions/index.ts\";\nexport {\n\tcreateExtensionRuntime,\n\tdefineTool,\n\tdiscoverAndLoadExtensions,\n\tExtensionRunner,\n\tisBashToolResult,\n\tisEditToolResult,\n\tisFindToolResult,\n\tisGrepToolResult,\n\tisLsToolResult,\n\tisReadToolResult,\n\tisToolCallEventType,\n\tisWriteToolResult,\n\twrapRegisteredTool,\n\twrapRegisteredTools,\n} from \"./core/extensions/index.ts\";\n// Footer data provider (git branch + extension statuses - data not otherwise available to extensions)\nexport type { ReadonlyFooterDataProvider } from \"./core/footer-data-provider.ts\";\nexport {\n\tappendRunRecord,\n\ttype ConfidenceMode,\n\ttype ConfidenceResult,\n\tcleanupImprovementSandbox,\n\tcompareMetric,\n\tcomputeMadConfidence,\n\tcreateImprovementDecisionTool,\n\tcreateImprovementLoopTool,\n\tcreateImprovementSandbox,\n\tdecideImprovement,\n\texportImprovementSandboxPatch,\n\ttype GitStatusEntry,\n\ttype ImprovementDecision,\n\ttype ImprovementDecisionInput,\n\ttype ImprovementDecisionReason,\n\ttype ImprovementDecisionResult,\n\ttype ImprovementLoopConfig,\n\ttype ImprovementLoopExec,\n\ttype ImprovementLoopInitInput,\n\ttype ImprovementLoopPaths,\n\ttype ImprovementLoopRecordInput,\n\ttype ImprovementLoopState,\n\ttype ImprovementLoopStatusInput,\n\ttype ImprovementLoopToolAction,\n\ttype ImprovementLoopToolDetails,\n\ttype ImprovementMeasurementCommandResult,\n\ttype ImprovementMeasurementResult,\n\ttype ImprovementRunRecord,\n\ttype ImprovementSandboxCleanupInput,\n\ttype ImprovementSandboxCreateInput,\n\ttype ImprovementSandboxExportInput,\n\ttype ImprovementSandboxRecord,\n\timprovementLoopPaths,\n\tinitImprovementLoop,\n\ttype LowConfidenceAction,\n\ttype MetricComparison,\n\ttype MetricDirection,\n\tmedian,\n\tmedianAbsoluteDeviation,\n\tmetricMapFromOutput,\n\ttype OwnedDiscardPlan,\n\ttype OwnedDiscardPlanInput,\n\tparseGitPorcelainStatus,\n\tparseMetricLines,\n\tplanOwnedDiscard,\n\treadImprovementLoopState,\n\treadRunRecords,\n\trecordImprovementRun,\n\trunImprovementMeasurement,\n\tselectPrimaryMetric,\n\tserializeRunRecord,\n} from \"./core/improvement-loop.ts\";\nexport { convertToLlm } from \"./core/messages.ts\";\nexport { ModelRegistry } from \"./core/model-registry.ts\";\nexport type {\n\tPackageManager,\n\tPathMetadata,\n\tProgressCallback,\n\tProgressEvent,\n\tResolvedPaths,\n\tResolvedResource,\n} from \"./core/package-manager.ts\";\nexport { DefaultPackageManager } from \"./core/package-manager.ts\";\nexport {\n\tACTIVE_TURN_TTL_MS,\n\tAUTO_RELOAD_COORDINATOR_TTL_MS,\n\tdescribeReloadSession,\n\tgetPendingReloadBlockers,\n\tisReloadSessionProcessAlive,\n\ttype PendingReloadBlockers,\n\ttype ReloadBlockerOptions,\n\ttype ReloadSessionRecord,\n} from \"./core/reload-blockers.ts\";\nexport type { ResourceCollision, ResourceDiagnostic, ResourceLoader } from \"./core/resource-loader.ts\";\nexport { DefaultResourceLoader, loadProjectContextFiles } from \"./core/resource-loader.ts\";\nexport {\n\tmergeResourceProfileMap,\n\tmergeResourceProfileSettings,\n\tparseResourceProfileBlocks,\n\tparseResourceProfileInput,\n\tparseResourceProfileJson,\n\tstripResourceProfileBlocks,\n} from \"./core/resource-profile-blocks.ts\";\n// SDK for programmatic usage\nexport {\n\tAgentSessionRuntime,\n\ttype AgentSessionRuntimeDiagnostic,\n\ttype AgentSessionServices,\n\ttype CreateAgentSessionFromServicesOptions,\n\ttype CreateAgentSessionOptions,\n\ttype CreateAgentSessionResult,\n\ttype CreateAgentSessionRuntimeFactory,\n\ttype CreateAgentSessionRuntimeResult,\n\ttype CreateAgentSessionServicesOptions,\n\t// Factory\n\tcreateAgentSession,\n\tcreateAgentSessionFromServices,\n\tcreateAgentSessionRuntime,\n\tcreateAgentSessionServices,\n\tcreateBashTool,\n\t// Tool factories (for custom cwd)\n\tcreateCodingTools,\n\tcreateEditTool,\n\tcreateFindTool,\n\tcreateGrepTool,\n\tcreateLsTool,\n\tcreateReadOnlyTools,\n\tcreateReadTool,\n\tcreateWriteTool,\n\ttype PromptTemplate,\n} from \"./core/sdk.ts\";\nexport {\n\ttype BranchSummaryEntry,\n\tbuildSessionContext,\n\ttype CompactionEntry,\n\tCURRENT_SESSION_VERSION,\n\ttype CustomEntry,\n\ttype CustomMessageEntry,\n\ttype FileEntry,\n\tgetLatestCompactionEntry,\n\ttype ModelChangeEntry,\n\tmigrateSessionEntries,\n\ttype NewSessionOptions,\n\tparseSessionEntries,\n\ttype SessionContext,\n\ttype SessionEntry,\n\ttype SessionEntryBase,\n\ttype SessionHeader,\n\ttype SessionInfo,\n\ttype SessionInfoEntry,\n\tSessionManager,\n\ttype SessionMessageEntry,\n\ttype ThinkingLevelChangeEntry,\n} from \"./core/session-manager.ts\";\nexport {\n\ttype CompactionSettings,\n\ttype DirectoryResourceProfileInfo,\n\tgetDirectoryResourceProfileInfo,\n\ttype ImageSettings,\n\tmatchesResourceProfilePattern,\n\ttype PackageSource,\n\ttype ResourceProfileFilterSettings,\n\ttype ResourceProfileKind,\n\ttype ResourceProfileSettings,\n\ttype RetrySettings,\n\tSettingsManager,\n\ttype SettingsManagerCreateOptions,\n} from \"./core/settings-manager.ts\";\n// Skills\nexport {\n\tformatSkillsForPrompt,\n\ttype LoadSkillsFromDirOptions,\n\ttype LoadSkillsResult,\n\tloadSkills,\n\tloadSkillsFromDir,\n\ttype Skill,\n\ttype SkillFrontmatter,\n} from \"./core/skills.ts\";\nexport { createSyntheticSourceInfo } from \"./core/source-info.ts\";\n// Tools\nexport {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashToolDefinition,\n\tcreateEditToolDefinition,\n\tcreateFindToolDefinition,\n\tcreateGrepToolDefinition,\n\tcreateLocalBashOperations,\n\tcreateLsToolDefinition,\n\tcreateReadToolDefinition,\n\tcreateWriteToolDefinition,\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n\tformatSize,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n\ttype ToolsOptions,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n\twithFileMutationQueue,\n} from \"./core/tools/index.ts\";\nexport { hasProjectTrustInputs, type ProjectTrustDecision, ProjectTrustStore } from \"./core/trust-manager.ts\";\n// Main entry point\nexport { type MainOptions, main } from \"./main.ts\";\n// Run modes for programmatic SDK usage\nexport {\n\tInteractiveMode,\n\ttype InteractiveModeOptions,\n\ttype ModelInfo,\n\ttype PrintModeOptions,\n\tRpcClient,\n\ttype RpcClientOptions,\n\ttype RpcCommand,\n\ttype RpcEventListener,\n\ttype RpcResponse,\n\ttype RpcSessionState,\n\trunPrintMode,\n\trunRpcMode,\n} from \"./modes/index.ts\";\n// UI components for extensions\nexport {\n\tArminComponent,\n\tAssistantMessageComponent,\n\tBashExecutionComponent,\n\tBorderedLoader,\n\tBranchSummaryMessageComponent,\n\tCompactionSummaryMessageComponent,\n\tCustomEditor,\n\tCustomMessageComponent,\n\tDynamicBorder,\n\tExtensionEditorComponent,\n\tExtensionInputComponent,\n\tExtensionSelectorComponent,\n\tFooterComponent,\n\tkeyHint,\n\tkeyText,\n\tLoginDialogComponent,\n\tModelSelectorComponent,\n\tOAuthSelectorComponent,\n\ttype RenderDiffOptions,\n\trawKeyHint,\n\trenderDiff,\n\trenderTitleBadge,\n\trenderToolTitle,\n\tSessionSelectorComponent,\n\ttype SettingsCallbacks,\n\ttype SettingsConfig,\n\tSettingsSelectorComponent,\n\tShowImagesSelectorComponent,\n\tSkillInvocationMessageComponent,\n\tThemeSelectorComponent,\n\tThinkingSelectorComponent,\n\tTitleBadgeComponent,\n\ttype TitleBadgeOptions,\n\ttype TitleBadgeSegment,\n\ttype TitleBadgeStatus,\n\tToolExecutionComponent,\n\ttype ToolExecutionOptions,\n\tToolTitleComponent,\n\ttype ToolTitleOptions,\n\ttype ToolTitleSegment,\n\ttype ToolTitleStatus,\n\tTreeSelectorComponent,\n\ttitleBadge,\n\ttoolTitle,\n\ttruncateToVisualLines,\n\tUserMessageComponent,\n\tUserMessageSelectorComponent,\n\ttype VisualTruncateResult,\n} from \"./modes/interactive/components/index.ts\";\n// Theme utilities for custom tools and extensions\nexport {\n\tgetLanguageFromPath,\n\tgetMarkdownTheme,\n\tgetSelectListTheme,\n\tgetSettingsListTheme,\n\thighlightCode,\n\tinitTheme,\n\tTheme,\n\ttype ThemeColor,\n} from \"./modes/interactive/theme/theme.ts\";\n// Clipboard utilities\nexport { copyToClipboard } from \"./utils/clipboard.ts\";\nexport { parseFrontmatter, stripFrontmatter } from \"./utils/frontmatter.ts\";\nexport { convertToPng } from \"./utils/image-convert.ts\";\nexport { formatDimensionNote, type ResizedImage, resizeImage } from \"./utils/image-resize.ts\";\n// Shell utilities\nexport { getShellConfig } from \"./utils/shell.ts\";\n"]}
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider",
3
- "version": "0.80.26",
3
+ "version": "0.80.27",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-custom-provider",
9
- "version": "0.80.26",
9
+ "version": "0.80.27",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sdk": "^0.52.0"
12
12
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider-anthropic",
3
3
  "private": true,
4
- "version": "0.80.26",
4
+ "version": "0.80.27",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider-gitlab-duo",
3
3
  "private": true,
4
- "version": "0.80.26",
4
+ "version": "0.80.27",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",