@kodax-ai/kodax 0.7.96 → 0.7.97-alpha.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 +86 -0
- package/README.md +85 -62
- package/README_CN.md +57 -67
- package/config-templates/config.example.jsonc +0 -14
- package/dist/chunks/{agent-7N427EVB.js → agent-J7SHFM5N.js} +1 -1
- package/dist/chunks/argument-completer-ZJQOWTIS.js +2 -0
- package/dist/chunks/{chunk-ABZDFK2X.js → chunk-2GV6MQ4T.js} +14 -14
- package/dist/chunks/{chunk-6QI3GOYG.js → chunk-3PS3YEDS.js} +1 -1
- package/dist/chunks/chunk-4VJMQDTH.js +417 -0
- package/dist/chunks/{chunk-NI7PBPUR.js → chunk-5DSUVP46.js} +1 -1
- package/dist/chunks/chunk-5P7RTSZT.js +21 -0
- package/dist/chunks/{chunk-XXNR6S4Q.js → chunk-6ZAQKFIM.js} +1 -1
- package/dist/chunks/chunk-7V2QBZ73.js +137 -0
- package/dist/chunks/{chunk-C7U542KM.js → chunk-F7DHZH6T.js} +1 -1
- package/dist/chunks/{chunk-7IMWOR34.js → chunk-HSRYDDPF.js} +1 -1
- package/dist/chunks/chunk-K3DQGSQU.js +372 -0
- package/dist/chunks/chunk-NO23K2CB.js +2 -0
- package/dist/chunks/{chunk-NKT3B3DR.js → chunk-OT5WHAX4.js} +1 -1
- package/dist/chunks/{chunk-YEAUDI6U.js → chunk-QGWHJIO4.js} +1 -1
- package/dist/chunks/chunk-QOFFAY5C.js +261 -0
- package/dist/chunks/{chunk-4PFZ7BEE.js → chunk-QVDTORL3.js} +11 -11
- package/dist/chunks/chunk-QZ4B4AWG.js +473 -0
- package/dist/chunks/chunk-RXDS6CNA.js +355 -0
- package/dist/chunks/{chunk-WV3DJVW4.js → chunk-VDGPJQL7.js} +135 -135
- package/dist/chunks/chunk-VEZ4WHPN.js +641 -0
- package/dist/chunks/chunk-ZPPAT25E.js +5 -0
- package/dist/chunks/chunk-ZQYWDI4O.js +1 -0
- package/dist/chunks/chunk-ZS2GUADU.js +498 -0
- package/dist/chunks/{chunk-GN2IY5YE.js → chunk-ZTYZYXGV.js} +1 -1
- package/dist/chunks/{chunk-EM4XJBTK.js → chunk-ZZQ4GDVU.js} +1 -1
- package/dist/chunks/{client-6WZZTTSV.js → client-MXOJ5XUN.js} +1 -1
- package/dist/chunks/{compaction-config-ZMEJU4U7.js → compaction-config-5VZSGKBQ.js} +1 -1
- package/dist/chunks/{construction-bootstrap-RX4DMHI7.js → construction-bootstrap-U2ZU2WAT.js} +1 -1
- package/dist/chunks/dist-CSLNWLOE.js +2 -0
- package/dist/chunks/dist-XXMJMJDU.js +2 -0
- package/dist/chunks/host-RUXYZFYN.js +2 -0
- package/dist/chunks/readline-helpers-JCVULR4C.js +2 -0
- package/dist/chunks/run-manager-DRIM5VNE.js +2 -0
- package/dist/chunks/utils-MQEBGKIX.js +2 -0
- package/dist/index.d.ts +63 -30
- package/dist/index.js +10 -6
- package/dist/kodax_bootstrap.js +1 -1
- package/dist/kodax_cli.js +1745 -1734
- package/dist/kodax_resume.js +32 -35
- 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/sandbox-network-broker.js +77 -77
- package/dist/sdk-a2a.d.ts +33 -18
- package/dist/sdk-a2a.js +8 -9
- package/dist/sdk-agent.d.ts +33 -26
- package/dist/sdk-agent.js +1 -1
- package/dist/sdk-client.d.ts +40 -0
- package/dist/sdk-client.js +2 -0
- package/dist/sdk-coding.d.ts +87 -499
- package/dist/sdk-coding.js +1 -1
- package/dist/sdk-experimental-memory.d.ts +3 -4
- package/dist/sdk-experimental-memory.js +1 -1
- package/dist/sdk-llm.d.ts +11 -9
- 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 +3 -1
- package/dist/sdk-media.js +1 -1
- package/dist/sdk-repl.d.ts +317 -70
- package/dist/sdk-repl.js +2 -2
- package/dist/sdk-runtime.d.ts +580 -452
- package/dist/sdk-runtime.js +1 -1
- package/dist/sdk-sandbox.js +1 -1
- package/dist/sdk-session.d.ts +13 -9
- package/dist/sdk-session.js +1 -1
- package/dist/sdk-skills.js +1 -1
- package/dist/semantic-worker.js +57 -57
- package/dist/types-chunks/{base.d-Bt9lhwSV.d.ts → base.d-ZBOdjDUT.d.ts} +2 -1
- package/dist/types-chunks/{bash-prefix-extractor.d-DWFIMg0v.d.ts → bash-prefix-extractor.d-DvswAXKS.d.ts} +136 -66
- package/dist/types-chunks/{capability-learning.d-gRtO03f6.d.ts → capability-learning.d-B4pxKwP4.d.ts} +1 -1
- package/dist/types-chunks/{capability.d-Ch5Vos33.d.ts → capability.d-DOF3r0fJ.d.ts} +1 -1
- package/dist/types-chunks/{capsule.d-Dj1n6s0Y.d.ts → capsule.d-B4atvlxE.d.ts} +7 -19
- package/dist/types-chunks/client-contract-A1jdk6xz.d.ts +1993 -0
- package/dist/types-chunks/{controller.d-C0IM1Tud.d.ts → controller.d-BkUJ_3sl.d.ts} +1 -1
- package/dist/types-chunks/{controller.d-J2t1q8Ly.d.ts → controller.d-yyKajPTi.d.ts} +140 -1380
- package/dist/types-chunks/{cost-tracker.d-BWI4lFWn.d.ts → cost-tracker.d-BeaenODW.d.ts} +2 -47
- package/dist/types-chunks/{history-retrieval.d-CPN5PMBV.d.ts → history-retrieval.d-JdFfkeF3.d.ts} +2 -2
- package/dist/types-chunks/{manager.d-rtmywU9M.d.ts → manager.d-C_20XqCV.d.ts} +8 -1
- package/dist/types-chunks/manifest.d-Bw2i-zQi.d.ts +18 -0
- package/dist/types-chunks/provider-credential-context.d-BH2OaB1b.d.ts +47 -0
- package/dist/types-chunks/provider-request-observation.d-jL8T6wVO.d.ts +34 -0
- package/dist/types-chunks/{public-api.d-amBop8Nk.d.ts → public-api.d-Cq8ILMte.d.ts} +52 -13
- package/dist/types-chunks/{resolver.d-BrwLoWNr.d.ts → resolver.d-DLY01RHx.d.ts} +4 -2
- package/dist/types-chunks/{types.d-CSv0_cZC.d.ts → review-inbox.d-BeaLRNHx.d.ts} +251 -3
- package/dist/types-chunks/{shell-command-sets.d-oejwpP_7.d.ts → review-packet.d-D4bbTbq3.d.ts} +46 -3
- package/dist/types-chunks/{exec-policy.d-BPESl90L.d.ts → run-manager.d-C7Q71rin.d.ts} +385 -62
- package/dist/types-chunks/runtime-client-info-CxnlZlW5.d.ts +175 -0
- package/dist/types-chunks/{sdk-session-B6XjHNU1.d.ts → sdk-session-BDFjCpDn.d.ts} +12 -4
- package/dist/types-chunks/{side-query.d-DHWG1JZg.d.ts → side-query.d-DTrhVd_r.d.ts} +4 -3
- package/dist/types-chunks/trusted-repl-entry-vbUM8R6P.d.ts +445 -0
- package/dist/types-chunks/{types.d-CtO8mR1s.d.ts → types.d-BJTN-RZr.d.ts} +5 -5
- package/dist/types-chunks/{types.d-BrQMB-hy.d.ts → types.d-BjOq57-z.d.ts} +6 -0
- package/dist/types-chunks/types.d-o7t9dds4.d.ts +1484 -0
- package/dist/types-chunks/{utils.d-DcznBeQ3.d.ts → utils.d-CWiMhFfu.d.ts} +202 -36
- package/docs/CLIENT_CONTRACT.md +441 -0
- package/docs/SDK_MIGRATION.md +123 -0
- package/docs/SPACE_SDK_SEAMS.md +139 -0
- package/package.json +10 -5
- package/public_docs/README.md +12 -133
- package/public_docs/configuration/config-files.md +8 -14
- package/public_docs/sdk/embedder-guide.md +494 -420
- package/dist/chunks/argument-completer-FAIHW7HZ.js +0 -2
- package/dist/chunks/chunk-66XN5AFU.js +0 -417
- package/dist/chunks/chunk-7O2AIFNE.js +0 -373
- package/dist/chunks/chunk-DSXUXUZG.js +0 -5
- package/dist/chunks/chunk-GYO73UYQ.js +0 -275
- package/dist/chunks/chunk-HPCS3LZ5.js +0 -324
- package/dist/chunks/chunk-HZYRLIOC.js +0 -137
- package/dist/chunks/chunk-SC2ELSUS.js +0 -675
- package/dist/chunks/chunk-TEUD5VPJ.js +0 -471
- package/dist/chunks/chunk-TYZ2ZAYL.js +0 -487
- package/dist/chunks/dist-3UCCMCYR.js +0 -2
- package/dist/chunks/dist-F5IWZSAY.js +0 -2
- package/dist/chunks/host-W2JJ3V3Q.js +0 -2
- package/dist/chunks/run-manager-RBWU3EVE.js +0 -2
- package/dist/chunks/utils-DJ4ZFJGL.js +0 -2
- package/dist/runtime-worker.js +0 -5381
- package/dist/types-chunks/review-inbox.d-CTeUIKda.d.ts +0 -225
- package/dist/types-chunks/run-manager.d-hm1XgEou.d.ts +0 -94
- package/dist/types-chunks/trusted-repl-entry-D0w5M0UZ.d.ts +0 -323
- package/dist/types-chunks/types.d-B1l9pWyX.d.ts +0 -146
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
+
import{F as x,G as b,a as p,b as u,f as v,m as h,n as y,o as m}from"./chunk-ZS2GUADU.js";import{q as w}from"./chunk-QOFFAY5C.js";import{_d as f}from"./chunk-VDGPJQL7.js";import{a as t}from"./chunk-ONUPGMER.js";function g(s,c){let i=t(async e=>{let o=structuredClone(e.input);for(let a of["authorization","credential","hostTools","providerCredential","providerCredentialAccess","origin","trustedRunId"])delete o[a];let n=await c?.({...e,input:o},s);return{...o,...n===void 0?{}:{authorization:structuredClone(n)}}},"authorize");return{statistics:s.statistics??{read:t(async()=>{throw new Error("Execution facts require a compatible Host.")},"read"),readRequests:t(async()=>{throw new Error("Execution facts require a compatible Host.")},"readRequests"),readTools:t(async()=>{throw new Error("Execution facts require a compatible Host.")},"readTools")},lifecycle:s.lifecycle??{requestExit:t(async()=>{throw new Error("Client exit control requires a compatible daemon Host.")},"requestExit"),readExit:t(async()=>{throw new Error("Client exit control requires a compatible daemon Host.")},"readExit"),listPendingExits:t(async()=>{throw new Error("Client exit control requires a compatible daemon Host.")},"listPendingExits")},commands:{execute:t(async e=>s.invocations.executeCommand(await i({kind:"command",input:e})),"execute"),readPrompt:t(e=>s.invocations.readCommandPrompt(e),"readPrompt")},review:{start:t(async e=>s.invocations.startReview(await i({kind:"review",input:e})),"start")},host:{shutdown:t(()=>s.daemon!==void 0?s.daemon.shutdown():s.close().then(()=>({accepted:!0})),"shutdown")},sessions:{cancel:t(e=>s.sessions.cancel(e),"cancel"),create:t(e=>s.sessions.create(e),"create"),list:t(e=>s.sessions.list(e),"list"),read:t(e=>s.sessions.load(e),"read"),delete:t(e=>s.sessions.delete(e),"delete"),archive:t(e=>s.sessions.archive(e),"archive"),unarchive:t(e=>s.sessions.unarchive(e),"unarchive"),getAutoModeStats:t(async e=>await s.sessions.getAutoModeStats(e)??void 0,"getAutoModeStats"),getSettings:t(async e=>p(await s.sessions.getSettings(e)),"getSettings"),getSettingsVersioned:t(async e=>{let o=await s.sessions.getSettingsVersioned(e);return{revision:o.revision,value:p(o.value)}},"getSettingsVersioned"),updateSettingsVersioned:t(async(e,o,n)=>{let a=await s.sessions.updateSettingsVersioned(e,o,n);return{revision:a.revision,value:p(a.value)}},"updateSettingsVersioned"),updateSettings:t(async(e,o)=>p(await s.sessions.updateSettings(e,o)),"updateSettings"),observe:t((e,o,n)=>s.sessions.observeView(e,o,n),"observe"),readItem:t((e,o,n)=>s.sessions.readViewItem(e,o,n),"readItem"),readHistory:t((e,o)=>s.sessions.readHistory(e,o),"readHistory"),readHistoryEntry:t((e,o,n)=>s.sessions.readHistoryEntry(e,o,n),"readHistoryEntry"),searchHistory:t((e,o)=>s.sessions.searchHistory(e,o),"searchHistory"),readGoal:t(e=>s.sessions.readGoal(e),"readGoal"),createGoal:t((e,o)=>s.sessions.createGoal({sessionId:e,...o}),"createGoal"),pauseGoal:t(e=>s.sessions.pauseGoal(e),"pauseGoal"),resumeGoal:t(e=>s.sessions.resumeGoal(e),"resumeGoal"),clearGoal:t(e=>s.sessions.clearGoal(e),"clearGoal"),appendNotice:t(async(e,o)=>{if(!await s.sessions.appendNotice({sessionId:e,...o}))throw new Error("Host did not save the Session notice.")},"appendNotice"),readLineage:t(e=>s.sessions.readLineage(e),"readLineage"),labelEntry:t((e,o)=>s.sessions.labelEntry({sessionId:e,...o}),"labelEntry"),selectBranch:t((e,o,n)=>s.sessions.setActiveEntry({sessionId:e,entryId:o,...n}).then(a=>{if(a===null)throw Object.assign(new Error("No lineage entry matches the selector."),{code:"conflict"});return a}),"selectBranch"),rewindSession:t((e,o)=>s.sessions.rewind({sessionId:e,...o}).then(n=>{if(n===null)throw Object.assign(new Error("Rewind target no longer resolves."),{code:"conflict"});return n}),"rewindSession"),forkSession:t((e,o)=>s.sessions.fork({sessionId:e,...o??{}}).then(n=>{if(n===null)throw Object.assign(new Error("Fork boundary no longer resolves."),{code:"conflict"});return n}),"forkSession"),recoverSession:t((e,o)=>s.sessions.recover({sessionId:e,...o??{}}),"recoverSession"),compact:t(async(e,o)=>{let n=await i({kind:"compaction",input:{...o,sessionId:e}}),a=await s.sessions.compact({sessionId:n.sessionId,customInstructions:n.customInstructions,...n.authorization?.credential!==void 0?{credential:n.authorization.credential}:{}});return{compacted:a.compacted,messages:a.messages,tokensBefore:a.tokensBefore,tokensAfter:a.tokensAfter,...a.report!==void 0?{report:a.report}:{},...a.reason!==void 0?{reason:a.reason}:{}}},"compact")},learning:{list:t(e=>s.learning.list(e),"list"),get:t(e=>s.learning.get(e),"get"),getSnapshot:t(()=>s.learning.getSnapshot(),"getSnapshot"),events:t(e=>s.learning.events(e),"events"),subscribe:t(e=>s.learning.subscribe(e),"subscribe"),acknowledge:t(e=>s.learning.acknowledge(e),"acknowledge"),snooze:t((e,o)=>s.learning.snooze(e,o),"snooze"),reject:t(e=>s.learning.reject(e),"reject"),disable:t(e=>s.learning.disable(e),"disable"),rollback:t(e=>s.learning.rollback(e),"rollback"),promote:t((e,o)=>s.learning.promote(e,o),"promote"),review:t(e=>s.learning.review(e),"review"),trust:t(e=>s.learning.trust(e),"trust")},memory:{async forProject(e){let o=await s.memory.forProject(e);return{memoryRoot:o.memoryRoot,entrypointPath:o.entrypointPath,listReviews:t(()=>o.listReviews(),"listReviews"),reviewerProviderConfigured:t(()=>o.reviewerProviderConfigured(),"reviewerProviderConfigured"),rebuild:t(()=>o.rebuild(),"rebuild"),ensureOpenTarget:t(n=>o.ensureOpenTarget(n),"ensureOpenTarget"),controller:{listRefs:t(n=>o.controller.listRefs(n),"listRefs"),readRef:t(n=>o.controller.readRef(n),"readRef"),remember:t(n=>o.controller.remember(n),"remember"),forgetRef:t((n,a)=>o.controller.forgetRef(n,a),"forgetRef"),approveProposal:t((n,a,r)=>o.controller.approveProposal(n,a,r),"approveProposal"),rejectProposal:t((n,a,r)=>o.controller.rejectProposal(n,a,r),"rejectProposal"),listInbox:t(async()=>(await o.controller.listInbox()).map(n=>({...n,revision:f(n)})),"listInbox"),showProposal:t(async n=>{let a=await o.controller.showProposal(n);return a===void 0?void 0:{...a,revision:f(a)}},"showProposal")}}}},inputs:{submit:t(async e=>s.runs.acceptInput(await i({kind:"input",input:e})),"submit"),read:t((e,o)=>s.runs.getInput(e,o),"read"),withdraw:t((e,o)=>s.runs.withdrawInput(e,o),"withdraw")},runs:{startTool:t(async e=>{let o=await i({kind:"tool",input:e}),n=await s.runs.start({sessionId:o.sessionId,inputId:o.inputId,prompt:o.rawInput,options:{toolInvocation:{name:o.name,input:o.input}},...o.authorization!==void 0?{authorization:o.authorization}:{}});return{runId:n.runId,sessionId:n.sessionId}},"startTool"),read:t(e=>s.runs.get(e),"read"),stop:t(e=>s.runs.abort(e),"stop"),await:t(async e=>{let o=await s.runs.await(e);return{runId:o.runId,sessionId:o.sessionId,phase:o.phase,...o.result!==void 0?{result:o.result}:{},...o.error!==void 0?{error:o.error.message}:{},...o.terminal!==void 0?{terminal:o.terminal}:{},...o.stop!==void 0?{stop:o.stop}:{}}},"await")},interactions:{list:t(e=>s.interactions.list(e),"list"),respond:t((e,o)=>s.interactions.respond(e,o),"respond")},permissions:{listGrants:t(async()=>{let e=await s.permissions.listGrants();return{revision:e.revision,grants:e.value.map(o=>({id:o.id,...o.scope.sessionId!==void 0?{sessionId:o.scope.sessionId}:{},...o.label!==void 0?{label:o.label}:{},...o.persistence!==void 0?{persistence:o.persistence}:{}}))}},"listGrants"),revokeGrant:t((e,o)=>s.permissions.revokeGrant(e,o),"revokeGrant")},registrations:{list:t(()=>s.admin.agentRegistrations.list(),"list"),upsert:t((e,o)=>s.admin.agentRegistrations.upsert(e,o),"upsert"),setEnabled:t((e,o,n)=>s.admin.agentRegistrations.setEnabled(e,o,n),"setEnabled"),remove:t((e,o)=>s.admin.agentRegistrations.remove(e,o),"remove")},agents:{reviewLean:t(async e=>s.invocations.startAgentsLean(await i({kind:"agents_lean",input:e})),"reviewLean"),tree:t(e=>s.agents.tree(e),"tree"),detail:t((e,o)=>s.agents.detail(e,o),"detail"),spawn:t(async(e,o)=>{let n=await i({kind:"agent_spawn",input:{sessionId:e,agent:o}});return n.authorization===void 0?s.agents.spawn(e,n.agent):s.agents.spawn(e,n.agent,{authorization:n.authorization})},"spawn"),send:t((e,o,n,a)=>s.agents.send(e,o,n,a),"send"),followup:t(async(e,o,n,a)=>{let r=await i({kind:"agent_followup",input:{sessionId:e,actorPath:o,objective:n,...a?.expectedRevision===void 0?{}:{expectedRevision:a.expectedRevision}}});return s.agents.followup(e,o,n,{expectedRevision:r.expectedRevision,...r.authorization===void 0?{}:{authorization:r.authorization}})},"followup"),interrupt:t((e,o,n)=>s.agents.interrupt(e,o,n),"interrupt"),output:t((e,o,n)=>s.agents.output(e,o,n),"output"),wait:t((e,o,n,a)=>s.agents.wait(e,o,n,a?.signal===void 0?void 0:{signal:a.signal}),"wait")},config:{read:t(async()=>u(await s.config.read()),"read"),readEffective:t(async()=>{let{entries:e}=await s.config.readEffective(),o=t((a,r)=>({value:r,source:e[a]?.source??"unset",applied:e[a]?.applied===!0||e[a]?.present!==!0}),"project"),n=e.fallbackProviders?.value;return{verifierLog:o("verifierLog",e.verifierLog?.value==="1"||e.verifierLog?.value===!0),stallLog:o("stallLog",e.stallLog?.value==="1"||e.stallLog?.value===!0),fallbackProviders:o("fallbackProviders",typeof n=="string"?n.split(",").map(a=>a.trim()).filter(Boolean):Array.isArray(n)?n.filter(a=>typeof a=="string"):[])}},"readEffective"),patch:t(async e=>u(await s.config.patch(e)),"patch"),reload:t(async()=>({ok:!0,config:u((await s.config.reload()).config)}),"reload")},mcp:{status:t(()=>s.mcp.status(),"status"),listServers:t(()=>s.mcp.listServers(),"listServers"),getServer:t(e=>s.mcp.getServer(e),"getServer"),validateServer:t((e,o)=>s.mcp.validateServer(e,o),"validateServer"),upsertServer:t((e,o)=>s.mcp.upsertServer(e,o),"upsertServer"),deleteServer:t(e=>s.mcp.deleteServer(e),"deleteServer"),reloadServers:t(()=>s.mcp.reloadServers(),"reloadServers"),listTools:t(e=>s.mcp.listTools(e),"listTools")},workflows:{start:t(async e=>s.workflows.start({...await i({kind:"workflow",input:e}),settingsDefaults:"product"}),"start"),list:t(async e=>{let o=[];for(let n of await s.workflows.list(e??{})){let a=n.updatedAt===void 0?await s.workflows.get(n.runId):n;if(a?.updatedAt===void 0)throw new Error(`Workflow process is unavailable: ${n.runId}`);o.push({runId:n.runId,workflowName:n.workflow,status:n.status,totalSpawned:n.totalSpawned,eventCount:n.eventCount,runDir:n.runDir,...n.endedAt!==void 0?{endedAt:new Date(n.endedAt).toISOString()}:{},startedAt:new Date(n.startedAt).toISOString(),updatedAt:a.updatedAt,...a.displayName!==void 0?{displayName:a.displayName}:{},...n.resultText!==void 0?{resultSummary:n.resultText}:{},...n.error!==void 0?{error:n.error}:{}})}return o},"list"),get:t(e=>s.workflows.get(e),"get"),subscribe:t((e,o,n)=>{let a=s.workflows.subscribe(e,o,n);return{ready:a.ready??Promise.resolve(),close:t(()=>a.close(),"close")}},"subscribe"),pause:t(e=>s.workflows.pause(e),"pause"),resume:t(e=>s.workflows.resume(e),"resume"),stop:t((e,o)=>s.workflows.stop(e,o),"stop")},catalog:{extensions:t(async()=>{let e=await s.catalog.extensions(),o=t(({path:r,label:d,loadSource:l})=>({path:r,label:d,loadSource:l}),"loaded"),n=t(({kind:r,id:d,label:l})=>({kind:r,id:d,label:l}),"source"),a=e.diagnostics;return{active:e.active,extensions:e.extensions.map(o),diagnostics:a&&{loadedExtensions:a.loadedExtensions.map(o),capabilityProviders:a.capabilityProviders.map(({id:r,kinds:d,metadata:l})=>({id:r,kinds:d,metadata:l})),commands:a.commands.map(({name:r,aliases:d,description:l})=>({name:r,aliases:d,description:l})),tools:a.tools.map(r=>({name:r.name,source:n(r.source),shadowedSources:r.shadowedSources.map(n)})),hooks:a.hooks.map(r=>({hook:r.hook,order:r.order,source:n(r.source)})),failures:a.failures.map(r=>({stage:r.stage,target:r.target,message:r.message,source:n(r.source)})),defaults:{activeTools:a.defaults.activeTools,modelSelection:{...a.defaults.modelSelection},thinkingLevel:a.defaults.thinkingLevel}}}},"extensions"),providers:t(()=>s.catalog.providers(),"providers"),models:t(async e=>(await s.catalog.providers()).filter(o=>e?.provider===void 0||o.name===e.provider).map(o=>({provider:o.name,models:o.models})),"models"),reasoningEfforts:t(e=>s.catalog.reasoningEfforts(e),"reasoningEfforts"),probeReasoningEfforts:t(e=>s.catalog.probeReasoningEfforts(e),"probeReasoningEfforts"),forgetCapabilities:t(e=>s.catalog.forgetCapabilities(e),"forgetCapabilities"),commands:t(async e=>(await s.catalog.commands(e)).map(o=>({name:o.name,...o.aliases!==void 0?{aliases:o.aliases}:{},description:o.description,source:String(o.source),...o.userInvocable!==void 0?{userInvocable:o.userInvocable}:{}})),"commands"),skills:t(async e=>(await s.catalog.skills(e)).map(o=>({name:o.name,description:o.description,userInvocable:o.userInvocable,path:o.path,source:String(o.source)})),"skills")},disconnect:t(()=>s.close(),"disconnect")}}t(g,"toKodaXProductClient");import C from"node:path";async function H(s){let{instanceId:c,instanceSecret:i}=s.clientInfo;if(!c||!/^[A-Za-z0-9_.:-]{4,160}$/.test(c)||!i||i.length<32||i.length>512)throw new Error("Exit recovery requires the original stable client identity and secret.");let e=v(s.homeDir===void 0?w:C.resolve(s.homeDir,".kodax"),s.profile);return Promise.all(y(e,h(c,i)).map(o=>m(e,o)))}t(H,"readKodaXClientExits");async function q(s={}){return g(await b({...s,requirements:{productClient:1,productHistoryBoundaries:1,productExitControl:1,productExecutionFacts:1,...s.authorizeExecution?{productExecutionAuthorization:1,productActorAuthorization:1}:{}}}),s.authorizeExecution)}t(q,"ensureKodaXClient");async function j(s={}){let c=await x({homeDir:s.homeDir,profile:s.profile,endpoint:s.endpoint,daemonToken:s.token,autoStart:!1,clientInfo:s.clientInfo,requirements:{productClient:1,productHistoryBoundaries:1,productExitControl:1,productExecutionFacts:1,...s.authorizeExecution?{productExecutionAuthorization:1,productActorAuthorization:1}:{}}});return g(c,s.authorizeExecution)}t(j,"connectKodaXClient");export{g as a,H as b,q as c,j as d};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{D,
|
|
2
|
+
import{D,J as F}from"./chunk-2GV6MQ4T.js";import{g as q,h as j,i as N,j as P,ta as C}from"./chunk-4VJMQDTH.js";import{Dg as $,Eg as k,Fg as y,Ig as _,Jg as b,Kg as x,Qd as W,Rd as M,Wd as I}from"./chunk-VDGPJQL7.js";import{C as v,D as T,Fb as O,lb as E}from"./chunk-7V2QBZ73.js";import{a as o}from"./chunk-ONUPGMER.js";import{join as Le}from"node:path";var ae=["You generate KodaX Dynamic Workflow scripts.","Return JSON only. Do not wrap the answer in prose.","For simple tasks that do not benefit from multiple agents, return:",'{"action":"decline","reason":"..."}',"For complex tasks, return:",'{"action":"generate","manifest":{...},"source":"async function run(wf, args) { ... }","approvalSummary":"..."}',"Generated source may only coordinate agents through wf and args.","Generated source must return displayable final text for the user.","Never use import, require, process, fs, child_process, network APIs, shell commands, or direct file access."].join(`
|
|
3
3
|
`),G=12e4,le="KODAX_WORKFLOW_GENERATION_TIMEOUT_SEC",ce="KODAX_WORKFLOW_GENERATION_TIMEOUT_MS",ue=64,fe=2,de=2e3,pe=[{name:"default"},{name:"variant-results",finalText:o((e,n)=>`Variant smoke child report from ${e} (${n}).`,"finalText"),synthesizeText:"Variant smoke synthesis report."},{name:"unverified-success",status:o(()=>"completed_unverified","status"),finalText:o(e=>`Smoke result for ${e}: completed with verification warnings.`,"finalText"),synthesizeText:"Smoke synthesis: completed with verification warnings."},{name:"empty-args-rerun",args:o(()=>({}),"args")}],me=[{id:"import",pattern:/\bimport\s*(?:\(|['"*{]|\w+\s+from\b)/},{id:"require",pattern:/\brequire\s*\(/},{id:"process",pattern:/\bprocess\s*(?:\.|\[)/},{id:"fs",pattern:/\b(?:node:)?fs\b/},{id:"child_process",pattern:/\bchild_process\b/},{id:"shell",pattern:/\b(?:exec|spawn|execFile)\s*\(/},{id:"fetch",pattern:/\bfetch\s*\(/},{id:"Deno",pattern:/\bDeno\s*(?:\.|\[)/},{id:"Bun",pattern:/\bBun\s*(?:\.|\[)/},{id:"globalThis-index",pattern:/\bglobalThis\s*\[/}];function we(e=process.env,n){let t=v(n?.workflow?.generationTimeoutSec,"timeouts.workflow.generationTimeoutSec");if(t!==void 0)return t;let r=T(e[le]);if(r!==void 0)return r;let s=e[ce];if(s===void 0||s.trim().length===0)return G;let i=Number(s);return!Number.isFinite(i)||i<=0?G:Math.floor(i)}o(we,"resolveWorkflowGenerationTimeoutMs");function he(e,n){if(typeof e!="object"||e===null)throw new Error(`${n} must be an object`);return e}o(he,"readRecord");function K(e,n){let t=e[n];if(typeof t!="string"||t.trim().length===0)throw new Error(`workflow generation ${n} must be a non-empty string`);return t}o(K,"readNonEmptyString");function ge(e){let n=e.trim(),t=/^```(?:json)?\s*([\s\S]*?)\s*```$/i.exec(n);if(t?.[1])return t[1].trim();let r=n.indexOf("{"),s=n.lastIndexOf("}");if(r>=0&&s>r)return n.slice(r,s+1);throw new Error("workflow generation output did not contain a JSON object")}o(ge,"extractJsonText");function ke(e){let n=ge(e);return he(JSON.parse(n),"workflow generation output")}o(ke,"parseGenerationJson");function ye(e){if(typeof e=="string"){let t=e.trim();return t.length>0?t:void 0}if(typeof e!="object"||e===null)return;let n=e;for(let t of["name","id","title","phase"]){let r=n[t];if(typeof r=="string"&&r.trim().length>0)return r.trim()}}o(ye,"normalizePhaseEntry");function be(e){return e.split(/(?:->|\u2192|,|\n)/).map(n=>n.trim()).filter(n=>n.length>0)}o(be,"splitPhaseString");function xe(e){if(typeof e!="object"||e===null)return e;let n=e,t=n.phases,r;if(Array.isArray(t)){let s=t.map(ye);s.every(i=>i!==void 0)&&(r=s)}else if(typeof t=="string"){let s=be(t);s.length>0&&(r=s)}return r?{...n,phases:r}:e}o(xe,"normalizeGeneratedManifestCandidate");function ve(e){return e.match(/\bwf\.(?:runAgent|spawnAgent|synthesize)\s*\(/g)?.length??0}o(ve,"estimateDirectAgentCalls");function Se(e,n){let t=e.maxConcurrency*Math.max(1,e.phases.length)+2,r=ve(n)+2,s=Math.min(ue,Math.max(e.maxAgents,t,r));return s>e.maxAgents?{...e,maxAgents:s}:e}o(Se,"reserveGeneratedWorkflowAgentCapacity");function w(e){let n="",t=0,r=["code"],s=[0];for(;t<e.length;){let i=e[t],a=e[t+1];if(r[r.length-1]==="template"){if(i==="\\"){n+=" ",t+=2;continue}if(i==="`"){n+=" ",t+=1,r.pop(),s.pop();continue}if(i==="$"&&a==="{"){n+=" ",t+=2,r.push("code"),s.push(0);continue}n+=i===`
|
|
4
4
|
`?`
|
|
5
5
|
`:" ",t+=1;continue}if(i==="/"&&a==="/"){for(n+=" ",t+=2;t<e.length&&e[t]!==`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{La as c,
|
|
2
|
+
import{La as c,qf as o}from"./chunk-VDGPJQL7.js";import{a as n}from"./chunk-ONUPGMER.js";import{readFile as a}from"fs/promises";var i={enabled:!0,triggerPercent:75};async function s(r){let t=c("config.json");try{let e=await f(t);if(e?.compaction)return o({...i,...e.compaction})}catch{}return o(i)}n(s,"loadCompactionConfig");async function f(r){try{let t=await a(r,"utf-8");return JSON.parse(t)}catch{return null}}n(f,"readConfigFile");export{s as a};
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
+
import{ba as Me,da as _e}from"./chunk-K3DQGSQU.js";import{Ka as ke,Sa as Se,Wa as Ce}from"./chunk-VDGPJQL7.js";import{G as me,La as ge,Ma as ve,Na as ye,Oa as we,Pa as xe,Qa as Y,S as z,V as B,W as he,X as J,Xa as Ee,Ya as I,ab as Q,lb as be,qb as Pe}from"./chunk-7V2QBZ73.js";import{a as r}from"./chunk-ONUPGMER.js";import m from"fs";import h from"path";import{exec as wt,spawnSync as xt}from"child_process";import{promisify as Et}from"util";import{fileURLToPath as bt}from"url";var Z="en";function Ye(){return(process.env.LC_ALL||process.env.LC_MESSAGES||process.env.LANG||"").toLowerCase().startsWith("zh")?"zh":"en"}r(Ye,"detectSystemLocale");function Oe(e){if(!e||e==="auto"){Z=Ye();return}Z=e.toLowerCase().replace(/[-_].*/,"")==="zh"?"zh":"en"}r(Oe,"setLocale");var Ae={en:{"dialog.confirm":"[Confirm]","dialog.select":"[Select]","dialog.input":"[Input]","confirm.instruction.basic":"Press (y) yes, (n) no","confirm.instruction.always":"Press (y) yes, (a) always yes for this tool, (n) no","confirm.instruction.runtime_session":"Press (y) allow once, (s) allow this Runtime scope for the session, (n) no","confirm.instruction.runtime_persistent":"Press (y) allow once, (s) allow this Runtime scope for the session, (a) always allow this Runtime scope, (n) no","confirm.instruction.protected":"Press (y) to confirm, (n) to cancel (protected path)","confirm.result.approved":"Approved","confirm.result.approved_always":"Approved (always)","confirm.result.approved_session":"Approved (this session)","confirm.result.denied":"Denied","tool.bash.title":"Execute bash command?","tool.shell.title":"Execute shell command?","tool.write.title":"Write to file?","tool.edit.title":"Edit file?","tool.generic.title":"Execute {tool}?","field.reason":"Reason","field.intent":"Intent","field.target":"Target","field.scope":"Scope","field.risk":"Risk","field.summary":"Summary","intent.read":"Read project files","intent.delete":"Delete files","intent.deps":"Modify dependencies or environment","intent.modify":"Modify files","intent.execute":"Execute command","intent.write_file":"Write file","intent.edit_file":"Edit file","intent.use_tool":"Use {tool}","risk.destructive":"Destructive change","risk.deps":"May change dependencies or local tools","risk.modify":"May modify files","risk.unknown":"Command effects depend on its arguments","risk.network":"May access network","scope.outside":"Outside project","scope.protected":"Protected path","waiting.confirm":"Waiting: approval required","waiting.select":"Waiting: choose an option","waiting.input":"Waiting: answer the prompt","placeholder.confirm":"Respond to the approval prompt above...","placeholder.select":"Choose an option above...","placeholder.input":"Answer the prompt above...","placeholder.busy":"Agent is busy...","placeholder.queue":"Queue a follow-up for the next round...","placeholder.idle":"Type a message...","select.choice":"Choice:","select.type_number":"(type a number)","select.more":"{count} more choices...","select.more_above":"\u2191 {count} more above","select.more_below":"\u2193 {count} more below","select.confirm_hint":"Press Enter to confirm, Esc to cancel","select.navigate_hint":"Use \u2191\u2193 to navigate, Enter to confirm, Esc to cancel","select.multiselect_hint":"Use \u2191\u2193 to navigate, Space to toggle, Enter to confirm, Esc to cancel","select.multiselect_empty":"Select at least one option with Space before confirming.","select.multiselect_min":"Select at least {min} option(s) with Space before confirming.","select.multiselect_max":"Select at most {max} option(s) with Space before confirming.","select.back_prev":"\u2190 Back to previous question","input.default":"Default:","input.value":"Value:","input.type_response":"(type your response)","managed.completed":"Task completed","managed.completed.blocked":"Task blocked","managed.completed.continuation":"Task needs continuation","todo.progress":"{completed}/{total} completed","todo.transcript.progress":"Plan {completed}/{total} completed","todo.summary.done":"{count} done","todo.summary.more":"+{count} more",cancelled:"[Cancelled] Operation cancelled by user",cancellationRequested:"[Cancelling] Stop requested for the current reply",cancellationAccepted:"Stop request accepted; waiting for execution to settle.",cancellationConfirmed:"Stop confirmed:",cancellationRejected:"Stop request failed:"},zh:{"dialog.confirm":"[\u786E\u8BA4]","dialog.select":"[\u9009\u62E9]","dialog.input":"[\u8F93\u5165]","confirm.instruction.basic":"\u6309 (y) \u786E\u8BA4, (n) \u62D2\u7EDD","confirm.instruction.always":"\u6309 (y) \u786E\u8BA4, (a) \u59CB\u7EC8\u5141\u8BB8\u6B64\u5DE5\u5177, (n) \u62D2\u7EDD","confirm.instruction.runtime_session":"\u6309 (y) \u4EC5\u5141\u8BB8\u4E00\u6B21, (s) \u672C\u4F1A\u8BDD\u59CB\u7EC8\u5141\u8BB8\u8FD9\u9879\u7CBE\u786E\u64CD\u4F5C, (n) \u62D2\u7EDD","confirm.instruction.runtime_persistent":"\u6309 (y) \u4EC5\u5141\u8BB8\u4E00\u6B21, (s) \u672C\u4F1A\u8BDD\u59CB\u7EC8\u5141\u8BB8\u8FD9\u9879\u7CBE\u786E\u64CD\u4F5C, (a) \u59CB\u7EC8\u5141\u8BB8\u8FD9\u9879\u7CBE\u786E\u64CD\u4F5C, (n) \u62D2\u7EDD","confirm.instruction.protected":"\u6309 (y) \u786E\u8BA4, (n) \u53D6\u6D88 (\u53D7\u4FDD\u62A4\u8DEF\u5F84)","confirm.result.approved":"\u5DF2\u6279\u51C6","confirm.result.approved_always":"\u5DF2\u6279\u51C6 (\u59CB\u7EC8\u5141\u8BB8)","confirm.result.approved_session":"\u5DF2\u6279\u51C6 (\u672C\u4F1A\u8BDD)","confirm.result.denied":"\u5DF2\u62D2\u7EDD","tool.bash.title":"\u6267\u884C bash \u547D\u4EE4\uFF1F","tool.shell.title":"\u6267\u884C shell \u547D\u4EE4\uFF1F","tool.write.title":"\u5199\u5165\u6587\u4EF6\uFF1F","tool.edit.title":"\u7F16\u8F91\u6587\u4EF6\uFF1F","tool.generic.title":"\u6267\u884C {tool}\uFF1F","field.reason":"\u539F\u56E0","field.intent":"\u610F\u56FE","field.target":"\u76EE\u6807","field.scope":"\u8303\u56F4","field.risk":"\u98CE\u9669","field.summary":"\u6458\u8981","intent.read":"\u8BFB\u53D6\u9879\u76EE\u6587\u4EF6","intent.delete":"\u5220\u9664\u6587\u4EF6","intent.deps":"\u4FEE\u6539\u4F9D\u8D56\u6216\u73AF\u5883","intent.modify":"\u4FEE\u6539\u6587\u4EF6","intent.execute":"\u6267\u884C\u547D\u4EE4","intent.write_file":"\u5199\u5165\u6587\u4EF6","intent.edit_file":"\u7F16\u8F91\u6587\u4EF6","intent.use_tool":"\u4F7F\u7528 {tool}","risk.destructive":"\u7834\u574F\u6027\u53D8\u66F4","risk.deps":"\u53EF\u80FD\u4FEE\u6539\u4F9D\u8D56\u6216\u672C\u5730\u5DE5\u5177","risk.modify":"\u53EF\u80FD\u4FEE\u6539\u6587\u4EF6","risk.unknown":"\u547D\u4EE4\u6548\u679C\u53D6\u51B3\u4E8E\u53C2\u6570","risk.network":"\u53EF\u80FD\u8BBF\u95EE\u7F51\u7EDC","scope.outside":"\u9879\u76EE\u5916\u90E8","scope.protected":"\u53D7\u4FDD\u62A4\u8DEF\u5F84","waiting.confirm":"\u7B49\u5F85\u4E2D\uFF1A\u9700\u8981\u5BA1\u6279","waiting.select":"\u7B49\u5F85\u4E2D\uFF1A\u8BF7\u9009\u62E9","waiting.input":"\u7B49\u5F85\u4E2D\uFF1A\u8BF7\u56DE\u7B54","placeholder.confirm":"\u8BF7\u56DE\u5E94\u4E0A\u65B9\u7684\u5BA1\u6279\u63D0\u793A...","placeholder.select":"\u8BF7\u5728\u4E0A\u65B9\u9009\u62E9\u4E00\u4E2A\u9009\u9879...","placeholder.input":"\u8BF7\u56DE\u7B54\u4E0A\u65B9\u7684\u63D0\u793A...","placeholder.busy":"\u667A\u80FD\u4F53\u6B63\u5728\u5DE5\u4F5C\u4E2D...","placeholder.queue":"\u6392\u961F\u7B49\u5F85\u4E0B\u4E00\u8F6E\u8DDF\u8FDB...","placeholder.idle":"\u8F93\u5165\u6D88\u606F...","select.choice":"\u9009\u9879\uFF1A","select.type_number":"(\u8F93\u5165\u7F16\u53F7)","select.more":"\u8FD8\u6709 {count} \u4E2A\u9009\u9879...","select.more_above":"\u2191 \u4E0A\u65B9\u8FD8\u6709 {count} \u4E2A","select.more_below":"\u2193 \u4E0B\u65B9\u8FD8\u6709 {count} \u4E2A","select.confirm_hint":"\u6309 Enter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88","select.navigate_hint":"\u4F7F\u7528 \u2191\u2193 \u5BFC\u822A\uFF0CEnter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88","select.multiselect_hint":"\u4F7F\u7528 \u2191\u2193 \u5BFC\u822A\uFF0C\u7A7A\u683C \u5207\u6362\u9009\u4E2D\uFF0CEnter \u786E\u8BA4\uFF0CEsc \u53D6\u6D88","select.multiselect_empty":"\u8BF7\u5148\u4F7F\u7528\u7A7A\u683C\u9009\u62E9\u81F3\u5C11\u4E00\u4E2A\u9009\u9879\u3002","select.multiselect_min":"\u8BF7\u5148\u4F7F\u7528\u7A7A\u683C\u81F3\u5C11\u9009\u62E9 {min} \u4E2A\u9009\u9879\u3002","select.multiselect_max":"\u6700\u591A\u53EA\u80FD\u9009\u62E9 {max} \u4E2A\u9009\u9879\u3002","select.back_prev":"\u2190 \u8FD4\u56DE\u4E0A\u4E00\u9898","input.default":"\u9ED8\u8BA4\u503C\uFF1A","input.value":"\u503C\uFF1A","input.type_response":"(\u8F93\u5165\u4F60\u7684\u56DE\u7B54)","managed.completed":"\u4EFB\u52A1\u5B8C\u6210","managed.completed.blocked":"\u4EFB\u52A1\u53D7\u963B","managed.completed.continuation":"\u4EFB\u52A1\u9700\u8981\u7EE7\u7EED","todo.progress":"{completed}/{total} \u5DF2\u5B8C\u6210","todo.transcript.progress":"\u8BA1\u5212 {completed}/{total} \u5DF2\u5B8C\u6210","todo.summary.done":"{count} \u9879\u5DF2\u5B8C\u6210","todo.summary.more":"\u53E6\u6709 {count} \u9879",cancelled:"[\u5DF2\u53D6\u6D88] \u64CD\u4F5C\u5DF2\u88AB\u7528\u6237\u53D6\u6D88",cancellationRequested:"[\u6B63\u5728\u53D6\u6D88] \u5DF2\u8BF7\u6C42\u505C\u6B62\u5F53\u524D\u56DE\u590D",cancellationAccepted:"\u505C\u6B62\u8BF7\u6C42\u5DF2\u63A5\u53D7\uFF0C\u6B63\u5728\u7B49\u5F85\u6267\u884C\u6536\u5C3E\u3002",cancellationConfirmed:"\u505C\u6B62\u5DF2\u786E\u8BA4\uFF1A",cancellationRejected:"\u505C\u6B62\u8BF7\u6C42\u5931\u8D25\uFF1A"}};function Bt(e,t){let o=Ae[Z][e]??Ae.en[e]??e;if(t)for(let[i,s]of Object.entries(t))o=o.replace(`{${i}}`,String(s));return o}r(Bt,"t");var Re={core:`// Split configs: ~/.kodax/integrations/mcp.json, extensions.json, and a2a.json.
|
|
3
|
+
// KodaX core configuration template.
|
|
4
|
+
// Copy only the fields you need to ~/.kodax/config.json (strict JSON).
|
|
5
|
+
// MCP, A2A, and Extensions live in ~/.kodax/integrations/*.json; use
|
|
6
|
+
// \`kodax integrations migrate\` to preview legacy declarations.
|
|
7
|
+
{
|
|
8
|
+
// Active provider alias and optional model override. Run \`kodax setup\` or
|
|
9
|
+
// \`/model\` instead of editing these manually when possible.
|
|
10
|
+
// "provider": "deepseek",
|
|
11
|
+
// "model": "deepseek-flash",
|
|
12
|
+
// Add or reorder model ids shown by \`/model\` for a provider.
|
|
13
|
+
// "providerModels": {
|
|
14
|
+
// "deepseek": ["deepseek-flash", "deepseek-v4-pro"]
|
|
15
|
+
// },
|
|
16
|
+
|
|
17
|
+
// Native model reasoning. \`effort\` is the preferred explicit depth;
|
|
18
|
+
// \`reasoningCeiling\` is the session ceiling. \`reasoningMode\` and \`thinking\`
|
|
19
|
+
// remain accepted for backward compatibility.
|
|
20
|
+
// "effort": "high",
|
|
21
|
+
// "planModeEffort": "high",
|
|
22
|
+
// "reasoningCeiling": "auto",
|
|
23
|
+
// "reasoningMode": "auto",
|
|
24
|
+
// "thinking": true,
|
|
25
|
+
|
|
26
|
+
// Agent harness: "ama" enables adaptive multi-agent use; "sa" forces one
|
|
27
|
+
// agent. Permission profiles are "plan", "accept-edits", sandbox-first
|
|
28
|
+
// "auto", or direct-host "full-access". Full Access has no sandbox or
|
|
29
|
+
// approval prompts; built-in dangerous-command fallbacks do not apply.
|
|
30
|
+
// Explicit forbidden rules still block; explicit prompt rules cannot prompt.
|
|
31
|
+
// Exec Policy is separate:
|
|
32
|
+
// ~/.kodax/exec-policy.jsonc (and explicitly trusted project policy).
|
|
33
|
+
// "agentMode": "ama",
|
|
34
|
+
// "permissionMode": "accept-edits",
|
|
35
|
+
// User-level Bash allow patterns. Project additions belong in
|
|
36
|
+
// <project>/.kodax/config.local.json. Broad Bash(*) is rejected.
|
|
37
|
+
// "alwaysAllowTools": ["Bash(npm test)", "Bash(git status:*)"],
|
|
38
|
+
// "autoMode": {
|
|
39
|
+
// "classifierModel": "provider:model"
|
|
40
|
+
// },
|
|
41
|
+
// Optional policy body appended to the fixed Auto reviewer contract.
|
|
42
|
+
// Review runs only at a proven host boundary: 90s, then one infra-only 180s retry.
|
|
43
|
+
// "autoReview": { "policy": "Prefer reversible, narrowly scoped operations." },
|
|
44
|
+
|
|
45
|
+
// UI/manual locale.
|
|
46
|
+
// "locale": "zh",
|
|
47
|
+
|
|
48
|
+
// Custom providers store public connection metadata only. Put the actual
|
|
49
|
+
// credential in the named environment variable, never in this file. Use
|
|
50
|
+
// \`kodax setup --custom\` for the guided writer.
|
|
51
|
+
// "customProviders": [
|
|
52
|
+
// {
|
|
53
|
+
// "name": "my-relay",
|
|
54
|
+
// "protocol": "openai",
|
|
55
|
+
// "baseUrl": "https://api.example.com/v1",
|
|
56
|
+
// "apiKeyEnv": "MY_RELAY_API_KEY",
|
|
57
|
+
// "model": "provider/model",
|
|
58
|
+
// "models": ["provider/model", "provider/fast-model"],
|
|
59
|
+
// "reasoning": { "efforts": ["off", "low", "high"], "default": "high" },
|
|
60
|
+
// "userAgentMode": "compat",
|
|
61
|
+
// "contextWindow": 128000,
|
|
62
|
+
// "maxOutputTokens": 8192,
|
|
63
|
+
// "maxOutputTokensField": "max_completion_tokens",
|
|
64
|
+
// "thinkingBudgetCap": 32000,
|
|
65
|
+
// "imageInput": true,
|
|
66
|
+
// "promptCacheAffinity": false,
|
|
67
|
+
// "replayReasoningContent": false,
|
|
68
|
+
// "strictThinkingSignature": false,
|
|
69
|
+
// "streamMaxDurationMs": 300000,
|
|
70
|
+
// "verifyStrategy": "models-list"
|
|
71
|
+
// }
|
|
72
|
+
// ],
|
|
73
|
+
|
|
74
|
+
// Repository intelligence. Mode: "auto", "full", "light", or "off".
|
|
75
|
+
// "repoIntelligenceMode": "auto",
|
|
76
|
+
// "repoIntelligenceTrace": false,
|
|
77
|
+
// "repoIntelligence": {
|
|
78
|
+
// "toolWaitMs": 250,
|
|
79
|
+
// "workerTimeoutMs": 30000,
|
|
80
|
+
// "workerOldSpaceMb": 1024,
|
|
81
|
+
// "storageDir": "~/.kodax/repo-intelligence"
|
|
82
|
+
// },
|
|
83
|
+
|
|
84
|
+
// Runtime/provider diagnostics and timeouts.
|
|
85
|
+
// "streamIdleTimeoutMs": 120000,
|
|
86
|
+
// "verifierLog": false,
|
|
87
|
+
// "stallLog": false,
|
|
88
|
+
|
|
89
|
+
// Ordered provider fallback for child tasks and optional model tiers used by
|
|
90
|
+
// workflow/dispatch model hints.
|
|
91
|
+
// "fallbackProviders": ["ark-coding", "kimi-code"],
|
|
92
|
+
// "fastProvider": "openai",
|
|
93
|
+
// "fastModel": "gpt-5-mini",
|
|
94
|
+
// "deepProvider": "anthropic",
|
|
95
|
+
// "deepModel": "claude-opus-4-6",
|
|
96
|
+
|
|
97
|
+
// Provider/LSP/ACP process settings.
|
|
98
|
+
// "maxOutputTokens": 8192,
|
|
99
|
+
// "disablePromptCache": false,
|
|
100
|
+
// "lsp": true,
|
|
101
|
+
// "lspAutoDownload": false,
|
|
102
|
+
// "acpLogLevel": "info",
|
|
103
|
+
|
|
104
|
+
// Automatic large compaction is always enabled. Percentage defaults to 75
|
|
105
|
+
// and is clamped to 15..90. A missing/zero absolute threshold is inactive;
|
|
106
|
+
// otherwise the smaller percentage, absolute, and physical limit wins.
|
|
107
|
+
// "compaction": {
|
|
108
|
+
// "enabled": true,
|
|
109
|
+
// "contextWindow": 128000,
|
|
110
|
+
// "triggerPercent": 75,
|
|
111
|
+
// "triggerTokens": 0
|
|
112
|
+
// },
|
|
113
|
+
|
|
114
|
+
// 0 disables automatic session pruning.
|
|
115
|
+
// "sessionRetentionDays": 0,
|
|
116
|
+
|
|
117
|
+
// Workflow host concurrency. The Runtime still applies its system cap.
|
|
118
|
+
// "workflow": { "maxConcurrency": 8 }
|
|
119
|
+
}
|
|
120
|
+
`,mcp:`// User MCP declarations: ~/.kodax/integrations/mcp.json (strict JSON).
|
|
121
|
+
// The whole file hot-reloads; healthy entries remain active if one new entry
|
|
122
|
+
// fails to prepare. Keep credentials in \${env:NAME} references.
|
|
123
|
+
{
|
|
124
|
+
"version": 1,
|
|
125
|
+
"servers": {}
|
|
126
|
+
// Example:
|
|
127
|
+
// "servers": {
|
|
128
|
+
// "reporting": {
|
|
129
|
+
// "type": "streamable-http",
|
|
130
|
+
// "url": "https://mcp.example.com",
|
|
131
|
+
// "headers": { "Authorization": "Bearer \${env:REPORTING_MCP_TOKEN}" },
|
|
132
|
+
// "connect": "lazy"
|
|
133
|
+
// }
|
|
134
|
+
// }
|
|
135
|
+
}
|
|
136
|
+
`,a2a:`// Bidirectional A2A configuration: ~/.kodax/integrations/a2a.json.
|
|
137
|
+
// \`agents\` calls many third-party Agents. The optional singleton \`server\`
|
|
138
|
+
// exposes exactly one KodaX general task Agent; ACP remains the coding/editor
|
|
139
|
+
// protocol. Uncomment only the entries you need; no token value belongs here.
|
|
140
|
+
// Legacy version 1 files remain readable. Non-empty files require an explicit
|
|
141
|
+
// stopped-daemon migration; new/empty files and every later write use version 2.
|
|
142
|
+
{
|
|
143
|
+
"version": 2,
|
|
144
|
+
|
|
145
|
+
// Create this inbound block with \`kodax a2a expose\`; config never starts a
|
|
146
|
+
// listener by itself. Do not copy private Agent instructions, Runtime Skills,
|
|
147
|
+
// model names, or local paths into the public \`published.skills\` list.
|
|
148
|
+
// Managed workspaces default below
|
|
149
|
+
// ~/kodax_a2a_server_workspace/<runtime-profile>/contexts/<context-key>/.
|
|
150
|
+
// Native read/grep/glob remains available according to workspace access.
|
|
151
|
+
// Arbitrary shell is never exposed. Skill instructions/assets need no
|
|
152
|
+
// process authority. An exact checked-in scripts/... entry requires
|
|
153
|
+
// process="isolated", skillScripts admission, and \`kodax sandbox doctor\`.
|
|
154
|
+
// On native protocol 10, isolated Skill Script is POSIX-only. Windows is
|
|
155
|
+
// unavailable because its required per-command denyRead is unsupported.
|
|
156
|
+
// ASRT receives no KodaX credentials or ambient ~/.srt-settings.json and its
|
|
157
|
+
// script quota is observed; hostile tenants also require an outer container/VM.
|
|
158
|
+
//
|
|
159
|
+
// "server": {
|
|
160
|
+
// "execution": {
|
|
161
|
+
// "kind": "local-agent",
|
|
162
|
+
// "agentRef": { "source": "markdown:user", "name": "report-agent" },
|
|
163
|
+
// "workspace": { "mode": "managed" },
|
|
164
|
+
// "toolPolicy": {
|
|
165
|
+
// "workspace": "write",
|
|
166
|
+
// "process": "deny",
|
|
167
|
+
// "network": { "mode": "deny" },
|
|
168
|
+
// "tools": [],
|
|
169
|
+
// "mcp": {},
|
|
170
|
+
// "skillScripts": {},
|
|
171
|
+
// "subagents": "deny"
|
|
172
|
+
// }
|
|
173
|
+
// },
|
|
174
|
+
// "published": {
|
|
175
|
+
// "name": "KodaX Agent",
|
|
176
|
+
// "description": "Completes approved general tasks.",
|
|
177
|
+
// "version": "0.7.71",
|
|
178
|
+
// "skills": [{ "id": "general", "name": "General", "description": "Complete general tasks.", "tags": [] }],
|
|
179
|
+
// "inputModes": ["text/plain"],
|
|
180
|
+
// "outputModes": ["text/plain"]
|
|
181
|
+
// },
|
|
182
|
+
// "authentication": { "type": "bearer-env", "tokenEnv": "KODAX_A2A_TOKEN", "principalId": "configured-client" },
|
|
183
|
+
// "dataDir": "~/.kodax/a2a/tasks"
|
|
184
|
+
// },
|
|
185
|
+
|
|
186
|
+
// Production OAuth2 resource-server alternative for the server above. The
|
|
187
|
+
// external Authorization Server issues access tokens and, for JWT tokens,
|
|
188
|
+
// signs them. KodaX holds no issuer signing key; it validates RFC 9068 tokens
|
|
189
|
+
// against the issuer's rotating JWKS, audience, expiry, subject, and scopes.
|
|
190
|
+
// Replace the server.authentication value above with:
|
|
191
|
+
// {
|
|
192
|
+
// "type": "oauth2-jwt",
|
|
193
|
+
// "scheme": "enterprise-oauth",
|
|
194
|
+
// "issuer": "https://identity.example.com",
|
|
195
|
+
// "audience": "https://agent.example.com/a2a",
|
|
196
|
+
// "jwksUrl": "https://identity.example.com/.well-known/jwks.json",
|
|
197
|
+
// "tokenUrl": "https://identity.example.com/oauth/token",
|
|
198
|
+
// "metadataUrl": "https://identity.example.com/.well-known/oauth-authorization-server",
|
|
199
|
+
// "requiredScopes": ["a2a.invoke"]
|
|
200
|
+
// }
|
|
201
|
+
|
|
202
|
+
"agents": {
|
|
203
|
+
// Fixed Bearer compatibility example. \`enabled\` is hot desired state:
|
|
204
|
+
// disabled Agents remain configured but are not candidates for new
|
|
205
|
+
// orchestration, while already admitted remote tasks may finish.
|
|
206
|
+
// "reporting": {
|
|
207
|
+
// "cardUrl": "https://agents.example.com/.well-known/agent-card.json",
|
|
208
|
+
// "enabled": true,
|
|
209
|
+
// "credentialEnv": "REPORTING_A2A_TOKEN",
|
|
210
|
+
// "effect": "read"
|
|
211
|
+
// },
|
|
212
|
+
|
|
213
|
+
// Private addresses and plaintext HTTP are separate, default-deny
|
|
214
|
+
// permissions. Exact loopback HTTP needs neither. Private HTTP needs both;
|
|
215
|
+
// private HTTPS needs only allowPrivateAddresses. Prefer TLS whenever it is
|
|
216
|
+
// available. The equivalent CLI flags are \`--allow-private\` and
|
|
217
|
+
// \`--allow-insecure-http\`. OAuth token endpoints keep their stricter
|
|
218
|
+
// HTTPS-or-exact-loopback rule even when Agent transport HTTP is allowed.
|
|
219
|
+
// "intranet": {
|
|
220
|
+
// "cardUrl": "http://10.20.30.40/.well-known/agent-card.json",
|
|
221
|
+
// "enabled": true,
|
|
222
|
+
// "network": {
|
|
223
|
+
// "allowPrivateAddresses": true,
|
|
224
|
+
// "allowInsecureHttp": true
|
|
225
|
+
// },
|
|
226
|
+
// "effect": "read"
|
|
227
|
+
// },
|
|
228
|
+
|
|
229
|
+
// Standards-based machine-to-machine OAuth2 example. The external
|
|
230
|
+
// Authorization Server issues access tokens; KodaX obtains and caches them
|
|
231
|
+
// only in process memory. \`tokenUrl\` must exactly match the selected Card
|
|
232
|
+
// OAuth2 clientCredentials flow. Use \`kodax a2a enable|disable <name>\` to
|
|
233
|
+
// mutate \`enabled\` atomically; the owning Runtime applies it asynchronously.
|
|
234
|
+
// "reviewer": {
|
|
235
|
+
// "cardUrl": "https://reviewer.example.com/.well-known/agent-card.json",
|
|
236
|
+
// "enabled": false,
|
|
237
|
+
// "effect": "read",
|
|
238
|
+
// "authentication": {
|
|
239
|
+
// "type": "oauth2-client-credentials",
|
|
240
|
+
// "scheme": "enterprise-oauth",
|
|
241
|
+
// "issuer": "https://identity.example.com",
|
|
242
|
+
// "tokenUrl": "https://identity.example.com/oauth/token",
|
|
243
|
+
// "clientId": "kodax-reviewer",
|
|
244
|
+
// "clientSecretEnv": "REVIEWER_CLIENT_SECRET",
|
|
245
|
+
// "scopes": ["a2a.invoke"],
|
|
246
|
+
// "resource": "https://reviewer.example.com/",
|
|
247
|
+
// "clientAuthentication": "client-secret-basic"
|
|
248
|
+
// }
|
|
249
|
+
// }
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
`,extensions:`// Trusted user Extension paths: ~/.kodax/integrations/extensions.json.
|
|
253
|
+
// Extensions are host code. Reload is whole-domain atomic; use MCP for
|
|
254
|
+
// capabilities that should remain outside the KodaX process.
|
|
255
|
+
{
|
|
256
|
+
"version": 1,
|
|
257
|
+
"paths": []
|
|
258
|
+
}
|
|
259
|
+
`};function Ie(e){return Re[e]}r(Ie,"getConfigTemplate");import{closeSync as ne,existsSync as d,fsyncSync as $e,linkSync as it,mkdirSync as re,openSync as ie,readFileSync as je,renameSync as Ke,statSync as st,unlinkSync as K,watch as at,writeFileSync as Fe}from"node:fs";import{createHash as ct}from"node:crypto";import f from"node:path";import{closeSync as Qe,mkdirSync as Ze,openSync as et,rmSync as tt}from"node:fs";import nt from"node:path";var ee=class extends Error{static{r(this,"CoreConfigWriteConflictError")}constructor(t){super(`Core configuration is being changed by another KodaX writer: ${t}`),this.name="CoreConfigWriteConflictError"}};function ot(e){return`${e}.write.lock`}r(ot,"coreConfigWriteLockPath");function rt(e){if(!(!(e instanceof Error)||!("code"in e)))return typeof e.code=="string"?e.code:void 0}r(rt,"errorCode");function x(e,t){Ze(nt.dirname(e),{recursive:!0,mode:448});let n=ot(e),o;try{o=et(n,"wx",384)}catch(i){throw rt(i)==="EEXIST"?new ee(e):new Error(`Failed to acquire the core configuration write lock: ${e}`,{cause:i})}try{return t()}finally{Qe(o),tt(n,{force:!0})}}r(x,"withCoreConfigWriteLock");var k=class extends Error{static{r(this,"IntegrationConfigConflictError")}constructor(t,n,o){super(`Integration configuration revision changed for ${f.basename(t)} (expected ${n??"missing"}, actual ${o??"missing"}).`),this.name="IntegrationConfigConflictError"}},lt={mcp:"mcp.json",a2a:"a2a.json",extensions:"extensions.json"},dt=new Set(["type","command","args","cwd","env","url","headers","connect","startupTimeoutMs","requestTimeoutMs","auth"]);function P(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}r(P,"isRecord");function E(e,t){if(!P(e))throw new Error(`${t} must be an object.`);return e}r(E,"requireRecord");function F(e,t,n){let o=Object.keys(e).find(i=>!t.has(i));if(o!==void 0)throw new Error(`${n} has unknown field "${o}".`)}r(F,"assertNoUnknownKeys");function Xe(e,t){if(e.version!==1)throw new Error(`${t} version must be 1.`)}r(Xe,"requireVersionOne");function Te(e,t){let n=E(e,t);for(let[o,i]of Object.entries(n))if(o.trim().length===0||typeof i!="string")throw new Error(`${t} must contain non-empty string keys and string values.`);return structuredClone(n)}r(Te,"requireStringMap");function oe(e,t){if(!Array.isArray(e)||!e.every(n=>typeof n=="string"&&n.trim().length>0))throw new Error(`${t} must be an array of non-empty strings.`);return e.map(n=>n.trim())}r(oe,"requireStringArray");function te(e,t){if(e!==void 0&&(!Number.isFinite(e)||Number(e)<=0))throw new Error(`${t} must be a positive number.`)}r(te,"validatePositiveNumber");function ut(e,t){if(e.trim().length===0)throw new Error("MCP server names must not be empty.");let n=E(t,`MCP server "${e}"`);F(n,dt,`MCP server "${e}"`);let o=n.type??"stdio";if(!["stdio","sse","streamable-http","http"].includes(String(o)))throw new Error(`MCP server "${e}" has an unsupported transport type.`);if(o==="stdio"){if(typeof n.command!="string"||n.command.trim().length===0)throw new Error(`MCP server "${e}" stdio transport requires command.`)}else if(typeof n.url!="string"||n.url.trim().length===0)throw new Error(`MCP server "${e}" ${String(o)} transport requires url.`);if(n.args!==void 0&&oe(n.args,`MCP server "${e}" args`),n.cwd!==void 0&&typeof n.cwd!="string")throw new Error(`MCP server "${e}" cwd must be a string.`);if(n.env!==void 0&&Te(n.env,`MCP server "${e}" env`),n.headers!==void 0&&Te(n.headers,`MCP server "${e}" headers`),n.connect!==void 0&&!["lazy","prewarm","disabled"].includes(String(n.connect)))throw new Error(`MCP server "${e}" has an unsupported connect mode.`);if(te(n.startupTimeoutMs,`MCP server "${e}" startupTimeoutMs`),te(n.requestTimeoutMs,`MCP server "${e}" requestTimeoutMs`),n.auth!==void 0){let i=E(n.auth,`MCP server "${e}" auth`);if(F(i,new Set(["type","clientId","authorizationUrl","tokenUrl","scopes","redirectPort"]),`MCP server "${e}" auth`),i.type!=="oauth2")throw new Error(`MCP server "${e}" auth type must be oauth2.`);for(let a of["clientId","authorizationUrl","tokenUrl"])if(i[a]!==void 0&&typeof i[a]!="string")throw new Error(`MCP server "${e}" auth.${a} must be a string.`);i.scopes!==void 0&&oe(i.scopes,`MCP server "${e}" auth.scopes`),te(i.redirectPort,`MCP server "${e}" auth.redirectPort`)}return structuredClone(n)}r(ut,"parseMcpServer");function S(e){let t=E(e,"MCP integration config");F(t,new Set(["version","servers"]),"MCP integration config"),Xe(t,"MCP integration config");let n=E(t.servers,"MCP integration config servers"),o={};for(let[i,s]of Object.entries(n))o[i]=ut(i,s);return{version:1,servers:o}}r(S,"parseMcpIntegrationDocument");function C(e){let t=E(e,"Extensions integration config");F(t,new Set(["version","paths"]),"Extensions integration config"),Xe(t,"Extensions integration config");let n=oe(t.paths,"Extensions integration config paths");if(new Set(n).size!==n.length)throw new Error("Extensions integration config paths must not contain duplicates.");return{version:1,paths:n}}r(C,"parseExtensionsIntegrationDocument");function M(e,t){return f.join(f.resolve(t),"integrations",lt[e])}r(M,"resolveIntegrationConfigPath");function A(e){return f.join(f.resolve(e),"config.json")}r(A,"coreConfigPath");function Ue(e){return ct("sha256").update(e).digest("hex")}r(Ue,"hashText");function se(e){let t=je(e,"utf8");try{return{raw:t,value:JSON.parse(t)}}catch(n){let o=n instanceof Error?n.message:String(n);throw new Error(`Invalid JSON: ${o}`)}}r(se,"readJsonFile");function _(e){return{domain:e.domain,source:e.source,path:e.path,revision:Ue(e.raw),document:structuredClone(e.document),loadedAt:new Date().toISOString()}}r(_,"snapshot");function X(e){let t=A(e);return d(t)?E(se(t).value,"Core config"):{}}r(X,"readCoreConfig");function U(e){let t=M("mcp",e);if(d(t)){let s=se(t);return _({domain:"mcp",source:"user",path:t,raw:s.raw,document:S(s.value)})}let n=A(e),o=X(e).mcpServers,i=S({version:1,servers:o===void 0?{}:o});return _({domain:"mcp",source:o===void 0?"default":"legacy-user",path:o===void 0?t:n,raw:JSON.stringify(i),document:i})}r(U,"readMcpIntegration");function q(e){let t=M("extensions",e);if(d(t)){let s=se(t);return _({domain:"extensions",source:"user",path:t,raw:s.raw,document:C(s.value)})}let n=A(e),o=X(e).extensions,i=C({version:1,paths:o===void 0?[]:o});return _({domain:"extensions",source:o===void 0?"default":"legacy-user",path:o===void 0?t:n,raw:JSON.stringify(i),document:i})}r(q,"readExtensionsIntegration");function ft(e){if(!P(e))return[];let t=[],n=/(token|secret|password|api[_-]?key|authorization)/i;for(let[o,i]of Object.entries(e))if(P(i))for(let s of["env","headers"]){let a=i[s];if(P(a))for(let[c,l]of Object.entries(a))n.test(c)&&typeof l=="string"&&!l.startsWith("${env:")&&t.push(`MCP server "${o}" ${s}.${c} may contain a literal secret.`)}return t}r(ft,"likelySecretWarnings");function pt(e){let t=X(e),n=M("mcp",e),o=M("extensions",e),i=t.mcpServers,s=t.extensions,a=P(i)?Object.keys(i).length:0,c=Array.isArray(s)?s.length:0,l=r((g,N,$)=>d(g)?{action:"none",entries:N,destination:g,reason:"destination-exists"}:$?{action:"create",entries:N,destination:g}:{action:"none",entries:0,destination:g,reason:"legacy-absent"},"domainPlan");return{mcp:l(n,a,i!==void 0),extensions:l(o,c,s!==void 0),warnings:ft(i)}}r(pt,"planLegacyIntegrationMigration");function mt(e,t){let n=A(e);re(f.dirname(n),{recursive:!0,mode:448});let o=`${n}.${process.pid}.${Date.now()}.tmp`,i=ie(o,"wx",384);try{Fe(i,`${JSON.stringify(t,null,2)}
|
|
260
|
+
`,"utf8"),$e(i)}finally{ne(i)}try{Ke(o,n)}catch(s){throw d(o)&&K(o),new Error("Failed to atomically clean legacy integration fields.",{cause:s})}}r(mt,"writeCoreConfigAtomically");function ln(e){return x(A(e.configHome),()=>ht(e))}r(ln,"migrateLegacyIntegrationConfig");function ht(e){let t=pt(e.configHome),n=X(e.configHome),o=t.mcp.action==="create"?S({version:1,servers:P(n.mcpServers)?n.mcpServers:{}}):void 0,i=t.extensions.action==="create"?C({version:1,paths:Array.isArray(n.extensions)?n.extensions:[]}):void 0,s=[];if(o)try{T({domain:"mcp",configHome:e.configHome,expectedRevision:null,document:o,validate:S}),s.push("mcp")}catch(c){if(!(c instanceof k))throw c}if(i)try{T({domain:"extensions",configHome:e.configHome,expectedRevision:null,document:i,validate:C}),s.push("extensions")}catch(c){if(!(c instanceof k))throw c}let a=!1;if(e.cleanupLegacy&&d(A(e.configHome))){let c={...n};d(t.mcp.destination)&&delete c.mcpServers,d(t.extensions.destination)&&delete c.extensions,gt(n,c)||(mt(e.configHome,c),a=!0)}return{...t,applied:s,cleanedLegacy:a}}r(ht,"migrateLegacyIntegrationConfigUnlocked");function gt(e,t){return JSON.stringify(e)===JSON.stringify(t)}r(gt,"isDeepStrictEqualForConfig");function Le(e){return d(e)?Ue(je(e,"utf8")):void 0}r(Le,"currentUserRevision");function vt(e){let t=`${e}.lock`;try{return{fd:ie(t,"wx",384),path:t}}catch(n){throw new Error(`Integration configuration is busy: ${f.basename(e)}`,{cause:n})}}r(vt,"acquireWriteLock");function T(e){let t=M(e.domain,e.configHome),n=e.validate(e.document);re(f.dirname(t),{recursive:!0,mode:448});let o=vt(t);try{let i=Le(t),s=e.expectedRevision===null?void 0:e.expectedRevision;if(e.expectedRevision!==void 0&&i!==s)throw new k(t,s,i);let a=`${JSON.stringify(n,null,2)}
|
|
261
|
+
`,c=`${t}.${process.pid}.${Date.now()}.tmp`,l=ie(c,"wx",384);try{Fe(l,a,"utf8"),$e(l)}finally{ne(l)}try{e.expectedRevision===null?(it(c,t),K(c)):Ke(c,t)}catch(g){throw d(c)&&K(c),e.expectedRevision===null&&d(t)?new k(t,void 0,Le(t)):new Error(`Failed to atomically replace ${f.basename(t)}.`,{cause:g})}return _({domain:e.domain,source:"user",path:t,raw:a,document:n})}finally{ne(o.fd),d(o.path)&&K(o.path)}}r(T,"writeIntegrationDocument");function yt(e){if(!d(e))return"missing";let t=st(e);return`${t.dev}:${t.ino}:${t.size}:${t.mtimeMs}`}r(yt,"metadataSignature");function De(e){return e.map(t=>`${t}:${yt(t)}`).join("|")}r(De,"observationSignature");function j(e,t){return{code:e,message:t,time:new Date().toISOString()}}r(j,"safeDiagnostic");var Ne=class{static{r(this,"IntegrationConfigController")}#u;#n;#r;#a;#m;#f;#p;#e;#t;#c;#l;#h="";#s=[];#o;#i;#g=Promise.resolve();#d=new Set;constructor(t){this.#u=t.domain,this.#n=M(t.domain,t.configHome),this.#r=t.fallbackPath===void 0?void 0:f.resolve(t.fallbackPath),this.#a=this.#r===void 0?[this.#n]:[this.#n,this.#r],this.#f=t.validate,this.#m=t.read,this.#p=t.coldStartDefault===void 0?void 0:structuredClone(this.#f(t.coldStartDefault))}async initialize(){let t=await this.reload();if(!t.ok&&!this.#e&&this.#p!==void 0){let n=structuredClone(this.#p);this.#e=_({domain:this.#u,source:"default",path:this.#n,raw:JSON.stringify(n),document:n})}if(!this.#e)throw new Error(t.ok?"Integration configuration did not produce a snapshot.":t.error);return structuredClone(this.#e)}snapshot(){return this.#e?structuredClone(this.#e):void 0}status(){let t=this.#t?this.#c:void 0,n=this.#t?this.#l:void 0;return{domain:this.#u,path:t??this.#e?.path??this.#n,...this.#e?{revision:this.#e.revision,lastReloadAt:this.#e.loadedAt}:{},...n??this.#e?.source?{source:n??this.#e?.source}:{},...this.#t?{diagnostic:this.#t}:{},watching:this.#s.length>0}}subscribe(t){return this.#d.add(t),()=>{this.#d.delete(t)}}reload(){let t=this.#g.then(()=>this.#v());return this.#g=t.then(()=>{},()=>{}),t}async#v(){this.#h=De(this.#a);let t;try{t=this.#m(),this.#f(t.document)}catch{let o=this.#y();return this.#c=o.path,this.#l=o.source,this.#t=j("invalid-config","Integration configuration is invalid; check the file against its versioned schema."),{ok:!1,error:this.#t.message}}let n=this.#e?structuredClone(this.#e):void 0;try{for(let o of this.#d)await o(structuredClone(t),n)}catch{return this.#c=t.path,this.#l=t.source,this.#t=j("activation-failed","Integration configuration could not be activated; the previous configuration remains active."),{ok:!1,error:this.#t.message}}return this.#e=t,this.#t=void 0,this.#c=void 0,this.#l=void 0,{ok:!0,snapshot:structuredClone(t)}}async ensureCurrent(){return De(this.#a)===this.#h&&this.#e?{ok:!0,snapshot:structuredClone(this.#e)}:this.reload()}startWatching(t=100,n=2e3){if(this.#s.length>0||this.#i)return;re(f.dirname(this.#n),{recursive:!0,mode:448});let o=new Map;for(let i of this.#a){let s=f.dirname(i),a=o.get(s)??new Set;a.add(f.basename(i)),o.set(s,a)}for(let[i,s]of o)try{let a=at(i,(c,l)=>{l!==null&&!s.has(l.toString())||(this.#o&&clearTimeout(this.#o),this.#o=setTimeout(()=>{this.#o=void 0,this.reload()},t),this.#o.unref?.())});a.unref(),a.on("error",()=>{this.#t=j("watcher-degraded","Integration watcher is degraded; metadata polling remains active.")}),this.#s.push(a)}catch{this.#t=j("watcher-degraded","Integration watcher is degraded; metadata polling remains active.")}this.#i=setInterval(()=>{this.ensureCurrent()},n),this.#i.unref?.()}close(){this.#o&&clearTimeout(this.#o),this.#o=void 0,this.#i&&clearInterval(this.#i),this.#i=void 0;for(let t of this.#s)t.close();this.#s.length=0,this.#d.clear()}#y(){return d(this.#n)?{path:this.#n,source:"user"}:this.#r&&d(this.#r)?{path:this.#r,source:"legacy-user"}:{path:this.#n,source:"default"}}};var Pt=Et(wt),qe=2,We=!1,u=ke(),kn=h.join(u,"sessions"),p=h.join(u,"config.json"),Sn=60,v=null,ce=!1,kt="dumb";function St(e){let t=h.basename(e).toLowerCase(),n="__KODAX_SHELL_ENV_START__",o=`printf '%s\\0' '${n}'; env -0`;return t==="fish"?{args:["-i","-c",o],sentinel:n}:{args:t==="bash"||t==="zsh"?["-ic",o]:["-lc",o],sentinel:n}}r(St,"buildShellEnvCommand");function Ct(e,t){let n=`${t}\0`,o=e.lastIndexOf(n);if(o===-1)return{};let i=e.slice(o+n.length),s={};for(let a of i.split("\0")){if(!a)continue;let c=a.indexOf("=");c<=0||(s[a.slice(0,c)]=a.slice(c+1))}return s}r(Ct,"parseNullDelimitedShellEnv");function Mt(e={}){let t=e.env??process.env;if((e.platform??process.platform)==="win32"||t.KODAX_DISABLE_SHELL_ENV_HYDRATION==="1")return!1;let o=e.shell??t.SHELL;if(!o||!h.isAbsolute(o))return!1;let{args:i,sentinel:s}=St(o),a=e.run??xt,c={...t,TERM:kt},l=a(o,i,{encoding:"utf8",env:c,maxBuffer:1024*1024,timeout:5e3,windowsHide:!0,detached:!0,stdio:["ignore","pipe","pipe"]});if(l.status!==0||!l.stdout)return!1;let g=typeof l.stdout=="string"?l.stdout:l.stdout.toString("utf8"),N=Ct(g,s),$=!1;for(let[V,Je]of Object.entries(N))V!=="TERM"&&t[V]===void 0&&(t[V]=Je,$=!0);return $}r(Mt,"hydrateProcessEnvFromShell");function _t(){if(!ce){ce=!0;try{Mt()}catch{}}}r(_t,"ensureShellEnvironmentHydrated");function Cn(){ce=!1}r(Cn,"resetShellEnvironmentHydrationForTesting");function At(e){Ee(e.customProviders??[])}r(At,"registerConfiguredCustomProviders");function le(e){if(!Array.isArray(e))return;let t=e.filter(n=>typeof n=="string").map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:[]}r(le,"normalizeConfiguredExtensions");function ue(){let e=m.readFileSync(p,"utf8"),t=JSON.parse(e);if(!(t===null||typeof t!="object"||Array.isArray(t)))return{raw:e,value:t}}r(ue,"readPersistedCoreConfig");function Ve(e){m.writeFileSync(p,JSON.stringify(e,null,2))}r(Ve,"writePersistedCoreConfig");function Ot(e){if(e.permissionMode!=="default")return e;let t={...e,permissionMode:"accept-edits"};try{x(p,()=>{let n=ue();n?.value.permissionMode==="default"&&Ve({...n.value,permissionMode:"accept-edits"})})}catch{}return t}r(Ot,"migrateLegacyPermissionModeInConfig");function Rt(e){if(e.permissionMode!=="auto-in-project")return e;try{x(p,()=>{let t=ue();if(t?.value.permissionMode!=="auto-in-project")return;let n=t.raw.replace(/("permissionMode"\s*:\s*)"auto-in-project"/,'$1"auto"');n!==t.raw&&m.writeFileSync(p,n)})}catch{}return{...e,permissionMode:"auto"}}r(Rt,"migrateAutoInProjectAliasInConfig");function It(){if(v)return v;let e="0.7.97-alpha.2";if(e)return v=e,v;let t=h.join(h.dirname(bt(import.meta.url)),"../../package.json");if(m.existsSync(t))try{return v=JSON.parse(m.readFileSync(t,"utf-8")).version??"0.0.0",v??"0.0.0"}catch{}return v="0.0.0",v}r(It,"getVersion");var Mn=It();function Tt(e){return ve(e)}r(Tt,"getProviderModel");function de(e,t){let n=new Set(e.map(i=>i.toLowerCase())),o=[...e];for(let i of t)n.has(i.toLowerCase())||o.push(i);return o}r(de,"mergeModels");function Lt(e,t){t||(t=fe().providerModels);let n=t?.[e];if(n&&n.length>0){try{let o=Y(e);if(o.length>0)return de(n,o)}catch{}try{let o=I(e);if(o)return de(n,o.getAvailableModels())}catch{}return n}try{let o=Y(e);if(o.length>0)return o}catch{}try{let o=I(e);if(o)return o.getAvailableModels()}catch{}return[]}r(Lt,"getProviderAvailableModels");function Dt(e,t){let n=ye(e,t);if(n!=="unknown")return n;try{let o=I(e);if(o)return o.getReasoningCapability(t)}catch{}return"unknown"}r(Dt,"getProviderReasoningCapability");function Nt(e){let t=we(e);if(t)return t;try{return Q().find(o=>o.name===e)?.capabilityProfile??null}catch{return null}}r(Nt,"getProviderCapabilityProfile");function ze(e,t){let n=Nt(e),o=Dt(e,t);if(n)return{capabilityProfile:n,reasoningCapability:o};try{let i=be(e);return{capabilityProfile:i.getCapabilityProfile(),reasoningCapability:i.getReasoningCapability(t)}}catch{return null}}r(ze,"getProviderCapabilityMetadata");function _n(e,t){let n=ze(e,t);return n?Me({providerName:e,model:t,capabilityProfile:n.capabilityProfile,reasoningCapability:n.reasoningCapability==="unknown"?void 0:n.reasoningCapability}):null}r(_n,"getProviderCapabilitySnapshot");function $t(e,t,n,o){let i=ze(e,t);return i?_e({providerName:e,model:t,capabilityProfile:i.capabilityProfile,reasoningCapability:i.reasoningCapability==="unknown"?void 0:i.reasoningCapability,reasoningMode:n,hints:o}):null}r($t,"getProviderPolicyDecision");function An(e){let t=e.transport==="cli-bridge"?"CLI bridge":"Native API",n=e.conversationSemantics==="last-user-message"?"forwards only the latest user message":"preserves full conversation history",o=e.mcpSupport==="native"?"MCP available":"MCP unavailable";return`${t}; ${n}; ${o}`}r(An,"describeProviderCapabilitySummary");function On(e){switch(e){case"native-budget":return"B";case"native-effort":return"E";case"native-toggle":return"T";case"native-adaptive":return"A";default:return"-"}}r(On,"formatReasoningCapabilityShort");function R(e){if(e)return e==="none"?"off":e}r(R,"formatReasoningEffortForDisplay");function W(e,t){let n=R(t);n&&!e.includes(n)&&e.push(n)}r(W,"pushUniqueEffortDisplay");function Rn(e,t,n){let o=["auto"],i=H(e,t,n),s=i?.supportedEfforts?.filter(a=>a.isUserVisible!==!1);if(!s||s.length===0){for(let a of["off","low","medium","high"])W(o,a);return o}for(let a of s)a.value==="none"&&i?.supportsDisabledThinking===!1||W(o,a.value);return o}r(Rn,"getProviderReasoningEffortOptions");function In(e,t){let n=H(e,t),o=new Set(n?.disabledEfforts??[]),i=n?.supportedEfforts?.filter(l=>l.isUserVisible!==!1),s=[],a=n?.supportsDisabledThinking===!0;if(!i||i.length===0){for(let l of["low","medium","high"])W(s,l);a=!0}else for(let l of i){if(l.value==="none"){n?.supportsDisabledThinking!==!1&&(a=!0);continue}if(o.has(l.value)){n?.supportsDisabledThinking!==!1&&(a=!0);continue}W(s,l.value)}let c=[];return a&&c.push("off"),c.push(...s),c.push("auto"),c}r(In,"getProviderReasoningEffortCycle");function jt(e,t){if(t===!1)return"off";switch(e){case"off":return"off";case"quick":return"low";case"balanced":return"medium";case"deep":return"high";default:return"auto"}}r(jt,"legacyReasoningModeToEffortDisplay");function H(e,t,n){let o=t??Tt(e);if(!o)return;let i=Pe(e,o)?.reasoningProfile;if(i)return me(i,Se(e,o,n))}r(H,"resolveReasoningProfileForDisplay");function Tn(e){let t=R(e.effort)??jt(e.reasoningMode,e.thinking),n=H(e.provider,e.model);if(!n)return t;try{let o=he({capability:n,explicitEffort:e.effortOverride?e.effort:void 0,sessionEffort:e.effortOverride?void 0:e.effort,legacyReasoningMode:e.reasoningMode,thinking:e.thinking}),i=R(o.configuredEffort)??t,a=o.configuredEffort!==void 0&&n.supportsDisabledThinking!==!1&&n.disabledEfforts?.includes(o.configuredEffort)===!0?"off":R(o.effectiveEffort);return a&&a!==i?`${i}->${a}`:i}catch{if(e.effort)try{let o=J({currentEffort:e.effort,capability:n}),i=R(e.effort)??t,s=R(o.effectiveEffort);return s&&s!==i?`${i}->${s}`:i}catch{return t}return t}}r(Tn,"formatReasoningEffortStatusLabel");function Ln(e){let t=Vt(e);if(!t)return{preserved:!0};let n=H(e.provider,e.model);if(!n)return{configuredEffort:t,runtimeEffort:t,preserved:!0};let o=J({currentEffort:t,capability:n});return{configuredEffort:t,runtimeEffort:o.effectiveEffort,preserved:o.preserved,diagnostic:o.diagnostic}}r(Ln,"resolveProviderReasoningRuntimeEffort");function Kt(e){switch(e){case"native-budget":return"budget";case"native-effort":return"effort";case"native-toggle":return"toggle";case"native-adaptive":return"adaptive";default:return"none"}}r(Kt,"describeReasoningCapabilityControl");function Dn(e,t){if(e==="off")return"Reasoning disabled";switch(t){case"native-budget":return"Uses native thinking budget control";case"native-effort":return"Uses native reasoning effort control";case"native-toggle":return"Uses provider-native thinking toggle only";case"native-adaptive":return"Model adaptively decides thinking depth (Opus 4.7+)";case"none":return"Runs without native reasoning parameters";case"prompt-only":return"Uses prompt overlays only; no native reasoning parameter";default:return"Runs without native reasoning parameters"}}r(Dn,"describeReasoningExecution");function Nn(e){let t=[];e||(e=fe().providerModels);for(let n of xe())t.push({name:n.name,model:n.model,models:Lt(n.name,e),configured:n.capabilityProfile.transport==="cli-bridge"?!0:n.configured,reasoningCapability:n.reasoningCapability,capabilityProfile:n.capabilityProfile});try{let n=Q().map(o=>({...o,models:(()=>{let i=e?.[o.name];return i&&i.length>0?de(i,o.models):o.models})()}));t.push(...n)}catch{}return t}r(Nn,"getProviderList");function $n(e){if(ge(e))return!0;try{return I(e)?.isConfigured()??!1}catch{return!1}}r($n,"isProviderConfigured");var G=class extends Error{static{r(this,"InvalidAgentModeConfigError")}};function Ft(e){let t=e.agentMode;if(t===void 0||t==="ama"||t==="sa")return e;if(t!=="amaw"&&t!=="ama-workflow")throw new G(`Invalid agentMode "${t}" in ${p}. Expected "ama" or "sa".`);let n={...e,agentMode:"ama",schemaVersion:Math.max(e.schemaVersion??0,qe)};try{x(p,()=>{let o=ue();if(!o)return;let i=o.value.agentMode;i!=="amaw"&&i!=="ama-workflow"||Ve({...o.value,agentMode:"ama",schemaVersion:Math.max(typeof o.value.schemaVersion=="number"?o.value.schemaVersion:0,qe)})})}catch{}return We||(process.emitWarning(`Migrated persisted agentMode "${t}" to "ama". Workflow use is now explicit intent.`,{code:"KODAX_AGENT_MODE_MIGRATED"}),We=!0),n}r(Ft,"migrateLegacyAgentModeConfig");function fe(){try{if(m.existsSync(p)){let n=JSON.parse(m.readFileSync(p,"utf-8")),o=Ft(n),i=o.reasoningCeiling??o.reasoningMode,s=[],a={};try{s=[...q(u).document.paths]}catch{}try{a=U(u).document.servers}catch{}let{sandbox:c,...l}=o;return Rt(Ot({...l,reasoningMode:i,extensions:le(s),mcpServers:a}))}}catch(n){if(n instanceof G)throw n}let e,t;try{let n=q(u);n.source!=="default"&&(e=le([...n.document.paths]))}catch{}try{let n=U(u);n.source!=="default"&&(t=n.document.servers)}catch{}return{...e===void 0?{}:{extensions:e},...t===void 0?{}:{mcpServers:t}}}r(fe,"loadConfig");var Xt=h.join(u,"config.example.jsonc"),ae={mcp:h.join(u,"integrations","mcp.example.jsonc"),a2a:h.join(u,"integrations","a2a.example.jsonc"),extensions:h.join(u,"integrations","extensions.example.jsonc")},Ut=[{name:"core",path:Xt},{name:"mcp",path:ae.mcp},{name:"a2a",path:ae.a2a},{name:"extensions",path:ae.extensions}];function qt(){let e=[];for(let t of Ut)try{if(m.existsSync(t.path))continue;m.mkdirSync(h.dirname(t.path),{recursive:!0}),m.writeFileSync(t.path,Ie(t.name),"utf8"),e.push(t.path)}catch{}return e}r(qt,"ensureExampleConfigFiles");function jn(){return qt()[0]}r(jn,"ensureExampleConfigFile");var D=new Map;function Kn(e){let t=process.env[e];return t===void 0?"unset":D.get(e)===t?"persisted":"environment"}r(Kn,"inspectConfigEnvironmentSource");function Be(e,t,n=!1){let o=process.env[e],i=D.get(e),s=i!==void 0&&o===i;if(o!==void 0&&!s&&!n){D.delete(e);return}if(t===void 0){(s||n)&&delete process.env[e],D.delete(e);return}process.env[e]=t,D.set(e,t)}r(Be,"projectConfigEnvironment");var pe=[{configPath:"streamIdleTimeoutMs",env:"KODAX_STREAM_IDLE_TIMEOUT_MS",value:r(e=>b(e.streamIdleTimeoutMs),"value")},{configPath:"repoIntelligenceMode",env:"KODAX_REPO_INTELLIGENCE",value:r(e=>e.repoIntelligenceMode,"value")},{configPath:"repoIntelligenceTrace",env:"KODAX_REPO_INTELLIGENCE_TRACE",value:r(e=>O(e.repoIntelligenceTrace),"value")},{configPath:"verifierLog",env:"KODAX_VERIFIER_LOG",value:r(e=>O(e.verifierLog),"value")},{configPath:"stallLog",env:"KODAX_STALL_LOG",value:r(e=>O(e.stallLog),"value")},{configPath:"fallbackProviders",env:"KODAX_FALLBACK_PROVIDERS",value:r(e=>Gt(e.fallbackProviders),"value")},{configPath:"fastProvider",env:"KODAX_FAST_PROVIDER",value:r(e=>y(e.fastProvider),"value")},{configPath:"fastModel",env:"KODAX_FAST_MODEL",value:r(e=>y(e.fastModel),"value")},{configPath:"deepProvider",env:"KODAX_DEEP_PROVIDER",value:r(e=>y(e.deepProvider),"value")},{configPath:"deepModel",env:"KODAX_DEEP_MODEL",value:r(e=>y(e.deepModel),"value")},{configPath:"provider",env:"KODAX_PROVIDER",value:r(e=>y(e.provider),"value")},{configPath:"effort",env:"KODAX_EFFORT",value:r(e=>y(e.effort),"value")},{configPath:"sessionRetentionDays",env:"KODAX_SESSION_RETENTION_DAYS",value:r(e=>b(e.sessionRetentionDays),"value")},{configPath:"maxOutputTokens",env:"KODAX_MAX_OUTPUT_TOKENS",value:r(e=>b(e.maxOutputTokens),"value")},{configPath:"disablePromptCache",env:"KODAX_DISABLE_PROMPT_CACHE",value:r(e=>O(e.disablePromptCache),"value")},{configPath:"lsp",env:"KODAX_LSP",value:r(e=>O(e.lsp),"value")},{configPath:"lspAutoDownload",env:"KODAX_LSP_DOWNLOAD",value:r(e=>O(e.lspAutoDownload),"value")},{configPath:"acpLogLevel",env:"KODAX_ACP_LOG",value:r(e=>y(e.acpLogLevel),"value")},{configPath:"repoIntelligence.toolWaitMs",env:"KODAX_REPO_INTELLIGENCE_TOOL_WAIT_MS",value:r(e=>b(e.repoIntelligence?.toolWaitMs),"value")},{configPath:"repoIntelligence.workerTimeoutMs",env:"KODAX_REPO_INTELLIGENCE_WORKER_TIMEOUT_MS",value:r(e=>b(e.repoIntelligence?.workerTimeoutMs),"value")},{configPath:"repoIntelligence.workerOldSpaceMb",env:"KODAX_REPO_INTELLIGENCE_WORKER_OLD_SPACE_MB",value:r(e=>b(e.repoIntelligence?.workerOldSpaceMb),"value")},{configPath:"repoIntelligence.storageDir",env:"KODAX_REPO_INTELLIGENCE_STORAGE_DIR",value:r(e=>y(e.repoIntelligence?.storageDir),"value")},{configPath:"workflow.maxConcurrency",env:"KODAX_WORKFLOW_MAX_CONCURRENCY",value:r(e=>b(e.workflow?.maxConcurrency),"value")}];function Wt(e){for(let t of pe)Be(t.env,t.value(e))}r(Wt,"applyConfigSurfaceBridges");function y(e){return e?.trim()||void 0}r(y,"normalizedConfigString");function b(e){return typeof e=="number"&&Number.isFinite(e)?String(e):void 0}r(b,"configNumberString");function O(e){return e===void 0?void 0:e?"1":"0"}r(O,"configBooleanString");function Gt(e){return e?.filter(t=>t.trim().length>0).join(",")}r(Gt,"configStringList");var Fn=[...pe.map(({configPath:e,env:t})=>({configPath:e,env:t}))];function Ht(e){Wt(e)}r(Ht,"applyConfigEnvironment");function Xn(e,t=!1){for(let n of pe)["fallbackProviders","verifierLog","stallLog"].includes(n.configPath)&&(t&&!Object.hasOwn(e,n.configPath)||Be(n.env,n.value(e),t))}r(Xn,"applyExecutionConfigEnvironment");function Un(){_t();let e=fe();return Ht(e),At(e),Oe(e.locale),e}r(Un,"prepareRuntimeConfig");function qn(e){let{extensions:t,mcpServers:n,...o}=e;if(x(p,()=>{let i={};if(m.existsSync(p))try{let a=JSON.parse(m.readFileSync(p,"utf8"));a&&typeof a=="object"&&!Array.isArray(a)&&(i=a)}catch{}let s={...i,...o};for(let a of Object.keys(o))o[a]===void 0&&delete s[a];m.writeFileSync(p,JSON.stringify(s,null,2))}),t!==void 0){let i=q(u);T({domain:"extensions",configHome:u,...i.source==="user"?{expectedRevision:i.revision}:{},document:{version:1,paths:le(t)??[]},validate:C})}if(n!==void 0){let i=U(u);T({domain:"mcp",configHome:u,...i.source==="user"?{expectedRevision:i.revision}:{},document:{version:1,servers:n},validate:S})}}r(qn,"saveConfig");function Wn(e,t,n){return e.effort!==void 0||B(n).kind==="value"||t.effort!==void 0}r(Wn,"resolveInitialEffortOverride");function w(e){return e?.trim()?e:void 0}r(w,"nonEmptySelection");function Gn(e){return w(e.explicitProvider)??w(e.environmentProvider)??w(e.configuredProvider)??e.defaultProvider}r(Gn,"resolveRuntimeProviderSelection");function Hn(e){let t=w(e.explicitModel);if(t)return t;let n=w(e.configuredModel);if(!n)return;let o=w(e.explicitProvider)??w(e.environmentProvider);return o?w(e.configuredProvider)===o?n:void 0:n}r(Hn,"resolveRuntimeModelSelection");function Vn(e){if(e.explicitEffort!==void 0)return z(e.explicitEffort);let t=B(e.environmentEffort);return t.kind==="value"?t.value:e.configuredEffort===void 0?void 0:z(e.configuredEffort)}r(Vn,"resolveRuntimeEffortSelection");function Vt(e){return e.permissionMode==="plan"&&e.effortOverride!==!0&&e.planModeEffort!==void 0?e.planModeEffort:e.effort}r(Vt,"resolvePermissionModeEffort");async function zn(e){try{await Ce({cwd:e});let{stdout:t}=await Pt("git rev-parse --show-toplevel",{cwd:e,windowsHide:!0});return t.trim()}catch{return null}}r(zn,"getGitRoot");function zt(e){switch(e){case"builtin":return"Built-in";case"runtime":return"Runtime extension";case"custom":return"Custom config";default:return"Unknown"}}r(zt,"formatProviderSourceKind");function Bn(e){let t=e.transport==="cli-bridge"?"CLI bridge":"Native API",n=e.conversationSemantics==="last-user-message"?"latest-user-message only":"full conversation history";return[`Source: ${zt(e.sourceKind)}`,`Transport: ${t}`,`Conversation semantics: ${n}`,`Context fidelity: ${e.contextFidelity}`,`Tool calling: ${e.toolCallingFidelity}`,`Session behavior: ${e.sessionSupport}`,`Long-running support: ${e.longRunningSupport}`,`Evidence-heavy flows: ${e.evidenceSupport}`,`Multimodal support: ${e.multimodalSupport}`,`MCP support: ${e.mcpSupport}`,`Reasoning control: ${Kt(e.reasoningCapability)}`]}r(Bn,"formatProviderCapabilityDetailLines");function Jn(e,t,n){return[{label:"General coding",hints:{}},{label:"Evidence-heavy review",hints:{evidenceHeavy:!0}},{label:"Long-running task",hints:{longRunning:!0}}].map(i=>({label:i.label,decision:$t(e,t,n,i.hints)})).filter(i=>i.decision!==null)}r(Jn,"getProviderCommonPolicyScenarios");var Ge=.5,He=0,L={locked:!1,queue:[]};async function Yn(e){for(;L.locked;)await new Promise(t=>L.queue.push(t));L.locked=!0;try{let t=(Date.now()-He)/1e3;t<Ge&&await new Promise(o=>setTimeout(o,(Ge-t)*1e3));let n=await e();return He=Date.now(),n}finally{L.locked=!1;let t=L.queue.shift();t&&t()}}r(Yn,"rateLimitedCall");export{Bt as a,Re as b,Ie as c,ee as d,ot as e,x as f,k as g,S as h,C as i,M as j,U as k,q as l,pt as m,ln as n,T as o,Ne as p,u as q,kn as r,p as s,Sn as t,Mt as u,Cn as v,At as w,It as x,Mn as y,Tt as z,Lt as A,Dt as B,Nt as C,_n as D,$t as E,An as F,On as G,R as H,Rn as I,In as J,Tn as K,Ln as L,Kt as M,Dn as N,Nn as O,$n as P,fe as Q,Xt as R,ae as S,qt as T,jn as U,Kn as V,Fn as W,Ht as X,Xn as Y,Un as Z,qn as _,Wn as $,Gn as aa,Hn as ba,Vn as ca,Vt as da,zn as ea,zt as fa,Bn as ga,Jn as ha,Yn as ia};
|