@cjhyy/code-shell 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/anthropic-UBSB5AQH.js +1 -0
  3. package/dist/arena/index.js +1 -104
  4. package/dist/arena-OW55ZCHT.js +3 -0
  5. package/dist/bwrap-PVZMLHZR.js +2 -0
  6. package/dist/chunk-2NS3JMNK.js +1 -0
  7. package/dist/chunk-3QP5BQ3L.js +1 -0
  8. package/dist/chunk-B7K2OWKC.js +2 -0
  9. package/dist/chunk-EWWK56K6.js +2 -0
  10. package/dist/chunk-FU7AHZNN.js +1 -0
  11. package/dist/chunk-HIJ2XXGX.js +1 -0
  12. package/dist/chunk-KCXSARAA.js +1 -0
  13. package/dist/chunk-NFH3UQ3E.js +2 -0
  14. package/dist/chunk-NMBYBGC7.js +250 -0
  15. package/dist/chunk-NVAZJ5XS.js +2 -0
  16. package/dist/chunk-O5HFCH2U.js +1 -0
  17. package/dist/chunk-P6JSTIFM.js +1 -0
  18. package/dist/chunk-PGANL6F2.js +3 -0
  19. package/dist/chunk-Q4O2HGWS.js +251 -0
  20. package/dist/chunk-QTWU7UNA.js +5 -0
  21. package/dist/chunk-RP26WO4R.js +1 -0
  22. package/dist/chunk-SNFAPSLA.js +1 -0
  23. package/dist/chunk-T222K6IV.js +18 -0
  24. package/dist/chunk-TKJA6W36.js +3 -0
  25. package/dist/chunk-UDPUTFQT.js +2 -0
  26. package/dist/chunk-W47Z7MGS.js +33 -0
  27. package/dist/chunk-WI6FSWGU.js +1 -0
  28. package/dist/chunk-WOP6MJKW.js +1 -0
  29. package/dist/chunk-XDOWC7EG.js +4 -0
  30. package/dist/chunk-Y2NS6HPO.js +641 -0
  31. package/dist/cli/main.js +303 -22037
  32. package/dist/cli/updater.d.ts +8 -0
  33. package/dist/client-base-6ZZJJYDY.js +1 -0
  34. package/dist/compaction-ECVQVOCT.js +1 -0
  35. package/dist/devtools-SGDUOOM4.js +1 -0
  36. package/dist/engine/engine.d.ts +15 -0
  37. package/dist/export-md-U72T7NW7.js +22 -0
  38. package/dist/file-history-7FQFEQOL.js +1 -0
  39. package/dist/index.d.ts +1 -1
  40. package/dist/index.js +1 -347
  41. package/dist/llm/token-counter.d.ts +17 -0
  42. package/dist/manager-C3TDN6MS.js +1 -0
  43. package/dist/mcp-manager-OP4XYV53.js +1 -0
  44. package/dist/memory-BNI4WEWL.js +1 -0
  45. package/dist/model-cache-HEDXI7UJ.js +1 -0
  46. package/dist/model-fetcher-BJ64META.js +1 -0
  47. package/dist/off-7SDVMMXW.js +1 -0
  48. package/dist/openai-KEWQ54TM.js +1 -0
  49. package/dist/openrouter-models-AM6M52D6.js +1 -0
  50. package/dist/openrouter-sync-5JNBL3Z6.js +1 -0
  51. package/dist/product/index.js +1 -21
  52. package/dist/run/index.js +1 -48
  53. package/dist/seatbelt-WBYROQT6.js +37 -0
  54. package/dist/session/session-manager.d.ts +2 -0
  55. package/dist/session-manager-AGWS5SMJ.js +1 -0
  56. package/dist/settings/schema.d.ts +72 -6
  57. package/dist/tool-summary-5UE62VU4.js +2 -0
  58. package/dist/tool-system/builtin/bash.d.ts +7 -1
  59. package/dist/tool-system/context.d.ts +7 -0
  60. package/dist/tool-system/investigation-guard.d.ts +9 -0
  61. package/dist/tool-system/sandbox/bwrap.d.ts +13 -0
  62. package/dist/tool-system/sandbox/index.d.ts +71 -0
  63. package/dist/tool-system/sandbox/off.d.ts +2 -0
  64. package/dist/tool-system/sandbox/seatbelt.d.ts +18 -0
  65. package/dist/types.d.ts +4 -0
  66. package/dist/ui/components/SessionPicker.d.ts +2 -0
  67. package/dist/ui/components/SpinnerWithVerb.d.ts +2 -2
  68. package/dist/ui/components/StatusLine.d.ts +2 -2
  69. package/dist/updater-OCNU2K2Z.js +1 -0
  70. package/package.json +8 -10
  71. package/skills-builtin/codeshell-help.md +135 -0
  72. package/dist/anthropic-IBTI4WL2.cjs +0 -10
  73. package/dist/anthropic-PRZZKHEZ.js +0 -10
  74. package/dist/arena/index.cjs +0 -104
  75. package/dist/arena-KBQOPLFV.cjs +0 -261
  76. package/dist/arena-O2L4TN6A.js +0 -261
  77. package/dist/chunk-2EP3CLEN.js +0 -44
  78. package/dist/chunk-2YW4FPFG.cjs +0 -101
  79. package/dist/chunk-3OA5G4TM.js +0 -47
  80. package/dist/chunk-52LGZKT3.cjs +0 -47
  81. package/dist/chunk-55XGPMAP.cjs +0 -146
  82. package/dist/chunk-5ECBT4YA.js +0 -450
  83. package/dist/chunk-6QVAYW7C.cjs +0 -438
  84. package/dist/chunk-6S4BJ65N.js +0 -113
  85. package/dist/chunk-76HYEPDM.js +0 -307
  86. package/dist/chunk-76W334S4.js +0 -54
  87. package/dist/chunk-7EG3V4JY.cjs +0 -113
  88. package/dist/chunk-7JVTYEEC.js +0 -340
  89. package/dist/chunk-7K6SDRRF.js +0 -9047
  90. package/dist/chunk-7Y6S3OCX.js +0 -438
  91. package/dist/chunk-A5LCRPDP.cjs +0 -54
  92. package/dist/chunk-BSW22MPA.js +0 -146
  93. package/dist/chunk-BUU5PZK2.cjs +0 -9048
  94. package/dist/chunk-BWTOS5BH.cjs +0 -5128
  95. package/dist/chunk-BXCY2FSE.js +0 -203
  96. package/dist/chunk-C5YQBIRK.js +0 -5128
  97. package/dist/chunk-HEKQCI7B.cjs +0 -224
  98. package/dist/chunk-HS2MFNUC.cjs +0 -44
  99. package/dist/chunk-IK4EWJBP.cjs +0 -203
  100. package/dist/chunk-JMR33QVF.cjs +0 -169
  101. package/dist/chunk-KOVYSDHZ.cjs +0 -340
  102. package/dist/chunk-KS3RYAYL.cjs +0 -45
  103. package/dist/chunk-MD32R22I.js +0 -50
  104. package/dist/chunk-MY5XHADU.cjs +0 -216
  105. package/dist/chunk-NUNC3VFB.cjs +0 -307
  106. package/dist/chunk-QRM7IF2S.cjs +0 -4711
  107. package/dist/chunk-R47ROHGL.cjs +0 -298
  108. package/dist/chunk-RMYKO74M.js +0 -1252
  109. package/dist/chunk-SFXHZSRF.js +0 -101
  110. package/dist/chunk-SIHHIQLO.js +0 -224
  111. package/dist/chunk-SNT563K3.cjs +0 -107
  112. package/dist/chunk-T6VYG46N.js +0 -105
  113. package/dist/chunk-TUY2T5KP.cjs +0 -105
  114. package/dist/chunk-VIAGTYYW.js +0 -169
  115. package/dist/chunk-VYL4EFRC.cjs +0 -1252
  116. package/dist/chunk-W22P377T.js +0 -299
  117. package/dist/chunk-WASS5YWB.js +0 -215
  118. package/dist/chunk-XDIQWQJ4.js +0 -4711
  119. package/dist/chunk-YIQBXAYU.cjs +0 -264
  120. package/dist/chunk-YJ77GQK5.js +0 -107
  121. package/dist/chunk-YUI524OE.cjs +0 -450
  122. package/dist/chunk-ZBPSQCPU.js +0 -264
  123. package/dist/cli/main.cjs +0 -22133
  124. package/dist/client-base-HTF236ZD.cjs +0 -9
  125. package/dist/client-base-QKRKCOWB.js +0 -9
  126. package/dist/compaction-6VU2T643.js +0 -33
  127. package/dist/compaction-OKUNTCA7.cjs +0 -33
  128. package/dist/devtools-T2NIZBJK.cjs +0 -6
  129. package/dist/devtools-YXWHOVKR.js +0 -6
  130. package/dist/export-md-RXDW6F5W.cjs +0 -135
  131. package/dist/export-md-XXKZANW5.js +0 -135
  132. package/dist/file-history-KYPE3ECT.cjs +0 -7
  133. package/dist/file-history-LF4F7X26.js +0 -7
  134. package/dist/index.cjs +0 -347
  135. package/dist/manager-C2IUXKRC.js +0 -7
  136. package/dist/manager-YYKWYTRM.cjs +0 -7
  137. package/dist/mcp-manager-QMKWPBZ4.js +0 -8
  138. package/dist/mcp-manager-Z3OKI74O.cjs +0 -8
  139. package/dist/memory-5LWZ6FI2.cjs +0 -9
  140. package/dist/memory-VIJLBAMQ.js +0 -9
  141. package/dist/model-cache-5KIYL5SL.js +0 -13
  142. package/dist/model-cache-OED3IM4R.cjs +0 -13
  143. package/dist/model-fetcher-HKGICACL.js +0 -8
  144. package/dist/model-fetcher-UR6WJOQP.cjs +0 -8
  145. package/dist/openai-JR2WEKOF.js +0 -10
  146. package/dist/openai-YBTOET4O.cjs +0 -10
  147. package/dist/openrouter-models-OU4GRZQY.cjs +0 -15
  148. package/dist/openrouter-models-TGKDKY52.js +0 -15
  149. package/dist/openrouter-sync-BBHUM3R6.cjs +0 -11
  150. package/dist/openrouter-sync-UXUSJCIR.js +0 -11
  151. package/dist/product/index.cjs +0 -21
  152. package/dist/run/index.cjs +0 -48
  153. package/dist/session-manager-Q22BBMD3.js +0 -8
  154. package/dist/session-manager-XODQVL3C.cjs +0 -8
  155. package/dist/tool-summary-63DPIS7G.cjs +0 -31
  156. package/dist/tool-summary-NP5CDBKG.js +0 -31
  157. package/dist/updater-QW473OF4.cjs +0 -17
  158. package/dist/updater-VFUAHCVY.js +0 -17
