@kodax-ai/kodax 0.7.97-alpha.4 → 0.7.97-alpha.5
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 +47 -1
- package/README.md +17 -3
- package/README_CN.md +13 -2
- package/dist/chunks/{agent-QPYNXWUF.js → agent-LWDHPWKV.js} +1 -1
- package/dist/chunks/argument-completer-LMS266JQ.js +2 -0
- package/dist/chunks/{chunk-XZ7CX74A.js → chunk-5W2ZCXOG.js} +1 -1
- package/dist/chunks/{chunk-KXRII4QU.js → chunk-7RLU6XIU.js} +1 -1
- package/dist/chunks/{chunk-TDDCFRPG.js → chunk-A5KR5LCP.js} +1 -1
- package/dist/chunks/{chunk-JRHESXS5.js → chunk-CF4B36EZ.js} +2 -2
- package/dist/chunks/{chunk-D2WGP3VS.js → chunk-F7TCQL2L.js} +2 -2
- package/dist/chunks/{chunk-DN4GBWSU.js → chunk-FHWRUQE3.js} +5 -5
- package/dist/chunks/{chunk-7VOTRMUH.js → chunk-ICCDQVLL.js} +3 -3
- package/dist/chunks/{chunk-62IOXGHA.js → chunk-IUTBOGEK.js} +136 -136
- package/dist/chunks/{chunk-BBF5A5BT.js → chunk-KDQREOAJ.js} +1 -1
- package/dist/chunks/{chunk-TOHJOSAB.js → chunk-PTESSP67.js} +37 -37
- package/dist/chunks/{chunk-4BYTAJU4.js → chunk-QDNDPIDD.js} +1 -1
- package/dist/chunks/{chunk-ULYEFYIV.js → chunk-STB66YFC.js} +1 -1
- package/dist/chunks/{chunk-ZGLYGBM2.js → chunk-SYDTD36A.js} +1 -1
- package/dist/chunks/{chunk-JNSL7ADK.js → chunk-TZ2NQZE2.js} +1 -1
- package/dist/chunks/{chunk-SLOIHXD6.js → chunk-U34QKQNI.js} +1 -1
- package/dist/chunks/{chunk-4HSDJRRJ.js → chunk-WTX6GRSV.js} +2 -2
- package/dist/chunks/{chunk-4VCYZ2PV.js → chunk-WZWVU5LK.js} +2 -2
- package/dist/chunks/{chunk-NGFXDSP2.js → chunk-XPH33F3A.js} +1 -1
- package/dist/chunks/{construction-bootstrap-VTZJZTQ3.js → construction-bootstrap-UCWFQ5OM.js} +1 -1
- package/dist/chunks/{dist-HFRRCJ5U.js → dist-THC5GMJ2.js} +1 -1
- package/dist/chunks/{host-Z66YR63P.js → host-BN6ZVWFJ.js} +1 -1
- package/dist/chunks/readline-helpers-OR6WAS7M.js +2 -0
- package/dist/chunks/{run-manager-FCHIWXXU.js → run-manager-FPX6KT6U.js} +1 -1
- package/dist/chunks/{tool-dispatch-I4H2QSL4.js → tool-dispatch-PB5MOVLY.js} +1 -1
- package/dist/chunks/{utils-I5Z4U76H.js → utils-Z6ZXMX6X.js} +1 -1
- package/dist/index.d.ts +11 -11
- package/dist/index.js +1 -1
- package/dist/kodax_bootstrap.js +1 -1
- package/dist/kodax_cli.js +1041 -1041
- 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/sdk-a2a.d.ts +7 -7
- package/dist/sdk-a2a.js +1 -1
- package/dist/sdk-client.d.ts +4 -4
- package/dist/sdk-client.js +1 -1
- package/dist/sdk-coding.d.ts +22 -15
- package/dist/sdk-coding.js +1 -1
- package/dist/sdk-repl.d.ts +12 -12
- package/dist/sdk-repl.js +1 -1
- package/dist/sdk-runtime.d.ts +8 -8
- package/dist/sdk-runtime.js +1 -1
- package/dist/sdk-sandbox.js +1 -1
- package/dist/sdk-session.d.ts +4 -4
- package/dist/sdk-session.js +1 -1
- package/dist/types-chunks/{bash-prefix-extractor.d-CLq7XgO7.d.ts → bash-prefix-extractor.d-CEy7z-Zn.d.ts} +9 -2
- package/dist/types-chunks/{client-contract-cQ9frDMg.d.ts → client-contract-C6EMeiD-.d.ts} +18 -2
- package/dist/types-chunks/{public-api.d-TxoZttfO.d.ts → public-api.d-BIbLLBhl.d.ts} +2 -2
- package/dist/types-chunks/{review-packet.d-WJNbgTeP.d.ts → review-packet.d-Cili3QF2.d.ts} +1 -1
- package/dist/types-chunks/{run-manager.d-CoLEnzEm.d.ts → run-manager.d-MHxLmLqw.d.ts} +1 -1
- package/dist/types-chunks/{runtime-client-info-gOaOHxcX.d.ts → runtime-client-info-DkjsCCbS.d.ts} +1 -1
- package/dist/types-chunks/{sdk-session-03IR_W0n.d.ts → sdk-session-CPHF0o9h.d.ts} +1 -1
- package/dist/types-chunks/{trusted-repl-entry-ByD3cHZk.d.ts → trusted-repl-entry-w_5uQSZq.d.ts} +5 -5
- package/dist/types-chunks/{types.d-CGVqYNNH.d.ts → types.d--WO3A2u5.d.ts} +1 -1
- package/dist/types-chunks/{utils.d-CuYGalHn.d.ts → utils.d-gX4cGt04.d.ts} +4 -4
- package/docs/CLIENT_CONTRACT.md +3 -0
- package/docs/SDK_MIGRATION.md +13 -1
- package/docs/SPACE_SDK_SEAMS.md +10 -2
- package/package.json +2 -2
- package/public_docs/README.md +5 -2
- package/public_docs/sdk/embedder-guide.md +49 -3
- package/dist/chunks/argument-completer-LLTQJ3AO.js +0 -2
- package/dist/chunks/readline-helpers-4CJH55V7.js +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -8,11 +8,57 @@ All notable changes to this project will be documented in this file.
|
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
+
## [0.7.97-alpha.5] - 2026-10-13
|
|
12
|
+
|
|
13
|
+
Fifth alpha of the v0.7.97 line: FEATURE_301's unified Artifact SDK and
|
|
14
|
+
format backends ship — the `ArtifactExecutionPort` seam grows to nine
|
|
15
|
+
public operations with native PDF, exact PNG/JPEG/WebP/SVG, candidate DOCX
|
|
16
|
+
pagination, and local HTML/SMIL evidence over one execution port serving
|
|
17
|
+
independent Node and shared-Host clients — and busy daemon preflights are
|
|
18
|
+
bounded before redundant full state scans (Issue 367). Every v0.7.96
|
|
19
|
+
stable and v0.7.97-alpha.1 through alpha.4 contract is retained. npm
|
|
20
|
+
publication remains a manual maintainer action.
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
|
|
24
|
+
- Unified optional Artifact SDK (developed in `27d08788`): public
|
|
25
|
+
`prepare` and `readEvidence`, native PDF, exact PNG and JPEG/WebP/SVG evidence,
|
|
26
|
+
candidate DOCX pagination, local HTML loaded-view capture and SVG SMIL samples.
|
|
27
|
+
The same execution port serves independent Node and existing shared-Host clients.
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- Artifact contracts use content formats, structured capabilities, file/surface
|
|
32
|
+
provenance, kind-matched capture locators, PNG dimensions and paginated layout.
|
|
33
|
+
These pre-release changes have no legacy aliases. Shared-Host image bytes use
|
|
34
|
+
existing attachment reads; core startup does not load optional renderers.
|
|
35
|
+
- SDK, Client/Space integration, migration, architecture and feature documents
|
|
36
|
+
distinguish source support from released packages and evidence readiness from
|
|
37
|
+
visual approval. See [support and limits](docs/ARTIFACT_SDK.md).
|
|
38
|
+
|
|
39
|
+
### Fixed
|
|
40
|
+
|
|
41
|
+
- Mixed-size PDF viewport cropping, DOCX rendering without optional settings,
|
|
42
|
+
cross-bundle admitted fixed-argv authority and Host tool image attachment delivery.
|
|
43
|
+
- Daemon preflight rejects known in-flight mutations before redundant full state
|
|
44
|
+
scans, and reports the actual method/count using the existing shutdown fence
|
|
45
|
+
(Issue 367). A mutation beginning during a read also stops further scans;
|
|
46
|
+
busy work is never treated as safe to stop.
|
|
47
|
+
|
|
48
|
+
Validation: 16,589 tests passed, with package/bundle/native/type checks recorded
|
|
49
|
+
in the [regression guide](docs/test-guides/FEATURE_301_v0.7.97_TEST_GUIDE.md).
|
|
50
|
+
Natural-task GLM/DeepSeek smoke observed automatic image review, but full
|
|
51
|
+
repair/re-review/delivery has not passed all checks. Native DOCX fidelity and
|
|
52
|
+
model-facing schema gaps remain open; see [E2E evidence](docs/research/automatic-visual-review-e2e-2026-10-13.md).
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
11
56
|
## [0.7.97-alpha.4] - 2026-10-12
|
|
12
57
|
|
|
13
58
|
Fourth alpha of the v0.7.97 line: FEATURE_301 adds the independent
|
|
14
59
|
`@kodax-ai/artifacts` package — PPTX authoring, bounded editing, and
|
|
15
|
-
current-file visual evidence through
|
|
60
|
+
current-file visual evidence through lightweight rendering (optional
|
|
61
|
+
LibreOffice/PDF conversion) — with an
|
|
16
62
|
optional managed KodaX adapter, and retires the out-of-band Sidecar
|
|
17
63
|
Verifier in favor of evidence-based in-run result review with the
|
|
18
64
|
`visual-review` builtin skill. Every v0.7.96 stable and
|
package/README.md
CHANGED
|
@@ -775,7 +775,7 @@ physical summary call.
|
|
|
775
775
|
|
|
776
776
|
**v0.7.97-alpha.4 release:** Adds the independent `@kodax-ai/artifacts`
|
|
777
777
|
package — PPTX authoring, bounded editing, and current-file visual
|
|
778
|
-
evidence through LibreOffice/PDF
|
|
778
|
+
evidence through lightweight rendering (optional LibreOffice/PDF conversion) — with an optional managed
|
|
779
779
|
KodaX adapter (FEATURE_301), and retires the out-of-band Sidecar
|
|
780
780
|
Verifier: the main agent now verifies requested requirements with actual
|
|
781
781
|
tool and rendered evidence before delivery, guided by the `visual-review`
|
|
@@ -789,6 +789,20 @@ starts, upgrades, or waits. See
|
|
|
789
789
|
Every v0.7.96 stable and v0.7.97-alpha.1/alpha.2/alpha.3 contract is
|
|
790
790
|
retained.
|
|
791
791
|
|
|
792
|
+
**v0.7.97-alpha.5 release:** Ships FEATURE_301's unified Artifact SDK and
|
|
793
|
+
format backends — nine SDK operations (`prepare`, `readEvidence`,
|
|
794
|
+
capabilities/diagnostics), native PDF, exact PNG/JPEG/WebP/SVG, candidate
|
|
795
|
+
DOCX pagination and local HTML/SMIL capture through the same
|
|
796
|
+
Node/shared-Host contract — plus a bounded busy daemon preflight (Issue
|
|
797
|
+
367) that stops redundant scans when a mutation begins mid-read. Rendering
|
|
798
|
+
works headlessly; automatic review needs available tools and an
|
|
799
|
+
image-capable provider, without a slash command. Native DOCX fidelity and
|
|
800
|
+
full natural-task repair/re-review/delivery remain unverified. See
|
|
801
|
+
[SDK support, setup and migration](docs/ARTIFACT_SDK.md) and the
|
|
802
|
+
[v0.7.97-alpha.5 release notes](docs/release.md#v0797-alpha5-release-preparation).
|
|
803
|
+
Every v0.7.96 stable and v0.7.97-alpha.1 through alpha.4 contract is
|
|
804
|
+
retained.
|
|
805
|
+
|
|
792
806
|
**v0.7.97-alpha.3 release:** Lets trusted Main bound Product Workflows.
|
|
793
807
|
`authorizeExecution` may return a `workflowHostPolicy` (`maxAgents`,
|
|
794
808
|
`tokenBudget`) without registering credential or hostTools leases, and the
|
|
@@ -1358,7 +1372,7 @@ kodax --repo-intelligence full --repo-intelligence-trace
|
|
|
1358
1372
|
|
|
1359
1373
|
## Architecture
|
|
1360
1374
|
|
|
1361
|
-
KodaX uses a **monorepo architecture** with npm workspaces. Four core packages ship in `@kodax-ai/kodax` with 13 SDK subpath exports (`/agent`, `/llm`, `/coding`, `/media`, `/repl`, `/skills`, `/mcp`, `/session`, `/client`, `/runtime`, `/sandbox`, `/a2a`, `/experimental-memory`; ADR-024 + ADR-032 + ADR-038, with ADR-036 consolidation). The independent optional `@kodax-ai/artifacts` package
|
|
1375
|
+
KodaX uses a **monorepo architecture** with npm workspaces. Four core packages ship in `@kodax-ai/kodax` with 13 SDK subpath exports (`/agent`, `/llm`, `/coding`, `/media`, `/repl`, `/skills`, `/mcp`, `/session`, `/client`, `/runtime`, `/sandbox`, `/a2a`, `/experimental-memory`; ADR-024 + ADR-032 + ADR-038, with ADR-036 consolidation). The independent optional `@kodax-ai/artifacts` package adds PPTX authoring/limited edits, PDF/image/SVG evidence, candidate DOCX preview, local HTML/SMIL capture, preparation and binary evidence reading. Core startup does not load renderers; the KodaX bridge uses managed permissions, sandbox and cancellation. [SDK support and limits](docs/ARTIFACT_SDK.md).
|
|
1362
1376
|
|
|
1363
1377
|
```
|
|
1364
1378
|
KodaX/
|
|
@@ -2047,7 +2061,7 @@ This development tree exposes 13 SDK subpaths plus the root. Shared product
|
|
|
2047
2061
|
applications use `@kodax-ai/kodax/client`; independent libraries and trusted Host
|
|
2048
2062
|
APIs remain available through the other subpaths. See the [Client contract](docs/CLIENT_CONTRACT.md)
|
|
2049
2063
|
and [SDK migration guide](docs/SDK_MIGRATION.md). This documentation was checked
|
|
2050
|
-
against package version `0.7.97-alpha.
|
|
2064
|
+
against package version `0.7.97-alpha.5`; npm publication is separate from
|
|
2051
2065
|
the current development-tree contract.
|
|
2052
2066
|
|
|
2053
2067
|
```bash
|
package/README_CN.md
CHANGED
|
@@ -304,7 +304,7 @@ SDK 系统代码契约更新,但没有放宽 shell/sandbox 的 fail-closed 边
|
|
|
304
304
|
`data_changed` 时通过权威 delta 合并恢复;后台持久化失败会显示为诊断,不再静默丢失。
|
|
305
305
|
|
|
306
306
|
**v0.7.97-alpha.4 发布**:新增独立的 `@kodax-ai/artifacts` 包——PPTX 创作、
|
|
307
|
-
|
|
307
|
+
有界编辑与当前文件视觉证据(轻量渲染,可选 LibreOffice/PDF 转换),并带可选的受管 KodaX
|
|
308
308
|
适配器(FEATURE_301);同时退役旁路 Sidecar Verifier:主 Agent 在交付前用
|
|
309
309
|
真实工具与渲染证据核验每条需求,由内置 `visual-review` 技能覆盖静态、分页、
|
|
310
310
|
交互与时间性表面,允许只读子评审者在同一 Run 内参与,未核验范围如实报告。
|
|
@@ -314,6 +314,17 @@ SDK 系统代码契约更新,但没有放宽 shell/sandbox 的 fail-closed 边
|
|
|
314
314
|
[v0.7.97-alpha.4 发布清单](docs/release.md#v0797-alpha4-release-preparation)。
|
|
315
315
|
所有 v0.7.96 稳定与 v0.7.97-alpha.1/alpha.2/alpha.3 契约全部保留。
|
|
316
316
|
|
|
317
|
+
**v0.7.97-alpha.5 发布**:交付 FEATURE_301 统一 Artifact SDK 与格式后端——
|
|
318
|
+
九项 SDK 操作(`prepare`、`readEvidence`、能力/诊断)、原生 PDF、精确
|
|
319
|
+
PNG/JPEG/WebP/SVG、DOCX 候选分页及本地 HTML/SMIL 捕获,独立 Node 与共享
|
|
320
|
+
Host 使用同一契约;同时为繁忙 daemon 预检加上边界(Issue 367),读取途中
|
|
321
|
+
出现变更即停止冗余扫描。文件渲染可无界面运行;自动审查需要可用取证工具及
|
|
322
|
+
支持图片输入的模型,不要求 slash。DOCX 原生保真和自然任务的完整
|
|
323
|
+
修复/复查/交付仍未全部验证。
|
|
324
|
+
详见 [SDK 支持、接入与迁移](docs/ARTIFACT_SDK.md) 与
|
|
325
|
+
[v0.7.97-alpha.5 发布清单](docs/release.md#v0797-alpha5-release-preparation)。
|
|
326
|
+
所有 v0.7.96 稳定与 v0.7.97-alpha.1 至 alpha.4 契约全部保留。
|
|
327
|
+
|
|
317
328
|
**v0.7.97-alpha.3 发布**:让可信 Main 为产品 Workflow 设定上限。
|
|
318
329
|
`authorizeExecution` 可以只返回 `workflowHostPolicy`(`maxAgents`、
|
|
319
330
|
`tokenBudget`),无需注册 credential 或 hostTools lease;宿主能力升级为
|
|
@@ -1255,7 +1266,7 @@ KodaX 是基于 npm workspaces 的 TypeScript monorepo,**4 个核心 workspace
|
|
|
1255
1266
|
|
|
1256
1267
|
KodaX 有两层结构,SDK 用户需要分开理解:
|
|
1257
1268
|
|
|
1258
|
-
- **源码层**:4 个核心 workspace 包,另有独立可选 `@kodax-ai/artifacts`:PPTX
|
|
1269
|
+
- **源码层**:4 个核心 workspace 包,另有独立可选 `@kodax-ai/artifacts`:PPTX 创作/限定编辑,PDF/图片/SVG 取证、DOCX 轻量预览、本地网页与 SMIL 捕获,公共准备和真实图片读取。核心启动不加载渲染依赖;桥接沿用受管权限、沙箱和取消。[SDK 支持与限制](docs/ARTIFACT_SDK.md)。
|
|
1259
1270
|
- **当前源码打包导出**(不表示已发布到 npm):单个 bundled 包 `@kodax-ai/kodax`,对外暴露 13 个 SDK subpath(SDK 消费者 `import` 时看到的接口)。subpath 分两种角色:
|
|
1260
1271
|
- **完整包 subpath**(`/agent`、`/llm`、`/coding`、`/repl`)—— 每个 1:1 对应一个源码包,暴露完整公开 API。
|
|
1261
1272
|
- **集成与窄子集 subpath**(`/media`、`/skills`、`/mcp`、`/session`、`/client`、`/runtime`、`/sandbox`、`/a2a`、`/experimental-memory`)—— 聚焦能力或宿主集成边界;`/experimental-memory` 明确为 opt-in 不稳定接口。
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{Aa as e,Ba as f,Ra as g,Ta as h,mb as i,nb as j,wb as k,za as d}from"./chunk-
|
|
2
|
+
import{Aa as e,Ba as f,Ra as g,Ta as h,mb as i,nb as j,wb as k,za as d}from"./chunk-XPH33F3A.js";import{a as c}from"./chunk-STB66YFC.js";import"./chunk-V26LAWJY.js";import"./chunk-ICCDQVLL.js";import"./chunk-IUTBOGEK.js";import"./chunk-6ERRCDWZ.js";import"./chunk-3XIY3OYT.js";import{Rb as a,Sb as b}from"./chunk-62V3CQH4.js";import"./chunk-YVBBU6K5.js";import"./chunk-2AM3FRQ7.js";import"./chunk-ONUPGMER.js";export{e as bucketProviderPayloadSize,g as buildAutoRepoIntelligenceContext,f as checkPromiseSignal,b as cleanupIncompleteToolCalls,h as describeTransientProviderRetry,c as emitResilienceDebug,d as estimateProviderPayloadBytes,k as runKodaX,j as saveRequiredSessionSnapshot,i as saveSessionSnapshot,a as validateAndFixToolHistory};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
+
import{$a as a,ab as b}from"./chunk-F7TCQL2L.js";import"./chunk-ZQYWDI4O.js";import"./chunk-CF4B36EZ.js";import"./chunk-2E3TJ7KO.js";import"./chunk-WZWVU5LK.js";import"./chunk-XPH33F3A.js";import"./chunk-STB66YFC.js";import"./chunk-QDNDPIDD.js";import"./chunk-V26LAWJY.js";import"./chunk-WTX6GRSV.js";import"./chunk-ICCDQVLL.js";import"./chunk-IUTBOGEK.js";import"./chunk-6ERRCDWZ.js";import"./chunk-3XIY3OYT.js";import"./chunk-62V3CQH4.js";import"./chunk-YVBBU6K5.js";import"./chunk-2AM3FRQ7.js";import"./chunk-ONUPGMER.js";export{a as ArgumentCompleter,b as createArgumentCompleter};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{a as C,b as m}from"./chunk-
|
|
2
|
+
import{a as C,b as m}from"./chunk-A5KR5LCP.js";import{D as k,K as O,j as K,q as X}from"./chunk-WZWVU5LK.js";import{rb as g,wb as p}from"./chunk-XPH33F3A.js";import{d as x,jc as f}from"./chunk-IUTBOGEK.js";import{a as s}from"./chunk-ONUPGMER.js";import{isDeepStrictEqual as R}from"node:util";function y(e,o){let a=e.events,r=new Map;return{...e,guardrails:e.guardrails?.map(t=>{if(t.kind!=="tool"||t.name!=="auto-mode")return t;let n=t.beforeTool;return n?{...t,kind:"tool",async beforeTool(d,i){let T=f(d),c=T?.ok?T.call:d;o.revoke(c.id),r.delete(c.id);let l=await n.call(t,d,i);return l.action==="allow"&&r.set(c.id,structuredClone(c)),l}}:t}),events:{...a,async beforeToolExecute(t,n,d){let i=d?.toolId,T=i===void 0?void 0:r.get(i);i!==void 0&&(o.revoke(i),r.delete(i));let c=await a?.beforeToolExecute?.(t,n,d);if(i!==void 0){let l={id:i,name:t,input:n};(c===!0||c===void 0&&R(l,T))&&o.grant(l)}return c??!0},onToolExecutionEnd(t,n){o.revoke(t.id),a?.onToolExecutionEnd?.(t,n)}}}}s(y,"withDirectTextApprovals");function u(e){if(e.context?.trustedTextMutationHost!==void 0)return e;let o=e.context?.gitRoot??e.context?.executionCwd??process.cwd(),a=e.context?.executionCwd??o,r=m(a,()=>e.context?.resolveShellPermissionMode?.()==="auto"),t=C(()=>[o,a,...e.context?.workspaceSandboxRoots?.list()??[]],n=>x(n,a,[],e.context?.resolveShellPermissionMode?.()==="full-access"),()=>e.context?.resolveShellPermissionMode?.()==="full-access",r.authorize);return y({...e,context:{...e.context,trustedTextMutationHost:t}},r)}s(u,"withTrustedTextMutationHost");function v(e,o){return p(u(e),o)}s(v,"runKodaX");function P(e,o){return K(u(e),o)}s(P,"startKodaX");function S(e,o){return k(u(e),o)}s(S,"runManagedTask");function E(e){let o=e.runAgent??p,a=e.createOptions;return O({...e,createOptions:s((r,t,n)=>u(a?.(r,t,n)??n),"createOptions"),runAgent:s((r,t)=>o(u(r),t),"runAgent")})}s(E,"createKodaXTaskRunner");function D(e={}){let o=g(e),a=o.substrateExecutor;return Object.freeze({...o,substrateExecutor:s(((r,t,n,d)=>{let i=n?.presetOptions??{};return a(r,t,{...n,presetOptions:u(i)},d)}),"substrateExecutor")})}s(D,"createDefaultCodingAgent");var A=class extends X{static{s(this,"KodaXClient")}constructor(o){super(o,v)}};export{u as a,v as b,P as c,S as d,E as e,D as f,A as g};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{K as W,a as c,da as G,z as j}from"./chunk-
|
|
2
|
+
import{K as W,a as c,da as G,z as j}from"./chunk-CF4B36EZ.js";import{wa as x,ya as O}from"./chunk-WZWVU5LK.js";import{a as o}from"./chunk-ONUPGMER.js";import*as Q from"child_process";import*as v from"path";import*as R from"fs";import*as Z from"os";import h from"chalk";import f from"chalk";var ee=100,te=/\b(curl|wget|invoke-webrequest|invoke-restmethod|iwr|irm)\b/i,U=/\b(rm|del|erase|remove-item|rmdir|rd|git clean)\b/i,Y=/\b(npm|pnpm|yarn|pip|choco|winget)\s+(install|add|remove|uninstall|update|upgrade|ci)\b/i,K=/\b(set-content|add-content|out-file|new-item|copy-item|move-item|rename-item|cp|mv|copy|move|ren|touch)\b/i;function $(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}o($,"readString");function d(e,t,n){n&&e.push({label:t,value:n})}o(d,"pushField");function ne(e){return e.replace(/\s+/g," ").trim()}o(ne,"normalizeWhitespace");function re(e,t){if(e.length<=t)return e;let n=Math.ceil((t-3)/2),r=Math.floor((t-3)/2);return`${e.slice(0,n)}...${e.slice(e.length-r)}`}o(re,"truncateMiddle");function oe(e){let t=e;return t=t.replace(/\b(authorization\s*:\s*bearer\s+)([^\s'"]+)/gi,(n,r)=>`${r}[REDACTED]`),t=t.replace(/\b((?:authorization|cookie)\s*:\s*)([^'"]+)/gi,(n,r)=>`${r}[REDACTED]`),t=t.replace(/\b(bearer\s+)([^\s'"]+)/gi,(n,r)=>`${r}[REDACTED]`),t=t.replace(/\b(api[_-]?key|access[_-]?token|refresh[_-]?token|token|secret|password|passwd|cookie|session)\b(\s*[:=]\s*)(['"]?)([^'"\s]+)(\3)/gi,(n,r,s,i)=>`${r}${s}${i}[REDACTED]${i}`),t=t.replace(/(--(?:api-key|token|secret|password|cookie)\s+)(\S+)/gi,(n,r)=>`${r}[REDACTED]`),t=t.replace(/((?:-u|--user)\s+)(\S+)/gi,(n,r)=>`${r}[REDACTED]`),t}o(oe,"maskSensitiveSegments");function B(e){return re(oe(ne(e)),ee)}o(B,"summarizeCommand");function se(e){return x(e)?c("intent.read"):U.test(e)?c("intent.delete"):Y.test(e)?c("intent.deps"):O(e)||K.test(e)?c("intent.modify"):c("intent.execute")}o(se,"classifyShellIntent");function ie(e){let t=[];return U.test(e)?t.push(c("risk.destructive")):Y.test(e)?t.push(c("risk.deps")):O(e)||K.test(e)?t.push(c("risk.modify")):x(e)||t.push(c("risk.unknown")),te.test(e)&&t.push(c("risk.network")),t}o(ie,"classifyShellRisks");function ce(e){if(Array.isArray(e))return e.filter(t=>typeof t=="object"&&t!==null&&typeof t.kind=="string")}o(ce,"readSignals");function ue(e){if(e){if(e.some(t=>t.kind==="protected_path"))return c("scope.protected");if(e.some(t=>t.kind==="outside_project"||t.kind==="shell_redirect_outside"))return c("scope.outside")}}o(ue,"scopeFromSignals");function ae(e){if(e._outsideProject===!0)return c("scope.outside");if(e._alwaysConfirm===!0)return c("scope.protected")}o(ae,"scopeFromMarkers");function le(e){if(!e)return[];let t=[],n=e.some(s=>s.kind==="dangerous_pattern"&&s.severity==="high"),r=e.some(s=>s.kind==="dangerous_pattern"&&s.severity==="medium");return n?t.push(c("risk.destructive")):r&&t.push(c("risk.modify")),e.some(s=>s.kind==="network")&&t.push(c("risk.network")),e.some(s=>s.kind==="package_install")&&t.push(c("risk.deps")),t}o(le,"risksFromSignals");var de={Reason:"field.reason",Intent:"field.intent",Target:"field.target",Scope:"field.scope",Risk:"field.risk",Summary:"field.summary"};function fe(e){return c(de[e])}o(fe,"localizeFieldLabel");function C(e,t){return{title:e,fields:t,details:t.map(n=>`${fe(n.label)}: ${n.value}`)}}o(C,"buildDisplayFromFields");function A(e,t){if(e==="confirm"){let l=$(t._message);if(l)return C(l,[])}if(e==="exit_plan_mode"){let l=$(t.plan),y="Approve plan? (exits plan mode \u2192 accept-edits)";return l?{title:y,fields:[],details:l.split(`
|
|
3
3
|
`)}:C(y,[])}let n=[],r=$(t.path),s=$(t.command),i=$(t._reason)??$(t.justification),u=ce(t._classifierSignals),a=ue(u)??ae(t);switch(d(n,"Reason",i),e){case"bash":case"shell_command":{if(s){d(n,"Intent",se(s)),d(n,"Scope",a);let l=le(u),y=l.length>0?l:ie(s);y.length>0&&d(n,"Risk",y.join("; ")),d(n,"Summary",B(s))}else d(n,"Scope",a);return C(e==="bash"?c("tool.bash.title"):c("tool.shell.title"),n)}case"write":return d(n,"Intent",c("intent.write_file")),d(n,"Target",r),d(n,"Scope",a),C(c("tool.write.title"),n);case"edit":return d(n,"Intent",c("intent.edit_file")),d(n,"Target",r),d(n,"Scope",a),C(c("tool.edit.title"),n);default:return d(n,"Intent",c("intent.use_tool",{tool:e})),d(n,"Target",r),d(n,"Scope",a),s&&d(n,"Summary",B(s)),C(c("tool.generic.title",{tool:e}),n)}}o(A,"buildToolConfirmationDisplay");function Pe(e,t){let n=A(e,t);return n.details.length>0?`${n.title}
|
|
4
4
|
${n.details.join(`
|
|
5
5
|
`)}`:n.title}o(Pe,"buildToolConfirmationPrompt");var z="Runtime state: run active until this approval is resolved.";function Fe(e,t){if(!t.confirmed)return{type:"reject",reason:"User rejected the tool call."};if(t.runtimeGrantKind===void 0)return{type:"allow_once"};let n=e.grantSuggestions?.find(r=>r.kind===t.runtimeGrantKind);return n?t.runtimeGrantKind==="session"?{type:"allow_session",suggestionId:n.id}:{type:"allow_always",suggestionId:n.id}:{type:"reject",reason:"Runtime grant suggestion expired."}}o(Fe,"resolveReplRuntimePermissionDecision");function Le(e){let t=e.classifierModelEnv??e.classifierModel;return{...t!==void 0?{classifierModel:t}:{},...e.reviewPolicy!==void 0?{reviewPolicy:e.reviewPolicy}:{}}}o(Le,"toReplRuntimeAutoModeSettings");import*as H from"child_process";var E;function pe(){if(process.platform!=="win32")return null;if(E!==void 0)return E;try{E=H.execFileSync(process.env.ComSpec??"cmd.exe",["/d","/s","/c","chcp"],{encoding:"utf8",stdio:["ignore","pipe","ignore"],windowsHide:!0}).match(/(\d{3,5})/)?.[1]??null}catch{E=null}return E}o(pe,"detectWindowsCodePage");function P(){let e=process.env;return!!(e.COLORTERM==="truecolor"||e.COLORTERM==="24bit"||e.TERM_PROGRAM==="iTerm.app"||e.WT_SESSION||e.TERM==="xterm-kitty"||e.TERM_PROGRAM==="vscode"||e.TERM_PROGRAM==="gnome-terminal")}o(P,"supportsTrueColor");function me(){if(P())return!0;let e=process.env.TERM||"";return e.includes("256color")||e==="xterm-256color"||e==="screen-256color"||e==="tmux-256color"}o(me,"supports256Colors");function w(){let e=process.env,t=e.LC_ALL||"",n=e.LC_CTYPE||"",r=e.LANG||"";if(t==="C"||t==="POSIX"||n==="C"||n==="POSIX"||r==="C"||r==="POSIX")return!1;let s=`${t}|${n}|${r}`.toLowerCase();return s.includes("utf-8")||s.includes("utf8")?!0:process.platform==="win32"?e.WT_SESSION||e.TERM_PROGRAM==="vscode"?!0:pe()==="65001":!0}o(w,"supportsUnicode");function he(){let e=process.env;return!!(e.TERM_PROGRAM==="iTerm.app"||e.WT_SESSION||e.TERM==="xterm-kitty"||e.TERM_PROGRAM==="vscode"||e.TERM_PROGRAM==="Apple_Terminal"||e.TERM_PROGRAM==="gnome-terminal"||e.COLORTERM)}o(he,"supportsEmoji");function ye(){if(process.stdout?.columns)return process.stdout.columns;let t=process.env.COLUMNS;if(t){let n=Number.parseInt(t,10);if(!Number.isNaN(n)&&n>0)return n}return 80}o(ye,"getTerminalWidth");function ge(){let e=process.env;return!!(e.NO_COLOR||e.TERM==="dumb"||e.CI)}o(ge,"isScreenReader");function we(){return process.stdout?.isTTY??!1}o(we,"isTTY");function We(){return{trueColor:P(),colors256:me(),unicode:w(),emoji:he(),tty:we(),columns:ye(),screenReader:ge()}}o(We,"detectTerminalCapabilities");var ke=[{key:"y",label:"Yes",description:"Confirm the action",value:"yes"},{key:"n",label:"No",description:"Cancel the action",value:"no"}],be=[{key:"y",label:"Yes",description:"Allow this once",value:"yes"},{key:"n",label:"No",description:"Cancel",value:"no"},{key:"a",label:"Always",description:"Always allow this kind of action",value:"always"}];function Te(e,t=!0){return e.map(n=>{let r=f.dim(`[${n.key}]`);return t?`${r} ${f.cyan(n.label)} ${f.dim(`- ${n.description}`)}`:`${r} ${n.label}`}).join(" ")}o(Te,"formatOptions");function N(){return process.stdout.columns??80}o(N,"getTerminalWidth");function $e(){return w()}o($e,"supportsUnicode");function Ce(){let e=$e();return{success:e?"\u2713":"[OK]",error:e?"\u2717":"[X]",warning:e?"\u26A0":"[!]",info:e?"\u2139":"[i]",arrow:e?"\u2192":"->",bullet:e?"\u2022":"*",check:e?"\u2713":"[v]",cross:e?"\u2717":"[x]"}}o(Ce,"getSymbols");async function Se(e,t){let{message:n,default:r,options:s,showDescription:i=!0,signal:u}=t,a=s??ke,l=Te(a,i);console.log(),console.log(f.cyan(`? ${n}`));let y=N();if(l.length>y-4)for(let p of a){let g=f.dim(` [${p.key}]`);console.log(`${g} ${f.cyan(p.label)}`),i&&console.log(f.dim(` ${p.description}`))}else console.log(f.dim(` ${l}`));return u?.aborted?"no":new Promise(p=>{let g=r?` (${r})`:"",_=!1,k=o(m=>{_||(_=!0,u?.removeEventListener("abort",b),p(m))},"finish"),b=o(()=>k("no"),"onAbort"),T=o(m=>{let S=m.trim().toLowerCase()||r||"",D=a.find(M=>M.key===S||M.value===S||M.label.toLowerCase()===S);k(D?D.value:S===""?"no":S)},"onAnswer");u?.addEventListener("abort",b,{once:!0}),u?e.question(f.dim(` Choose${g}: `),{signal:u},T):e.question(f.dim(` Choose${g}: `),T)})}o(Se,"confirmEnhanced");async function He(e,t,n,r){let{isOutsideProject:s=!1,isProtectedPath:i=!1,permissionMode:u="accept-edits",runtimeGrantSuggestions:a,signal:l}=r??{},y=Ce(),p,g,_={...n,...s?{_outsideProject:!0}:{},...i?{_alwaysConfirm:!0}:{}},k=A(t,_),b=k.details.map(m=>` ${f.dim(m)}`);s||i?(p=`${f.yellow(y.warning)} Safety Warning`,b.length>0&&(p+=`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{g,i as x,j as v}from"./chunk-
|
|
2
|
+
import{g,i as x,j as v}from"./chunk-KDQREOAJ.js";import{c as T}from"./chunk-IUTBOGEK.js";import{a as d}from"./chunk-ONUPGMER.js";import u from"node:fs";import{createHash as C}from"node:crypto";import{createRequire as O}from"node:module";import l from"node:path";var h=5;var E=O(import.meta.url),S=3e4,f;function P(t,o){let e=t.replaceAll("/","\\"),a=e.toLowerCase(),r=e.slice(3),c=(r===""?[]:r.split("\\")).some(n=>{let i=n.split(".",1)[0].toUpperCase(),p=["CON","PRN","AUX","NUL","CONIN$","CONOUT$"].includes(i)||/^(?:COM|LPT)[1-9¹²³]$/.test(i);return n===""||n==="."||n===".."||n.endsWith(".")||n.endsWith(" ")||/[\u0000-\u001f<>"|?*]/.test(n)||/~[0-9¹²³]/.test(n)||p});if(t.includes("\0")||e.startsWith("\\\\")||a.startsWith("\\??\\")||a.startsWith("\\device\\")||a.startsWith("\\global??\\")||a.startsWith("globalroot\\")||!/^[A-Za-z]:\\/.test(e)||e.slice(2).includes(":")||c)throw new T({code:"text_mutation_unsafe_path",path:t,message:`Trusted text mutation ${o} must use a local drive-absolute path; UNC and device namespaces are denied: ${t}`})}d(P,"assertLocalDriveAbsolutePath");function m(t,o){if(process.platform==="win32"){P(t,o);return}if(t.includes("\0")||!l.isAbsolute(t)||t.startsWith("//"))throw new T({code:"text_mutation_unsafe_path",path:t,message:`Trusted text mutation ${o} must use a local absolute path: ${t}`})}d(m,"assertSupportedAbsolutePath");function y(t,o){let e=l.relative(t,o);return e===""||!e.startsWith("..")&&!l.isAbsolute(e)}d(y,"sameOrInside");function A(t){let o=new Map;for(let e of t){let a=l.resolve(e),r=process.platform==="win32"?a.toLowerCase():a;o.has(r)||o.set(r,a)}return[...o.values()].sort((e,a)=>a.length-e.length)}d(A,"normalizedRootCandidates");function w(t,o,e=!1){m(t,"target");for(let n of o)m(n,"write root");let a=l.resolve(t),r=[...A(o)];if(e){let n=l.dirname(a);for(;!u.existsSync(n);){let i=l.dirname(n);if(i===n)break;n=i}r.unshift(n)}let s=r.find(n=>n!==a&&y(n,a)),c=d(n=>{try{if(!u.lstatSync(n).isDirectory())throw new Error("write root is not a directory");return u.realpathSync.native(n)}catch(i){throw new T({code:"text_mutation_unsafe_path",path:t,message:`Trusted text mutation write root is unavailable: ${n}`,cause:i})}},"canonicalizeRoot");if(s!==void 0){let n=c(s);return{canonicalRoot:n,canonicalTarget:l.join(n,l.relative(s,a))}}for(let n of r){let i=c(n);if(i!==a&&y(i,a))return{canonicalRoot:i,canonicalTarget:a}}throw new T({code:"text_mutation_policy_denied",path:t,message:`Trusted text mutation target is outside the Runtime write roots: ${t}`})}d(w,"authorizeTarget");function _(t,o=t){if(g(t),f!==void 0)return f;let e=v(import.meta.url,h,t,o),a=K(e);return f=X(a),f}d(_,"loadNativeBinding");function X(t){if(typeof t.textTransactionProtocol!="function"||typeof t.TrustedTextTransactionRoot!="function"||t.textTransactionProtocol()!==h)throw new Error(`The KodaX trusted text transaction binding must implement protocol ${h}.`);return t}d(X,"validateNativeBinding");function K(t){if(process.platform==="win32")return E(t);let o=u.openSync(t,u.constants.O_RDONLY|u.constants.O_NOFOLLOW);try{let e=u.fstatSync(o);if(!e.isFile()||e.nlink!==1||e.size>64*1024*1024)throw new Error("The protected native text binding has an unsafe identity.");let a=l.basename(l.dirname(t)).toLowerCase(),r=u.readFileSync(o),s=C("sha256").update(r).digest("hex");if(!/^[0-9a-f]{64}$/.test(a)||s!==a)throw new Error("The protected native text binding changed after provisioning.");let c={exports:{}},n=process.platform==="linux"?`/proc/self/fd/${o}`:`/dev/fd/${o}`;return process.dlopen(c,n),c.exports}finally{u.closeSync(o)}}d(K,"loadNativeBindingFile");function N(t,o,e){return process.platform==="win32"?new t.TrustedTextTransactionRoot(o,void 0,e):new t.TrustedTextTransactionRoot(o,x(),e)}d(N,"createNativeRoot");function k(t){switch(t){case"invalid_path":case"reparse_point":case"hard_link":return"text_mutation_unsafe_path";case"unauthorized_path":return"text_mutation_policy_denied";case"remote_filesystem":case"unsupported_filesystem":case"unsupported_platform":return"text_mutation_unsupported_filesystem";case"contended":return"text_mutation_contended";case"stale":return"text_mutation_stale";case"metadata_preservation":return"text_mutation_metadata_preservation_failed";default:return"text_mutation_io_failed"}}d(k,"mappedNativeErrorCode");function R(t,o){if(o instanceof T)throw o;let e=o instanceof Error?o.message:String(o),a="KODAX_TEXT_TRANSACTION:",r=e.indexOf(a),s={};if(r>=0)try{let c=JSON.parse(e.slice(r+a.length));c!==null&&typeof c=="object"&&!Array.isArray(c)&&(s=c)}catch{s={}}throw new T({code:k(s.code),path:t,message:s.message??e,...typeof s.os_code=="number"?{osCode:s.os_code}:{},cause:o})}d(R,"translateNativeError");function B(t){return{state:t.state,content:t.content,revision:t.revision,slot:t.slotId,canonicalPath:t.canonicalPath}}d(B,"publicSnapshot");function L(t,o,e){if(e.status==="stale"){if(typeof e.currentRevision!="string")throw new Error("Native text transaction returned a stale result without a revision.");return{status:"stale",currentRevision:e.currentRevision}}if(typeof e.slotId!="string"||typeof e.preContent!="string"||typeof e.preRevision!="string"||typeof e.postRevision!="string")throw new Error("Native text transaction returned an incomplete commit receipt.");let a={before:{state:e.preRevision.startsWith("missing:")?"missing":"present",content:e.preContent,revision:e.preRevision,slot:e.slotId,canonicalPath:t},after:{state:"present",content:o,revision:e.postRevision,slot:e.slotId,canonicalPath:t},recoveredAbandonedLock:e.abandonedLock===!0};if(e.status==="committed_uncertain"){if(typeof e.message!="string"||e.message==="")throw new Error("Native text transaction returned an uncertain commit without a reason.");return{status:"committed_uncertain",...a,reason:e.message}}return{status:"written",...a}}d(L,"requireWrittenOutcome");function F(t,o,e=()=>!1,a){return{async snapshot(r){if(r.signal?.aborted)throw r.signal.reason;m(r.path,"target");let s=e(),c=a?.(r.toolCall,r.path,"snapshot")===!0,n=w(r.path,t(),s||c);o(n.canonicalTarget),g([n.canonicalTarget]);try{let i=_([n.canonicalTarget],t()),p=N(i,n.canonicalRoot,s);return B(await p.snapshot(n.canonicalTarget))}catch(i){R(n.canonicalTarget,i)}},async commit(r){if(r.signal?.aborted)throw r.signal.reason;m(r.path,"target");let s=e(),c=a?.(r.toolCall,r.path,"commit")===!0,n=w(r.path,t(),s||c);o(n.canonicalTarget),g([n.canonicalTarget]);try{let i=_([n.canonicalTarget],t()),b=await N(i,n.canonicalRoot,s).commit(n.canonicalTarget,r.expectedRevision,r.content,r.createParentDirectories,S);return L(n.canonicalTarget,r.content,b)}catch(i){R(n.canonicalTarget,i)}}}}d(F,"createTrustedTextMutationHost");import W from"node:path";import{isDeepStrictEqual as I}from"node:util";var $=new Set(["write","edit","multi_edit","insert_after_anchor"]);function Z(t,o){let e=new Map,a=d(r=>{let s=W.resolve(t,r);return process.platform==="win32"?s.toLowerCase():s},"normalize");return{grant(r){!o()||!$.has(r.name)||typeof r.input.path!="string"||e.set(r.id,{call:structuredClone(r),target:a(r.input.path),phase:"snapshot"})},authorize(r,s,c){if(!o())return e.clear(),!1;let n=r===void 0?void 0:e.get(r.id);return!n||n.phase!==c||a(s)!==n.target||!I(r,n.call)?!1:(c==="snapshot"?n.phase="commit":e.delete(n.call.id),!0)},revoke(r){e.delete(r)},clear(){e.clear()}}}d(Z,"createTrustedTextApprovals");export{F as a,Z as b};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
|
|
2
|
-
import{ia as Me,ka as _e}from"./chunk-
|
|
2
|
+
import{ia as Me,ka as _e}from"./chunk-XPH33F3A.js";import{Ka as ke,Sa as Se,Wa as Ce}from"./chunk-62V3CQH4.js";import{H as me,Ma as ge,Na as ve,Oa as ye,Pa as we,Qa as xe,Ra as Y,T as z,W as B,X as he,Y as J,Ya as Ee,Za as R,bb as Q,mb as be,rb as Pe}from"./chunk-2AM3FRQ7.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
3
|
// KodaX core configuration template.
|
|
4
4
|
// Copy only the fields you need to ~/.kodax/config.json (strict JSON).
|
|
5
5
|
// MCP, A2A, and Extensions live in ~/.kodax/integrations/*.json; use
|
|
@@ -257,4 +257,4 @@ import{ia as Me,ka as _e}from"./chunk-NGFXDSP2.js";import{Ka as ke,Sa as Se,Wa a
|
|
|
257
257
|
}
|
|
258
258
|
`};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)}
|
|
259
259
|
`,"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{I({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{I({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 De(e){return d(e)?Ue(je(e,"utf8")):void 0}r(De,"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 I(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=De(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)}
|
|
260
|
-
`,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,De(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(I,"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 Le(e){return e.map(t=>`${t}:${yt(t)}`).join("|")}r(Le,"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=Le(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 Le(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.4";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 Dt(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=R(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=R(e);if(o)return o.getAvailableModels()}catch{}return[]}r(Dt,"getProviderAvailableModels");function Lt(e,t){let n=ye(e,t);if(n!=="unknown")return n;try{let o=R(e);if(o)return o.getReasoningCapability(t)}catch{}return"unknown"}r(Lt,"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=Lt(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 O(e){if(e)return e==="none"?"off":e}r(O,"formatReasoningEffortForDisplay");function W(e,t){let n=O(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=O(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=O(o.configuredEffort)??t,a=o.configuredEffort!==void 0&&n.supportsDisabledThinking!==!1&&n.disabledEfforts?.includes(o.configuredEffort)===!0?"off":O(o.effectiveEffort);return a&&a!==i?`${i}->${a}`:i}catch{if(e.effort)try{let o=J({currentEffort:e.effort,capability:n}),i=O(e.effort)??t,s=O(o.effectiveEffort);return s&&s!==i?`${i}->${s}`:i}catch{return t}return t}}r(Tn,"formatReasoningEffortStatusLabel");function Dn(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(Dn,"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 Ln(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(Ln,"describeReasoningExecution");function Nn(e){let t=[];e||(e=fe().providerModels);for(let n of xe())t.push({name:n.name,model:n.model,models:Dt(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 R(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 L=new Map;function Kn(e){let t=process.env[e];return t===void 0?"unset":L.get(e)===t?"persisted":"environment"}r(Kn,"inspectConfigEnvironmentSource");function Be(e,t,n=!1){let o=process.env[e],i=L.get(e),s=i!==void 0&&o===i;if(o!==void 0&&!s&&!n){L.delete(e);return}if(t===void 0){(s||n)&&delete process.env[e],L.delete(e);return}process.env[e]=t,L.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=>T(e.repoIntelligenceTrace),"value")},{configPath:"stallLog",env:"KODAX_STALL_LOG",value:r(e=>T(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=>T(e.disablePromptCache),"value")},{configPath:"lsp",env:"KODAX_LSP",value:r(e=>T(e.lsp),"value")},{configPath:"lspAutoDownload",env:"KODAX_LSP_DOWNLOAD",value:r(e=>T(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 T(e){return e===void 0?void 0:e?"1":"0"}r(T,"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","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);I({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);I({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,D={locked:!1,queue:[]};async function Yn(e){for(;D.locked;)await new Promise(t=>D.queue.push(t));D.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{D.locked=!1;let t=D.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,I 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,Dt as A,Lt as B,Nt as C,_n as D,$t as E,An as F,On as G,O as H,Rn as I,In as J,Tn as K,Dn as L,Kt as M,Ln 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};
|
|
260
|
+
`,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,De(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(I,"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 Le(e){return e.map(t=>`${t}:${yt(t)}`).join("|")}r(Le,"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=Le(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 Le(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.5";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 Dt(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=R(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=R(e);if(o)return o.getAvailableModels()}catch{}return[]}r(Dt,"getProviderAvailableModels");function Lt(e,t){let n=ye(e,t);if(n!=="unknown")return n;try{let o=R(e);if(o)return o.getReasoningCapability(t)}catch{}return"unknown"}r(Lt,"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=Lt(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 O(e){if(e)return e==="none"?"off":e}r(O,"formatReasoningEffortForDisplay");function W(e,t){let n=O(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=O(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=O(o.configuredEffort)??t,a=o.configuredEffort!==void 0&&n.supportsDisabledThinking!==!1&&n.disabledEfforts?.includes(o.configuredEffort)===!0?"off":O(o.effectiveEffort);return a&&a!==i?`${i}->${a}`:i}catch{if(e.effort)try{let o=J({currentEffort:e.effort,capability:n}),i=O(e.effort)??t,s=O(o.effectiveEffort);return s&&s!==i?`${i}->${s}`:i}catch{return t}return t}}r(Tn,"formatReasoningEffortStatusLabel");function Dn(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(Dn,"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 Ln(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(Ln,"describeReasoningExecution");function Nn(e){let t=[];e||(e=fe().providerModels);for(let n of xe())t.push({name:n.name,model:n.model,models:Dt(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 R(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 L=new Map;function Kn(e){let t=process.env[e];return t===void 0?"unset":L.get(e)===t?"persisted":"environment"}r(Kn,"inspectConfigEnvironmentSource");function Be(e,t,n=!1){let o=process.env[e],i=L.get(e),s=i!==void 0&&o===i;if(o!==void 0&&!s&&!n){L.delete(e);return}if(t===void 0){(s||n)&&delete process.env[e],L.delete(e);return}process.env[e]=t,L.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=>T(e.repoIntelligenceTrace),"value")},{configPath:"stallLog",env:"KODAX_STALL_LOG",value:r(e=>T(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=>T(e.disablePromptCache),"value")},{configPath:"lsp",env:"KODAX_LSP",value:r(e=>T(e.lsp),"value")},{configPath:"lspAutoDownload",env:"KODAX_LSP_DOWNLOAD",value:r(e=>T(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 T(e){return e===void 0?void 0:e?"1":"0"}r(T,"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","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);I({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);I({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,D={locked:!1,queue:[]};async function Yn(e){for(;D.locked;)await new Promise(t=>D.queue.push(t));D.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{D.locked=!1;let t=D.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,I 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,Dt as A,Lt as B,Nt as C,_n as D,$t as E,An as F,On as G,O as H,Rn as I,In as J,Tn as K,Dn as L,Kt as M,Ln 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};
|