@kodax-ai/kodax 0.7.97-alpha.9 → 0.7.97-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +393 -0
- package/README.md +170 -29
- package/README_CN.md +116 -17
- package/config-templates/config.example.jsonc +2 -3
- package/dist/artifacts/skills/artifact-review/SKILL.md +44 -7
- package/dist/builtin/code-review/SKILL.md +5 -17
- package/dist/builtin/git-workflow/SKILL.md +9 -8
- package/dist/builtin/skill-creator/SKILL.md +38 -108
- package/dist/builtin/skill-creator/references/evaluation.md +50 -0
- package/dist/builtin/skill-creator/scripts/analyze-benchmark.d.ts +2 -0
- package/dist/builtin/skill-creator/scripts/analyze-benchmark.js +6 -3
- package/dist/builtin/skill-creator/scripts/compare-runs.d.ts +2 -0
- package/dist/builtin/skill-creator/scripts/compare-runs.js +6 -3
- package/dist/builtin/skill-creator/scripts/grade-evals.d.ts +2 -0
- package/dist/builtin/skill-creator/scripts/grade-evals.js +6 -3
- package/dist/builtin/skill-creator/scripts/run-eval.js +3 -3
- package/dist/builtin/skill-creator/scripts/run-loop.js +2 -1
- package/dist/builtin/skill-creator/scripts/run-trigger-eval.d.ts +2 -0
- package/dist/builtin/skill-creator/scripts/run-trigger-eval.js +3 -1
- package/dist/builtin/skill-creator/scripts/utils.d.ts +1 -1
- package/dist/builtin/skill-creator/scripts/utils.js +8 -0
- package/dist/builtin/tdd/SKILL.md +24 -40
- package/dist/builtin/visual-review/SKILL.md +7 -3
- package/dist/chunks/agent-DS7M57WD.js +2 -0
- package/dist/chunks/agent-adapter-TLWGGK3V.js +2 -0
- package/dist/chunks/argument-completer-OGCXKTRQ.js +2 -0
- package/dist/chunks/bedrock-native-Z5VNWF5U.js +4 -0
- package/dist/chunks/cell-LV7MNPNQ.js +2 -0
- package/dist/chunks/chunk-2HH5AS7E.js +1157 -0
- package/dist/chunks/chunk-3CP7AUWY.js +2 -0
- package/dist/chunks/chunk-45ZP2YHG.js +2 -0
- package/dist/chunks/chunk-4Y6U7AH4.js +9 -0
- package/dist/chunks/chunk-52EN2777.js +2 -0
- package/dist/chunks/{chunk-HXCY52Z2.js → chunk-53CJDQS2.js} +1 -1
- package/dist/chunks/{chunk-JNB2FL6P.js → chunk-5MUVRFMU.js} +1 -1
- package/dist/chunks/chunk-65652LR4.js +2 -0
- package/dist/chunks/chunk-6TITQQAI.js +351 -0
- package/dist/chunks/chunk-AGUM5SWX.js +2 -0
- package/dist/chunks/chunk-BBZWF2EA.js +2 -0
- package/dist/chunks/chunk-C6JGLEYD.js +2 -0
- package/dist/chunks/chunk-D36OIMV7.js +142 -0
- package/dist/chunks/chunk-D425EZGC.js +2 -0
- package/dist/chunks/chunk-D5OW7UD5.js +2 -0
- package/dist/chunks/chunk-DCE7XQUG.js +2 -0
- package/dist/chunks/chunk-DV5YPYLW.js +10 -0
- package/dist/chunks/chunk-EISRVOBJ.js +4 -0
- package/dist/chunks/chunk-EPK6EWRI.js +12 -0
- package/dist/chunks/chunk-F6GJXQNA.js +29 -0
- package/dist/chunks/chunk-GJXOTOZB.js +465 -0
- package/dist/chunks/chunk-GZUWQZJD.js +2 -0
- package/dist/chunks/chunk-I325ER7D.js +2 -0
- package/dist/chunks/chunk-ISLK6R2P.js +2 -0
- package/dist/chunks/chunk-J2L2NK6E.js +366 -0
- package/dist/chunks/chunk-JAF2YLZO.js +14 -0
- package/dist/chunks/chunk-KDLOPBFZ.js +2 -0
- package/dist/chunks/chunk-KDSO7V4O.js +5 -0
- package/dist/chunks/chunk-KE2NBMAP.js +20 -0
- package/dist/chunks/chunk-MCDZNQWD.js +634 -0
- package/dist/chunks/chunk-NSR4RW2F.js +3 -0
- package/dist/chunks/chunk-OGTRDK4Q.js +359 -0
- package/dist/chunks/chunk-P55RJIOG.js +18 -0
- package/dist/chunks/chunk-P7OJRV5Z.js +2 -0
- package/dist/chunks/chunk-QP47JIWP.js +3 -0
- package/dist/chunks/chunk-QSZCR5GC.js +190 -0
- package/dist/chunks/chunk-R2HTPDI7.js +2 -0
- package/dist/chunks/chunk-R42S4BLA.js +2 -0
- package/dist/chunks/chunk-RYBUYHDL.js +5 -0
- package/dist/chunks/chunk-SDPZFH6M.js +4 -0
- package/dist/chunks/chunk-SK3RRGHJ.js +142 -0
- package/dist/chunks/chunk-TQ475LOI.js +2 -0
- package/dist/chunks/chunk-UF3GZ5PO.js +2 -0
- package/dist/chunks/chunk-UL6YIT4M.js +2 -0
- package/dist/chunks/chunk-V2XJSFFE.js +19 -0
- package/dist/chunks/chunk-V4WSBIXB.js +2 -0
- package/dist/chunks/chunk-V5RCDBKU.js +2 -0
- package/dist/chunks/{chunk-FX4R5PB3.js → chunk-W2CWO4PQ.js} +1 -1
- package/dist/chunks/chunk-W33QJA3M.js +2 -0
- package/dist/chunks/chunk-WMMESRP3.js +9 -0
- package/dist/chunks/chunk-WWPVEK6B.js +127 -0
- package/dist/chunks/chunk-X5M7TLJV.js +2 -0
- package/dist/chunks/chunk-XDMNJW6J.js +42 -0
- package/dist/chunks/{chunk-L22BDZGE.js → chunk-XZSFUGPN.js} +1 -1
- package/dist/chunks/client-LTIFNED5.js +2 -0
- package/dist/chunks/compaction-config-ECMOFP5H.js +2 -0
- package/dist/chunks/{construction-bootstrap-XBHM6NON.js → construction-bootstrap-OAZKGI5Y.js} +1 -1
- package/dist/chunks/devtools-MVOFT6N7.js +2 -0
- package/dist/chunks/devtools-TXYDDL2A.js +2 -0
- package/dist/chunks/dist-5J53DGAO.js +2 -0
- package/dist/chunks/errors-ER7ZRPWC.js +2 -0
- package/dist/chunks/google-native-WLL27OV7.js +2 -0
- package/dist/chunks/host-65E5NM5P.js +2 -0
- package/dist/chunks/mistral-native-JXPIDDYZ.js +5 -0
- package/dist/chunks/model-DZF6URW3.js +2 -0
- package/dist/chunks/permission-YVVMLQ5I.js +2 -0
- package/dist/chunks/pi-messages-5LLOZH57.js +16 -0
- package/dist/chunks/readline-helpers-UZXWBRXQ.js +2 -0
- package/dist/chunks/responses-websocket-Y4N5GXD3.js +2 -0
- package/dist/chunks/run-manager-ZFACIZM2.js +2 -0
- package/dist/chunks/running-session-Q5Y6A2QV.js +2 -0
- package/dist/chunks/skills-TJP6BLZJ.js +2 -0
- package/dist/chunks/tool-dispatch-MLM3QTSU.js +2 -0
- package/dist/chunks/utils-2QNMYRGA.js +2 -0
- package/dist/generated-config-templates.json +6 -0
- package/dist/index.d.ts +34 -32
- package/dist/index.js +6 -6
- package/dist/kodax_bootstrap.js +4 -2
- package/dist/kodax_cli.js +1755 -2979
- package/dist/kodax_doctor.js +3 -0
- package/dist/kodax_resume.js +30 -30
- package/dist/manual-topics.json +2211 -0
- package/dist/native/darwin-arm64/kodax-text-transaction.node +0 -0
- package/dist/native/darwin-arm64/manifest.json +1 -1
- package/dist/native/win32-x64/kodax-windows-sandbox.exe +0 -0
- package/dist/native/win32-x64/kodax-windows-text-transaction.node +0 -0
- package/dist/native/win32-x64/manifest.json +2 -2
- package/dist/one-shot-task.js +2 -0
- package/dist/provider-auth-cli.js +16 -0
- package/dist/provider-capabilities.json +560 -40
- package/dist/runtime-daemon-schema.json +1 -0
- package/dist/sandbox-network-broker.js +260 -795
- package/dist/script-cell.js +1 -0
- package/dist/script-worker.cjs +2189 -0
- package/dist/sdk-a2a.d.ts +23 -22
- package/dist/sdk-a2a.js +6 -8
- package/dist/sdk-agent.d.ts +125 -98
- package/dist/sdk-agent.js +1 -1
- package/dist/sdk-client.d.ts +16 -10
- package/dist/sdk-client.js +1 -1
- package/dist/sdk-coding.d.ts +109 -80
- package/dist/sdk-coding.js +1 -1
- package/dist/sdk-experimental-memory.d.ts +3 -3
- package/dist/sdk-experimental-memory.js +1 -1
- package/dist/sdk-llm.d.ts +265 -14
- package/dist/sdk-llm.js +1 -1
- package/dist/sdk-mcp.d.ts +3 -3
- package/dist/sdk-mcp.js +1 -1
- package/dist/sdk-media.d.ts +41 -166
- package/dist/sdk-media.js +1 -1
- package/dist/sdk-repl.d.ts +81 -51
- package/dist/sdk-repl.js +2 -2
- package/dist/sdk-runtime.d.ts +216 -2989
- package/dist/sdk-runtime.js +1 -1
- package/dist/sdk-sandbox.js +1 -1
- package/dist/sdk-session.d.ts +15 -14
- package/dist/sdk-session.js +1 -1
- package/dist/sdk-skills.d.ts +2 -2
- package/dist/sdk-skills.js +1 -1
- package/dist/semantic-worker.js +121 -75
- package/dist/static-text.json +371 -0
- package/dist/storage-repair-cli.js +3 -0
- package/dist/types-chunks/auth-file.d-ovsHEqD4.d.ts +178 -0
- package/dist/types-chunks/{bash-prefix-extractor.d-DFH463j2.d.ts → bash-prefix-extractor.d-CJliu5-D.d.ts} +326 -168
- package/dist/types-chunks/{capability-learning.d-B4pxKwP4.d.ts → capability-learning.d-BXDEOON2.d.ts} +4 -4
- package/dist/types-chunks/{capability.d-DOF3r0fJ.d.ts → capability.d-DapzKxy3.d.ts} +1 -1
- package/dist/types-chunks/{capsule.d-CwpmHGFB.d.ts → capsule.d-EMwSALqK.d.ts} +5 -5
- package/dist/types-chunks/{client-contract-CRm9ZpL2.d.ts → client-contract-B7q69yMA.d.ts} +265 -67
- package/dist/types-chunks/{controller.d-B4GyqWri.d.ts → controller.d-C0SAuNKu.d.ts} +1 -1
- package/dist/types-chunks/{controller.d-P3H97ddz.d.ts → controller.d-D-hPLKaA.d.ts} +71 -11
- package/dist/types-chunks/{cost-tracker.d-BeaenODW.d.ts → cost-tracker.d-D1CTx-IO.d.ts} +37 -7
- package/dist/types-chunks/{base.d-ZBOdjDUT.d.ts → errors.d-D73qdYbS.d.ts} +91 -74
- package/dist/types-chunks/{history-retrieval.d-BzKWDjzG.d.ts → history-retrieval.d-BwEUR9cb.d.ts} +2 -2
- package/dist/types-chunks/{manager.d-C8OlTe2J.d.ts → manager.d-BMH8Q6TV.d.ts} +1 -1
- package/dist/types-chunks/{manifest.d-COreAnXG.d.ts → manifest.d-YE3-AIeO.d.ts} +1 -1
- package/dist/types-chunks/{provider-credential-context.d-BH2OaB1b.d.ts → provider-credential-context.d-Dw-sWcnu.d.ts} +11 -2
- package/dist/types-chunks/{provider-request-observation.d-C_bEqr4m.d.ts → provider-request-observation.d-CNe9vse3.d.ts} +4 -2
- package/dist/types-chunks/{public-api.d-BLmqDi73.d.ts → public-api.d-BhDU643p.d.ts} +13 -10
- package/dist/types-chunks/queue-BxQhqhFM.d.ts +166 -0
- package/dist/types-chunks/{resolver.d-DLY01RHx.d.ts → resolver.d-DrkpD8wY.d.ts} +142 -103
- package/dist/types-chunks/{review-inbox.d-BTLDdpG2.d.ts → review-inbox.d-Bgt46S7L.d.ts} +16 -3
- package/dist/types-chunks/{review-packet.d-Crra1Q7t.d.ts → review-packet.d-ChOfJaNI.d.ts} +7 -7
- package/dist/types-chunks/{run-manager.d-DmS1edk4.d.ts → run-manager.d-ChzguipG.d.ts} +48 -12
- package/dist/types-chunks/{runtime-client-info-BBBxdU8V.d.ts → runtime-client-info-P_mRDG7j.d.ts} +93 -7
- package/dist/types-chunks/runtime-event-BW5Pla7a.d.ts +48 -0
- package/dist/types-chunks/sdk-runtime-cDe7qmN3.d.ts +2244 -0
- package/dist/types-chunks/{sdk-session-DipY_CCd.d.ts → sdk-session-D3pcSbnA.d.ts} +13 -4
- package/dist/types-chunks/{sdk-skills-DokfOoJF.d.ts → sdk-skills-C-UA1A6I.d.ts} +3 -1
- package/dist/types-chunks/{side-query.d-DTrhVd_r.d.ts → side-query.d-UFKdWSw7.d.ts} +4 -4
- package/dist/types-chunks/{types.d-Jxj49rqO.d.ts → skill-invocation-error.d-gsNNDnnt.d.ts} +24 -14
- package/dist/types-chunks/task-results.d-XMdWq0eA.d.ts +15 -0
- package/dist/types-chunks/{trusted-repl-entry-B1cb7lAn.d.ts → trusted-repl-entry-Bbkd2HlO.d.ts} +10 -10
- package/dist/types-chunks/{types.d-BjOq57-z.d.ts → types.d-Bi8iUd6x.d.ts} +248 -4
- package/dist/types-chunks/{types.d-NyCB6ztO.d.ts → types.d-BlXTogOo.d.ts} +24 -13
- package/dist/types-chunks/types.d-BvEGNdN-.d.ts +131 -0
- package/dist/types-chunks/{types.d-Cb8RdrjU.d.ts → types.d-D8qQjMeo.d.ts} +5 -1
- package/dist/types-chunks/{utils.d-Bt6USYa5.d.ts → utils.d-CxHyBvO6.d.ts} +11 -7
- package/dist/windows-native-scripts.json +5 -0
- package/docs/ARTIFACT_SDK.md +8 -0
- package/docs/CLIENT_CONTRACT.md +195 -9
- package/docs/SDK_MIGRATION.md +887 -2
- package/docs/SPACE_SDK_SEAMS.md +255 -2
- package/package.json +33 -6
- package/public_docs/README.md +27 -2
- package/public_docs/configuration/config-files.md +6 -0
- package/public_docs/configuration/custom-providers.md +62 -0
- package/public_docs/configuration/providers.md +238 -3
- package/public_docs/configuration/sandbox.md +30 -0
- package/public_docs/getting-started/quickstart.md +10 -1
- package/public_docs/sdk/embedder-guide.md +476 -206
- package/dist/chunks/agent-C7MMIRIH.js +0 -2
- package/dist/chunks/argument-completer-WIQAV5GP.js +0 -2
- package/dist/chunks/chunk-2AM3FRQ7.js +0 -137
- package/dist/chunks/chunk-2TBKGO2Q.js +0 -497
- package/dist/chunks/chunk-35P7QL2Q.js +0 -2
- package/dist/chunks/chunk-5DQTOU2E.js +0 -69
- package/dist/chunks/chunk-7NH5BGE4.js +0 -350
- package/dist/chunks/chunk-AWYO4MH3.js +0 -635
- package/dist/chunks/chunk-CIPS75XZ.js +0 -260
- package/dist/chunks/chunk-CRQWSDHV.js +0 -429
- package/dist/chunks/chunk-HD5BDOPC.js +0 -2
- package/dist/chunks/chunk-JXZMES45.js +0 -12
- package/dist/chunks/chunk-KJSZTP5N.js +0 -2
- package/dist/chunks/chunk-KYHMB6XR.js +0 -431
- package/dist/chunks/chunk-ONUPGMER.js +0 -2
- package/dist/chunks/chunk-P42PHZWC.js +0 -351
- package/dist/chunks/chunk-SHG3EIH5.js +0 -19
- package/dist/chunks/chunk-UH6VOCVP.js +0 -2
- package/dist/chunks/chunk-V26LAWJY.js +0 -2
- package/dist/chunks/chunk-WOHHMGEF.js +0 -394
- package/dist/chunks/chunk-WONYJBAA.js +0 -2
- package/dist/chunks/chunk-XJWNIFC2.js +0 -298
- package/dist/chunks/chunk-XMWTEVFZ.js +0 -1481
- package/dist/chunks/chunk-YJTIPSNW.js +0 -22
- package/dist/chunks/chunk-YVBBU6K5.js +0 -5
- package/dist/chunks/client-XFASU74S.js +0 -2
- package/dist/chunks/compaction-config-JZNGDKWW.js +0 -2
- package/dist/chunks/devtools-CD6KSIHE.js +0 -2
- package/dist/chunks/devtools-XR5F2C6T.js +0 -2
- package/dist/chunks/dist-M4HLQAX7.js +0 -2
- package/dist/chunks/dist-ZLR4OTDD.js +0 -2
- package/dist/chunks/host-EHVJWNGS.js +0 -2
- package/dist/chunks/readline-helpers-KIDMSK76.js +0 -2
- package/dist/chunks/run-manager-HNGIYMG7.js +0 -2
- package/dist/chunks/tool-dispatch-ON33NJR5.js +0 -2
- package/dist/chunks/utils-RHR6YHB2.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
+
import{h as f,k as v,l as y}from"./chunk-P55RJIOG.js";import{c as T}from"./chunk-OGTRDK4Q.js";import{a as c}from"./chunk-V4WSBIXB.js";import u from"node:fs";import{createHash as O}from"node:crypto";import{createRequire as C}from"node:module";import l from"node:path";var h=5;var P=C(import.meta.url),E=3e4,p;function S(t,o){let e=t.replaceAll("/","\\"),r=e.toLowerCase(),a=e.slice(3),d=(a===""?[]:a.split("\\")).some(n=>{let i=n.split(".",1)[0].toUpperCase(),g=["CON","PRN","AUX","NUL","CONIN$","CONOUT$"].includes(i)||/^(?:COM|LPT)[1-9¹²³]$/.test(i);return n===""||n==="."||n===".."||n.endsWith(".")||n.endsWith(" ")||/[\u0000-\u001f<>"|?*]/.test(n)||/~[0-9¹²³]/.test(n)||g});if(t.includes("\0")||e.startsWith("\\\\")||r.startsWith("\\??\\")||r.startsWith("\\device\\")||r.startsWith("\\global??\\")||r.startsWith("globalroot\\")||!/^[A-Za-z]:\\/.test(e)||e.slice(2).includes(":")||d)throw new T({code:"text_mutation_unsafe_path",path:t,message:`Trusted text mutation ${o} must use a local drive-absolute path; UNC and device namespaces are denied: ${t}`})}c(S,"assertLocalDriveAbsolutePath");function m(t,o){if(process.platform==="win32"){S(t,o);return}if(t.includes("\0")||!l.isAbsolute(t)||t.startsWith("//"))throw new T({code:"text_mutation_unsafe_path",path:t,message:`Trusted text mutation ${o} must use a local absolute path: ${t}`})}c(m,"assertSupportedAbsolutePath");function w(t,o){let e=l.relative(t,o);return e===""||!e.startsWith("..")&&!l.isAbsolute(e)}c(w,"sameOrInside");function A(t){let o=new Map;for(let e of t){let r=l.resolve(e),a=process.platform==="win32"?r.toLowerCase():r;o.has(a)||o.set(a,r)}return[...o.values()].sort((e,r)=>r.length-e.length)}c(A,"normalizedRootCandidates");function _(t,o,e=!1){m(t,"target");for(let n of o)m(n,"write root");let r=l.resolve(t),a=[...A(o)];if(e){let n=l.dirname(r);for(;!u.existsSync(n);){let i=l.dirname(n);if(i===n)break;n=i}a.unshift(n)}let s=a.find(n=>n!==r&&w(n,r)),d=c(n=>{try{if(!u.lstatSync(n).isDirectory())throw new Error("write root is not a directory");return u.realpathSync.native(n)}catch(i){throw new T({code:"text_mutation_unsafe_path",path:t,message:`Trusted text mutation write root is unavailable: ${n}`,cause:i})}},"canonicalizeRoot");if(s!==void 0){let n=d(s);return{canonicalRoot:n,canonicalTarget:l.join(n,l.relative(s,r))}}for(let n of a){let i=d(n);if(i!==r&&w(i,r))return{canonicalRoot:i,canonicalTarget:r}}throw new T({code:"text_mutation_policy_denied",path:t,message:`Trusted text mutation target is outside the Runtime write roots: ${t}`})}c(_,"authorizeTarget");function x(t,o=t){if(f(t),p!==void 0)return p;let e=y(import.meta.url,h,t,o),r=B(e);return p=X(r),p}c(x,"loadNativeBinding");function z(){try{return{ready:!0,protocol:x([]).textTransactionProtocol()}}catch(t){return{ready:!1,error:t instanceof Error?t.message:String(t)}}}c(z,"probeTrustedTextNativeBinding");function X(t){if(typeof t.textTransactionProtocol!="function"||typeof t.TrustedTextTransactionRoot!="function"||t.textTransactionProtocol()!==h)throw new Error(`The KodaX trusted text transaction binding must implement protocol ${h}.`);return t}c(X,"validateNativeBinding");function B(t){if(process.platform==="win32")return P(t);let o=u.openSync(t,u.constants.O_RDONLY|u.constants.O_NOFOLLOW);try{let e=u.fstatSync(o);if(!e.isFile()||e.nlink!==1||e.size>64*1024*1024)throw new Error("The protected native text binding has an unsafe identity.");let r=l.basename(l.dirname(t)).toLowerCase(),a=u.readFileSync(o),s=O("sha256").update(a).digest("hex");if(!/^[0-9a-f]{64}$/.test(r)||s!==r)throw new Error("The protected native text binding changed after provisioning.");let d={exports:{}},n=process.platform==="linux"?`/proc/self/fd/${o}`:`/dev/fd/${o}`;return process.dlopen(d,n),d.exports}finally{u.closeSync(o)}}c(B,"loadNativeBindingFile");function N(t,o,e){return process.platform==="win32"?new t.TrustedTextTransactionRoot(o,void 0,e):new t.TrustedTextTransactionRoot(o,v(),e)}c(N,"createNativeRoot");function W(t){switch(t){case"invalid_path":case"reparse_point":case"hard_link":return"text_mutation_unsafe_path";case"unauthorized_path":return"text_mutation_policy_denied";case"remote_filesystem":case"unsupported_filesystem":case"unsupported_platform":return"text_mutation_unsupported_filesystem";case"contended":return"text_mutation_contended";case"stale":return"text_mutation_stale";case"metadata_preservation":return"text_mutation_metadata_preservation_failed";default:return"text_mutation_io_failed"}}c(W,"mappedNativeErrorCode");function R(t,o){if(o instanceof T)throw o;let e=o instanceof Error?o.message:String(o),r="KODAX_TEXT_TRANSACTION:",a=e.indexOf(r),s={};if(a>=0)try{let d=JSON.parse(e.slice(a+r.length));d!==null&&typeof d=="object"&&!Array.isArray(d)&&(s=d)}catch{s={}}throw new T({code:W(s.code),path:t,message:s.message??e,...typeof s.os_code=="number"?{osCode:s.os_code}:{},cause:o})}c(R,"translateNativeError");function k(t){return{state:t.state,content:t.content,revision:t.revision,slot:t.slotId,canonicalPath:t.canonicalPath}}c(k,"publicSnapshot");function I(t,o,e){if(e.status==="stale"){if(typeof e.currentRevision!="string")throw new Error("Native text transaction returned a stale result without a revision.");return{status:"stale",currentRevision:e.currentRevision}}if(typeof e.slotId!="string"||typeof e.preContent!="string"||typeof e.preRevision!="string"||typeof e.postRevision!="string")throw new Error("Native text transaction returned an incomplete commit receipt.");let r={before:{state:e.preRevision.startsWith("missing:")?"missing":"present",content:e.preContent,revision:e.preRevision,slot:e.slotId,canonicalPath:t},after:{state:"present",content:o,revision:e.postRevision,slot:e.slotId,canonicalPath:t},recoveredAbandonedLock:e.abandonedLock===!0};if(e.status==="committed_uncertain"){if(typeof e.message!="string"||e.message==="")throw new Error("Native text transaction returned an uncertain commit without a reason.");return{status:"committed_uncertain",...r,reason:e.message}}return{status:"written",...r}}c(I,"requireWrittenOutcome");function H(t,o,e=()=>!1,r){return{async snapshot(a){if(a.signal?.aborted)throw a.signal.reason;m(a.path,"target");let s=e(),d=r?.(a.toolCall,a.path,"snapshot")===!0,n=_(a.path,t(),s||d);o(n.canonicalTarget),f([n.canonicalTarget]);try{let i=x([n.canonicalTarget],t()),g=N(i,n.canonicalRoot,s);return k(await g.snapshot(n.canonicalTarget))}catch(i){R(n.canonicalTarget,i)}},async commit(a){if(a.signal?.aborted)throw a.signal.reason;m(a.path,"target");let s=e(),d=r?.(a.toolCall,a.path,"commit")===!0,n=_(a.path,t(),s||d);o(n.canonicalTarget),f([n.canonicalTarget]);try{let i=x([n.canonicalTarget],t()),b=await N(i,n.canonicalRoot,s).commit(n.canonicalTarget,a.expectedRevision,a.content,a.createParentDirectories,E);return I(n.canonicalTarget,a.content,b)}catch(i){R(n.canonicalTarget,i)}}}}c(H,"createTrustedTextMutationHost");export{z as a,H as b};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
+
import{a as o}from"./chunk-V4WSBIXB.js";function i(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}o(i,"isRecord");function d(e){return i(e)?typeof e.taskId=="string"&&(e.route==="local"||e.route==="external")&&typeof e.agentId=="string"&&typeof e.objective=="string"&&typeof e.state=="string"&&typeof e.cancellation=="string"&&i(e.registration)&&typeof e.idempotencyKey=="string"&&typeof e.dispatchAttempt=="number"&&typeof e.createdAt=="string"&&typeof e.updatedAt=="string":!1}o(d,"isTask");function u(e){return i(e)?typeof e.taskId=="string"&&Number.isSafeInteger(e.seq)&&typeof e.timestamp=="string"&&typeof e.type=="string":!1}o(u,"isEvent");function l(e,a){let r=JSON.parse(e);if(!d(r)||r.taskId!==a)throw new Error("Runtime agent task snapshot does not match its storage binding.");let t=r.registration;if(!i(t)||!i(t.capabilities)||!i(t.effects))throw new Error("Recovery snapshot requires a complete task registration.");let c=t.capabilities,s=t.effects;if(!["agentId","executorId","configurationRevision"].every(n=>typeof t[n]=="string"&&t[n].length>0)||!["native","constructed","external"].includes(t.origin)||!["native","a2a","mcp","http"].includes(t.protocol)||t.endpointIdentityHash!==void 0&&typeof t.endpointIdentityHash!="string"||!["streaming","durableTasks","inputRequired","cancellation","artifacts"].every(n=>["supported","unsupported","conditional"].includes(c[n]))||!["none","read","write","unknown"].includes(s.remote)||!["none","proposal","direct"].includes(s.workspace)||!["submitted","working","input-required","auth-required","completed","failed","canceled","rejected","unknown"].includes(r.state)||!["none","requested","confirmed","unsupported","failed","unknown"].includes(r.cancellation))throw new Error("Recovery snapshot has an invalid task registration or state.");return r}o(l,"parseRuntimeAgentTaskSnapshot");function y(e,a){let r=e.trim();if(!r)return[];let t=0;return r.split(/\r?\n/).map((c,s)=>{let n;try{n=JSON.parse(c)}catch{throw new Error(`Invalid Runtime agent event JSON at line ${s+1}`)}if(!u(n))throw new Error(`Invalid Runtime agent event shape at line ${s+1}`);if(n.taskId!==a)throw new Error(`Runtime agent event taskId does not match its ledger at line ${s+1}`);if(n.seq<=t)throw new Error(`Runtime agent events require a strictly increasing positive sequence at line ${s+1}`);return t=n.seq,n})}o(y,"parseRuntimeAgentEventLedger");export{l as a,y as b};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
+
import{a as o,b as R,c as G}from"./chunk-V4WSBIXB.js";var D=R((ue,w)=>{"use strict";w.exports=o(function(e){return e.map(function(r){return r===""?"''":r&&typeof r=="object"?r.op.replace(/(.)/g,"\\$1"):/["\s\\]/.test(r)&&!/'/.test(r)?"'"+r.replace(/(['])/g,"\\$1")+"'":/["'\s]/.test(r)?'"'+r.replace(/(["\\$`!])/g,"\\$1")+'"':String(r).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}])/g,"$1\\$2")}).join(" ")},"quote")});var B=R((fe,q)=>{"use strict";var _="(?:"+["\\|\\|","\\&\\&",";;","\\|\\&","\\<\\(","\\<\\<\\<",">>",">\\&","<\\&","[&;()|<>]"].join("|")+")",N=new RegExp("^"+_+"$"),C="|&;()<> \\t",V='"((\\\\"|[^"])*?)"',J="'((\\\\'|[^'])*?)'",k=/^#$/,I="'",L='"',b="$",S="",z=4294967296;for(O=0;O<4;O++)S+=(z*Math.random()).toString(16);var O,K=new RegExp("^"+S);function Z(n,e){for(var r=e.lastIndex,t=[],i;i=e.exec(n);)t.push(i),e.lastIndex===i.index&&(e.lastIndex+=1);return e.lastIndex=r,t}o(Z,"matchAll");function F(n,e,r){var t=typeof n=="function"?n(r):n[r];return typeof t>"u"&&r!=""?t="":typeof t>"u"&&(t="$"),typeof t=="object"?e+S+JSON.stringify(t)+S:e+t}o(F,"getVar");function H(n,e,r){r||(r={});var t=r.escape||"\\",i="(\\"+t+`['"`+C+`]|[^\\s'"`+C+"])+",s=new RegExp(["("+_+")","("+i+"|"+V+"|"+J+")+"].join("|"),"g"),l=Z(n,s);if(l.length===0)return[];e||(e={});var h=!1;return l.map(function(p){var a=p[0];if(!a||h)return;if(N.test(a))return{op:a};var v=!1,d=!1,c="",g=!1,u;function x(){u+=1;var E,$,m=a.charAt(u);if(m==="{"){if(u+=1,a.charAt(u)==="}")throw new Error("Bad substitution: "+a.slice(u-2,u+1));if(E=a.indexOf("}",u),E<0)throw new Error("Bad substitution: "+a.slice(u));$=a.slice(u,E),u=E}else if(/[*@#?$!_-]/.test(m))$=m,u+=1;else{var A=a.slice(u);E=A.match(/[^\w\d_]/),E?($=A.slice(0,E.index),u+=E.index-1):($=A,u=a.length)}return F(e,"",$)}for(o(x,"parseEnvVar"),u=0;u<a.length;u++){var f=a.charAt(u);if(g=g||!v&&(f==="*"||f==="?"),d)c+=f,d=!1;else if(v)f===v?v=!1:v==I?c+=f:f===t?(u+=1,f=a.charAt(u),f===L||f===t||f===b?c+=f:c+=t+f):f===b?c+=x():c+=f;else if(f===L||f===I)v=f;else{if(N.test(f))return{op:a};if(k.test(f)){h=!0;var T={comment:n.slice(p.index+u+1)};return c.length?[c,T]:[T]}else f===t?d=!0:f===b?c+=x():c+=f}}return g?{op:"glob",pattern:c}:c}).reduce(function(p,a){return typeof a>"u"?p:p.concat(a)},[])}o(H,"parseInternal");q.exports=o(function(e,r,t){var i=H(e,r,t);return typeof r!="function"?i:i.reduce(function(s,l){if(typeof l=="object")return s.concat(l);var h=l.split(RegExp("("+S+".*?"+S+")","g"));return h.length===1?s.concat(h[0]):s.concat(h.filter(Boolean).map(function(p){return K.test(p)?JSON.parse(p.split(S)[1]):p}))},[])},"parse")});var P=R(y=>{"use strict";y.quote=D();y.parse=B()});var Q=G(P(),1);var U=new Set(["/dev/null","nul","NUL"]);function X(n){let e=[],r=0,t=null,i=!1;for(let s=0;s<n.length;s+=1){let l=n[s];if(l===`
|
|
3
|
+
`||l==="\r"){t===null&&(e.push(n.slice(r,s)),l==="\r"&&n[s+1]===`
|
|
4
|
+
`&&(s+=1),r=s+1,i=!1);continue}if(!i){if(t===null&&l==="#"){i=!0;continue}if(l==="\\"&&t!=="'"){let h=n[s+1];h!==`
|
|
5
|
+
`&&h!=="\r"&&h!==void 0&&(s+=1);continue}l!=="'"&&l!=='"'||(t===null?t=l:t===l&&(t=null))}}return e.push(n.slice(r)),e}o(X,"splitUnquotedShellLines");function Y(n){let e=n.at(-1);return e!==void 0&&typeof e!="string"&&"op"in e&&["&&","||","|",";"].includes(e.op)}o(Y,"endsWithShellContinuation");function ee(n){let e=[];for(let r of X(n)){let t=(0,Q.parse)(r,i=>`$${i}`).filter(i=>typeof i=="string"||!("comment"in i));t.length!==0&&(e.length>0&&!Y(e)&&e.push({op:";"}),e.push(...t))}return e}o(ee,"parseAllShellLines");function te(n){let e=null,r=!1,t=!1,i=!0;for(let s=0;s<n.length;s+=1){let l=n[s];if(l===`
|
|
6
|
+
`||l==="\r"){let h=t&&!r;r=!1,t=!1,l==="\r"&&n[s+1]===`
|
|
7
|
+
`&&(s+=1),!h&&e===null&&(i=!0);continue}if(!r){if(l==="$"&&n[s+1]==="("&&!t&&e!=="'")return!0;t?(t=!1,i=!1):l==="\\"&&e!=="'"?t=!0:l==="'"&&e!=='"'?(e=e==="'"?null:"'",i=!1):l==='"'&&e!=="'"?(e=e==='"'?null:'"',i=!1):l==="#"&&e===null&&i?r=!0:e===null&&/[\s;|&()<>]/.test(l)?i=!0:i=!1}}return!1}o(te,"hasActiveBashCommandSubstitution");function ne(n){let e=null,r=!1;for(let t=0;t<n.length;t+=1){let i=n[t];if(i===`
|
|
8
|
+
`||i==="\r"){r=!1,i==="\r"&&n[t+1]===`
|
|
9
|
+
`&&(t+=1);continue}if(!r){if(i==="$"&&n[t+1]==="("&&e!=="'")return!0;i==="'"&&e!=='"'?e=e==="'"?null:"'":i==='"'&&e!=="'"?e=e==='"'?null:'"':i==="#"&&e===null&&(r=!0)}}return!1}o(ne,"hasActivePowerShellCommandSubstitution");function re(n){return te(n)||ne(n)}o(re,"hasActiveCommandSubstitution");function ce(n){return U.has(n)||U.has(n.toLowerCase())}o(ce,"isNullDevice");function pe(n){let e=n.trim();if(!e)return{statements:[],unparseable:!1};if(e.includes("`")||re(e))return{statements:[],unparseable:!0};let r;try{r=ee(e)}catch{return{statements:[],unparseable:!0}}let t=[],i=[],s=[],l=[],h=null,p=!1,a=o(()=>{(s.length>0||l.length>0)&&(i.push({argv:s,redirections:l}),s=[],l=[])},"flushStage"),v=o(d=>{a(),i.length>0&&(t.push({precedingOp:h,stages:i}),i=[]),h=d},"flushStatement");for(let d=0;d<r.length;d+=1){let c=r[d];if(typeof c=="string"){s.push(c);continue}if("op"in c){let g=c.op;if(g==="&&"||g==="||"||g===";"){v(g);continue}if(g==="|"){a();continue}if(g==="&"){let u=r[d+1];if(s.length===0&&i.length===0&&typeof u=="string")continue;if(u!==void 0&&typeof u!="string"&&"op"in u&&(u.op===">"||u.op===">>")){let x=r[d+2];if(typeof x!="string"){p=!0,d+=1;continue}l.push(j(`&${u.op}`,x)),d+=2;continue}p=!0;continue}if(se(g)){let u=null,x=s[s.length-1];x!==void 0&&/^[0-9]+$/.test(x)&&(u=x,s.pop());let f=r[d+1];if(typeof f!="string"){p=!0;continue}l.push(j(u?`${u}${g}`:g,f)),d+=1;continue}if(g==="glob"){let u=c.pattern;typeof u=="string"?s.push(u):p=!0;continue}p=!0;continue}if("comment"in c)break;p=!0}return v(null),{statements:t,unparseable:p}}o(pe,"parseBashCommand");function he(n){let e=[];for(let r of n.statements)for(let t of r.stages)e.push(...t.argv);return e}o(he,"flattenArgv");function de(n){let e=[];for(let r of n.statements)for(let t of r.stages){let i=t.argv[0];for(let s of t.redirections)e.push({...s,stageCommand:i})}return e}o(de,"flattenRedirections");var ie=new Set([">",">>","<","<<","<<<","&>","&>>",">&"]),M=/^([0-9]+|&)(>>?|<<?)$/,W=/^([0-9]+)?(>&)$/;function se(n){return ie.has(n)||M.test(n)||W.test(n)}o(se,"isRedirectionOp");function j(n,e){let r=null,t=n,i=M.exec(n),s=W.exec(n);s?(r=s[1]??null,t=s[2]):i&&(r=i[1],t=i[2]);let l=t===">&"&&/^(?:[0-9]+|-)$/.test(e);return{op:n,fd:r,append:t===">>"||n==="&>>",input:t==="<"||t==="<<"||n==="<<<",target:e,...l?{descriptorDuplication:!0}:{}}}o(j,"parseRedirection");export{ce as a,pe as b,he as c,de as d};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
+
import{b as s}from"./chunk-KDLOPBFZ.js";import{a as o}from"./chunk-V4WSBIXB.js";var d="thinking-binding-controls-2026-08-01";function g(t){let i=t.thinking;return!!i&&typeof i=="object"&&"block_binding"in i}o(g,"hasThinkingBinding");function h(t,i,r,p,a=!1){let e=r?.thinkingDisplay;if(e!==void 0&&(!["summarized","omitted"].includes(e)||i?.supportsThinkingDisplay!==!0))throw new s("Thinking display requires a declared supported native model.",p,{retryable:!1});let n=t.thinking;!n||typeof n!="object"||!("type"in n)||!["adaptive","enabled"].includes(n.type)||(i?.supportsThinkingDisplay&&Object.assign(n,{display:e??"summarized"}),i?.supportsThinkingBlockBinding&&n.type==="adaptive"&&(Object.assign(n,{block_binding:{prefix_mismatch_behavior:"drop_block"}}),a&&Object.assign(t,{anthropic_beta:[d]})))}o(h,"applyAnthropicThinkingOptions");export{d as a,g as b,h as c};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{
|
|
2
|
+
import{E as j,P as W,a as c,ia as G}from"./chunk-EISRVOBJ.js";import{l as x,n as O}from"./chunk-X5M7TLJV.js";import{a as o}from"./chunk-V4WSBIXB.js";import*as Q from"child_process";import*as v from"path";import*as R from"fs";import*as Z from"os";import h from"chalk";import f from"chalk";var ee=100,te=/\b(curl|wget|invoke-webrequest|invoke-restmethod|iwr|irm)\b/i,U=/\b(rm|del|erase|remove-item|rmdir|rd|git clean)\b/i,Y=/\b(npm|pnpm|yarn|pip|choco|winget)\s+(install|add|remove|uninstall|update|upgrade|ci)\b/i,K=/\b(set-content|add-content|out-file|new-item|copy-item|move-item|rename-item|cp|mv|copy|move|ren|touch)\b/i;function $(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}o($,"readString");function d(e,t,n){n&&e.push({label:t,value:n})}o(d,"pushField");function ne(e){return e.replace(/\s+/g," ").trim()}o(ne,"normalizeWhitespace");function re(e,t){if(e.length<=t)return e;let n=Math.ceil((t-3)/2),r=Math.floor((t-3)/2);return`${e.slice(0,n)}...${e.slice(e.length-r)}`}o(re,"truncateMiddle");function oe(e){let t=e;return t=t.replace(/\b(authorization\s*:\s*bearer\s+)([^\s'"]+)/gi,(n,r)=>`${r}[REDACTED]`),t=t.replace(/\b((?:authorization|cookie)\s*:\s*)([^'"]+)/gi,(n,r)=>`${r}[REDACTED]`),t=t.replace(/\b(bearer\s+)([^\s'"]+)/gi,(n,r)=>`${r}[REDACTED]`),t=t.replace(/\b(api[_-]?key|access[_-]?token|refresh[_-]?token|token|secret|password|passwd|cookie|session)\b(\s*[:=]\s*)(['"]?)([^'"\s]+)(\3)/gi,(n,r,s,i)=>`${r}${s}${i}[REDACTED]${i}`),t=t.replace(/(--(?:api-key|token|secret|password|cookie)\s+)(\S+)/gi,(n,r)=>`${r}[REDACTED]`),t=t.replace(/((?:-u|--user)\s+)(\S+)/gi,(n,r)=>`${r}[REDACTED]`),t}o(oe,"maskSensitiveSegments");function B(e){return re(oe(ne(e)),ee)}o(B,"summarizeCommand");function se(e){return x(e)?c("intent.read"):U.test(e)?c("intent.delete"):Y.test(e)?c("intent.deps"):O(e)||K.test(e)?c("intent.modify"):c("intent.execute")}o(se,"classifyShellIntent");function ie(e){let t=[];return U.test(e)?t.push(c("risk.destructive")):Y.test(e)?t.push(c("risk.deps")):O(e)||K.test(e)?t.push(c("risk.modify")):x(e)||t.push(c("risk.unknown")),te.test(e)&&t.push(c("risk.network")),t}o(ie,"classifyShellRisks");function ce(e){if(Array.isArray(e))return e.filter(t=>typeof t=="object"&&t!==null&&typeof t.kind=="string")}o(ce,"readSignals");function ue(e){if(e){if(e.some(t=>t.kind==="protected_path"))return c("scope.protected");if(e.some(t=>t.kind==="outside_project"||t.kind==="shell_redirect_outside"))return c("scope.outside")}}o(ue,"scopeFromSignals");function ae(e){if(e._outsideProject===!0)return c("scope.outside");if(e._alwaysConfirm===!0)return c("scope.protected")}o(ae,"scopeFromMarkers");function le(e){if(!e)return[];let t=[],n=e.some(s=>s.kind==="dangerous_pattern"&&s.severity==="high"),r=e.some(s=>s.kind==="dangerous_pattern"&&s.severity==="medium");return n?t.push(c("risk.destructive")):r&&t.push(c("risk.modify")),e.some(s=>s.kind==="network")&&t.push(c("risk.network")),e.some(s=>s.kind==="package_install")&&t.push(c("risk.deps")),t}o(le,"risksFromSignals");var de={Reason:"field.reason",Intent:"field.intent",Target:"field.target",Scope:"field.scope",Risk:"field.risk",Summary:"field.summary"};function fe(e){return c(de[e])}o(fe,"localizeFieldLabel");function C(e,t){return{title:e,fields:t,details:t.map(n=>`${fe(n.label)}: ${n.value}`)}}o(C,"buildDisplayFromFields");function A(e,t){if(e==="confirm"){let l=$(t._message);if(l)return C(l,[])}if(e==="exit_plan_mode"){let l=$(t.plan),y="Approve plan? (exits plan mode \u2192 accept-edits)";return l?{title:y,fields:[],details:l.split(`
|
|
3
3
|
`)}:C(y,[])}let n=[],r=$(t.path),s=$(t.command),i=$(t._reason)??$(t.justification),u=ce(t._classifierSignals),a=ue(u)??ae(t);switch(d(n,"Reason",i),e){case"bash":case"shell_command":{if(s){d(n,"Intent",se(s)),d(n,"Scope",a);let l=le(u),y=l.length>0?l:ie(s);y.length>0&&d(n,"Risk",y.join("; ")),d(n,"Summary",B(s))}else d(n,"Scope",a);return C(e==="bash"?c("tool.bash.title"):c("tool.shell.title"),n)}case"write":return d(n,"Intent",c("intent.write_file")),d(n,"Target",r),d(n,"Scope",a),C(c("tool.write.title"),n);case"edit":return d(n,"Intent",c("intent.edit_file")),d(n,"Target",r),d(n,"Scope",a),C(c("tool.edit.title"),n);default:return d(n,"Intent",c("intent.use_tool",{tool:e})),d(n,"Target",r),d(n,"Scope",a),s&&d(n,"Summary",B(s)),C(c("tool.generic.title",{tool:e}),n)}}o(A,"buildToolConfirmationDisplay");function Pe(e,t){let n=A(e,t);return n.details.length>0?`${n.title}
|
|
4
4
|
${n.details.join(`
|
|
5
5
|
`)}`:n.title}o(Pe,"buildToolConfirmationPrompt");var z="Runtime state: run active until this approval is resolved.";function Fe(e,t){if(!t.confirmed)return{type:"reject",reason:"User rejected the tool call."};if(t.runtimeGrantKind===void 0)return{type:"allow_once"};let n=e.grantSuggestions?.find(r=>r.kind===t.runtimeGrantKind);return n?t.runtimeGrantKind==="session"?{type:"allow_session",suggestionId:n.id}:{type:"allow_always",suggestionId:n.id}:{type:"reject",reason:"Runtime grant suggestion expired."}}o(Fe,"resolveReplRuntimePermissionDecision");function Le(e){let t=e.classifierModelEnv??e.classifierModel;return{...t!==void 0?{classifierModel:t}:{},...e.reviewPolicy!==void 0?{reviewPolicy:e.reviewPolicy}:{}}}o(Le,"toReplRuntimeAutoModeSettings");import*as H from"child_process";var E;function pe(){if(process.platform!=="win32")return null;if(E!==void 0)return E;try{E=H.execFileSync(process.env.ComSpec??"cmd.exe",["/d","/s","/c","chcp"],{encoding:"utf8",stdio:["ignore","pipe","ignore"],windowsHide:!0}).match(/(\d{3,5})/)?.[1]??null}catch{E=null}return E}o(pe,"detectWindowsCodePage");function P(){let e=process.env;return!!(e.COLORTERM==="truecolor"||e.COLORTERM==="24bit"||e.TERM_PROGRAM==="iTerm.app"||e.WT_SESSION||e.TERM==="xterm-kitty"||e.TERM_PROGRAM==="vscode"||e.TERM_PROGRAM==="gnome-terminal")}o(P,"supportsTrueColor");function me(){if(P())return!0;let e=process.env.TERM||"";return e.includes("256color")||e==="xterm-256color"||e==="screen-256color"||e==="tmux-256color"}o(me,"supports256Colors");function w(){let e=process.env,t=e.LC_ALL||"",n=e.LC_CTYPE||"",r=e.LANG||"";if(t==="C"||t==="POSIX"||n==="C"||n==="POSIX"||r==="C"||r==="POSIX")return!1;let s=`${t}|${n}|${r}`.toLowerCase();return s.includes("utf-8")||s.includes("utf8")?!0:process.platform==="win32"?e.WT_SESSION||e.TERM_PROGRAM==="vscode"?!0:pe()==="65001":!0}o(w,"supportsUnicode");function he(){let e=process.env;return!!(e.TERM_PROGRAM==="iTerm.app"||e.WT_SESSION||e.TERM==="xterm-kitty"||e.TERM_PROGRAM==="vscode"||e.TERM_PROGRAM==="Apple_Terminal"||e.TERM_PROGRAM==="gnome-terminal"||e.COLORTERM)}o(he,"supportsEmoji");function ye(){if(process.stdout?.columns)return process.stdout.columns;let t=process.env.COLUMNS;if(t){let n=Number.parseInt(t,10);if(!Number.isNaN(n)&&n>0)return n}return 80}o(ye,"getTerminalWidth");function ge(){let e=process.env;return!!(e.NO_COLOR||e.TERM==="dumb"||e.CI)}o(ge,"isScreenReader");function we(){return process.stdout?.isTTY??!1}o(we,"isTTY");function We(){return{trueColor:P(),colors256:me(),unicode:w(),emoji:he(),tty:we(),columns:ye(),screenReader:ge()}}o(We,"detectTerminalCapabilities");var ke=[{key:"y",label:"Yes",description:"Confirm the action",value:"yes"},{key:"n",label:"No",description:"Cancel the action",value:"no"}],be=[{key:"y",label:"Yes",description:"Allow this once",value:"yes"},{key:"n",label:"No",description:"Cancel",value:"no"},{key:"a",label:"Always",description:"Always allow this kind of action",value:"always"}];function Te(e,t=!0){return e.map(n=>{let r=f.dim(`[${n.key}]`);return t?`${r} ${f.cyan(n.label)} ${f.dim(`- ${n.description}`)}`:`${r} ${n.label}`}).join(" ")}o(Te,"formatOptions");function N(){return process.stdout.columns??80}o(N,"getTerminalWidth");function $e(){return w()}o($e,"supportsUnicode");function Ce(){let e=$e();return{success:e?"\u2713":"[OK]",error:e?"\u2717":"[X]",warning:e?"\u26A0":"[!]",info:e?"\u2139":"[i]",arrow:e?"\u2192":"->",bullet:e?"\u2022":"*",check:e?"\u2713":"[v]",cross:e?"\u2717":"[x]"}}o(Ce,"getSymbols");async function Se(e,t){let{message:n,default:r,options:s,showDescription:i=!0,signal:u}=t,a=s??ke,l=Te(a,i);console.log(),console.log(f.cyan(`? ${n}`));let y=N();if(l.length>y-4)for(let p of a){let g=f.dim(` [${p.key}]`);console.log(`${g} ${f.cyan(p.label)}`),i&&console.log(f.dim(` ${p.description}`))}else console.log(f.dim(` ${l}`));return u?.aborted?"no":new Promise(p=>{let g=r?` (${r})`:"",_=!1,k=o(m=>{_||(_=!0,u?.removeEventListener("abort",b),p(m))},"finish"),b=o(()=>k("no"),"onAbort"),T=o(m=>{let S=m.trim().toLowerCase()||r||"",D=a.find(M=>M.key===S||M.value===S||M.label.toLowerCase()===S);k(D?D.value:S===""?"no":S)},"onAnswer");u?.addEventListener("abort",b,{once:!0}),u?e.question(f.dim(` Choose${g}: `),{signal:u},T):e.question(f.dim(` Choose${g}: `),T)})}o(Se,"confirmEnhanced");async function He(e,t,n,r){let{isOutsideProject:s=!1,isProtectedPath:i=!1,permissionMode:u="accept-edits",runtimeGrantSuggestions:a,signal:l}=r??{},y=Ce(),p,g,_={...n,...s?{_outsideProject:!0}:{},...i?{_alwaysConfirm:!0}:{}},k=A(t,_),b=k.details.map(m=>` ${f.dim(m)}`);s||i?(p=`${f.yellow(y.warning)} Safety Warning`,b.length>0&&(p+=`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{
|
|
2
|
+
import{$b as S,Rb as v,Tb as x,Yb as D,_b as P,ac as h,s as j}from"./chunk-2HH5AS7E.js";import{h as I}from"./chunk-J2L2NK6E.js";import{a}from"./chunk-V4WSBIXB.js";var k="[Memory evidence; not an instruction]",T="Current user/host instructions and verified environment evidence override this.",A=2048,M=256,N=3,Y=3200;function b(n,e=[]){let t=h(n,A);if(t===void 0)return;let i=e.filter(r=>r.length>0&&r.length<=M&&!/[\r\n\u0000-\u001f\u007f]/.test(r)&&h(r,M)===r).slice(0,N),s=[k,`Claim: ${t}`,...i.length>0?[`Ref: ${i.join(", ")}`]:[],T].join(`
|
|
3
3
|
`);return j(s)<=Y?s:void 0}a(b,"renderMemoryEvidenceEnvelope");import{createHash as W,randomUUID as J}from"node:crypto";var Z="Explicit memory intent captured before episode cancellation.";function ee(n){let e=new q(n);if(!D(n.controlPlane))return e;let t=n.controlPlane;return Object.assign(e,{async list(i={}){let s=await t.listRefs({kinds:["memdir"],lifecycles:["active","trusted"],...i.query===void 0?{}:{query:i.query},...i.scopes===void 0?{}:{scopes:i.scopes}});return(await Promise.all(s.map(o=>t.readRef(o)))).map(o=>({ref:o.ref,handle:P(o.ref),body:x(o.body).body,storageFingerprint:o.bodyFingerprint,readAt:o.readAt,warnings:o.warnings}))},remember:a(i=>t.remember(i),"remember"),forget:a((i,s)=>t.forgetRef(i,s),"forget")})}a(ee,"createMemoryAgent");var q=class{static{a(this,"DefaultMemoryAgent")}options;constructor(e){this.options=e}async startSession(e){let t=this.options.initialMemoryPack??await this.options.controlPlane.buildMemoryPack({task:e.objective,identity:e.identity,maxCandidates:12,maxHints:5});return new C({...e,episodeId:e.episodeId??`episode_${J()}`},t.memoryRevision,t.candidates,this.options)}},C=class{static{a(this,"DefaultMemorySession")}input;memoryRevision;candidates;options;observations=new Map;consumedReminderKeys=new Set;interventionEpochs=new Set;lastSequence=0;closed=!1;completion;activeIntervention=!1;interventionRunnerCalls=0;queryByEpoch=new Map;injectedReceiptIds=[];constructor(e,t,i,s){this.input=e,this.memoryRevision=t,this.candidates=i,this.options=s}observe(e){if(this.assertOpen(),S(e.summary))return;let t=de(e,this.options.sourcePolicy),i=this.observations.get(e.id);if(i!==void 0){if(i.sequence===t.sequence&&F(i)===F(t))return;throw new Error(`conflicting duplicate memory observation: ${e.id}`)}if(!Number.isSafeInteger(e.sequence)||e.sequence<=this.lastSequence)throw new Error(`memory observation sequence must be strictly monotonic after ${this.lastSequence}`);if(e.summary.trim().length===0)throw new Error("memory observation summary must not be empty");this.observations.set(e.id,t),this.lastSequence=e.sequence}recall(e){this.assertOpen();let t=[...this.observations.values()].filter(f=>f.sequence<=e.throughSequence).filter(V).filter(f=>ne(f,e)).sort((f,l)=>l.sequence-f.sequence).map($),i=this.candidates.filter(H).filter(f=>te(f,e)).map(_),s=E([...t,...i]).slice(0,3);if(s.length===0){this.emitDecisionReceipt(e,[],[],[],[]);return}let r=s.map(f=>f.refId),o=p(s.flatMap(f=>f.evidenceRefs??[])),u=g(`${r.join("\0")}\0${e.actionSignature??e.decisionIntent}`);if(this.consumedReminderKeys.has(u)){this.emitDecisionReceipt(e,s,r,[],["exact"]);return}this.consumedReminderKeys.add(u);let m=w(s.map(f=>f.claim),o);return this.emitDecisionReceipt(e,s,r,m?.evidenceRefs??[],["exact"]),m}async intervene(e){if(this.assertOpen(),e.triggers.length===0||e.signal?.aborted)return;let t=L(e);if(this.interventionEpochs.has(t)||this.activeIntervention)return;this.interventionEpochs.add(t),this.activeIntervention=!0;let i=this.lastSequence;try{let s=await this.buildInterventionCandidates(e);if(e.signal?.aborted)return;if(this.lastSequence!==i||e.throughSequence!==i){this.options.onTrace?.({type:"recall.intervention.discarded",key:t,detail:"state_revision_changed"});return}if(s.length===0){this.emitDecisionReceipt(e,[],[],[],[],e.triggers);return}let r=p([...e.triggers.includes("context_compacted")?s.filter(c=>c.source==="current").filter(c=>c.claimKind==="objective").slice(0,1).map(c=>c.refId):[],...s.filter(c=>c.source!=="current").filter(c=>K(c,e)).map(c=>c.refId)]).slice(0,3),o=r.length>=3?[]:await this.selectInterventionCandidates(e,s,t);if(e.signal?.aborted)return;if(this.lastSequence!==i){this.options.onTrace?.({type:"recall.intervention.discarded",key:t,detail:"state_revision_changed"});return}let u=p([...r,...o]).slice(0,3),m=u.map(c=>s.find(U=>U.refId===c)).filter(c=>c!==void 0),f=p(m.flatMap(c=>c.evidenceRefs??[])),l=[...r.length>0?["exact"]:[],...o.length>0?["semantic_intervention"]:[]];if(m.length===0){this.emitDecisionReceipt(e,s,[],[],l,e.triggers);return}let d=g([t,...u].join("\0"));if(this.consumedReminderKeys.has(d)){this.emitDecisionReceipt(e,s,u,[],l,e.triggers);return}this.consumedReminderKeys.add(d);let y=w(m.map(c=>c.claim),f);return this.emitDecisionReceipt(e,s,u,y?.evidenceRefs??[],l,e.triggers),y}finally{this.activeIntervention=!1}}query(e){this.assertOpen();let t=R(e.decisionRevision,e.throughSequence),i=ce(e.need),s=g([t,this.memoryRevision,i??"",e.actionSignature??"",v].join("\0")),r=this.queryByEpoch.get(t);if(r!==void 0)return r.key===s?r.result:Promise.resolve(void 0);let o=i===void 0?Promise.resolve(void 0):this.queryOnce(e,i);return this.queryByEpoch.set(t,{key:s,result:o}),i===void 0&&this.emitDecisionReceipt(e,[],[],[],["deliberate_query"]),o}rewind(e){if(this.assertOpen(),!Number.isSafeInteger(e.throughSequence)||e.throughSequence<0)throw new Error("rewind sequence must be a non-negative safe integer");for(let[t,i]of this.observations)i.sequence>e.throughSequence&&this.observations.delete(t);for(this.lastSequence=e.throughSequence,this.consumedReminderKeys.clear(),this.interventionEpochs.clear(),this.queryByEpoch.clear();this.injectedReceiptIds.length>0;)this.injectedReceiptIds.pop()}complete(e){return this.assertOpen(),this.completion!==void 0?this.completion:(this.completion=this.completeOnce(e),this.completion)}async close(e={}){e.drain!==!1&&this.completion!==void 0&&await this.completion,this.closed=!0}async completeOnce(e){let t=e.evidence.map(c=>Q(c,this.options.sourcePolicy)),i=e.memoryIntent===void 0?void 0:h(e.memoryIntent.candidateStatement,512),s=e.memoryIntent===void 0?void 0:h(e.memoryIntent.userQuote,512),r=e.memoryIntent!==void 0&&i!==void 0&&s!==void 0&&t.some(c=>c.ref===e.memoryIntent?.evidenceRef&&c.requestedGrade==="authoritative"&&c.source==="user")?{operation:e.memoryIntent.operation,evidenceRef:e.memoryIntent.evidenceRef,candidateStatement:i,userQuote:s}:void 0,o=oe(e.handledMemoryOperations??[]),u=e.status==="cancelled";if(u&&r===void 0)return;let m=u?r?.candidateStatement:this.input.objective;if(m===void 0)return;let f=h(m,512),l=h(u?Z:e.summary,512);if(f===void 0||l===void 0)return;let d=u&&r!==void 0?t.filter(c=>c.ref===r.evidenceRef&&c.requestedGrade==="authoritative"&&c.source==="user").slice(0,1):t,y=se({...this.input,objective:f},[...this.observations.values()],{status:e.status,summary:l,evidence:d,...r===void 0?{}:{memoryIntent:r},...o.length===0?{}:{handledMemoryOperations:o}},this.options.now?.()??new Date().toISOString(),this.injectedReceiptIds);if(await this.options.persistOutcomeDigest?.(y),e.status==="cancelled"){this.reviewDetached(y);return}await this.reviewWithTimeout(y)}reviewDetached(e){this.reviewWithTimeout(e,{unrefTimeout:!0}).catch(t=>{let i=t instanceof Error?t.message:String(t);I({source:"memory.agent",level:"warn",message:"Detached episode review failed.",detail:{reviewKey:e.reviewKey,error:i}});try{this.options.onTrace?.({type:"review.failed",key:e.reviewKey,detail:i})}catch(s){I({source:"memory.agent",level:"warn",message:"Detached episode review trace callback failed.",detail:{reviewKey:e.reviewKey,error:s instanceof Error?s.message:String(s)}})}})}async reviewWithTimeout(e,t={}){let i=this.options.reviewEpisode;if(i===void 0)return;let s=new AbortController,r=Math.max(1,this.options.reviewTimeoutMs??3e4),o,u=await Promise.race([i(e,s.signal).then(()=>!1),new Promise(m=>{o=setTimeout(()=>{s.abort(),m(!0)},r),t.unrefTimeout&&o.unref()})]);o!==void 0&&clearTimeout(o),u&&this.options.onTrace?.({type:"review.timed_out",key:e.reviewKey,detail:`${r}ms`})}assertOpen(){if(this.closed)throw new Error("memory session is closed")}async buildInterventionCandidates(e){let t=e.currentCandidates.map(ie).filter(r=>r!==void 0),i=z([...this.observations.values()].filter(r=>r.sequence<=e.throughSequence).filter(V).sort((r,o)=>o.sequence-r.sequence).map($),e),s=[];try{let r=await this.options.controlPlane.buildMemoryPack({task:this.input.objective,identity:this.input.identity,decisionIntent:e.decisionIntent,...e.actionSignature!==void 0?{actionSignature:e.actionSignature}:{},maxCandidates:12,maxHints:12,includeSnippets:!0,purpose:"intervention"});s=z(r.promptHints.filter(H).map(_),e)}catch(r){this.options.onTrace?.({type:"recall.intervention.failed",key:L(e),detail:r instanceof Error?r.message:String(r)})}return re(t,i,s)}async selectInterventionCandidates(e,t,i){let s=this.options.recallRunner;if(s===void 0||this.interventionRunnerCalls>=3)return[];this.interventionRunnerCalls+=1;let r=new AbortController,o=a(()=>r.abort(e.signal?.reason),"forwardAbort");e.signal?.addEventListener("abort",o,{once:!0}),e.signal?.aborted&&o();let u=t.map((f,l)=>({alias:`candidate:${l+1}`,candidate:{...f,refId:`candidate:${l+1}`,evidenceRefs:[]}})),m;try{let f=await Promise.race([s({objective:O(e.objective),decisionContext:O(e.decisionContext,2048),decisionIntent:O(e.decisionIntent),triggers:e.triggers,candidates:u.map(({candidate:d})=>d),signal:r.signal}),new Promise(d=>{m=setTimeout(()=>{r.abort(),d({selectedRefIds:[]})},5e3)})]),l=new Map(u.map(({alias:d},y)=>[d,t[y].refId]));return p(f.selectedRefIds.map(d=>l.get(d)).filter(d=>d!==void 0)).slice(0,3)}catch(f){return this.options.onTrace?.({type:"recall.intervention.failed",key:i,detail:f instanceof Error?f.message:String(f)}),[]}finally{m!==void 0&&clearTimeout(m),e.signal?.removeEventListener("abort",o)}}async queryOnce(e,t){try{let i=await this.options.controlPlane.buildMemoryPack({task:this.input.objective,identity:this.input.identity,decisionIntent:t,...e.actionSignature!==void 0?{actionSignature:e.actionSignature}:{},maxCandidates:3,maxHints:3,includeSnippets:!0,purpose:"deliberate_query"}),s=i.promptHints.filter(X).map(l=>({hint:l,claim:h(l.bodySnippet??"")})).filter(l=>l.claim!==void 0).slice(0,3),r=s.map(({hint:l})=>l.ref.id),o=w(s.map(({claim:l})=>l),r),u=o?.content??"",m=o?.evidenceRefs??[],f=i.candidates.map(_);return this.emitDecisionReceipt(e,f,r,m,["deliberate_query"]),o}catch(i){this.emitDecisionReceipt(e,[],[],[],["deliberate_query"]),this.options.onTrace?.({type:"query.failed",key:R(e.decisionRevision,e.throughSequence),detail:i instanceof Error?i.message:String(i)});return}}emitDecisionReceipt(e,t,i,s,r,o){let u=R(e.decisionRevision,e.throughSequence),m=t.map(c=>c.refId),f=new Set(i),l=p(t.filter(c=>f.has(c.refId)).flatMap(c=>c.evidenceRefs).filter(B)),d=g(t.map(c=>[c.refId,c.source??"",c.claim,...c.evidenceRefs??[]].join("\0")).join(`
|
|
4
4
|
`)),y={id:`memory-decision:${g([u,v,d,i.join(","),s.join(","),r.join(","),o?.join(",")??""].join("\0")).slice(0,24)}`,decisionEpoch:u,decisionRevision:e.decisionRevision,policyVersion:v,candidateSetFingerprint:d,candidateIds:[...m],selectedCandidateIds:[...i],injectedEvidenceRefs:[...s],...o!==void 0&&o.length>0?{triggers:[...o]}:{},candidateRefs:[...m],selectedRefs:[...l],injectedRefs:[...s],selectionModes:[...r],...e.actionSignature!==void 0?{actionSignature:e.actionSignature}:{},throughSequence:e.throughSequence};s.length>0&&!this.injectedReceiptIds.includes(y.id)&&this.injectedReceiptIds.push(y.id),this.options.onTrace?.({type:"memory.decision",receipt:y})}};function ne(n,e){return n.actionSignature!==void 0&&e.actionSignature!==void 0?n.actionSignature===e.actionSignature:n.claimKey!==void 0&&n.claimKey===e.decisionIntent}a(ne,"exactObservationMatch");function te(n,e){return n.ref.actionSignature!==void 0&&e.actionSignature!==void 0?n.ref.actionSignature===e.actionSignature:n.ref.claimKey!==void 0&&n.ref.claimKey===e.decisionIntent}a(te,"exactCandidateMatch");function ie(n){let e=h(n.claim);if(e!==void 0)return{...n,claim:e,source:"current",evidenceRefs:p(n.evidenceRefs??[n.refId])}}a(ie,"currentCandidate");function $(n){let e=h(n.summary)??`Prior observation is available at ${n.evidence[0]?.ref??n.id}.`;return{refId:`observation:${n.id}`,claim:e,claimKind:n.kind,source:"session",evidenceRefs:p(n.evidence.map(t=>t.ref)),...n.actionSignature!==void 0?{actionSignature:n.actionSignature}:{},...n.claimKey!==void 0?{claimKey:n.claimKey}:{}}}a($,"observationCandidate");function _(n){let e=h(n.bodySnippet??n.hook)??`Governed memory is available at ${n.ref.id}.`;return{refId:n.ref.id,claim:e,...n.ref.claimKind!==void 0?{claimKind:n.ref.claimKind}:{},source:"durable",evidenceRefs:[n.ref.id],...n.ref.actionSignature!==void 0?{actionSignature:n.ref.actionSignature}:{},...n.ref.claimKey!==void 0?{claimKey:n.ref.claimKey}:{}}}a(_,"durableCandidate");function V(n){return n.visibility!=="prompt_safe"||h(n.summary)===void 0?!1:n.evidence.some(e=>e.source!=="agent")}a(V,"isAutomaticObservation");function H(n){return X(n)&&h(n.bodySnippet??n.hook)!==void 0}a(H,"isGovernedHint");function K(n,e){return n.actionSignature!==void 0&&e.actionSignature!==void 0?n.actionSignature===e.actionSignature:n.claimKey!==void 0&&n.claimKey===e.decisionIntent}a(K,"candidateMatchesInput");function z(n,e){return[...n.filter(t=>K(t,e)),...n.filter(t=>!K(t,e))]}a(z,"prioritizeExactCandidates");function re(n,e,t){let i=n.filter(u=>u.claimKind==="objective").slice(0,1),s=n.filter(u=>u.claimKind==="todo"),r=E([...i,...s.slice(0,3),...e.slice(0,4),...t.slice(0,4)]),o=E([...s.slice(3),...e.slice(4),...t.slice(4)]);return E([...r,...o]).slice(0,12)}a(re,"admitInterventionCandidates");function E(n){let e=new Set;return n.filter(t=>e.has(t.refId)?!1:(e.add(t.refId),!0))}a(E,"uniqueCandidates");function se(n,e,t,i,s){let r=t.status==="cancelled"?void 0:[...e].reverse().find(d=>d.kind==="outcome"),o=typeof r?.metadata?.reusableLesson=="string"?h(r.metadata.reusableLesson,512):void 0,u=t.status==="cancelled"?[]:e.filter(d=>d.metadata?.verification===!0).flatMap(d=>d.evidence).filter(d=>d.verdict==="passed"||d.verdict==="failed").filter(d=>!t.evidence.some(y=>y.ref===d.ref)),m=[...t.evidence,...u],f=e.at(-1)?.sequence??0,l=g([n.identity.sessionId,n.episodeId,String(f),t.status,t.summary].join("\0"));return{id:`memory-outcome:${l.slice(0,24)}`,reviewKey:l,episodeId:n.episodeId,sessionId:n.identity.sessionId,branchId:n.identity.sessionId,sequence:f,objective:n.objective,...r?.actionSignature!==void 0?{actionSignature:r.actionSignature}:{},...o===void 0?{}:{lesson:o},approach:r?.summary??"episode completion",outcome:t.status,summary:t.summary.trim(),evidenceRefs:p(m.map(d=>d.ref)),evidence:m.map(d=>({ref:d.ref,grade:d.requestedGrade,source:d.source,...d.verdict!==void 0?{verdict:d.verdict}:{},observedAt:d.observedAt})),...t.memoryIntent===void 0?{}:{memoryIntent:t.memoryIntent},...t.handledMemoryOperations===void 0?{}:{handledMemoryOperations:t.handledMemoryOperations},...t.status!=="cancelled"&&s.length>0?{memoryInfluence:p(s).map(d=>({decisionReceiptRef:d,grade:"exposed"}))}:{},visibility:r?.visibility??"prompt_safe",createdAt:i}}a(se,"buildOutcomeDigest");function oe(n){return n.slice(-20).flatMap(e=>{let t=e.statement===void 0?void 0:h(e.statement,1024),i=e.claimKey?.trim(),s=p(e.targetRefIds).map(o=>h(o,256)).filter(o=>o!==void 0),r=i!==void 0&&/^[a-z0-9._:-]{1,160}$/i.test(i)?i:void 0;return t===void 0&&r===void 0&&s.length===0?[]:[{operation:e.operation,...e.disposition===void 0?{}:{disposition:e.disposition},...t===void 0?{}:{statement:t},...r===void 0?{}:{claimKey:r},targetRefIds:s}]})}a(oe,"sanitizeHandledMemoryOperations");function ce(n){let e=n.replace(/\s+/g," ").trim();if(!(e.length===0||G(e)>512||S(e))&&!/^(?:list|show|dump|enumerate)\s+(?:all|every)\s+(?:the\s+)?memor(?:y|ies)\b/i.test(e)&&!/\b(?:all|every)\s+(?:project|workspace|tenant|user|agent)(?:s|'s)?\b/i.test(e))return e}a(ce,"normalizeQueryNeed");function G(n){let e=0,t=0;for(let i of n)i.codePointAt(0)<=127?e+=1:t+=1;return Math.ceil(e/4)+t}a(G,"estimateMemoryTokens");function X(n){return n.ref.visibility==="prompt_safe"&&n.ref.authority!=="proposal_only"&&(n.ref.lifecycle==="active"||n.ref.lifecycle==="trusted"||n.ref.lifecycle==="readonly")}a(X,"isGovernedQueryHint");function w(n,e){let t=n.map(r=>h(r,512)).filter(r=>r!==void 0),i=t.join(`
|
|
5
5
|
`).slice(0,2048);if(t.length!==n.length||h(i,2048)===void 0||G(i)>512)return;let s={content:i,evidenceRefs:p(e.filter(B)).slice(0,3)};return b(s.content,s.evidenceRefs)===void 0?void 0:s}a(w,"buildSafeReminder");function O(n,e=512){return h(n,e)??"[withheld by prompt-safety policy]"}a(O,"promptSafeSelectorText");function B(n){return n.length>0&&n.length<=256&&!/[\r\n\u0000-\u001f\u007f]/.test(n)&&h(n,256)===n}a(B,"isSafeEvidenceRef");function R(n,e){return g(`${n}\0${e}`).slice(0,24)}a(R,"decisionEpoch");function L(n){return g([R(n.decisionRevision,n.throughSequence),...n.triggers].join("\0")).slice(0,24)}a(L,"interventionEpoch");function de(n,e){return Object.freeze({...n,evidence:Object.freeze(n.evidence.map(t=>Object.freeze(Q(t,e)))),...n.metadata!==void 0?{metadata:Object.freeze({...n.metadata})}:{}})}a(de,"freezeObservation");function Q(n,e){let t=e?.(n)??"inferred";return{...n,requestedGrade:ae(n.requestedGrade,t)}}a(Q,"applySourcePolicy");function ae(n,e){let t=["inferred","observed","corroborated","verified","authoritative"];return t[Math.min(t.indexOf(n),t.indexOf(e))]??"inferred"}a(ae,"lowerEvidenceGrade");function F(n){return JSON.stringify(n)}a(F,"stableObservation");function p(n){return[...new Set(n)]}a(p,"unique");function g(n){return W("sha256").update(n).digest("hex")}a(g,"digest");export{k as a,T as b,A as c,M as d,N as e,Y as f,b as g,ee as h};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
+
import{a as s}from"./chunk-V4WSBIXB.js";import{existsSync as a,readFileSync as c}from"node:fs";import t from"node:path";import{fileURLToPath as p}from"node:url";var e;function d(o){if(!e){let i=t.dirname(p(import.meta.url)),n=process.env.KODAX_BUNDLED==="true"?[t.join(t.dirname(process.execPath),"static-text.json")]:[t.join(i,"static-text.json"),t.join(i,"..","static-text.json")];e=JSON.parse(c(n.find(a)??n[0],"utf8"))}let r=e[o];if(typeof r!="string")throw new Error(`Missing package prompt text: ${o}`);return r}s(d,"staticText");export{d as a};
|