@tangle-network/agent-runtime 0.104.0 → 0.106.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/README.md +176 -42
  2. package/dist/activation-CRjVfOiy.js +203 -0
  3. package/dist/activation-CRjVfOiy.js.map +1 -0
  4. package/dist/activation-DyWB0K6E.d.ts +98 -0
  5. package/dist/agent.d.ts +216 -234
  6. package/dist/agent.js +615 -547
  7. package/dist/agent.js.map +1 -1
  8. package/dist/analyst-loop-DGdtVENg.js +517 -0
  9. package/dist/analyst-loop-DGdtVENg.js.map +1 -0
  10. package/dist/analyst-loop.d.ts +10 -43
  11. package/dist/analyst-loop.js +2 -11
  12. package/dist/backends-Dy8NujB4.js +713 -0
  13. package/dist/backends-Dy8NujB4.js.map +1 -0
  14. package/dist/candidate-execution/index.d.ts +4 -192
  15. package/dist/candidate-execution/index.js +5 -66
  16. package/dist/candidate-execution-DqMbv1rU.js +488 -0
  17. package/dist/candidate-execution-DqMbv1rU.js.map +1 -0
  18. package/dist/coder-yhVWbdWc.js +40 -0
  19. package/dist/coder-yhVWbdWc.js.map +1 -0
  20. package/dist/conversation-XucG_K3l.js +1265 -0
  21. package/dist/conversation-XucG_K3l.js.map +1 -0
  22. package/dist/conversation.d.ts +2 -804
  23. package/dist/conversation.js +2 -55
  24. package/dist/environment-provider-CfLUmKmf.js +1168 -0
  25. package/dist/environment-provider-CfLUmKmf.js.map +1 -0
  26. package/dist/environment-provider-IUGU3epE.d.ts +964 -0
  27. package/dist/environment-provider.d.ts +2 -78
  28. package/dist/environment-provider.js +2 -18
  29. package/dist/errors-DEAvWQPy.js +111 -0
  30. package/dist/errors-DEAvWQPy.js.map +1 -0
  31. package/dist/improvement-adapter-Cr5TBSji.d.ts +166 -0
  32. package/dist/improvement-cycle-C095kS_g.js +2624 -0
  33. package/dist/improvement-cycle-C095kS_g.js.map +1 -0
  34. package/dist/index-BGdxAwfO.d.ts +838 -0
  35. package/dist/index-C-FYUuFG.d.ts +193 -0
  36. package/dist/index-CbNM40xG.d.ts +140 -0
  37. package/dist/index-DruSKs3Z.d.ts +7224 -0
  38. package/dist/index-Efjb3nrQ.d.ts +671 -0
  39. package/dist/index.d.ts +14 -1134
  40. package/dist/index.js +2134 -1972
  41. package/dist/index.js.map +1 -1
  42. package/dist/intelligence.d.ts +776 -888
  43. package/dist/intelligence.js +1466 -1410
  44. package/dist/intelligence.js.map +1 -1
  45. package/dist/{kb-gate-CwHO0vz6.d.ts → kb-gate-C8z2juK8.d.ts} +33 -31
  46. package/dist/kb-gate-DpaSwXVx.js +80 -0
  47. package/dist/kb-gate-DpaSwXVx.js.map +1 -0
  48. package/dist/knowledge-Ku-mPP4f.js +433 -0
  49. package/dist/knowledge-Ku-mPP4f.js.map +1 -0
  50. package/dist/knowledge.d.ts +2 -150
  51. package/dist/knowledge.js +2 -40
  52. package/dist/local-harness-Dh8PJ0ot.d.ts +455 -0
  53. package/dist/loop-runner-bin-BXsFEUcf.d.ts +162 -0
  54. package/dist/loop-runner-bin-BwjQ1NfH.js +268 -0
  55. package/dist/loop-runner-bin-BwjQ1NfH.js.map +1 -0
  56. package/dist/loop-runner-bin.d.ts +2 -17
  57. package/dist/loop-runner-bin.js +2 -24
  58. package/dist/loops.d.ts +5 -4164
  59. package/dist/loops.js +8 -419
  60. package/dist/mcp/bin.d.ts +1 -1
  61. package/dist/mcp/bin.js +116 -146
  62. package/dist/mcp/bin.js.map +1 -1
  63. package/dist/mcp/index.d.ts +295 -437
  64. package/dist/mcp/index.js +1242 -1177
  65. package/dist/mcp/index.js.map +1 -1
  66. package/dist/mcp/memory-bin.d.ts +1 -1
  67. package/dist/mcp/memory-bin.js +37 -16
  68. package/dist/mcp/memory-bin.js.map +1 -1
  69. package/dist/memory-server-DL6cE2Ag.js +234 -0
  70. package/dist/memory-server-DL6cE2Ag.js.map +1 -0
  71. package/dist/model-resolution-Btd9iIKV.js +98 -0
  72. package/dist/model-resolution-Btd9iIKV.js.map +1 -0
  73. package/dist/openai-tools-B68JaOCx.d.ts +24 -0
  74. package/dist/openai-tools-CKLy1C7M.js +44 -0
  75. package/dist/openai-tools-CKLy1C7M.js.map +1 -0
  76. package/dist/otel-export-D34IQW1C.js +843 -0
  77. package/dist/otel-export-D34IQW1C.js.map +1 -0
  78. package/dist/platform.d.ts +188 -185
  79. package/dist/platform.js +185 -218
  80. package/dist/platform.js.map +1 -1
  81. package/dist/prepare-B53sPV7M.js +4292 -0
  82. package/dist/prepare-B53sPV7M.js.map +1 -0
  83. package/dist/primeintellect/index.d.ts +150 -147
  84. package/dist/primeintellect/index.js +626 -1004
  85. package/dist/primeintellect/index.js.map +1 -1
  86. package/dist/profiles.d.ts +296 -490
  87. package/dist/profiles.js +722 -749
  88. package/dist/profiles.js.map +1 -1
  89. package/dist/protected-model-port-BLPH5VVv.js +722 -0
  90. package/dist/protected-model-port-BLPH5VVv.js.map +1 -0
  91. package/dist/protected-model-port-BP6Z4eau.d.ts +283 -0
  92. package/dist/protected-redaction--F3v1oo8.js +200 -0
  93. package/dist/protected-redaction--F3v1oo8.js.map +1 -0
  94. package/dist/redact-D-u-rrcn.js +82 -0
  95. package/dist/redact-D-u-rrcn.js.map +1 -0
  96. package/dist/redact-kbIOjfjM.d.ts +452 -0
  97. package/dist/researcher-CoVqNhfI.js +433 -0
  98. package/dist/researcher-CoVqNhfI.js.map +1 -0
  99. package/dist/runtime-BG0BziaP.js +5408 -0
  100. package/dist/runtime-BG0BziaP.js.map +1 -0
  101. package/dist/sandbox-events-DeI5xX8P.js +316 -0
  102. package/dist/sandbox-events-DeI5xX8P.js.map +1 -0
  103. package/dist/spawn-journal-CwPvKUTa.js +456 -0
  104. package/dist/spawn-journal-CwPvKUTa.js.map +1 -0
  105. package/dist/structural-rollout-IXUEplky.js +1445 -0
  106. package/dist/structural-rollout-IXUEplky.js.map +1 -0
  107. package/dist/substrate-B0TYNrXn.js +27 -0
  108. package/dist/substrate-B0TYNrXn.js.map +1 -0
  109. package/dist/{substrate-Dyiqmd3o.d.ts → substrate-BcnuSHXm.d.ts} +57 -54
  110. package/dist/supervise-BiRutHS9.js +7321 -0
  111. package/dist/supervise-BiRutHS9.js.map +1 -0
  112. package/dist/supervisor-DTKhF-RV.js +3826 -0
  113. package/dist/supervisor-DTKhF-RV.js.map +1 -0
  114. package/dist/testing.d.ts +4 -3
  115. package/dist/testing.js +2478 -2637
  116. package/dist/testing.js.map +1 -1
  117. package/dist/tool-server-RcWgLIsL.js +141 -0
  118. package/dist/tool-server-RcWgLIsL.js.map +1 -0
  119. package/dist/trace-propagation-CJJC7SVB.js +57 -0
  120. package/dist/trace-propagation-CJJC7SVB.js.map +1 -0
  121. package/dist/types-BaIpb0XT.d.ts +492 -0
  122. package/dist/types-BevOjfTY.d.ts +765 -0
  123. package/dist/types-C9j4qg6l.d.ts +500 -0
  124. package/dist/types-Cja5OTGh.d.ts +190 -0
  125. package/dist/util-MVgdwuIS.js +145 -0
  126. package/dist/util-MVgdwuIS.js.map +1 -0
  127. package/dist/workspace-archive-BosQiotA.js +575 -0
  128. package/dist/workspace-archive-BosQiotA.js.map +1 -0
  129. package/package.json +43 -55
  130. package/skills/build-with-agent-runtime/SKILL.md +16 -9
  131. package/skills/loop-writer/SKILL.md +1 -1
  132. package/dist/activation-Cm-9MMX1.d.ts +0 -69
  133. package/dist/analyst-loop.js.map +0 -1
  134. package/dist/backends-BO4Jqoe2.d.ts +0 -134
  135. package/dist/candidate-execution/index.js.map +0 -1
  136. package/dist/chunk-2KGAN2HM.js +0 -1256
  137. package/dist/chunk-2KGAN2HM.js.map +0 -1
  138. package/dist/chunk-2QJSNOGK.js +0 -48
  139. package/dist/chunk-2QJSNOGK.js.map +0 -1
  140. package/dist/chunk-2UABGGUB.js +0 -474
  141. package/dist/chunk-2UABGGUB.js.map +0 -1
  142. package/dist/chunk-2VZYRB55.js +0 -834
  143. package/dist/chunk-2VZYRB55.js.map +0 -1
  144. package/dist/chunk-2X65HYMI.js +0 -3526
  145. package/dist/chunk-2X65HYMI.js.map +0 -1
  146. package/dist/chunk-3MDZX7YU.js +0 -125
  147. package/dist/chunk-3MDZX7YU.js.map +0 -1
  148. package/dist/chunk-3PPVCS75.js +0 -199
  149. package/dist/chunk-3PPVCS75.js.map +0 -1
  150. package/dist/chunk-5HNDYWUT.js +0 -6424
  151. package/dist/chunk-5HNDYWUT.js.map +0 -1
  152. package/dist/chunk-5IBQAPVB.js +0 -29
  153. package/dist/chunk-5IBQAPVB.js.map +0 -1
  154. package/dist/chunk-5QOB7H74.js +0 -387
  155. package/dist/chunk-5QOB7H74.js.map +0 -1
  156. package/dist/chunk-ATDFUJYI.js +0 -4728
  157. package/dist/chunk-ATDFUJYI.js.map +0 -1
  158. package/dist/chunk-B7K7V22Y.js +0 -699
  159. package/dist/chunk-B7K7V22Y.js.map +0 -1
  160. package/dist/chunk-DPEUKJRO.js +0 -27
  161. package/dist/chunk-DPEUKJRO.js.map +0 -1
  162. package/dist/chunk-FD2MBMOH.js +0 -494
  163. package/dist/chunk-FD2MBMOH.js.map +0 -1
  164. package/dist/chunk-FJI3EXU3.js +0 -2402
  165. package/dist/chunk-FJI3EXU3.js.map +0 -1
  166. package/dist/chunk-HAO4CXHP.js +0 -200
  167. package/dist/chunk-HAO4CXHP.js.map +0 -1
  168. package/dist/chunk-ISPWRSEC.js +0 -408
  169. package/dist/chunk-ISPWRSEC.js.map +0 -1
  170. package/dist/chunk-KRBFHMV6.js +0 -1228
  171. package/dist/chunk-KRBFHMV6.js.map +0 -1
  172. package/dist/chunk-L5DST3QC.js +0 -351
  173. package/dist/chunk-L5DST3QC.js.map +0 -1
  174. package/dist/chunk-M22PL4GH.js +0 -171
  175. package/dist/chunk-M22PL4GH.js.map +0 -1
  176. package/dist/chunk-NURIQBJQ.js +0 -72
  177. package/dist/chunk-NURIQBJQ.js.map +0 -1
  178. package/dist/chunk-PZZKQVQV.js +0 -52
  179. package/dist/chunk-PZZKQVQV.js.map +0 -1
  180. package/dist/chunk-Q2JSAVQ3.js +0 -671
  181. package/dist/chunk-Q2JSAVQ3.js.map +0 -1
  182. package/dist/chunk-SBTWKPVR.js +0 -5576
  183. package/dist/chunk-SBTWKPVR.js.map +0 -1
  184. package/dist/chunk-SGKPNBXE.js +0 -60
  185. package/dist/chunk-SGKPNBXE.js.map +0 -1
  186. package/dist/chunk-SNSMRT6H.js +0 -680
  187. package/dist/chunk-SNSMRT6H.js.map +0 -1
  188. package/dist/chunk-STJEHM5F.js +0 -1338
  189. package/dist/chunk-STJEHM5F.js.map +0 -1
  190. package/dist/chunk-UPWGXKXB.js +0 -254
  191. package/dist/chunk-UPWGXKXB.js.map +0 -1
  192. package/dist/chunk-YEJR7IXO.js +0 -68
  193. package/dist/chunk-YEJR7IXO.js.map +0 -1
  194. package/dist/chunk-ZXICDSAK.js +0 -907
  195. package/dist/chunk-ZXICDSAK.js.map +0 -1
  196. package/dist/completion-gate-Bv47cOnn.d.ts +0 -256
  197. package/dist/conversation.js.map +0 -1
  198. package/dist/coordination-CxtzMxSM.d.ts +0 -2570
  199. package/dist/environment-provider.js.map +0 -1
  200. package/dist/improve--2A0gK1-.d.ts +0 -440
  201. package/dist/improvement-adapter-HAZz-7vK.d.ts +0 -203
  202. package/dist/knowledge.js.map +0 -1
  203. package/dist/local-harness-CtK9dSny.d.ts +0 -175
  204. package/dist/loop-runner-bin-DUOGtvOl.d.ts +0 -207
  205. package/dist/loop-runner-bin.js.map +0 -1
  206. package/dist/loops.js.map +0 -1
  207. package/dist/openai-tools-fnj6SRVg.d.ts +0 -46
  208. package/dist/protected-model-port-DzkUY3HQ.d.ts +0 -271
  209. package/dist/sanitize-DEbPNtyI.d.ts +0 -328
  210. package/dist/structural-rollout-C4mabf87.d.ts +0 -446
  211. package/dist/supervise-7q9F5brx.d.ts +0 -379
  212. package/dist/types-BCoemcXU.d.ts +0 -802
  213. package/dist/types-BwoZWq-i.d.ts +0 -510
  214. package/dist/types-Cbp72qyu.d.ts +0 -491
  215. package/dist/types-CmYCMbFT.d.ts +0 -203
  216. package/dist/types-CvNwMzQt.d.ts +0 -957
  217. package/dist/worktree-fanout-WsOzt8qu.d.ts +0 -999
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protected-redaction--F3v1oo8.js","names":[],"sources":["../src/candidate-execution/protected-redaction.ts"],"sourcesContent":["import { createHmac, randomBytes } from 'node:crypto'\n\nimport {\n DEFAULT_REDACTION_RULES,\n REDACTION_VERSION,\n type RedactionRule,\n redactString,\n} from '@tangle-network/agent-eval'\n\nexport interface ProtectedRedactionReport {\n version: string\n redactionCount: number\n byRule: Record<string, number>\n}\n\nexport interface ProtectedTraceIdentity {\n readonly runId: string\n readonly tags: Readonly<Record<string, string>>\n}\n\nexport interface ProtectedRecordRedactor {\n record<T>(value: T): T\n query<T>(value: T): T\n identifier(value: string): string\n traceIdentity(trace: ProtectedTraceIdentity): ProtectedTraceIdentity\n report(): ProtectedRedactionReport\n}\n\n/** Create one execution-local namespace for identifiers changed by redaction. */\nexport function createProtectedRecordRedactor(\n protectedValues: readonly string[],\n): ProtectedRecordRedactor {\n const identityKey = randomBytes(32)\n const aggregate: ProtectedRedactionReport = {\n version: REDACTION_VERSION,\n redactionCount: 0,\n byRule: {},\n }\n\n const mergeReport = (report: ProtectedRedactionReport): void => {\n aggregate.version = report.version\n aggregate.redactionCount += report.redactionCount\n for (const [rule, count] of Object.entries(report.byRule)) {\n aggregate.byRule[rule] = (aggregate.byRule[rule] ?? 0) + count\n }\n }\n\n const redactScalar = <T>(value: T, record: boolean): T => {\n const redacted = redactProtectedValue(value, protectedValues)\n if (record) mergeReport(redacted.report)\n return redacted.value\n }\n\n const identifier = (value: string, record: boolean): string => {\n const redacted = redactScalar(value, record)\n if (redacted === value) return value\n const digest = createHmac('sha256', identityKey).update(value).digest('hex')\n return `${redacted}:hmac-sha256:${digest}`\n }\n\n const transform = <T>(value: T, record: boolean): T => {\n const transformed = transformProtectedRecord(\n value,\n undefined,\n record,\n redactScalar,\n identifier,\n ) as T\n assertNoProtectedEvidence(transformed, protectedValues)\n return transformed\n }\n\n return Object.freeze({\n record: <T>(value: T): T => transform(value, true),\n query: <T>(value: T): T => transform(value, false),\n identifier: (value: string): string => identifier(value, false),\n traceIdentity: (trace: ProtectedTraceIdentity): ProtectedTraceIdentity =>\n transform(trace, false),\n report: (): ProtectedRedactionReport => ({\n version: aggregate.version,\n redactionCount: aggregate.redactionCount,\n byRule: { ...aggregate.byRule },\n }),\n })\n}\n\n/** Redact protected values at the first persistence boundary, including object keys and bytes. */\nexport function redactProtectedValue<T>(\n value: T,\n protectedValues: readonly string[],\n): { value: T; report: ProtectedRedactionReport } {\n const report: ProtectedRedactionReport = {\n version: REDACTION_VERSION,\n redactionCount: 0,\n byRule: {},\n }\n const rules = protectedRedactionRules(protectedValues)\n const redacted = redactNode(value, protectedValues, rules, report) as T\n assertNoProtectedEvidence(redacted, protectedValues)\n return { value: redacted, report }\n}\n\nexport function redactProtectedReason(reason: string, protectedValues: readonly string[]): string {\n try {\n return redactProtectedValue(reason, protectedValues).value\n } catch {\n return 'candidate execution failed with a protected error'\n }\n}\n\nexport function assertNoProtectedEvidence(\n value: unknown,\n protectedValues: readonly string[],\n): void {\n if (value instanceof Uint8Array) {\n assertNoProtectedBytes(value, protectedValues)\n return\n }\n if (typeof value === 'string') {\n for (const protectedValue of protectedValueVariants(protectedValues)) {\n if (value.includes(protectedValue)) {\n throw new Error('protected value survived candidate evidence redaction')\n }\n }\n if (decodedBase64ContainsProtectedValue(value, protectedValues)) {\n throw new Error('base64 protected value survived candidate evidence redaction')\n }\n return\n }\n if (Array.isArray(value)) {\n for (const entry of value) assertNoProtectedEvidence(entry, protectedValues)\n return\n }\n if (value && typeof value === 'object') {\n for (const [key, entry] of Object.entries(value)) {\n assertNoProtectedEvidence(key, protectedValues)\n assertNoProtectedEvidence(entry, protectedValues)\n }\n }\n}\n\nexport function assertNoProtectedBytes(\n bytes: Uint8Array,\n protectedValues: readonly string[],\n): void {\n if (containsProtectedBytes(bytes, protectedValues)) {\n throw new Error('protected value survived candidate evidence byte redaction')\n }\n}\n\nfunction redactNode(\n value: unknown,\n protectedValues: readonly string[],\n rules: readonly RedactionRule[],\n report: ProtectedRedactionReport,\n): unknown {\n if (value instanceof Uint8Array) {\n if (containsProtectedBytes(value, protectedValues)) {\n recordRedaction(report, 'candidate-access-binary', 1)\n return Uint8Array.from(Buffer.from('[redacted:candidate-access-binary]', 'utf8'))\n }\n return Uint8Array.from(value)\n }\n if (typeof value === 'string') {\n if (decodedBase64ContainsProtectedValue(value, protectedValues)) {\n recordRedaction(report, 'candidate-access-binary', 1)\n return '[redacted:candidate-access-binary]'\n }\n const redacted = redactString(value, [...rules])\n for (const [rule, count] of Object.entries(redacted.report.byRule)) {\n recordRedaction(report, rule, count)\n }\n return redacted.output\n }\n if (Array.isArray(value)) {\n return value.map((entry) => redactNode(entry, protectedValues, rules, report))\n }\n if (value && typeof value === 'object') {\n const entries: Array<[string, unknown]> = []\n const seenKeys = new Set<string>()\n for (const [key, entry] of Object.entries(value)) {\n const redactedKey = redactNode(key, protectedValues, rules, report)\n if (typeof redactedKey !== 'string' || seenKeys.has(redactedKey)) {\n throw new Error('protected evidence redaction produced an ambiguous object key')\n }\n seenKeys.add(redactedKey)\n entries.push([redactedKey, redactNode(entry, protectedValues, rules, report)])\n }\n return Object.fromEntries(entries)\n }\n return value\n}\n\nfunction transformProtectedRecord(\n value: unknown,\n fieldName: string | undefined,\n record: boolean,\n redactScalar: <T>(value: T, record: boolean) => T,\n redactIdentifier: (value: string, record: boolean) => string,\n): unknown {\n if (value instanceof Uint8Array) return redactScalar(value, record)\n if (typeof value === 'string') {\n return fieldName && isIdentifierFieldName(fieldName)\n ? redactIdentifier(value, record)\n : redactScalar(value, record)\n }\n if (Array.isArray(value)) {\n return value.map((entry) =>\n transformProtectedRecord(entry, fieldName, record, redactScalar, redactIdentifier),\n )\n }\n if (!value || typeof value !== 'object') return value\n\n if (fieldName === 'tags') {\n return transformTagMap(value, record, redactScalar, redactIdentifier)\n }\n if (fieldName === 'tag') {\n return transformTagFilter(value, record, redactScalar, redactIdentifier)\n }\n\n const entries: Array<[string, unknown]> = []\n const seenKeys = new Set<string>()\n for (const [key, entry] of Object.entries(value)) {\n const redactedKey = redactScalar(key, record)\n if (seenKeys.has(redactedKey)) {\n throw new Error('protected evidence redaction produced an ambiguous object key')\n }\n seenKeys.add(redactedKey)\n entries.push([\n redactedKey,\n transformProtectedRecord(entry, key, record, redactScalar, redactIdentifier),\n ])\n }\n return Object.fromEntries(entries)\n}\n\nfunction transformTagMap(\n value: object,\n record: boolean,\n redactScalar: <T>(value: T, record: boolean) => T,\n redactIdentifier: (value: string, record: boolean) => string,\n): Record<string, unknown> {\n const entries: Array<[string, unknown]> = []\n const seenKeys = new Set<string>()\n for (const [key, entry] of Object.entries(value)) {\n const redactedKey = redactIdentifier(key, record)\n if (seenKeys.has(redactedKey)) {\n throw new Error('protected evidence redaction produced an ambiguous trace tag')\n }\n seenKeys.add(redactedKey)\n entries.push([\n redactedKey,\n typeof entry === 'string'\n ? redactIdentifier(entry, record)\n : transformProtectedRecord(entry, key, record, redactScalar, redactIdentifier),\n ])\n }\n return Object.fromEntries(entries)\n}\n\nfunction transformTagFilter(\n value: object,\n record: boolean,\n redactScalar: <T>(value: T, record: boolean) => T,\n redactIdentifier: (value: string, record: boolean) => string,\n): Record<string, unknown> {\n const output: Record<string, unknown> = {}\n for (const [key, entry] of Object.entries(value)) {\n const redactedKey = redactScalar(key, record)\n output[redactedKey] =\n (key === 'key' || key === 'value') && typeof entry === 'string'\n ? redactIdentifier(entry, record)\n : transformProtectedRecord(entry, key, record, redactScalar, redactIdentifier)\n }\n return output\n}\n\nfunction isIdentifierFieldName(name: string): boolean {\n return /ids?$/i.test(name)\n}\n\nfunction protectedRedactionRules(protectedValues: readonly string[]): RedactionRule[] {\n const exactRules = protectedValueVariants(protectedValues)\n .sort((left, right) => right.length - left.length || left.localeCompare(right))\n .map((value, index) => ({\n id: `candidate-access-${index}`,\n pattern: new RegExp(escapeRegularExpression(value), 'g'),\n replacement: '[redacted:candidate-access]',\n }))\n return [...exactRules, ...DEFAULT_REDACTION_RULES]\n}\n\nfunction recordRedaction(report: ProtectedRedactionReport, rule: string, count: number): void {\n if (count <= 0) return\n report.redactionCount += count\n report.byRule[rule] = (report.byRule[rule] ?? 0) + count\n}\n\nfunction containsProtectedBytes(bytes: Uint8Array, protectedValues: readonly string[]): boolean {\n const source = Buffer.from(bytes)\n return protectedValueVariants(protectedValues).some((value) =>\n source.includes(Buffer.from(value, 'utf8')),\n )\n}\n\nfunction decodedBase64ContainsProtectedValue(\n value: string,\n protectedValues: readonly string[],\n): boolean {\n if (value.length < 4 || value.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(value)) {\n return false\n }\n try {\n return containsProtectedBytes(Buffer.from(value, 'base64'), protectedValues)\n } catch {\n return false\n }\n}\n\nfunction protectedValueVariants(protectedValues: readonly string[]): string[] {\n const variants = new Set<string>()\n for (const value of normalizedProtectedValues(protectedValues)) {\n variants.add(value)\n variants.add(Buffer.from(value, 'utf8').toString('base64'))\n variants.add(Buffer.from(value, 'utf8').toString('base64url'))\n variants.add(encodeURIComponent(value))\n }\n return [...variants]\n}\n\nfunction normalizedProtectedValues(values: readonly string[]): string[] {\n return [...new Set(values.filter((value) => value.length > 0))]\n}\n\nfunction escapeRegularExpression(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n"],"mappings":";;;;AA6BA,SAAgB,8BACd,iBACyB;CACzB,MAAM,cAAc,YAAY,EAAE;CAClC,MAAM,YAAsC;EAC1C,SAAS;EACT,gBAAgB;EAChB,QAAQ,CAAC;CACX;CAEA,MAAM,eAAe,WAA2C;EAC9D,UAAU,UAAU,OAAO;EAC3B,UAAU,kBAAkB,OAAO;EACnC,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,OAAO,MAAM,GACtD,UAAU,OAAO,SAAS,UAAU,OAAO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c,OAAqB;CAC5F,IAAI,SAAS,GAAG;CAChB,OAAO,kBAAkB;CACzB,OAAO,OAAO,SAAS,OAAO,OAAO,SAAS,KAAK;AACrD;AAEA,SAAS,uBAAuB,OAAmB,iBAA6C;CAC9F,MAAM,SAAS,OAAO,KAAK,KAAK;CAChC,OAAO,uBAAuB,eAAe,CAAC,CAAC,MAAM,UACnD,OAAO,SAAS,OAAO,KAAK,OAAO,MAAM,CAAC,CAC5C;AACF;AAEA,SAAS,oCACP,OACA,iBACS;CACT,IAAI,MAAM,SAAS,KAAK,MAAM,SAAS,MAAM,KAAK,CAAC,yBAAyB,KAAK,KAAK,GACpF,OAAO;CAET,IAAI;EACF,OAAO,uBAAuB,OAAO,KAAK,OAAO,QAAQ,GAAG,eAAe;CAC7E,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,uBAAuB,iBAA8C;CAC5E,MAAM,2BAAW,IAAI,IAAY;CACjC,KAAK,MAAM,SAAS,0BAA0B,eAAe,GAAG;EAC9D,SAAS,IAAI,KAAK;EAClB,SAAS,IAAI,OAAO,KAAK,OAAO,MAAM,CAAC,CAAC,SAAS,QAAQ,CAAC;EAC1D,SAAS,IAAI,OAAO,KAAK,OAAO,MAAM,CAAC,CAAC,SAAS,WAAW,CAAC;EAC7D,SAAS,IAAI,mBAAmB,KAAK,CAAC;CACxC;CACA,OAAO,CAAC,GAAG,QAAQ;AACrB;AAEA,SAAS,0BAA0B,QAAqC;CACtE,OAAO,CAAC,GAAG,IAAI,IAAI,OAAO,QAAQ,UAAU,MAAM,SAAS,CAAC,CAAC,CAAC;AAChE;AAEA,SAAS,wBAAwB,OAAuB;CACtD,OAAO,MAAM,QAAQ,uBAAuB,MAAM;AACpD"}
@@ -0,0 +1,82 @@
1
+ //#region src/redact.ts
2
+ const redactedMarker = "[redacted]";
3
+ /** Secret-bearing key names: when an object key matches, its value is fully
4
+ * replaced regardless of the value's own content. Lowercased compare. */
5
+ const secretKeyPattern = /(api[-_]?key|secret|token|password|passwd|authorization|auth|private[-_]?key|credential|access[-_]?key|client[-_]?secret|session[-_]?(id|token)|cookie|bearer)/i;
6
+ /** In-value secret/PII patterns scrubbed from any string, regardless of key. */
7
+ const valuePatterns = [
8
+ /\bBearer\s+[A-Za-z0-9._\-+/=]{8,}/gi,
9
+ /\b(?:sk|pk|rk|ak)[-_][A-Za-z0-9_-]{12,}/g,
10
+ /\bgh[pousr]_[A-Za-z0-9]{20,}/g,
11
+ /\bAKIA[0-9A-Z]{16}\b/g,
12
+ /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g,
13
+ /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g
14
+ ];
15
+ /** Secret assignments embedded inside an otherwise opaque string, including
16
+ * serialized JSON and log-style `key=value` text. */
17
+ const secretAssignmentPattern = /((?:"|')?(?:api[-_]?key|secret|token|password|passwd|authorization|auth|private[-_]?key|credential|access[-_]?key|client[-_]?secret|session[-_]?(?:id|token)|cookie|bearer)(?:"|')?\s*[:=]\s*)(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[^\s,;}]+)/gi;
18
+ /** Scrub a single string of in-value secret/PII patterns. */
19
+ function scrubString(input) {
20
+ let out = input;
21
+ for (const pattern of valuePatterns) out = out.replace(pattern, redactedMarker);
22
+ return out.replace(secretAssignmentPattern, `$1${redactedMarker}`);
23
+ }
24
+ /**
25
+ * The built-in redactor. Walks objects and arrays; replaces values under
26
+ * secret-bearing keys wholesale; scrubs in-value patterns from every string.
27
+ * Cycle-safe (a seen-set short-circuits self-referential payloads to
28
+ * `'[circular]'`), depth-bounded, and total — never throws on customer input.
29
+ */
30
+ function defaultRedactor(value) {
31
+ return walk(value, /* @__PURE__ */ new WeakSet(), 0);
32
+ }
33
+ const maxDepth = 32;
34
+ function walk(value, seen, depth) {
35
+ if (depth > maxDepth) return "[truncated]";
36
+ if (typeof value === "string") return scrubString(value);
37
+ if (value === null || typeof value !== "object") return value;
38
+ if (seen.has(value)) return "[circular]";
39
+ seen.add(value);
40
+ if (Array.isArray(value)) return value.map((item) => walk(item, seen, depth + 1));
41
+ const out = {};
42
+ for (const [key, v] of Object.entries(value)) {
43
+ if (secretKeyPattern.test(key)) {
44
+ out[key] = redactedMarker;
45
+ continue;
46
+ }
47
+ out[key] = walk(v, seen, depth + 1);
48
+ }
49
+ return out;
50
+ }
51
+ /** Stable identity input for saved work that depends on built-in redaction behavior. */
52
+ function defaultRedactorIdentityMaterial() {
53
+ const patternIdentity = (pattern) => ({
54
+ source: pattern.source,
55
+ flags: pattern.flags
56
+ });
57
+ return {
58
+ marker: redactedMarker,
59
+ secretKeyPattern: patternIdentity(secretKeyPattern),
60
+ valuePatterns: valuePatterns.map(patternIdentity),
61
+ secretAssignmentPattern: patternIdentity(secretAssignmentPattern),
62
+ maxDepth,
63
+ scrubString: Function.prototype.toString.call(scrubString),
64
+ walk: Function.prototype.toString.call(walk),
65
+ defaultRedactor: Function.prototype.toString.call(defaultRedactor)
66
+ };
67
+ }
68
+ /**
69
+ * Resolve the redactor a client uses. A caller-supplied hook handles
70
+ * domain-specific values first, then the built-in scrubber still removes
71
+ * common credentials and email addresses. Returning `false` is the explicit
72
+ * opt-out for already-reviewed public values.
73
+ */
74
+ function resolveRedactor(redact) {
75
+ if (redact === false) return (value) => value;
76
+ if (!redact) return defaultRedactor;
77
+ return (value) => defaultRedactor(redact(value));
78
+ }
79
+ //#endregion
80
+ export { defaultRedactorIdentityMaterial as n, resolveRedactor as r, defaultRedactor as t };
81
+
82
+ //# sourceMappingURL=redact-D-u-rrcn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redact-D-u-rrcn.js","names":[],"sources":["../src/redact.ts"],"sourcesContent":["/**\n *\n * Redaction for values that may leave the Runtime process. The default scrubs\n * common leak classes (API keys, bearer tokens, emails, private keys) from\n * strings and walks nested objects and arrays. A customer with domain-specific\n * PII supplies their own `redact` hook.\n *\n * This is intentionally narrower than `src/sanitize.ts` (which redacts the\n * runtime's *event envelope* field-by-field): here the value is opaque\n * customer payload, so the scrub is value-shaped, not schema-shaped.\n *\n * @experimental\n */\n\n/** A redactor maps an arbitrary trace value to a safe-to-export value. Pure;\n * must not throw on cyclic input (the default tolerates cycles). */\nexport type Redactor = (value: unknown) => unknown\n\nconst redactedMarker = '[redacted]'\n\n/** Secret-bearing key names: when an object key matches, its value is fully\n * replaced regardless of the value's own content. Lowercased compare. */\nconst secretKeyPattern =\n /(api[-_]?key|secret|token|password|passwd|authorization|auth|private[-_]?key|credential|access[-_]?key|client[-_]?secret|session[-_]?(id|token)|cookie|bearer)/i\n\n/** In-value secret/PII patterns scrubbed from any string, regardless of key. */\nconst valuePatterns: ReadonlyArray<RegExp> = [\n // Bearer tokens.\n /\\bBearer\\s+[A-Za-z0-9._\\-+/=]{8,}/gi,\n // Provider-style API keys (sk-..., sk-tan-..., pk_live_..., ghp_...).\n /\\b(?:sk|pk|rk|ak)[-_][A-Za-z0-9_-]{12,}/g,\n /\\bgh[pousr]_[A-Za-z0-9]{20,}/g,\n // AWS access key ids.\n /\\bAKIA[0-9A-Z]{16}\\b/g,\n // PEM private-key blocks.\n /-----BEGIN [A-Z ]*PRIVATE KEY-----[\\s\\S]*?-----END [A-Z ]*PRIVATE KEY-----/g,\n // Email addresses.\n /\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}\\b/g,\n]\n\n/** Secret assignments embedded inside an otherwise opaque string, including\n * serialized JSON and log-style `key=value` text. */\nconst secretAssignmentPattern =\n /((?:\"|')?(?:api[-_]?key|secret|token|password|passwd|authorization|auth|private[-_]?key|credential|access[-_]?key|client[-_]?secret|session[-_]?(?:id|token)|cookie|bearer)(?:\"|')?\\s*[:=]\\s*)(?:\"(?:\\\\.|[^\"\\\\])*\"|'(?:\\\\.|[^'\\\\])*'|[^\\s,;}]+)/gi\n\n/** Scrub a single string of in-value secret/PII patterns. */\nfunction scrubString(input: string): string {\n let out = input\n for (const pattern of valuePatterns) {\n out = out.replace(pattern, redactedMarker)\n }\n return out.replace(secretAssignmentPattern, `$1${redactedMarker}`)\n}\n\n/**\n * The built-in redactor. Walks objects and arrays; replaces values under\n * secret-bearing keys wholesale; scrubs in-value patterns from every string.\n * Cycle-safe (a seen-set short-circuits self-referential payloads to\n * `'[circular]'`), depth-bounded, and total — never throws on customer input.\n */\nexport function defaultRedactor(value: unknown): unknown {\n return walk(value, new WeakSet(), 0)\n}\n\nconst maxDepth = 32\n\nfunction walk(value: unknown, seen: WeakSet<object>, depth: number): unknown {\n if (depth > maxDepth) return '[truncated]'\n if (typeof value === 'string') return scrubString(value)\n if (value === null || typeof value !== 'object') return value\n if (seen.has(value)) return '[circular]'\n seen.add(value)\n\n if (Array.isArray(value)) {\n return value.map((item) => walk(item, seen, depth + 1))\n }\n\n const out: Record<string, unknown> = {}\n for (const [key, v] of Object.entries(value as Record<string, unknown>)) {\n if (secretKeyPattern.test(key)) {\n out[key] = redactedMarker\n continue\n }\n out[key] = walk(v, seen, depth + 1)\n }\n return out\n}\n\n/** Stable identity input for saved work that depends on built-in redaction behavior. */\nexport function defaultRedactorIdentityMaterial(): unknown {\n const patternIdentity = (pattern: RegExp) => ({\n source: pattern.source,\n flags: pattern.flags,\n })\n return {\n marker: redactedMarker,\n secretKeyPattern: patternIdentity(secretKeyPattern),\n valuePatterns: valuePatterns.map(patternIdentity),\n secretAssignmentPattern: patternIdentity(secretAssignmentPattern),\n maxDepth,\n scrubString: Function.prototype.toString.call(scrubString),\n walk: Function.prototype.toString.call(walk),\n defaultRedactor: Function.prototype.toString.call(defaultRedactor),\n }\n}\n\n/**\n * Resolve the redactor a client uses. A caller-supplied hook handles\n * domain-specific values first, then the built-in scrubber still removes\n * common credentials and email addresses. Returning `false` is the explicit\n * opt-out for already-reviewed public values.\n */\nexport function resolveRedactor(redact: Redactor | false | undefined): Redactor {\n if (redact === false) return (value) => value\n if (!redact) return defaultRedactor\n return (value) => defa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U,SAAS,KAAK,WAAW;EACzD,MAAM,SAAS,UAAU,SAAS,KAAK,IAAI;EAC3C,iBAAiB,SAAS,UAAU,SAAS,KAAK,eAAe;CACnE;AACF;;;;;;;AAQA,SAAgB,gBAAgB,QAAgD;CAC9E,IAAI,WAAW,OAAO,QAAQ,UAAU;CACxC,IAAI,CAAC,QAAQ,OAAO;CACpB,QAAQ,UAAU,gBAAgB,OAAO,KAAK,CAAC;AACjD"}
@@ -0,0 +1,452 @@
1
+ import { a as LocalHarnessResult, c as runLocalHarness, i as LocalHarness, r as CodexTokenUsage, t as CodexExecutionEvidence } from "./local-harness-Dh8PJ0ot.js";
2
+ import { AnalystFinding, CostLedgerHandle, MaximumCharge } from "@tangle-network/agent-eval";
3
+ import { CompareOptimizationMethodsOptions, LabeledScenarioStore, OptimizationMethod, OptimizationMethodComparison, WorktreeAdapter } from "@tangle-network/agent-eval/campaign";
4
+ import { AgentProfile as AgentProfile$1, ReasoningEffort, Sha256Digest } from "@tangle-network/agent-interface";
5
+ import { MutableSurface, Scenario as Scenario$1, SelfImproveBudget, SelfImproveOptions, SelfImproveResult } from "@tangle-network/agent-eval/contract";
6
+ //#region src/improvement/improvement-driver.d.ts
7
+ /** The byte-producing seam — the ONE thing that differs between the cheap
8
+ * reflective path and the full agentic path. A generator makes (uncommitted)
9
+ * changes inside `worktreePath`; the driver commits them via the worktree
10
+ * adapter's `finalize`. */
11
+ interface CandidateGenerator {
12
+ kind: string;
13
+ /** Whether this generator can produce a candidate from an EMPTY findings set
14
+ * and no phase-2 report — i.e. it draws its change signal from the repo and
15
+ * the raw-trace filesystem context on disk, not only from pre-summarized
16
+ * findings. An agentic coder (`agenticGenerator`) sets this: the seed repo +
17
+ * raw traces ARE the signal, so it must still run the full `populationSize`
18
+ * when the distiller yielded nothing (this is the meta-harness contract — the
19
+ * agent diagnoses from the raw traces itself). A patch-applier
20
+ * (`reflectiveGenerator`) leaves it unset — with no findings there is no
21
+ * patch to draft, so the driver short-circuits rather than spin up worktrees
22
+ * for a guaranteed no-op. Default `false`. */
23
+ proposesWithoutFindings?: boolean;
24
+ generate(args: {
25
+ /** The candidate worktree — a clean checkout of the current incumbent. */
26
+ worktreePath: string;
27
+ /** Phase-2 research report (analyst findings + diff), opaque. */
28
+ report: unknown;
29
+ /** Findings resolved from the report or the loop context. */
30
+ findings: AnalystFinding[];
31
+ /** Handle to all captured data, to ground the change. */
32
+ dataset?: LabeledScenarioStore;
33
+ /** DEPTH: max iterations the generator may take (agentic uses this; the
34
+ * reflective generator ignores it). */
35
+ maxShots: number;
36
+ signal: AbortSignal;
37
+ /** Generation coordinates supplied by Runtime's internal code candidate driver. */
38
+ generation?: number;
39
+ candidateIndex?: number;
40
+ /** Shared run-wide paid-call account supplied by agent-eval 0.117+. */
41
+ costLedger?: CostLedgerHandle;
42
+ /** Receipt attribution phase supplied alongside `costLedger`. */
43
+ costPhase?: string;
44
+ }): Promise<{
45
+ applied: boolean;
46
+ summary: string;
47
+ /** Short slug for the candidate. When present (with `rationale`), the
48
+ * driver returns a `ProposedCandidate` wrapper so the label survives to
49
+ * `GenerationRecord` and the emitted provenance. */
50
+ label?: string;
51
+ /** Why this change was proposed — bounded, derived from the findings the
52
+ * shot addressed. Paired with `label`. */
53
+ rationale?: string;
54
+ }>;
55
+ }
56
+ //#endregion
57
+ //#region src/improvement/agentic-generator.d.ts
58
+ /** Dedicated ephemeral root for generic author-profile files. Every declared
59
+ * file must live below this root so cleanup cannot alter candidate-owned files. */
60
+ declare const AGENTIC_PROFILE_RESOURCE_ROOT = ".agent-runtime-profile-resources";
61
+ /** Outcome of verifying a candidate worktree. `feedback` (compiler errors,
62
+ * failing test output) is fed into the next shot when `ok` is false. */
63
+ interface VerifyResult {
64
+ ok: boolean;
65
+ feedback?: string;
66
+ }
67
+ /** Verifies the edited worktree. Sync or async; throws only on a setup fault
68
+ * (a candidate that fails verification returns `{ok:false}`, it does not
69
+ * throw). */
70
+ type Verifier = (worktreePath: string, signal?: AbortSignal) => Promise<VerifyResult> | VerifyResult;
71
+ interface AgenticGeneratorShotReceipt {
72
+ readonly generation: number | null;
73
+ readonly candidateIndex: number | null;
74
+ /** One-based shot number within this candidate. */
75
+ readonly shot: number;
76
+ readonly maxShots: number;
77
+ readonly harness: LocalHarness;
78
+ readonly model: string | null;
79
+ readonly reasoningEffort: ReasoningEffort | null;
80
+ readonly promptSha256: `sha256:${string}`;
81
+ readonly startedAt: string;
82
+ readonly completedAt: string;
83
+ readonly durationMs: number;
84
+ readonly exitCode: number | null;
85
+ readonly timedOut: boolean;
86
+ /** True when caller cancellation reached the author process; absent in older receipts. */
87
+ readonly aborted?: boolean;
88
+ readonly killedBySignal: NodeJS.Signals | null;
89
+ readonly stdoutBytes: number | null;
90
+ readonly stdoutSha256: `sha256:${string}` | null;
91
+ readonly stderrBytes: number | null;
92
+ readonly stderrSha256: `sha256:${string}` | null;
93
+ readonly usage: CodexTokenUsage | null;
94
+ /** Digest of the exact profile-file workspace plan applied for this shot. */
95
+ readonly profileWorkspacePlanDigest: string | null;
96
+ readonly profileWorkspaceFileCount: number;
97
+ /** Shared run-ledger call id for this exact shot. */
98
+ readonly costCallId: string | null;
99
+ /** Whether dollars came from the provider, the pricing table, or are unknown. */
100
+ readonly costBasis: 'provider-reported' | 'estimated-pricing' | 'unknown';
101
+ readonly costUsd: number | null;
102
+ /** True only for a provider-reported amount, never for a pricing estimate. */
103
+ readonly costUsdKnown: boolean;
104
+ readonly evidence: CodexExecutionEvidence | null;
105
+ readonly error: {
106
+ readonly name: string;
107
+ readonly message: string;
108
+ } | null;
109
+ }
110
+ /** Frozen exact harness result for an author shot: full streams, process state,
111
+ * token usage, and execution-policy evidence.
112
+ * The `onShotCompleted` callback receives `null` when execution failed before
113
+ * the harness returned. */
114
+ type AgenticGeneratorShotExecution = Readonly<Omit<LocalHarnessResult, 'usage' | 'evidence'> & {
115
+ readonly usage?: Readonly<CodexTokenUsage>;
116
+ readonly evidence?: Readonly<Omit<CodexExecutionEvidence, 'readDeniedPaths' | 'policy'>> & {
117
+ readonly readDeniedPaths: ReadonlyArray<string>;
118
+ readonly policy: Readonly<CodexExecutionEvidence['policy']>;
119
+ };
120
+ }>;
121
+ /** Worktree decision emitted before a completed shot is retried, accepted, or
122
+ * discarded. The callback runs while `worktreePath` is still available, so
123
+ * callers can persist the exact diff. */
124
+ type AgenticGeneratorShotDisposition = {
125
+ readonly kind: 'clean';
126
+ readonly worktreePath: string;
127
+ } | {
128
+ readonly kind: 'rejected';
129
+ readonly worktreePath: string;
130
+ readonly stage: 'raw-trace-evidence' | 'verification';
131
+ readonly feedback: string | null;
132
+ } | {
133
+ readonly kind: 'accepted';
134
+ readonly worktreePath: string;
135
+ readonly verified: boolean;
136
+ } | {
137
+ readonly kind: 'setup-error';
138
+ readonly worktreePath: string;
139
+ readonly stage: 'worktree-inspection' | 'raw-trace-evidence' | 'verification';
140
+ readonly error: {
141
+ readonly name: string;
142
+ readonly message: string;
143
+ };
144
+ };
145
+ interface AgenticGeneratorOptions {
146
+ /** Local coding harness to run in the worktree. Default `claude`. */
147
+ harness?: LocalHarness;
148
+ /** Author profile rendered through the canonical harness mapper. Required
149
+ * for reproducible Codex so model and reasoning settings are explicit. */
150
+ profile?: AgentProfile$1;
151
+ /** Run Codex with isolated configuration, exact prompt evidence, and required
152
+ * terminal token usage. Requires `harness: 'codex'` and `profile`. */
153
+ codexReproducible?: boolean;
154
+ /** Absolute paths reproducible Codex must not read. A function can derive
155
+ * candidate-specific paths after the driver creates its worktree. */
156
+ codexReadDeniedPaths?: ReadonlyArray<string> | ((worktreePath: string) => ReadonlyArray<string>);
157
+ /** Awaited once for every attempted author shot, including process failures.
158
+ * The second argument preserves the exact harness result, including stdout
159
+ * and stderr, before worktree inspection or verification can reject the
160
+ * shot. Throwing aborts the candidate so evidence persistence fails closed. */
161
+ onShotCompleted?: (receipt: AgenticGeneratorShotReceipt, execution: AgenticGeneratorShotExecution | null) => void | Promise<void>;
162
+ /** Awaited after worktree inspection and before the shot is accepted,
163
+ * retried, or discarded. Throwing aborts the candidate. */
164
+ onShotDisposition?: (receipt: AgenticGeneratorShotReceipt, disposition: AgenticGeneratorShotDisposition) => void | Promise<void>;
165
+ /** Optional hard upper bound passed to the run-wide CostLedger before each
166
+ * author shot. This MUST be enforced by the provider or executor; a planning
167
+ * estimate is not an admissible bound. Omit for an uncapped ledger. A capped
168
+ * ledger rejects before model dispatch when this is absent. */
169
+ maximumCharge?: MaximumCharge;
170
+ /** Per-shot wall-clock timeout (ms). Default = `runLocalHarness` default (5m). */
171
+ timeoutMs?: number;
172
+ /** Build the harness task prompt from the report + findings. Override for
173
+ * domain phrasing; the default turns findings into a concrete coder task. */
174
+ buildPrompt?: (args: {
175
+ report: unknown;
176
+ findings: AnalystFinding[];
177
+ }) => string;
178
+ /** Verify the worktree after each dirtying shot. When set, a candidate that
179
+ * fails verification is NOT returned — the failure feeds the next shot
180
+ * (verify-in-session), up to `maxShots`; a candidate that never verifies is
181
+ * discarded (`applied:false`), never shipped. Omitted ⇒ legacy behavior:
182
+ * the first dirty shot is the candidate. See `commandVerifier`. */
183
+ verify?: Verifier;
184
+ /** Test seam — inject the harness runner (defaults to `runLocalHarness`). */
185
+ runHarness?: typeof runLocalHarness;
186
+ /** Test seam — inject the worktree-dirty check (defaults to `git status`). */
187
+ isDirty?: (worktreePath: string) => boolean;
188
+ }
189
+ /** Full-agentic `CandidateGenerator` (the `shots=N, sandbox=on` setting): run a real coding harness inside the candidate worktree so the agent makes the change in place. */
190
+ declare function agenticGenerator(opts?: AgenticGeneratorOptions): CandidateGenerator;
191
+ /** Turn the analyst's findings (+ optional report) into a concrete coder task —
192
+ * the senior scientific-method framing shared with the tool/MCP build prompts. */
193
+ declare function defaultBuildPrompt(args: {
194
+ report: unknown;
195
+ findings: AnalystFinding[];
196
+ }): string;
197
+ /** A `Verifier` that runs a command in the worktree: exit 0 ⇒ ok, any other
198
+ * exit ⇒ failed with stdout+stderr as feedback. The common case — verify by
199
+ * `tsc --noEmit`, `pnpm build`, or a test command. A timeout is treated as a
200
+ * FAILED candidate (a change that hangs the build is a bad change); a missing
201
+ * binary or spawn fault throws (a setup bug, not a failed candidate — no
202
+ * silent fallback). */
203
+ declare function commandVerifier(command: string, args?: string[], timeoutMs?: number): Verifier;
204
+ //#endregion
205
+ //#region src/improvement/profile-types.d.ts
206
+ type DeepReadonly<T> = T extends ((...args: never[]) => unknown) ? T : T extends readonly (infer TItem)[] ? readonly DeepReadonly<TItem>[] : T extends object ? { readonly [TKey in keyof T]: DeepReadonly<T[TKey]>; } : T;
207
+ /** Complete immutable profile value used during measured execution. */
208
+ type ReadonlyAgentProfile = DeepReadonly<AgentProfile$1>;
209
+ //#endregion
210
+ //#region src/improvement/improve-types.d.ts
211
+ /** The executable agent lever `improve` optimizes. Profile fields remain
212
+ * portable AgentProfile coordinates; implementation and orchestration files
213
+ * use the code surface so a winner can be sealed into an exact candidate.
214
+ * `rollout-policy` is the inference-time structuralRollout dials
215
+ * (`profile.extensions['structural-rollout']`). */
216
+ type ImproveSurface = 'prompt' | 'skills' | 'tools' | 'mcp' | 'hooks' | 'subagents' | 'agent-profile' | 'memory' | 'code' | 'rollout-policy';
217
+ type ImproveProfileSurface = Exclude<ImproveSurface, 'code'>;
218
+ interface ImproveMethodContext {
219
+ /** Validated baseline profile. */
220
+ readonly profile: ReadonlyAgentProfile;
221
+ /** Runtime-derived identity for upstream optimizer resume state. */
222
+ readonly evaluationRef: Sha256Digest;
223
+ /** Exact profile coordinate being optimized. */
224
+ readonly surface: ImproveProfileSurface;
225
+ /** Exact bytes supplied to the optimization method. */
226
+ readonly baselineSurface: MutableSurface;
227
+ /** Structured value represented by `baselineSurface`, before serialization. */
228
+ readonly baselineValue: unknown;
229
+ /** Findings produced before this search, if any. */
230
+ readonly findings: readonly unknown[];
231
+ }
232
+ /** Build a complete method after trace findings are available. */
233
+ type ImproveMethodFactory<TScenario extends Scenario$1, TArtifact> = (context: ImproveMethodContext) => OptimizationMethod<TScenario, TArtifact>;
234
+ type ImproveMethodSource<TScenario extends Scenario$1, TArtifact> = OptimizationMethod<TScenario, TArtifact> | ImproveMethodFactory<TScenario, TArtifact>;
235
+ /** Runs one exact materialized profile on one scenario. */
236
+ type ImproveProfileAgent<TScenario extends Scenario$1, TArtifact> = (profile: ReadonlyAgentProfile, scenario: TScenario, ctx: Parameters<CompareOptimizationMethodsOptions<TScenario, TArtifact>['dispatchWithSurface']>[2]) => Promise<TArtifact>;
237
+ /** Exact materialized profile presented for validation before any candidate run. */
238
+ interface ImproveCandidateValidationInput {
239
+ profile: ReadonlyAgentProfile;
240
+ surface: ImproveProfileSurface;
241
+ candidateSurface: MutableSurface;
242
+ value: unknown;
243
+ isBaseline: boolean;
244
+ }
245
+ type ImproveCandidateValidator = (input: ImproveCandidateValidationInput) => void;
246
+ type ImproveOptimizationRunOptions<TScenario extends Scenario$1, TArtifact> = Omit<NonNullable<CompareOptimizationMethodsOptions<TScenario, TArtifact>['optimizationRunOptions']>, 'dispatchRef'>;
247
+ /** Complete-method configuration for every non-code profile surface. */
248
+ type ImproveMethodOptions<TScenario extends Scenario$1, TArtifact> = Omit<CompareOptimizationMethodsOptions<TScenario, TArtifact>, 'baselineSurface' | 'dispatchRef' | 'dispatchWithSurface' | 'methods' | 'optimizationConcurrency' | 'optimizationRunOptions'> & {
249
+ /** Exact profile coordinate optimized by `method`. Default `'prompt'`. */
250
+ surface?: ImproveProfileSurface;
251
+ /**
252
+ * Immutable digest of `agent`, profile component mapping, models, tools, and
253
+ * every closure or external setting that can change measured behavior.
254
+ */
255
+ executionRef: Sha256Digest;
256
+ /** A complete optimizer or a factory that can incorporate current findings. */
257
+ method: ImproveMethodSource<TScenario, TArtifact>;
258
+ /** Runs the exact complete profile materialized from one candidate surface. */
259
+ agent: ImproveProfileAgent<TScenario, TArtifact>;
260
+ /** Reject a materialized profile before it reaches the agent callback. */
261
+ validateCandidate?: ImproveCandidateValidator;
262
+ /** Trace or analyst findings available to a method factory. */
263
+ findings?: readonly unknown[];
264
+ /** Select the exact inline skill document for `surface: 'skills'`. */
265
+ skills?: ImproveSkillsOptions;
266
+ /**
267
+ * Map a profile to named text components and apply the winning components.
268
+ * Valid only with `surface: 'agent-profile'`.
269
+ */
270
+ profileComponents?: ImproveProfileComponents;
271
+ /** Shared settings for method train and selection calls. */
272
+ optimizationRunOptions?: ImproveOptimizationRunOptions<TScenario, TArtifact>;
273
+ /** Ship only when the paired final-test interval is entirely above this lift. Default `0`. */
274
+ minimumLift?: number;
275
+ };
276
+ /** Runtime-owned code search in isolated git worktrees. */
277
+ type ImproveCodeRunOptions<TScenario extends Scenario$1, TArtifact> = Omit<SelfImproveOptions<TScenario, TArtifact>, 'analyzeGeneration' | 'baselineSurface' | 'budget' | 'findings' | 'gate' | 'llm' | 'method' | 'mutationPrimitives' | 'proposer' | 'proposerTarget' | 'selectionScenarios'> & {
278
+ surface: 'code';
279
+ /** Local code-search budget. Method-only selection controls do not apply. */
280
+ budget?: Omit<SelfImproveBudget, 'selectionFraction'>;
281
+ /** Findings supplied to Runtime's code candidate driver. */
282
+ findings?: readonly unknown[];
283
+ /** Gate mode. `'holdout'` (default) runs the held-out promotion gate;
284
+ * `'none'` is a baseline-only run (`budget.generations = 0`). */
285
+ gate?: 'holdout' | 'none';
286
+ /** Per-generation findings producer for Runtime's code search.
287
+ * Pass your own producer to replace the code-trace distiller; pass `null`
288
+ * to keep the static findings for every generation. */
289
+ analyzeGeneration?: SelfImproveOptions<TScenario, TArtifact>['analyzeGeneration'] | null;
290
+ /** Feed code candidates paths to prior raw traces instead of a failure digest.
291
+ * Defaults to true for durable runs and false for in-memory runs. */
292
+ rawTraceContext?: boolean;
293
+ /** Isolated repository and candidate generator settings. */
294
+ code: ImproveCodeOptions;
295
+ /** Custom held-back-exam decision. The string `gate` above controls whether
296
+ * the exam runs; this callback controls how its evidence decides promotion. */
297
+ promotionGate?: SelfImproveOptions<TScenario, TArtifact>['gate'];
298
+ };
299
+ /** The canonical improvement API: complete methods for profiles, worktrees for code. */
300
+ type ImproveOptions<TScenario extends Scenario$1, TArtifact> = ImproveMethodOptions<TScenario, TArtifact> | ImproveCodeRunOptions<TScenario, TArtifact>;
301
+ interface ImproveSkillsOptions {
302
+ /** `name` of one inline entry in `profile.resources.skills`. */
303
+ resourceName: string;
304
+ }
305
+ /** Caller-owned mapping for optimizing several profile fields as one candidate. */
306
+ interface ImproveProfileComponents {
307
+ /** Extract the exact named text components optimized together. */
308
+ read(profile: ReadonlyAgentProfile): Readonly<Record<string, string>>;
309
+ /** Apply a complete winning component map to a detached profile. */
310
+ apply(profile: ReadonlyAgentProfile, components: Readonly<Record<string, string>>): ReadonlyAgentProfile;
311
+ }
312
+ interface ImproveCodeOptions {
313
+ /** Repo root candidate worktrees fork from. */
314
+ repoRoot: string;
315
+ /** Base ref candidates fork from. Default `main`. */
316
+ baseRef?: string;
317
+ /** Directory worktrees are created under. Default `<repoRoot>/.worktrees`. */
318
+ worktreeDir?: string;
319
+ /** Git-compatible adapter override, primarily for tests. Candidate advancement
320
+ * still requires normal Git worktree and commit semantics. */
321
+ worktree?: WorktreeAdapter;
322
+ /** Coding harness the agentic generator runs in each worktree. Default `claude`. */
323
+ harness?: LocalHarness;
324
+ /** Verify a candidate worktree before it becomes a measurable surface; failures
325
+ * feed the next shot (see `agenticGenerator.verify` / `commandVerifier`). */
326
+ verify?: Verifier;
327
+ /** Per-shot wall-clock timeout for the harness (ms). */
328
+ timeoutMs?: number;
329
+ /** Byte-producer override, used for tests and custom candidate production.
330
+ * When set, `harness`, `verify`, and `timeoutMs` are unused. */
331
+ generator?: CandidateGenerator;
332
+ }
333
+ interface ImprovementProfileCandidate {
334
+ /** Surface searched by this run. */
335
+ surface: ImproveProfileSurface;
336
+ /** Exact winning value returned by agent-eval. */
337
+ value: MutableSurface;
338
+ /** Exact complete profile instance measured on the final cases. */
339
+ profile: ReadonlyAgentProfile;
340
+ }
341
+ interface ImprovementCodeCandidate {
342
+ surface: 'code';
343
+ value: MutableSurface;
344
+ profile?: never;
345
+ }
346
+ type ImprovementCandidate = ImprovementProfileCandidate | ImprovementCodeCandidate;
347
+ /** Normalized spend reported for one Runtime improvement run. */
348
+ interface ImproveCost {
349
+ totalCostUsd: number;
350
+ accountingComplete: boolean;
351
+ incompleteReasons: string[];
352
+ }
353
+ /** Optimizer ancestry sealed into downstream candidate experiments. */
354
+ interface ImproveLineage {
355
+ /** Unique Runtime invocation used to isolate this run's cost receipts. */
356
+ invocationId: string;
357
+ /** Upstream optimizer run when reported, otherwise this Runtime optimization invocation. */
358
+ runId: string;
359
+ /** Exact train-plus-selection scenario payloads exposed to candidate selection. */
360
+ developmentSplitDigest: Sha256Digest;
361
+ /** Complete callback, materializer, model, tool, and closure identity for a profile run. */
362
+ executionRef?: Sha256Digest;
363
+ /** Complete baseline profile identity for a profile run. */
364
+ baselineProfileDigest?: Sha256Digest;
365
+ }
366
+ interface ImproveResultBase<TCandidate extends ImprovementCandidate> {
367
+ /** Frozen candidate only. Live state is changed through an approved activation. */
368
+ candidate: TCandidate;
369
+ /** Final-test decision for this search result. */
370
+ decision: SelfImproveResult<Scenario$1, unknown>['gateDecision'];
371
+ /** Final-test lift when one was measured. */
372
+ lift?: number;
373
+ /** Paired final-test confidence interval for method-based profile runs. */
374
+ liftInterval?: {
375
+ low: number;
376
+ high: number;
377
+ };
378
+ /** Full search and final-test spend. */
379
+ cost: ImproveCost;
380
+ /** Full wall-clock duration. */
381
+ durationMs: number;
382
+ /** Optimizer ancestry used when sealing a candidate experiment. */
383
+ lineage: ImproveLineage;
384
+ /** Number of generations explored by Runtime's code path. */
385
+ generationsExplored?: number;
386
+ /** Release resources owned by this result. Idempotent; currently disposes
387
+ * the returned code worktree and is a no-op for profile-only surfaces. */
388
+ dispose(): Promise<void>;
389
+ }
390
+ interface ImproveMethodResult extends ImproveResultBase<ImprovementProfileCandidate> {
391
+ mode: 'method';
392
+ method: string;
393
+ /** External optimizer package and resumable run identity, when reported. */
394
+ provenance?: OptimizationMethodComparison['best']['provenance'];
395
+ decision: 'ship' | 'hold';
396
+ lift: number;
397
+ liftInterval: {
398
+ low: number;
399
+ high: number;
400
+ };
401
+ raw: OptimizationMethodComparison;
402
+ }
403
+ interface ImproveCodeResult<TScenario extends Scenario$1, TArtifact> extends ImproveResultBase<ImprovementCodeCandidate> {
404
+ mode: 'code';
405
+ raw: SelfImproveResult<TScenario, TArtifact>;
406
+ }
407
+ type ImproveResult<TScenario extends Scenario$1, TArtifact> = ImproveMethodResult | ImproveCodeResult<TScenario, TArtifact>;
408
+ //#endregion
409
+ //#region src/improvement/improve.d.ts
410
+ /**
411
+ * Optimize one exact profile surface with a complete method.
412
+ */
413
+ declare function improve<TScenario extends Scenario$1, TArtifact>(profile: AgentProfile$1, opts: ImproveMethodOptions<TScenario, TArtifact>): Promise<ImproveMethodResult>;
414
+ /**
415
+ * Optimize repository code through Runtime's isolated worktree path.
416
+ */
417
+ declare function improve<TScenario extends Scenario$1, TArtifact>(opts: ImproveCodeRunOptions<TScenario, TArtifact>): Promise<ImproveCodeResult<TScenario, TArtifact>>;
418
+ //#endregion
419
+ //#region src/redact.d.ts
420
+ /**
421
+ *
422
+ * Redaction for values that may leave the Runtime process. The default scrubs
423
+ * common leak classes (API keys, bearer tokens, emails, private keys) from
424
+ * strings and walks nested objects and arrays. A customer with domain-specific
425
+ * PII supplies their own `redact` hook.
426
+ *
427
+ * This is intentionally narrower than `src/sanitize.ts` (which redacts the
428
+ * runtime's *event envelope* field-by-field): here the value is opaque
429
+ * customer payload, so the scrub is value-shaped, not schema-shaped.
430
+ *
431
+ * @experimental
432
+ */
433
+ /** A redactor maps an arbitrary trace value to a safe-to-export value. Pure;
434
+ * must not throw on cyclic input (the default tolerates cycles). */
435
+ type Redactor = (value: unknown) => unknown;
436
+ /**
437
+ * The built-in redactor. Walks objects and arrays; replaces values under
438
+ * secret-bearing keys wholesale; scrubs in-value patterns from every string.
439
+ * Cycle-safe (a seen-set short-circuits self-referential payloads to
440
+ * `'[circular]'`), depth-bounded, and total — never throws on customer input.
441
+ */
442
+ declare function defaultRedactor(value: unknown): unknown;
443
+ /**
444
+ * Resolve the redactor a client uses. A caller-supplied hook handles
445
+ * domain-specific values first, then the built-in scrubber still removes
446
+ * common credentials and email addresses. Returning `false` is the explicit
447
+ * opt-out for already-reviewed public values.
448
+ */
449
+ declare function resolveRedactor(redact: Redactor | false | undefined): Redactor;
450
+ //#endregion
451
+ export { AGENTIC_PROFILE_RESOURCE_ROOT as A, CandidateGenerator as B, ImproveSkillsOptions as C, ImprovementProfileCandidate as D, ImprovementCodeCandidate as E, Verifier as F, VerifyResult as I, agenticGenerator as L, AgenticGeneratorShotDisposition as M, AgenticGeneratorShotExecution as N, DeepReadonly as O, AgenticGeneratorShotReceipt as P, commandVerifier as R, ImproveResult as S, ImprovementCandidate as T, ImproveOptimizationRunOptions as _, ImproveCandidateValidationInput as a, ImproveProfileComponents as b, ImproveCodeResult as c, ImproveLineage as d, ImproveMethodContext as f, ImproveMethodSource as g, ImproveMethodResult as h, improve as i, AgenticGeneratorOptions as j, ReadonlyAgentProfile as k, ImproveCodeRunOptions as l, ImproveMethodOptions as m, defaultRedactor as n, ImproveCandidateValidator as o, ImproveMethodFactory as p, resolveRedactor as r, ImproveCodeOptions as s, Redactor as t, ImproveCost as u, ImproveOptions as v, ImproveSurface as w, ImproveProfileSurface as x, ImproveProfileAgent as y, defaultBuildPrompt as z };
452
+ //# sourceMappingURL=redact-kbIOjfjM.d.ts.map