@kodax-ai/kodax 0.7.83 → 0.7.85
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 +154 -4
- package/README.md +48 -26
- package/README_CN.md +26 -21
- package/dist/chunks/agent-OQ37XUWF.js +2 -0
- package/dist/chunks/argument-completer-IMRSIF2N.js +2 -0
- package/dist/chunks/chunk-2XJQNFVR.js +379 -0
- package/dist/chunks/chunk-3E4OSFP2.js +1279 -0
- package/dist/chunks/chunk-CDWYKVZC.js +482 -0
- package/dist/chunks/chunk-CZCEFGQG.js +412 -0
- package/dist/chunks/chunk-IA246OAN.js +679 -0
- package/dist/chunks/chunk-IWRNGH4M.js +319 -0
- package/dist/chunks/chunk-MJ4G5ZCW.js +2 -0
- package/dist/chunks/{chunk-RAQGGVIF.js → chunk-ODRLFQQH.js} +1 -1
- package/dist/chunks/chunk-RSOAHVUR.js +5 -0
- package/dist/chunks/chunk-RTFVMEF6.js +415 -0
- package/dist/chunks/{chunk-XB2JNLXH.js → chunk-SR4E5FQK.js} +2 -2
- package/dist/chunks/{chunk-HI6RCW5Y.js → chunk-TBBY2DKE.js} +2 -2
- package/dist/chunks/chunk-UH5WNJXF.js +92 -0
- package/dist/chunks/{chunk-6QILIBOU.js → chunk-ZVOXWLT6.js} +214 -201
- package/dist/chunks/compaction-config-3WLLNN57.js +2 -0
- package/dist/chunks/{construction-bootstrap-E4M3CY3N.js → construction-bootstrap-CZ6NWEWQ.js} +1 -1
- package/dist/chunks/dist-NFLLOZWF.js +2 -0
- package/dist/chunks/host-LWUSSCWH.js +2 -0
- package/dist/chunks/run-manager-PBMOVP7A.js +2 -0
- package/dist/chunks/utils-KFLK3EHJ.js +2 -0
- package/dist/index.d.ts +17 -15
- package/dist/index.js +2 -2
- package/dist/kodax_bootstrap.js +1 -1
- package/dist/kodax_cli.js +1975 -1564
- package/dist/kodax_resume.js +269 -90
- package/dist/runtime-worker.js +1824 -1419
- package/dist/sandbox-workspace-session.js +979 -66
- package/dist/sdk-a2a.d.ts +11 -10
- package/dist/sdk-a2a.js +9 -8
- package/dist/sdk-agent.d.ts +39 -299
- package/dist/sdk-agent.js +1 -1
- package/dist/sdk-coding.d.ts +103 -16
- package/dist/sdk-coding.js +1 -1
- package/dist/sdk-experimental-memory.d.ts +7 -20
- package/dist/sdk-experimental-memory.js +1 -1
- package/dist/sdk-mcp.js +1 -1
- package/dist/sdk-media.js +1 -1
- package/dist/sdk-repl.d.ts +14 -13
- package/dist/sdk-repl.js +2 -2
- package/dist/sdk-runtime.d.ts +64 -23
- package/dist/sdk-runtime.js +1 -1
- package/dist/sdk-sandbox.js +1 -1
- package/dist/sdk-session.d.ts +7 -6
- 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 +251 -64
- package/dist/types-chunks/{bash-prefix-extractor.d-CJM7OY-L.d.ts → bash-prefix-extractor.d-BnZQDirs.d.ts} +130 -13
- package/dist/types-chunks/{capsule.d-B7yoH4dM.d.ts → capsule.d-CN_iMqAS.d.ts} +2 -1
- package/dist/types-chunks/controller.d-A73Kf6tH.d.ts +105 -0
- package/dist/types-chunks/{controller.d-CYNuR2n9.d.ts → controller.d-Dzxz22X-.d.ts} +28 -1020
- package/dist/types-chunks/{guardrail.d-fM3mn4Op.d.ts → guardrail.d-BCkgaWT1.d.ts} +25 -19
- package/dist/types-chunks/{history-retrieval.d-BDI-ZMvY.d.ts → history-retrieval.d-Debbzn1z.d.ts} +1 -1
- package/dist/types-chunks/{public-api.d-i10kvYFs.d.ts → public-api.d-N6G6Jw8X.d.ts} +3 -2
- package/dist/types-chunks/{repl.d-Cs3eqGVT.d.ts → repl.d-BkTIOkJD.d.ts} +5 -5
- package/dist/types-chunks/review-inbox.d-DuZqFX-z.d.ts +221 -0
- package/dist/types-chunks/{run-manager.d-CodHf6rw.d.ts → run-manager.d-BS4lJfL3.d.ts} +1 -1
- package/dist/types-chunks/{sdk-session-CRXu5xNs.d.ts → sdk-session-DLkZTOc-.d.ts} +2 -2
- package/dist/types-chunks/{shell-command-sets.d-DfeSUjjM.d.ts → shell-command-sets.d-BrLw-WN9.d.ts} +3 -2
- package/dist/types-chunks/{types-Bf3Y3mW-.d.ts → types-PHjfwebT.d.ts} +62 -190
- package/dist/types-chunks/{types.d-BbtGlKZu.d.ts → types.d-BSPlmJqf.d.ts} +25 -6
- package/dist/types-chunks/{types.d-DIXZFauU.d.ts → types.d-Bo4fyMLu.d.ts} +1 -1
- package/dist/types-chunks/{types.d-DKs4tfSd.d.ts → types.d-Ch3BD97c.d.ts} +2 -2
- package/dist/types-chunks/types.d-DlLBRqZ9.d.ts +1057 -0
- package/dist/types-chunks/{utils.d-CgITiLyc.d.ts → utils.d-BI-kjuev.d.ts} +7 -4
- package/package.json +4 -2
- package/dist/chunks/agent-S7LMMTG7.js +0 -2
- package/dist/chunks/argument-completer-SQHG2LYE.js +0 -2
- package/dist/chunks/chunk-37RT45HT.js +0 -379
- package/dist/chunks/chunk-3DKQC7A2.js +0 -479
- package/dist/chunks/chunk-45E23YJI.js +0 -885
- package/dist/chunks/chunk-6UENDY33.js +0 -89
- package/dist/chunks/chunk-DSFHIUHZ.js +0 -655
- package/dist/chunks/chunk-DZUMH6GJ.js +0 -2
- package/dist/chunks/chunk-E7C4DRD2.js +0 -5
- package/dist/chunks/chunk-EVXIJPZ6.js +0 -218
- package/dist/chunks/chunk-KHEFUT6O.js +0 -5
- package/dist/chunks/chunk-LF2JBTBG.js +0 -319
- package/dist/chunks/chunk-TC2VHPG5.js +0 -348
- package/dist/chunks/chunk-URCS6CVP.js +0 -292
- package/dist/chunks/compaction-config-SSQ5NXUP.js +0 -2
- package/dist/chunks/dist-MIXP4ULB.js +0 -2
- package/dist/chunks/host-ZCPI7SMC.js +0 -2
- package/dist/chunks/run-manager-4RYG7HSP.js +0 -2
- package/dist/chunks/utils-7DKE2EKT.js +0 -2
- package/docs/SDK_EMBEDDER_GUIDE.md +0 -5735
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{a as n}from"./chunk-ONUPGMER.js";import{AsyncLocalStorage as $e}from"node:async_hooks";var Ue=new $e;function We(e){let t=Ue.getStore()?.credential;return t?S(e,t,new WeakMap):e}n(We,"redactScopedProviderCredential");function S(e,t,o){if(typeof e=="string")return e.split(t).join("[REDACTED_CREDENTIAL]");if(e===null||typeof e!="object")return e;let r=o.get(e);if(r!==void 0)return r;if(e instanceof Error){let s=new Error(S(e.message,t,o));return o.set(e,s),s.name=e.name,e.stack!==void 0&&(s.stack=S(e.stack,t,o)),s}if(Array.isArray(e)){let s=[];o.set(e,s);for(let l of e)s.push(S(l,t,o));return s}let i={};o.set(e,i);for(let[s,l]of Object.entries(Object.getOwnPropertyDescriptors(e))){if(!l.enumerable||!("value"in l))continue;let u=s.split(t).join("[REDACTED_CREDENTIAL]");i[u]=S(l.value,t,o)}return i}n(S,"redactCredentialValue");function X(e,t){return`${e}/${t??""}`}n(X,"capabilityCacheKey");function Ve(e,t,o){return e[X(t,o)]?.rejected??[]}n(Ve,"getRejectedEfforts");function ze(e,t,o,r,i,s){let l=X(t,o),u=e[l],m=u?.rejected.includes(r)?u.rejected:[...u?.rejected??[],r];return{...e,[l]:{rejected:m,source:i,updatedAt:s}}}n(ze,"addRejectedEffort");function He(e,t,o){if(!t)return{};let r={...e};return delete r[X(t,o)],r}n(He,"removeCacheEntry");function Ge(e){if(!e||typeof e!="object")return{};let t={};for(let[o,r]of Object.entries(e)){if(!r||typeof r!="object")continue;let i=r,s=Array.isArray(i.rejected)?i.rejected.filter(m=>typeof m=="string"):[],l=i.source==="probed"?"probed":"observed",u=typeof i.updatedAt=="string"?i.updatedAt:"";t[o]={rejected:s,source:l,updatedAt:u}}return t}n(Ge,"sanitizeCapabilityCache");import{AsyncLocalStorage as qe}from"node:async_hooks";var Je=new qe,Q=8,Y=32;function Qe(e){if(e===void 0)return;let t=Number.parseInt(e,10);return Number.isInteger(t)&&t>0?t:void 0}n(Qe,"parsePositiveInt");function Ye(){let e=L()?.workflow?.maxConcurrency,t=typeof e=="number"&&Number.isInteger(e)&&e>0?e:Qe(process.env.KODAX_WORKFLOW_MAX_CONCURRENCY)??Q;return Math.max(1,Math.min(Y,t))}n(Ye,"resolveWorkflowMaxConcurrency");function L(){return Je.getStore()}n(L,"getRunScopedConfig");var K={transport:"native-api",conversationSemantics:"full-history",mcpSupport:"none",contextFidelity:"full",toolCallingFidelity:"full",sessionSupport:"full",longRunningSupport:"full",multimodalSupport:"none",evidenceSupport:"full"},Z={...K,multimodalSupport:"image-input"},O={transport:"cli-bridge",conversationSemantics:"last-user-message",mcpSupport:"none",contextFidelity:"lossy",toolCallingFidelity:"limited",sessionSupport:"stateless",longRunningSupport:"limited",multimodalSupport:"none",evidenceSupport:"limited"},ee={...O,multimodalSupport:"image-input"};function F(e){return{transport:e.transport,conversationSemantics:e.conversationSemantics,mcpSupport:e.mcpSupport,contextFidelity:e.contextFidelity??"full",toolCallingFidelity:e.toolCallingFidelity??"full",sessionSupport:e.sessionSupport??"full",longRunningSupport:e.longRunningSupport??"full",multimodalSupport:e.multimodalSupport??"none",evidenceSupport:e.evidenceSupport??"full"}}n(F,"normalizeCapabilityProfile");import uo from"@anthropic-ai/sdk";import{parse as qn}from"partial-json";import xo from"openai";import{ClientSideConnection as Vo,PROTOCOL_VERSION as zo,ndJsonStream as Ho}from"@agentclientprotocol/sdk";var Bo=Object.freeze({status:"terminated"}),Lo=Object.freeze({status:"already-exited"}),Fo=Object.freeze({status:"unknown"}),jo=String.raw`
|
|
3
|
-
using System;
|
|
4
|
-
using System.Runtime.InteropServices;
|
|
5
|
-
using System.Text;
|
|
6
|
-
public static class KodaXNativeProcessSnapshot {
|
|
7
|
-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
|
8
|
-
private struct ProcessEntry32 {
|
|
9
|
-
public uint dwSize;
|
|
10
|
-
public uint cntUsage;
|
|
11
|
-
public uint th32ProcessID;
|
|
12
|
-
public IntPtr th32DefaultHeapID;
|
|
13
|
-
public uint th32ModuleID;
|
|
14
|
-
public uint cntThreads;
|
|
15
|
-
public uint th32ParentProcessID;
|
|
16
|
-
public int pcPriClassBase;
|
|
17
|
-
public uint dwFlags;
|
|
18
|
-
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
|
|
19
|
-
public string szExeFile;
|
|
20
|
-
}
|
|
21
|
-
[DllImport("kernel32.dll", SetLastError = true)]
|
|
22
|
-
private static extern IntPtr CreateToolhelp32Snapshot(uint flags, uint processId);
|
|
23
|
-
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
|
24
|
-
private static extern bool Process32First(IntPtr snapshot, ref ProcessEntry32 entry);
|
|
25
|
-
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
|
26
|
-
private static extern bool Process32Next(IntPtr snapshot, ref ProcessEntry32 entry);
|
|
27
|
-
[StructLayout(LayoutKind.Sequential)]
|
|
28
|
-
private struct FileTime {
|
|
29
|
-
public uint Low;
|
|
30
|
-
public uint High;
|
|
31
|
-
}
|
|
32
|
-
[DllImport("kernel32.dll", SetLastError = true)]
|
|
33
|
-
private static extern IntPtr OpenProcess(uint access, bool inheritHandle, uint processId);
|
|
34
|
-
[DllImport("kernel32.dll", SetLastError = true)]
|
|
35
|
-
private static extern bool GetProcessTimes(IntPtr process, out FileTime creation, out FileTime exit, out FileTime kernel, out FileTime user);
|
|
36
|
-
[DllImport("kernel32.dll", SetLastError = true)]
|
|
37
|
-
private static extern bool TerminateProcess(IntPtr process, uint exitCode);
|
|
38
|
-
[DllImport("kernel32.dll")]
|
|
39
|
-
private static extern void GetSystemTimeAsFileTime(out FileTime systemTime);
|
|
40
|
-
[DllImport("kernel32.dll")]
|
|
41
|
-
private static extern bool CloseHandle(IntPtr handle);
|
|
42
|
-
private static ulong ReadCreationTime(uint processId) {
|
|
43
|
-
var process = OpenProcess(0x1000, false, processId);
|
|
44
|
-
if (process == IntPtr.Zero) return 0;
|
|
45
|
-
try {
|
|
46
|
-
FileTime creation, exit, kernel, user;
|
|
47
|
-
if (!GetProcessTimes(process, out creation, out exit, out kernel, out user)) return 0;
|
|
48
|
-
return ((ulong)creation.High << 32) | creation.Low;
|
|
49
|
-
} finally {
|
|
50
|
-
CloseHandle(process);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
public static int TerminateExact(uint processId, ulong expectedCreationTime) {
|
|
54
|
-
var process = OpenProcess(0x1001, false, processId);
|
|
55
|
-
if (process == IntPtr.Zero) return 0;
|
|
56
|
-
try {
|
|
57
|
-
FileTime creation, exit, kernel, user;
|
|
58
|
-
if (!GetProcessTimes(process, out creation, out exit, out kernel, out user)) return 0;
|
|
59
|
-
var actual = (((ulong)creation.High << 32) | creation.Low) / 10000;
|
|
60
|
-
if (actual != expectedCreationTime) return 2;
|
|
61
|
-
return TerminateProcess(process, 1) ? 1 : 0;
|
|
62
|
-
} finally {
|
|
63
|
-
CloseHandle(process);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
public static string ReadRows() {
|
|
67
|
-
FileTime cutoffTime;
|
|
68
|
-
GetSystemTimeAsFileTime(out cutoffTime);
|
|
69
|
-
var cutoff = (((ulong)cutoffTime.High << 32) | cutoffTime.Low) / 10000;
|
|
70
|
-
var snapshot = CreateToolhelp32Snapshot(2, 0);
|
|
71
|
-
if (snapshot == new IntPtr(-1)) return string.Empty;
|
|
72
|
-
var rows = new StringBuilder();
|
|
73
|
-
var entry = new ProcessEntry32();
|
|
74
|
-
entry.dwSize = (uint)Marshal.SizeOf(entry);
|
|
75
|
-
try {
|
|
76
|
-
if (!Process32First(snapshot, ref entry)) return string.Empty;
|
|
77
|
-
do {
|
|
78
|
-
var creationTime = ReadCreationTime(entry.th32ProcessID) / 10000;
|
|
79
|
-
if (creationTime == 0 || creationTime <= cutoff) {
|
|
80
|
-
rows.Append(entry.th32ProcessID).Append(',').Append(entry.th32ParentProcessID).Append(',').Append(creationTime).Append('\n');
|
|
81
|
-
}
|
|
82
|
-
entry.dwSize = (uint)Marshal.SizeOf(entry);
|
|
83
|
-
} while (Process32Next(snapshot, ref entry));
|
|
84
|
-
return rows.ToString();
|
|
85
|
-
} finally {
|
|
86
|
-
CloseHandle(snapshot);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}`;import ae from"node:fs";import de from"node:os";import le from"node:path";var kt="gpt-5.4",Ct="auto-gemini-3",Pt=["gpt-5.4","gpt-5.3-codex","gpt-5.3-codex-spark"],Rt=["auto-gemini-3","gemini-3.1-pro-preview","gemini-3-flash-preview","gemini-2.5-pro","gemini-2.5-flash"];function ue(e){let t=new Set,o=[];for(let r of e){let i=r.trim();if(!i)continue;let s=i.toLowerCase();t.has(s)||(t.add(s),o.push(i))}return o}n(ue,"dedupePreserveOrder");function Et(){let e=le.join(de.homedir(),".codex","config.toml");try{return ae.readFileSync(e,"utf8").match(/^\s*model\s*=\s*"([^"]+)"/m)?.[1]?.trim()||null}catch{return null}}n(Et,"readCodexConfiguredModel");function Tt(){let e=le.join(de.homedir(),".gemini","settings.json");try{let t=JSON.parse(ae.readFileSync(e,"utf8")),o=typeof t.model=="string"?t.model.trim():"";return o||(typeof t.general?.model=="string"?t.general.model.trim():"")||null}catch{return null}}n(Tt,"readGeminiConfiguredModel");function T(){return Et()||kt}n(T,"getCodexCliDefaultModel");function x(){return Tt()||Ct}n(x,"getGeminiCliDefaultModel");function _(){return ue([T(),...Pt])}n(_,"getCodexCliKnownModels");function A(){return ue([x(),...Rt])}n(A,"getGeminiCliKnownModels");var Mr=x(),wr=A();var Fr=T(),jr=_();import{existsSync as Dt,readFileSync as Nt}from"node:fs";import w from"node:path";import{fileURLToPath as Bt}from"node:url";var ce=["none","prompt-only","native-effort","native-budget","native-toggle","native-adaptive","unknown"],fe=["openai-responses-effort","openai-chat-effort","codex-cli-config","anthropic-output-effort","anthropic-reasoning-effort","provider-budget","provider-toggle","prompt-only","none"],pe=["anthropic-adaptive","anthropic-budget","provider-budget","provider-toggle","none"],ge=["zai-glm-5.2","zai-glm-toggle","deepseek-v4-flash-openai","deepseek-v4-pro-openai","deepseek-v4-openai","deepseek-v4-anthropic","deepseek-toggle","kimi-k3","kimi-k2.7-code","kimi-hybrid-toggle","minimax-m3","minimax-m2-always","mimo-v2.5-toggle","qwen-hybrid-thinking","openai-chat-reasoning","openai-responses-reasoning","codex-cli-effort","claude-adaptive-xhigh","claude-adaptive-max","anthropic-budget","generic-thinking-toggle","none"],me=["max_tokens","max_completion_tokens"],he=["native","image-input-native","cli-bridge","image-input-cli-bridge"],ye=["count-tokens","models-list","minimal-message","unsupported"];function h(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}n(h,"isPlainObject");function E(e,t){if(typeof e!="string"||e.length===0)throw new Error(`provider-capabilities.json: ${t} must be a non-empty string`);return e}n(E,"requireString");function M(e,t){if(e!==void 0)return E(e,t)}n(M,"optionalString");function ke(e,t){if(e!==void 0){if(typeof e!="string"||!me.includes(e))throw new Error(`provider-capabilities.json: ${t} must be one of ${me.join(", ")}, got ${JSON.stringify(e)}`);return e}}n(ke,"optionalMaxOutputTokensField");function R(e,t){if(e!==void 0){if(typeof e!="number"||!Number.isFinite(e)||e<0)throw new Error(`provider-capabilities.json: ${t} must be a non-negative finite number`);return e}}n(R,"optionalNumber");function p(e,t){if(e!==void 0){if(typeof e!="boolean")throw new Error(`provider-capabilities.json: ${t} must be a boolean`);return e}}n(p,"optionalBoolean");function be(e,t){if(e!==void 0){if(!Array.isArray(e))throw new Error(`provider-capabilities.json: ${t} must be an array`);return e.map((o,r)=>E(o,`${t}[${r}]`))}}n(be,"optionalStringArray");function Mt(e,t){if(e===void 0)return;if(!h(e))throw new Error(`provider-capabilities.json: ${t} must be an object`);let o={};for(let[r,i]of Object.entries(e))o[r]=E(i,`${t}.${r}`);return o}n(Mt,"optionalStringMap");function wt(e,t){if(e!==void 0){if(typeof e!="string"||!ge.includes(e))throw new Error(`provider-capabilities.json: ${t} must be one of ${ge.join(", ")}, got ${JSON.stringify(e)}`);return e}}n(wt,"optionalReasoningPreset");function U(e,t){if(typeof e!="string"||!ce.includes(e))throw new Error(`provider-capabilities.json: ${t} must be one of ${ce.join(", ")}, got ${JSON.stringify(e)}`);return e}n(U,"requireReasoningCapability");function St(e,t){if(typeof e!="string"||!fe.includes(e))throw new Error(`provider-capabilities.json: ${t} must be one of ${fe.join(", ")}, got ${JSON.stringify(e)}`);return e}n(St,"requireEffortStrategy");function Kt(e,t){if(e!==void 0){if(typeof e!="string"||!pe.includes(e))throw new Error(`provider-capabilities.json: ${t} must be one of ${pe.join(", ")}, got ${JSON.stringify(e)}`);return e}}n(Kt,"optionalThinkingStrategy");function ve(e,t){if(e===void 0)return;if(!h(e))throw new Error(`provider-capabilities.json: ${t} must be an object`);let o=St(e.effortStrategy,`${t}.effortStrategy`),r=wt(e.reasoningPreset,`${t}.reasoningPreset`),i=Kt(e.thinkingStrategy,`${t}.thinkingStrategy`),s=M(e.defaultEffort,`${t}.defaultEffort`),l=Mt(e.effortAliases,`${t}.effortAliases`),u=be(e.disabledEfforts,`${t}.disabledEfforts`),m=be(e.localRejectEfforts,`${t}.localRejectEfforts`),y=p(e.allowCustomEffort,`${t}.allowCustomEffort`),b=p(e.supportsReasoningEffort,`${t}.supportsReasoningEffort`),v=p(e.supportsReasoningSummary,`${t}.supportsReasoningSummary`),k=p(e.supportsEncryptedReasoningReplay,`${t}.supportsEncryptedReasoningReplay`),C=p(e.supportsAdaptiveThinking,`${t}.supportsAdaptiveThinking`),a=p(e.supportsManualThinkingBudget,`${t}.supportsManualThinkingBudget`),P=p(e.supportsDisabledThinking,`${t}.supportsDisabledThinking`),g=p(e.requiresEffortBetaHeader,`${t}.requiresEffortBetaHeader`),d={effortStrategy:o};if(r!==void 0&&(d.reasoningPreset=r),i!==void 0&&(d.thinkingStrategy=i),s!==void 0&&(d.defaultEffort=s),l!==void 0&&(d.effortAliases=l),u!==void 0&&(d.disabledEfforts=u),m!==void 0&&(d.localRejectEfforts=m),e.supportedEfforts!==void 0){if(!Array.isArray(e.supportedEfforts))throw new Error(`provider-capabilities.json: ${t}.supportedEfforts must be an array`);d.supportedEfforts=e.supportedEfforts.map((c,f)=>{if(!h(c))throw new Error(`provider-capabilities.json: ${t}.supportedEfforts[${f}] must be an object`);return{value:E(c.value,`${t}.supportedEfforts[${f}].value`),...M(c.description,`${t}.supportedEfforts[${f}].description`)!==void 0?{description:M(c.description,`${t}.supportedEfforts[${f}].description`)}:{},...p(c.isDefault,`${t}.supportedEfforts[${f}].isDefault`)!==void 0?{isDefault:p(c.isDefault,`${t}.supportedEfforts[${f}].isDefault`)}:{},...p(c.isUserVisible,`${t}.supportedEfforts[${f}].isUserVisible`)!==void 0?{isUserVisible:p(c.isUserVisible,`${t}.supportedEfforts[${f}].isUserVisible`)}:{}}})}if(e.budgetByEffort!==void 0){if(!h(e.budgetByEffort))throw new Error(`provider-capabilities.json: ${t}.budgetByEffort must be an object`);let c={};for(let[f,J]of Object.entries(e.budgetByEffort))c[f]=R(J,`${t}.budgetByEffort.${f}`)??0;d.budgetByEffort=c}return y!==void 0&&(d.allowCustomEffort=y),b!==void 0&&(d.supportsReasoningEffort=b),v!==void 0&&(d.supportsReasoningSummary=v),k!==void 0&&(d.supportsEncryptedReasoningReplay=k),C!==void 0&&(d.supportsAdaptiveThinking=C),a!==void 0&&(d.supportsManualThinkingBudget=a),P!==void 0&&(d.supportsDisabledThinking=P),g!==void 0&&(d.requiresEffortBetaHeader=g),d}n(ve,"validateReasoningProfile");function Ce(e,t){let o=e.reasoningProfile,r=e.reasoningCapabilityV2;if(o!==void 0&&r!==void 0)throw new Error(`provider-capabilities.json: ${t} must not define both reasoningProfile and deprecated reasoningCapabilityV2`);return o!==void 0?ve(o,`${t}.reasoningProfile`):ve(r,`${t}.reasoningCapabilityV2`)}n(Ce,"validateReasoningProfileField");function _t(e,t){if(typeof e!="string"||!he.includes(e))throw new Error(`provider-capabilities.json: ${t} must be one of ${he.join(", ")}, got ${JSON.stringify(e)}`);return e}n(_t,"requireProfileName");function At(e,t){if(typeof e!="string"||!ye.includes(e))throw new Error(`provider-capabilities.json: ${t} must be one of ${ye.join(", ")}, got ${JSON.stringify(e)}`);return e}n(At,"requireVerifyStrategy");function Xt(e,t){if(!h(e))throw new Error(`provider-capabilities.json: ${t} must be an object`);let o=E(e.id,`${t}.id`),r=M(e.wireModel,`${t}.wireModel`),i=M(e.displayName,`${t}.displayName`),s=R(e.contextWindow,`${t}.contextWindow`),l=R(e.maxOutputTokens,`${t}.maxOutputTokens`),u=ke(e.maxOutputTokensField,`${t}.maxOutputTokensField`),m=R(e.thinkingBudgetCap,`${t}.thinkingBudgetCap`),y=p(e.replayReasoningContent,`${t}.replayReasoningContent`),b=p(e.strictThinkingSignature,`${t}.strictThinkingSignature`),v=R(e.streamMaxDurationMs,`${t}.streamMaxDurationMs`),k=e.reasoningCapability===void 0?void 0:U(e.reasoningCapability,`${t}.reasoningCapability`),C=Ce(e,t),a={id:o};return r!==void 0&&(a.wireModel=r),i!==void 0&&(a.displayName=i),s!==void 0&&(a.contextWindow=s),l!==void 0&&(a.maxOutputTokens=l),u!==void 0&&(a.maxOutputTokensField=u),m!==void 0&&(a.thinkingBudgetCap=m),k!==void 0&&(a.reasoningCapability=k),C!==void 0&&(a.reasoningProfile=C),y!==void 0&&(a.replayReasoningContent=y),b!==void 0&&(a.strictThinkingSignature=b),v!==void 0&&(a.streamMaxDurationMs=v),a}n(Xt,"validateModelDescriptor");function Ot(e,t){if(e===void 0)return;if(!h(e))throw new Error(`provider-capabilities.json: ${t} must be an object`);let o={};for(let[r,i]of Object.entries(e))o[r]=U(i,`${t}.${r}`);return o}n(Ot,"validateModelReasoningCapabilities");function It(e,t){if(!h(e))throw new Error(`provider-capabilities.json: providers.${t} must be an object`);let o=p(e.cliBridge,`providers.${t}.cliBridge`),r=E(e.apiKeyEnv,`providers.${t}.apiKeyEnv`),i=U(e.reasoningCapability,`providers.${t}.reasoningCapability`),s=Ce(e,`providers.${t}`),l=_t(e.capabilityProfile,`providers.${t}.capabilityProfile`),u=At(e.verifyStrategy,`providers.${t}.verifyStrategy`);if(o&&u!=="unsupported")throw new Error(`provider-capabilities.json: providers.${t} is a cliBridge entry but verifyStrategy="${u}" \u2014 must be "unsupported" (CLI binary owns credentials)`);let m=R(e.contextWindow,`providers.${t}.contextWindow`),y=R(e.maxOutputTokens,`providers.${t}.maxOutputTokens`),b=ke(e.maxOutputTokensField,`providers.${t}.maxOutputTokensField`),v=R(e.thinkingBudgetCap,`providers.${t}.thinkingBudgetCap`),k=p(e.supportsThinking,`providers.${t}.supportsThinking`),C=Ot(e.modelReasoningCapabilities,`providers.${t}.modelReasoningCapabilities`),a=M(e.model,`providers.${t}.model`);if(o&&(a!==void 0||e.models!==void 0))throw new Error(`provider-capabilities.json: providers.${t} is a cliBridge entry but defines model/models \u2014 must be omitted (filled at load time)`);if(!o&&a===void 0)throw new Error(`provider-capabilities.json: providers.${t}.model is required (only cliBridge entries may omit)`);let P;if(e.models!==void 0){if(!Array.isArray(e.models))throw new Error(`provider-capabilities.json: providers.${t}.models must be an array`);P=e.models.map((c,f)=>Xt(c,`providers.${t}.models[${f}]`));let d=new Set([...a===void 0?[]:[a],...P.map(c=>c.id)]);for(let[c,f]of P.entries())if(f.wireModel!==void 0&&!d.has(f.wireModel))throw new Error(`provider-capabilities.json: providers.${t}.models[${c}].wireModel must reference a declared model, got ${JSON.stringify(f.wireModel)}`)}let g={apiKeyEnv:r,reasoningCapability:i,capabilityProfile:l,verifyStrategy:u};return s!==void 0&&(g.reasoningProfile=s),a!==void 0&&(g.model=a),P!==void 0&&(g.models=P),m!==void 0&&(g.contextWindow=m),y!==void 0&&(g.maxOutputTokens=y),b!==void 0&&(g.maxOutputTokensField=b),v!==void 0&&(g.thinkingBudgetCap=v),k!==void 0&&(g.supportsThinking=k),C!==void 0&&(g.modelReasoningCapabilities=C),o&&(g.cliBridge=!0),g}n(It,"validateProviderEntry");function Pe(e){if(!h(e))throw new Error("provider-capabilities.json: root must be an object");if(e.version!==1)throw new Error(`provider-capabilities.json: version must be 1, got ${JSON.stringify(e.version)}`);let t=E(e.updatedAt,"updatedAt");if(!h(e.providers))throw new Error("provider-capabilities.json: providers must be an object");let o={};for(let[r,i]of Object.entries(e.providers))o[r]=It(i,r);return{version:1,updatedAt:t,providers:o}}n(Pe,"validateProviderCapabilitiesJson");var Lt=Object.freeze({native:K,"image-input-native":Z,"cli-bridge":O,"image-input-cli-bridge":ee}),B=null;function Ft(){if(process.env.KODAX_BUNDLED==="true")return w.join(w.dirname(process.execPath),"provider-capabilities.json");let e=w.dirname(Bt(import.meta.url)),t=[w.join(e,"provider-capabilities.json"),w.join(w.dirname(e),"provider-capabilities.json")];for(let o of t)if(Dt(o))return o;return t[0]}n(Ft,"resolveJsonPath");function jt(e){if(e.models){for(let t of e.models)t.reasoningProfile&&Re(t.reasoningProfile);for(let t of e.models)Object.freeze(t);Object.freeze(e.models)}return e.reasoningProfile&&Re(e.reasoningProfile),e.modelReasoningCapabilities&&Object.freeze(e.modelReasoningCapabilities),Object.freeze(e)}n(jt,"deepFreezeSnapshot");function Re(e){if(e.supportedEfforts){for(let t of e.supportedEfforts)Object.freeze(t);Object.freeze(e.supportedEfforts)}e.budgetByEffort&&Object.freeze(e.budgetByEffort),e.effortAliases&&Object.freeze(e.effortAliases),e.disabledEfforts&&Object.freeze(e.disabledEfforts),e.localRejectEfforts&&Object.freeze(e.localRejectEfforts),Object.freeze(e)}n(Re,"freezeReasoningProfile");function $t(e){if(e==="gemini-cli"){let t=x();return{model:t,models:A().filter(o=>o!==t).map(o=>({id:o}))}}if(e==="codex-cli"){let t=T();return{model:t,models:_().filter(o=>o!==t).map(o=>({id:o}))}}throw new Error(`provider-capabilities loader: unknown cliBridge provider '${e}'`)}n($t,"resolveCliBridgeModels");function Ut(e,t){let o=Lt[t.capabilityProfile];if(!o)throw new Error(`provider-capabilities loader: unknown capabilityProfile '${t.capabilityProfile}' for provider '${e}'`);if(t.cliBridge){let i=$t(e),s={model:i.model,models:i.models,apiKeyEnv:t.apiKeyEnv,reasoningCapability:t.reasoningCapability,capabilityProfile:o,verifyStrategy:t.verifyStrategy};return t.reasoningProfile!==void 0&&(s.reasoningProfile=t.reasoningProfile),t.supportsThinking!==void 0&&(s.supportsThinking=t.supportsThinking),s}let r={model:t.model,apiKeyEnv:t.apiKeyEnv,reasoningCapability:t.reasoningCapability,capabilityProfile:o,verifyStrategy:t.verifyStrategy};return t.reasoningProfile!==void 0&&(r.reasoningProfile=t.reasoningProfile),t.models!==void 0&&(r.models=t.models),t.modelReasoningCapabilities!==void 0&&(r.modelReasoningCapabilities=t.modelReasoningCapabilities),t.contextWindow!==void 0&&(r.contextWindow=t.contextWindow),t.maxOutputTokens!==void 0&&(r.maxOutputTokens=t.maxOutputTokens),t.maxOutputTokensField!==void 0&&(r.maxOutputTokensField=t.maxOutputTokensField),t.thinkingBudgetCap!==void 0&&(r.thinkingBudgetCap=t.thinkingBudgetCap),t.supportsThinking!==void 0&&(r.supportsThinking=t.supportsThinking),r}n(Ut,"buildSnapshot");function Ee(){if(B)return B;let e=Ft(),t;try{let i=Nt(e,"utf8");t=JSON.parse(i)}catch(i){let s=i instanceof Error?i.message:String(i);throw new Error(`provider-capabilities loader: failed to read ${e}: ${s}`)}let o=Pe(t),r={};for(let[i,s]of Object.entries(o.providers))r[i]=jt(Ut(i,s));return B=Object.freeze(r),B}n(Ee,"getProviderSnapshots");import ci from"@anthropic-ai/sdk";var z=Ee();var Te=process.env.KODAX_PROVIDER??"zhipu-coding";export{We as a,Ve as b,ze as c,He as d,Ge as e,Ye as f,F as g,z as h};
|