package/CHANGELOG.md CHANGED
@@ -8,6 +8,36 @@ breaking.
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [0.1.6] - 2026-05-13
12
+
13
+ ### Added
14
+ - **Built-in skills bundled with the package.** The skill scanner now also
15
+ reads `skills-builtin/` shipped inside the installed npm package. First
16
+ built-in is `codeshell-help` — answers questions about code-shell itself
17
+ (slash commands, provider/model setup, settings keys, hooks, MCP,
18
+ debugging flags) so a fresh install can self-document without the user
19
+ having to write their own help skill.
20
+ - **Headless mode in Engine.** New `headless: true` config flag (set by the
21
+ `run` command) puts InvestigationGuard into soft mode: the third re-read
22
+ of the same target turns into a stronger reminder instead of a hard
23
+ block, since unattended automations have no human to retry the task.
24
+
25
+ ### Fixed
26
+ - `code-shell run` now resolves API keys / baseUrl / model from
27
+ `settings.providers[]` and `settings.models[]` in addition to the legacy
28
+ `settings.model.*` mirror — matches what Engine reconciles at startup,
29
+ fixes "no API key found" false negatives for users on the new shape.
30
+ - Read-only filesystem (CI containers) no longer floods the log with
31
+ `tool_result.persist_failed` warnings — demoted to debug.
32
+ - **Boot crash on machines with Claude Code installed.** Settings loader
33
+ previously merged `~/.claude/settings.json` into our own config for
34
+ "zero-migration from Claude Code", but CC's schema diverges (`model` is
35
+ a string there, an object here) and the merge crashed startup before
36
+ the onboarding wizard could even render. Dropped the cross-read in
37
+ `SettingsManager`, `hasApiKey()`, and the updater's autoUpdates probe.
38
+ File-level compat (CLAUDE.md scanning, `.claude/skills/` discovery) is
39
+ unaffected — only the settings.json cross-read is removed.
40
+
11
41
  ## [0.1.5] - 2026-05-13
12
42
 
13
43
  ### Added
@@ -0,0 +1 @@
1
+ export{a as AnthropicClient}from'./chunk-WOP6MJKW.js';import'./chunk-O5HFCH2U.js';import'./chunk-HIJ2XXGX.js';import'./chunk-FU7AHZNN.js';import'./chunk-B7K2OWKC.js';import'./chunk-3QP5BQ3L.js';
@@ -1,104 +1 @@
1
- import {
2
- IterativeArena,
3
- codeFormat,
4
- defaultConvergence,
5
- diffRatio,
6
- documentFormat,
7
- getFormat
8
- } from "../chunk-RMYKO74M.js";
9
- import {
10
- Arena,
11
- ArenaLedger,
12
- DiscussionStrategy,
13
- LENS_NAMES,
14
- MODEL_PRESETS,
15
- PlanningStrategy,
16
- ReviewStrategy,
17
- applyReviewResult,
18
- buildConsensus,
19
- buildDigest,
20
- buildLensPrompt,
21
- collectEvidence,
22
- createProgressRenderer,
23
- formatArenaResult,
24
- formatArenaResultForSession,
25
- formatDigest,
26
- getLens,
27
- getMaxOutputTokens,
28
- getStrategy,
29
- getStrategyForPlan,
30
- hasTools,
31
- isStrategyV2,
32
- isTerminal,
33
- markUnderReview,
34
- markUnresolved,
35
- planArena,
36
- printArenaResult,
37
- registerClaims,
38
- renderProgress,
39
- resolveClaimStatus,
40
- resolveLenses,
41
- runAdjudication,
42
- runCrossReview,
43
- runDebateRounds,
44
- runParticipantResearch,
45
- runParticipantResearchWithDossiers,
46
- runVerificationReview,
47
- selectClaimsForReview,
48
- selectTools,
49
- transitionClaim,
50
- validTransitions
51
- } from "../chunk-C5YQBIRK.js";
52
- import "../chunk-XDIQWQJ4.js";
53
- import "../chunk-SFXHZSRF.js";
54
- import "../chunk-BXCY2FSE.js";
55
- import "../chunk-MD32R22I.js";
56
- export {
57
- Arena,
58
- ArenaLedger,
59
- DiscussionStrategy,
60
- IterativeArena,
61
- LENS_NAMES,
62
- MODEL_PRESETS,
63
- PlanningStrategy,
64
- ReviewStrategy,
65
- applyReviewResult,
66
- buildConsensus,
67
- buildDigest,
68
- buildLensPrompt,
69
- collectEvidence,
70
- createProgressRenderer,
71
- defaultConvergence as defaultIterateConvergence,
72
- formatArenaResult,
73
- formatArenaResultForSession,
74
- formatDigest,
75
- getFormat as getIterateFormat,
76
- getLens,
77
- getMaxOutputTokens,
78
- getStrategy,
79
- getStrategyForPlan,
80
- hasTools,
81
- isStrategyV2,
82
- isTerminal,
83
- codeFormat as iterateCodeFormat,
84
- diffRatio as iterateDiffRatio,
85
- documentFormat as iterateDocumentFormat,
86
- markUnderReview,
87
- markUnresolved,
88
- planArena,
89
- printArenaResult,
90
- registerClaims,
91
- renderProgress,
92
- resolveClaimStatus,
93
- resolveLenses,
94
- runAdjudication,
95
- runCrossReview,
96
- runDebateRounds,
97
- runParticipantResearch,
98
- runParticipantResearchWithDossiers,
99
- runVerificationReview,
100
- selectClaimsForReview,
101
- selectTools,
102
- transitionClaim,
103
- validTransitions
104
- };
1
+ export{j as IterativeArena,f as defaultIterateConvergence,i as getIterateFormat,g as iterateCodeFormat,e as iterateDiffRatio,h as iterateDocumentFormat}from'../chunk-Q4O2HGWS.js';export{J as Arena,I as ArenaLedger,e as DiscussionStrategy,j as LENS_NAMES,Q as MODEL_PRESETS,f as PlanningStrategy,d as ReviewStrategy,z as applyReviewResult,H as buildConsensus,u as buildDigest,i as buildLensPrompt,n as collectEvidence,U as createProgressRenderer,S as formatArenaResult,W as formatArenaResultForSession,v as formatDigest,g as getLens,R as getMaxOutputTokens,k as getStrategy,l as getStrategyForPlan,p as hasTools,c as isStrategyV2,B as isTerminal,y as markUnderReview,A as markUnresolved,m as planArena,T as printArenaResult,s as registerClaims,V as renderProgress,x as resolveClaimStatus,h as resolveLenses,G as runAdjudication,D as runCrossReview,F as runDebateRounds,q as runParticipantResearch,r as runParticipantResearchWithDossiers,E as runVerificationReview,t as selectClaimsForReview,o as selectTools,w as transitionClaim,C as validTransitions}from'../chunk-Y2NS6HPO.js';import'../chunk-NVAZJ5XS.js';import'../chunk-FU7AHZNN.js';import'../chunk-B7K2OWKC.js';import'../chunk-3QP5BQ3L.js';
@@ -0,0 +1,3 @@
1
+ import {a as a$1}from'./chunk-2NS3JMNK.js';import'./chunk-P6JSTIFM.js';import {c as c$1}from'./chunk-UDPUTFQT.js';import {U,V,J,W,T as T$1,R as R$1,Q as Q$1}from'./chunk-Y2NS6HPO.js';export{W as formatArenaResultForSession}from'./chunk-Y2NS6HPO.js';import'./chunk-NVAZJ5XS.js';import'./chunk-FU7AHZNN.js';import'./chunk-B7K2OWKC.js';import {h,a}from'./chunk-3QP5BQ3L.js';import l from'chalk';h();async function Q(e,s,a){let{models:n,mode:i,base:m,head:r,topic:t}=E(e),o=a?.output??(d=>console.log(d));if(!t){o(R());return}let f=j(s,n);if(f.length<2){o(L());return}let P=i?i.charAt(0).toUpperCase()+i.slice(1):"Auto";o(l.bold(`\u2550\u2550\u2550 Arena ${P} \u2550\u2550\u2550`)),o(l.dim(`Topic: ${t}`)),o(l.dim(`Models: ${f.map(d=>d.name).join(" vs ")}`));let x=a?.output?U(a.output):V,O=new J({participants:f,mode:i,enableContextTools:true,onProgress:x});try{let d=await O.run(t,{mode:i,base:m,head:r}),y=a?.outputMessage??a?.output;return y?y(W(d)):T$1(d),d}catch(d){o(l.red(`Arena failed: ${d.message}`));return}}a(Q,"runArenaReview");function T(e){let s=new a$1;try{let a=new c$1(process.cwd()).get();if(a.models?.length)for(let n of a.models)s.register({key:n.key,label:n.label,provider:n.provider??"",model:n.model,baseUrl:n.baseUrl??e.llm.baseUrl,apiKey:n.apiKey??e.llm.apiKey,maxOutputTokens:n.maxOutputTokens});}catch{}return s}a(T,"buildModelPool");function K(e,s,a){if(typeof e=="string"){let n=s.get(e);return n?{name:n.label??c(n.model),llm:{provider:n.provider,model:n.model,apiKey:n.apiKey??a.llm.apiKey,baseUrl:n.baseUrl??a.llm.baseUrl,temperature:.3,maxTokens:n.maxOutputTokens??R$1(n.model),enableStreaming:false}}:void 0}return {name:e.name,llm:{provider:e.provider??a.llm.provider,model:e.model,apiKey:e.apiKey??a.llm.apiKey,baseUrl:e.baseUrl??a.llm.baseUrl,temperature:.3,maxTokens:R$1(e.model),enableStreaming:false}}}a(K,"resolveOneParticipant");function j(e,s){let a=T(e);if(s)return s.split(",").map(r=>r.trim().toLowerCase()).map(r=>{let t=a.get(r);if(t)return {name:t.label??c(t.model),llm:{provider:t.provider,model:t.model,apiKey:t.apiKey??e.llm.apiKey,baseUrl:t.baseUrl??e.llm.baseUrl,temperature:.3,maxTokens:t.maxOutputTokens??R$1(t.model),enableStreaming:false}};let o=Q$1[r];return o?{name:c(o.model),llm:{provider:o.provider,model:o.model,apiKey:e.llm.apiKey,baseUrl:e.llm.baseUrl,temperature:.3,maxTokens:o.maxOutputTokens,enableStreaming:false}}:{name:c(r),llm:{...e.llm,model:r,enableStreaming:false}}});let n=new c$1(process.cwd()).get();if(n.arena?.participants?.length>=2){let m=n.arena.participants.map(r=>K(r,a,e)).filter(r=>r!==void 0);if(m.length>=2)return m}let i=[{name:c(e.llm.model),llm:{...e.llm,maxTokens:R$1(e.llm.model),enableStreaming:false}}];if(e.llm.baseUrl?.includes("openrouter")){let r=e.llm.model.includes("claude")?"openai/gpt-5.4":"anthropic/claude-opus-4.6";i.push({name:c(r),llm:{...e.llm,model:r,maxTokens:R$1(r),enableStreaming:false}});}return i}a(j,"resolveParticipants");var S=["review","discussion","planning"];function E(e){let s,a,n,i,m=[],r=e.split(/\s+/);for(let t=0;t<r.length;t++)if(r[t]==="--models"&&r[t+1])s=r[++t];else if(r[t]==="--mode"&&r[t+1]){let o=r[++t].toLowerCase();S.includes(o)?a=o:console.log(l.yellow(` Unknown mode "${o}", valid: ${S.join(", ")}`));}else r[t]==="--base"&&r[t+1]?n=r[++t]:r[t]==="--head"&&r[t+1]?i=r[++t]:m.push(r[t]);return {models:s,mode:a,base:n,head:i,topic:m.join(" ").trim()}}a(E,"parseFlags");function R(){return [l.bold("Arena \u2014 Multi-model collaborative analysis"),"",l.dim("Usage:")," /arena review the authentication module"," /arena --models claude,gpt4o is the error handling correct?"," /arena --mode planning design the new auth system"," /arena --mode discussion should we use REST or GraphQL"," /arena --base main review changes since main",' code-shell arena "review my latest changes"',"",`${l.dim("Modes:")} review (default), discussion, planning`,l.dim("Mode is auto-detected from the topic if --mode is not specified."),"",l.dim("Flags:")," --base <ref> Base branch/ref for comparison"," --head <ref> Head branch/ref (default: HEAD)","",`${l.dim("Available model presets:")} ${Object.keys(Q$1).join(", ")}`].join(`
2
+ `)}a(R,"formatUsage");function L(e){return [l.red("Arena needs at least 2 models."),"","Use --models to specify:"," /arena --models claude,gpt4o review the code","","Or configure in ~/.code-shell/settings.json:",' "arena": { "participants": [',' { "name": "Claude", "model": "anthropic/claude-sonnet-4-20250514" },',' { "name": "GPT-4o", "model": "openai/gpt-4o" }'," ]}"].join(`
3
+ `)}a(L,"formatModelHelp");function c(e){return (e.split("/").pop()??e).replace(/-\d.*$/,"").split("-").map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}a(c,"modelDisplayName");export{Q as runArenaReview};
@@ -0,0 +1,2 @@
1
+ import {h,a}from'./chunk-3QP5BQ3L.js';h();function p(n){return {name:"bwrap",wrap(s,t){let e=[];e.push("--ro-bind","/","/"),e.push("--dev","/dev"),e.push("--proc","/proc"),e.push("--tmpfs","/tmp");for(let r of n.writableRoots)e.push("--bind-try",r,r);for(let r of n.deniedReads)e.push("--ro-bind-try","/dev/null",r);return e.push("--unshare-pid","--unshare-ipc","--unshare-uts","--unshare-cgroup"),n.network==="deny"&&e.push("--unshare-net"),e.push("--die-with-parent"),e.push("--chdir",t.cwd),e.push(t.shell,"-c",s),{file:"bwrap",args:e}},hintForBlockedOutput(s){if(/Permission denied|No such file or directory.*bwrap/i.test(s))return `
2
+ [sandbox:bwrap] A path access was blocked by the sandbox. If this path should be writable, ask the user to update sandbox.writableRoots in settings.json.`}}}a(p,"createBwrapBackend");export{p as createBwrapBackend};
@@ -0,0 +1 @@
1
+ import {a as a$1}from'./chunk-P6JSTIFM.js';import {h,a}from'./chunk-3QP5BQ3L.js';h();var u=[[/^deepseek-v4(?:-|$)/i,1e6],[/(?:^|\/)deepseek-v4(?:-|$)/i,1e6]];function f(s){for(let[e,t]of u)if(e.test(s))return t}a(f,"lookupBuiltinContextWindow");var l=class{static{a(this,"ModelPool");}models=new Map;activeKey;providerCatalog;cacheDir;setProviderCatalog(e){this.providerCatalog=e;}setCacheDir(e){this.cacheDir=e;}reloadCachedContextWindows(){if(this.cacheDir)for(let[e,t]of this.models){if(t.maxContextTokens!=null||!t.providerKey)continue;let i=a$1(this.cacheDir,t.providerKey);if(!i)continue;let r=i.models.find(n=>n.id===t.model);r?.contextLength&&this.models.set(e,{...t,maxContextTokens:r.contextLength});}}constructor(e,t){if(e)for(let i of e)this.models.set(i.key,this.withBuiltinDefaults(i));t&&this.models.has(t)?this.activeKey=t:e?.length&&(this.activeKey=e[0].key);}register(e){this.models.set(e.key,this.withBuiltinDefaults(e)),this.activeKey||(this.activeKey=e.key);}withBuiltinDefaults(e){if(e.maxContextTokens!=null)return e;let t=f(e.model);return t==null?e:{...e,maxContextTokens:t}}switch(e){let t=this.models.get(e);if(!t){let i=[...this.models.keys()].join(", ");throw new Error(`Model "${e}" not found. Available: ${i}`)}return this.activeKey=e,t}get(e){if(e)return this.models.get(e);if(this.activeKey)return this.models.get(this.activeKey)}getActiveKey(){return this.activeKey}list(){return [...this.models.values()]}get size(){return this.models.size}has(e){return this.models.has(e)}toLLMConfig(e,t){let i=e.providerKey&&this.providerCatalog?this.providerCatalog.get(e.providerKey):void 0,r=a(n=>n&&n==="anthropic"?"anthropic":"openai","kindToClientProvider");return {provider:e.provider||r(i?.kind)||"openai",model:e.model,apiKey:e.apiKey??i?.apiKey??t?.apiKey,baseUrl:e.baseUrl??i?.baseUrl??t?.baseUrl,temperature:t?.temperature??.3,maxTokens:e.maxOutputTokens??t?.maxTokens??8192,enableStreaming:t?.enableStreaming??true}}resolveLLMConfig(e,t){let i=this.get(e);if(i)return this.toLLMConfig(i,t)}};export{l as a};
@@ -0,0 +1 @@
1
+ import _ from'path';import {fileURLToPath}from'url';var r=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var i=(t,e)=>r(t,"name",{value:e,configurable:true}),x=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,o)=>(typeof require<"u"?require:e)[o]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var l=(t,e)=>()=>(t&&(e=t(t=0)),e);var u=(t,e)=>{for(var o in e)r(t,o,{get:e[o],enumerable:true});},s=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of c(e))!f.call(t,m)&&m!==o&&r(t,m,{get:()=>e[m],enumerable:!(n=p(e,m))||n.enumerable});return t};var D=t=>s(r({},"__esModule",{value:true}),t);var a,g,R,T,h=l(()=>{a=i(()=>fileURLToPath(import.meta.url),"getFilename"),g=i(()=>_.dirname(a()),"getDirname"),R=g(),T=a();});export{i as a,x as b,l as c,u as d,D as e,R as f,T as g,h};
@@ -0,0 +1,2 @@
1
+ import {h as h$1,a}from'./chunk-3QP5BQ3L.js';import {existsSync,mkdirSync,appendFileSync,readdirSync,unlinkSync}from'fs';import {join}from'path';import {homedir}from'os';h$1();var u={debug:0,info:1,warn:2,error:3},g=join(homedir(),".code-shell","logs"),h=7,R=100;function b(){return process.env.CODE_SHELL_DEV==="1"||process.argv.includes("--debug")||process.argv.includes("-d")||process.argv.some(r=>r.startsWith("--debug="))?true:process.env.NODE_ENV==="test"||process.env.BUN_TEST==="1"||process.argv.some(r=>r.includes("/tests/")||r.endsWith(".test.ts"))?false:!!(process.argv[1]??"").includes("/src/")}a(b,"isLocalDev");function x(){let o=process.env.CODE_SHELL_LOG_LEVEL?.toLowerCase().trim();return o&&Object.hasOwn(u,o)?o:b()?"debug":"info"}a(x,"resolveDefaultLevel");function D(){let o=process.argv.find(t=>t.startsWith("--debug=")),r;if(o)r=o.slice(8);else {let t=process.env.CODE_SHELL_DEBUG;t&&t!=="1"&&t!=="true"&&(r=t);}if(!r)return null;let e=new Set(r.split(",").map(t=>t.trim().toLowerCase()).filter(Boolean));return e.size>0?e:null}a(D,"resolveCategoryFilter");var v=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`;function _(o){v=o;}a(_,"setCurrentSid");function C(){return v}a(C,"getCurrentSid");var l=[];var d=class o{constructor(r={}){this.context=r;this.enabled=process.env.CODE_SHELL_LOG!=="0",this.minLevel=x(),this.categoryFilter=D(),this.stderrEcho=process.env.CODE_SHELL_DEBUG==="1"||process.argv.includes("--debug-to-stderr")||process.argv.includes("-d2e");}static{a(this,"Logger");}enabled;minLevel;categoryFilter;stderrEcho;dirReady=false;child(r){return new o({...this.context,...r})}setSid(r){_(r);}getSid(){return C()}debug(r,e){this.write("debug",r,e);}info(r,e){this.write("info",r,e);}warn(r,e){this.write("warn",r,e);}error(r,e){let t,n;typeof r=="string"?(t=r,e instanceof Error?(n={error:e.message,stack:e.stack}):n=e):r instanceof Error?(t=r.message,n={stack:r.stack}):t=String(r),this.recordError(t,n),this.write("error",t,n);}recordError(r,e){l.length>=R&&l.shift(),l.push({msg:r,t:new Date().toISOString(),data:e});}write(r,e,t){if(!this.enabled||u[r]<u[this.minLevel])return;let n=t?.cat??this.context.cat;if(r==="debug"&&this.categoryFilter&&(!n||!this.categoryFilter.has(n.toLowerCase())))return;let i=new Date().toISOString(),c={t:i,l:r,msg:e,...this.context};n&&!c.cat&&(c.cat=n),c.sid===void 0&&(c.sid=v),t&&(c.d=t);let a=JSON.stringify(c)+`
2
+ `;if(this.stderrEcho){process.stderr.write(a);return}try{this.dirReady||(existsSync(g)||mkdirSync(g,{recursive:!0}),this.dirReady=!0);let w=i.slice(0,10);appendFileSync(join(g,`${w}.log`),a,"utf-8");}catch{}}getMinLevel(){return this.minLevel}isCategoryActive(r){return !this.categoryFilter||this.categoryFilter.has(r.toLowerCase())}span(r,e){let t=Date.now();return this.write("debug",`${r}.begin`,e),{end:a(n=>{let i=Date.now()-t;this.write("info",`${r}.end`,{...e,...n,duration_ms:i});},"end"),fail:a((n,i)=>{let c=Date.now()-t,a=n instanceof Error?n.message:String(n);this.write("error",`${r}.fail`,{...e,...i,duration_ms:c,error:a});},"fail")}}},B=new d;function H(){try{if(!existsSync(g))return;let o=readdirSync(g).filter(r=>r.endsWith(".log")).sort();if(o.length<=h)return;for(let r of o.slice(0,o.length-h))try{unlinkSync(join(g,r));}catch{}}catch{}}a(H,"rotateLogs");export{C as a,B as b,H as c};
@@ -0,0 +1,2 @@
1
+ import {a as a$1,c as c$1,b}from'./chunk-P6JSTIFM.js';import {h,a}from'./chunk-3QP5BQ3L.js';import {existsSync,readFileSync}from'fs';import {fileURLToPath}from'url';import {dirname,join}from'path';h();h();var S=/(?:^|[-_/])(?:embed(?:ding)?|whisper|tts|audio|image|dall-?e|moderation|rerank|guard|vision-only)(?:$|[-_/])/i,i=a(e=>!S.test(e),"isChatLike"),s=a(e=>e?{Authorization:`Bearer ${e}`}:{},"bearer"),g={openai:{label:"OpenAI",defaultBaseUrl:"https://api.openai.com/v1",modelsPath:"/models",protocol:"openai-compat",authHeader:s,chatFilter:i},anthropic:{label:"Anthropic",defaultBaseUrl:"https://api.anthropic.com/v1",modelsPath:"/models",protocol:"anthropic-style",authHeader:a(e=>e?{"x-api-key":e,"anthropic-version":"2023-06-01"}:{"anthropic-version":"2023-06-01"},"authHeader"),chatFilter:i},deepseek:{label:"DeepSeek",defaultBaseUrl:"https://api.deepseek.com/v1",modelsPath:"/models",protocol:"openai-compat",authHeader:s,chatFilter:i},xai:{label:"xAI (Grok)",defaultBaseUrl:"https://api.x.ai/v1",modelsPath:"/models",protocol:"openai-compat",authHeader:s,chatFilter:i},mistral:{label:"Mistral",defaultBaseUrl:"https://api.mistral.ai/v1",modelsPath:"/models",protocol:"openai-compat",authHeader:s,chatFilter:i},groq:{label:"Groq",defaultBaseUrl:"https://api.groq.com/openai/v1",modelsPath:"/models",protocol:"openai-compat",authHeader:s,chatFilter:i},google:{label:"Google Gemini",defaultBaseUrl:"https://generativelanguage.googleapis.com/v1beta",modelsPath:"/models",protocol:"gemini",authHeader:a(()=>({}),"authHeader"),authQuery:a(e=>e?{key:e}:{},"authQuery"),chatFilter:a(e=>i(e)&&/gemini/i.test(e),"chatFilter")},openrouter:{label:"OpenRouter",defaultBaseUrl:"https://openrouter.ai/api/v1",modelsPath:"/models",protocol:"openai-compat",authHeader:s,chatFilter:i},ollama:{label:"Ollama (local)",defaultBaseUrl:"http://localhost:11434",modelsPath:"/api/tags",protocol:"ollama",authHeader:a(()=>({}),"authHeader"),chatFilter:i},custom:{label:"Custom",defaultBaseUrl:"",modelsPath:"/models",protocol:"openai-compat",authHeader:s,chatFilter:i}};function f(e){return g[e]??g.custom}a(f,"getKindMeta");var U=dirname(fileURLToPath(import.meta.url)),x=join(U,"..","data","openrouter-models.json");async function q(e,a){let n=f(e.kind);if(!a.refresh){let o=a$1(a.cacheDir,e.key);if(o&&!c$1(o))return {...o,fromCache:true}}if(e.kind==="openrouter")return L(e.key,a.cacheDir);try{let o=e.modelsPath??n.modelsPath,t=new URL(M(e.baseUrl,o)),P=n.authHeader(e.apiKey??"");if(n.authQuery){let m=n.authQuery(e.apiKey??"");for(let[R,b]of Object.entries(m))t.searchParams.set(R,b);}let p=await fetch(t.toString(),{headers:{Accept:"application/json",...P},signal:AbortSignal.timeout(a.timeoutMs??2e4)});if(!p.ok)return c(e.key,a.cacheDir,`HTTP ${p.status}`);let k=await p.json(),y=H(k,n.protocol).filter(m=>n.chatFilter(m.id));return b(a.cacheDir,e.key,y)}catch(o){let t=o.message||String(o);return c(e.key,a.cacheDir,t)}}a(q,"fetchModelList");function H(e,a){switch(a){case "ollama":return (e.models??[]).map(t=>({id:t.name,contextLength:0,maxOutputTokens:0}));case "anthropic-style":return (e.data??[]).map(t=>({id:t.id,contextLength:t.context_window??2e5,maxOutputTokens:t.max_output_tokens??0}));case "gemini":return (e.models??[]).map(t=>({id:t.name.replace(/^models\//,""),contextLength:t.inputTokenLimit??0,maxOutputTokens:t.outputTokenLimit??0}));case "openai-compat":return (e.data??[]).map(t=>({id:t.id,contextLength:t.context_window??t.context_length??0,maxOutputTokens:t.max_completion_tokens??0}))}return a}a(H,"normalize");function L(e,a){if(!existsSync(x))return c(e,a,"openrouter snapshot missing");try{let o=(JSON.parse(readFileSync(x,"utf-8")).models??[]).map(t=>({id:t.id,contextLength:t.contextLength??0,maxOutputTokens:t.maxOutputTokens??0}));return b(a,e,o)}catch(n){return c(e,a,n.message)}}a(L,"loadOpenRouterSnapshot");function c(e,a,n){let o=a$1(a,e);return o?{...o,error:n,fromCache:true}:{fetchedAt:new Date().toISOString(),providerKey:e,models:[],error:n}}a(c,"errorResult");function M(e,a){return e?`${e.replace(/\/$/,"")}${a.startsWith("/")?"":"/"}${a}`:a}a(M,"joinUrl");
2
+ export{g as a,q as b};
@@ -0,0 +1 @@
1
+ import {h as h$1,a as a$1}from'./chunk-3QP5BQ3L.js';h$1();var e=class extends Error{constructor(s,o){super(s);this.details=o;this.name="FrameworkError";}static{a$1(this,"FrameworkError");}},i=class extends e{constructor(s,o,u){super(s,u);this.provider=o;this.name="LLMError";}static{a$1(this,"LLMError");}},p=class extends i{constructor(s,o){super(`Rate limit exceeded for ${s}`,s,{retryAfter:o});this.retryAfter=o;this.name="LLMRateLimitError";}static{a$1(this,"LLMRateLimitError");}},x=class extends i{static{a$1(this,"ContextLimitError");}constructor(t){super("Context limit exceeded",t),this.name="ContextLimitError";}},c=class extends e{constructor(s,o,u){super(s,u);this.toolName=o;this.name="ToolError";}static{a$1(this,"ToolError");}},a=class extends c{static{a$1(this,"ToolNotFoundError");}constructor(t){super(`Tool not found: ${t}`,t),this.name="ToolNotFoundError";}},l=class extends c{static{a$1(this,"ToolExecutionError");}constructor(t,s){super(`Tool execution failed: ${t} - ${s}`,t,{cause:s}),this.name="ToolExecutionError";}},g=class extends c{constructor(s,o){super(`Tool timed out after ${o}ms: ${s}`,s,{timeoutMs:o});this.timeoutMs=o;this.name="ToolTimeoutError";}static{a$1(this,"ToolTimeoutError");}},m=class extends e{static{a$1(this,"PermissionDeniedError");}constructor(t,s){super(`Permission denied for tool: ${t}${s?` - ${s}`:""}`,{toolName:t,reason:s}),this.name="PermissionDeniedError";}},h=class extends e{static{a$1(this,"SessionError");}constructor(t,s){super(t,s),this.name="SessionError";}},$=class extends e{static{a$1(this,"TranscriptError");}constructor(t,s){super(t,s),this.name="TranscriptError";}},b=class extends e{static{a$1(this,"ConfigError");}constructor(t,s){super(t,s),this.name="ConfigError";}};export{e as a,i as b,p as c,x as d,c as e,a as f,l as g,g as h,m as i,h as j,$ as k,b as l};
@@ -0,0 +1 @@
1
+ import {d,c as c$1,b as b$1}from'./chunk-FU7AHZNN.js';import {b}from'./chunk-B7K2OWKC.js';import {h,a}from'./chunk-3QP5BQ3L.js';h();var c=class g{constructor(e){this.config=e;this.provider=e.provider,this.model=e.model,this.temperature=e.temperature??.3,this.maxTokens=e.maxTokens??8192,this.timeout=e.timeout??12e4,this.retryMaxAttempts=e.retryMaxAttempts??3,this.enableStreaming=e.enableStreaming??true,this.initClient();}static{a(this,"LLMClientBase");}provider;model;temperature;maxTokens;timeout;retryMaxAttempts;enableStreaming;static onUsage;usage={records:[],totalPromptTokens:0,totalCompletionTokens:0,totalTokens:0,requestCount:0};recordUsage(e,i){i?.recordUsage!==false&&(this.usage.records.push(e),this.usage.totalPromptTokens+=e.promptTokens,this.usage.totalCompletionTokens+=e.completionTokens,this.usage.totalTokens+=e.totalTokens,this.usage.requestCount++,g.onUsage?.(this.model,e));}getUsage(){return {...this.usage}}async withRetry(e,i){let o=i??this.retryMaxAttempts,n;for(let t=1;t<=o;t++)try{return await e()}catch(r){if(n=r,r instanceof d)throw r;if(r instanceof c$1){let s=(r.retryAfter??t*2)*1e3;b.warn("llm.retry",{cat:"llm",provider:this.provider,model:this.model,attempt:t,of:o,reason:"rate_limit",waitMs:s}),await new Promise(T=>setTimeout(T,s));continue}if(t===o){b.error("llm.exhausted",{cat:"llm",provider:this.provider,model:this.model,attempts:o,error:r.message});break}let m=Math.min(1e3*Math.pow(2,t-1),3e4);b.warn("llm.retry",{cat:"llm",provider:this.provider,model:this.model,attempt:t,of:o,reason:"error",error:r.message,backoffMs:m}),await new Promise(s=>setTimeout(s,m));}throw n??new b$1("Unknown LLM error")}};export{c as a};
@@ -0,0 +1 @@
1
+ import {L,ca,ba,V,ea}from'./chunk-NMBYBGC7.js';import {h,a}from'./chunk-3QP5BQ3L.js';import {join}from'path';import {homedir}from'os';h();h();function R(y,s){let{preset:e,adapter:t,contract:o}=y,w=e.name,x=["Read","Write","Edit","Glob","Grep","Bash","AskUserQuestion","Agent","ToolSearch","TaskCreate","TaskList","TaskUpdate","TaskGet"],i=new Set([...x,...t?.enableTools??[]]);for(let n of t?.disableTools??[])i.delete(n);let S=[{tool:"Read",decision:"allow"},{tool:"Glob",decision:"allow"},{tool:"Grep",decision:"allow"},{tool:"AskUserQuestion",decision:"allow"},{tool:"ToolSearch",decision:"allow"},{tool:"TaskCreate",decision:"allow"},{tool:"TaskList",decision:"allow"},{tool:"TaskUpdate",decision:"allow"},{tool:"TaskGet",decision:"allow"},...t?.permissionRules??[]],l={name:w,label:e.label,description:e.description,promptSections:e.sections??["base","orchestration"],injectGitStatus:e.injectGitStatus??false,builtinTools:[...i],defaultPermissionRules:S};L(l);let r;o?.evaluator?Array.isArray(o.evaluator)?r=new ca(o.evaluator):r=o.evaluator:r=new ba;let c=t?.tools??[],d=c.map(n=>({definition:n.definition,execute:n.execute})),u=s.runsDir??join(homedir(),".code-shell","runs"),k=new V(u);return {manager:new ea({store:k,executor:{llm:s.llm,maxTurns:o?.maxTurns??30,maxContextTokens:o?.maxContextTokens??2e5,permissionMode:s.permissionMode??"acceptEdits",sessionStorageDir:s.sessionStorageDir,mcpServers:t?.mcpServers,enabledBuiltinTools:[...i],disabledBuiltinTools:t?.disableTools,customSystemPrompt:e.customPrompt,appendSystemPrompt:e.appendPrompt,hooks:t?.hooks,customTools:d.length>0?d:void 0},concurrency:o?.concurrency??1,runsDir:u,evaluator:r,defaultTags:o?.defaultTags,defaultMetadata:o?.defaultMetadata}),preset:l,customTools:c}}a(R,"defineProduct");export{R as a};
@@ -0,0 +1,2 @@
1
+ import {a as a$2}from'./chunk-NVAZJ5XS.js';import {h,a as a$1}from'./chunk-3QP5BQ3L.js';h();var a="https://openrouter.ai/api/v1/models";function c(t){if(!t)return 0;let e=Number(t);return Number.isFinite(e)?e*1e6:0}a$1(c,"priceToPerMillion");function p(t){return {id:t.id,name:t.name??t.id,created:t.created??0,contextLength:t.top_provider?.context_length??t.context_length??0,maxOutputTokens:t.top_provider?.max_completion_tokens??0,inputPricePerMillion:c(t.pricing?.prompt),outputPricePerMillion:c(t.pricing?.completion),modalities:t.architecture?.input_modalities??[]}}a$1(p,"slim");async function f(t=15e3){try{let e=await fetch(a,{headers:{Accept:"application/json"},signal:AbortSignal.timeout(t)});if(!e.ok)return {ok:!1,count:0,error:`HTTP ${e.status} ${e.statusText}`};let r=((await e.json()).data??[]).map(p).sort((s,u)=>u.created-s.created);return a$2({fetchedAt:new Date().toISOString(),source:a,count:r.length,models:r}),{ok:!0,count:r.length}}catch(e){return {ok:false,count:0,error:e.message}}}a$1(f,"syncOpenRouterCatalog");
2
+ export{f as a};