@cjhyy/code-shell 0.1.6 → 0.2.0

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 (171) hide show
  1. package/dist/anthropic-OVRWAZRD.js +1 -0
  2. package/dist/arena/index.js +1 -104
  3. package/dist/arena-64T2EQD4.js +3 -0
  4. package/dist/bwrap-PVZMLHZR.js +2 -0
  5. package/dist/chunk-2EUIMKJA.js +1 -0
  6. package/dist/chunk-2GJ7H5NC.js +641 -0
  7. package/dist/chunk-2OD6VR4N.js +2 -0
  8. package/dist/chunk-3QP5BQ3L.js +1 -0
  9. package/dist/chunk-A4M2Y42L.js +2 -0
  10. package/dist/chunk-DEYFK6FP.js +1 -0
  11. package/dist/chunk-DTPABBSV.js +2 -0
  12. package/dist/chunk-EU3J7TBP.js +1 -0
  13. package/dist/chunk-FU7AHZNN.js +1 -0
  14. package/dist/chunk-L7B2ORID.js +4 -0
  15. package/dist/chunk-M7VU4YVY.js +49 -0
  16. package/dist/chunk-MGP35GKD.js +254 -0
  17. package/dist/chunk-MLCTC53I.js +1 -0
  18. package/dist/chunk-O5HFCH2U.js +1 -0
  19. package/dist/chunk-P6JSTIFM.js +1 -0
  20. package/dist/chunk-Q3RSX66I.js +1 -0
  21. package/dist/chunk-QTWU7UNA.js +5 -0
  22. package/dist/chunk-RERBX75D.js +251 -0
  23. package/dist/chunk-SNFAPSLA.js +1 -0
  24. package/dist/chunk-T222K6IV.js +18 -0
  25. package/dist/chunk-TKJA6W36.js +3 -0
  26. package/dist/chunk-VKKU4LOM.js +3 -0
  27. package/dist/chunk-WI6FSWGU.js +1 -0
  28. package/dist/chunk-XXCZE2U2.js +2 -0
  29. package/dist/chunk-ZSAONDT6.js +2 -0
  30. package/dist/cli/main.js +303 -22060
  31. package/dist/cli/onboarding.d.ts +7 -2
  32. package/dist/client-base-F5FCRSB3.js +1 -0
  33. package/dist/compaction-L3Y6NG4N.js +1 -0
  34. package/dist/context/compaction.d.ts +2 -1
  35. package/dist/data/static-catalogs.d.ts +25 -0
  36. package/dist/devtools-SGDUOOM4.js +1 -0
  37. package/dist/engine/engine.d.ts +24 -0
  38. package/dist/engine/turn-loop.d.ts +20 -0
  39. package/dist/export-md-U72T7NW7.js +22 -0
  40. package/dist/file-history-7FQFEQOL.js +1 -0
  41. package/dist/index.d.ts +1 -1
  42. package/dist/index.js +1 -347
  43. package/dist/llm/capabilities/index.d.ts +20 -0
  44. package/dist/llm/capabilities/rules.d.ts +26 -0
  45. package/dist/llm/capabilities/types.d.ts +108 -0
  46. package/dist/llm/model-pool.d.ts +7 -0
  47. package/dist/llm/provider-catalog.d.ts +2 -0
  48. package/dist/llm/provider-kinds.d.ts +1 -1
  49. package/dist/llm/providers/openai.d.ts +22 -0
  50. package/dist/llm/token-counter.d.ts +17 -0
  51. package/dist/llm/types.d.ts +8 -0
  52. package/dist/logging/logger.d.ts +10 -2
  53. package/dist/logging/session-recorder.d.ts +16 -3
  54. package/dist/manager-J6FXEUEK.js +1 -0
  55. package/dist/mcp-manager-27EVBKRT.js +1 -0
  56. package/dist/memory-BNI4WEWL.js +1 -0
  57. package/dist/model-cache-HEDXI7UJ.js +1 -0
  58. package/dist/model-fetcher-X5W5EASG.js +1 -0
  59. package/dist/off-7SDVMMXW.js +1 -0
  60. package/dist/openai-3QEADSYL.js +1 -0
  61. package/dist/openrouter-models-GZVCRWD2.js +1 -0
  62. package/dist/openrouter-sync-WG4AG5NC.js +1 -0
  63. package/dist/product/index.js +1 -21
  64. package/dist/protocol/client.d.ts +1 -1
  65. package/dist/run/index.js +1 -48
  66. package/dist/seatbelt-L54CNI2Y.js +37 -0
  67. package/dist/session/session-manager.d.ts +2 -0
  68. package/dist/session-manager-AGWS5SMJ.js +1 -0
  69. package/dist/settings/schema.d.ts +147 -21
  70. package/dist/tool-summary-V2B3MD5N.js +2 -0
  71. package/dist/tool-system/builtin/bash.d.ts +7 -1
  72. package/dist/tool-system/context.d.ts +7 -0
  73. package/dist/tool-system/executor.d.ts +4 -0
  74. package/dist/tool-system/sandbox/bwrap.d.ts +13 -0
  75. package/dist/tool-system/sandbox/index.d.ts +78 -0
  76. package/dist/tool-system/sandbox/off.d.ts +2 -0
  77. package/dist/tool-system/sandbox/seatbelt.d.ts +18 -0
  78. package/dist/tool-system/task-guard.d.ts +30 -0
  79. package/dist/types.d.ts +17 -0
  80. package/dist/ui/components/SessionPicker.d.ts +2 -0
  81. package/dist/ui/components/SpinnerWithVerb.d.ts +7 -2
  82. package/dist/ui/components/StatusLine.d.ts +7 -3
  83. package/dist/updater-OCNU2K2Z.js +1 -0
  84. package/package.json +7 -10
  85. package/dist/anthropic-IBTI4WL2.cjs +0 -10
  86. package/dist/anthropic-PRZZKHEZ.js +0 -10
  87. package/dist/arena/index.cjs +0 -104
  88. package/dist/arena-2LTLIXOL.js +0 -261
  89. package/dist/arena-ADB7DRFI.cjs +0 -261
  90. package/dist/chunk-2YW4FPFG.cjs +0 -101
  91. package/dist/chunk-3OA5G4TM.js +0 -47
  92. package/dist/chunk-3QO25N6E.js +0 -4711
  93. package/dist/chunk-3SBSUOWZ.js +0 -447
  94. package/dist/chunk-52LGZKT3.cjs +0 -47
  95. package/dist/chunk-55XGPMAP.cjs +0 -146
  96. package/dist/chunk-6QVAYW7C.cjs +0 -438
  97. package/dist/chunk-6S4BJ65N.js +0 -113
  98. package/dist/chunk-76HYEPDM.js +0 -307
  99. package/dist/chunk-7BI3V74Y.cjs +0 -447
  100. package/dist/chunk-7EG3V4JY.cjs +0 -113
  101. package/dist/chunk-7JVTYEEC.js +0 -340
  102. package/dist/chunk-7QIM3BKD.js +0 -44
  103. package/dist/chunk-7Y6S3OCX.js +0 -438
  104. package/dist/chunk-ABRRONJ7.js +0 -107
  105. package/dist/chunk-BSW22MPA.js +0 -146
  106. package/dist/chunk-BXCY2FSE.js +0 -203
  107. package/dist/chunk-BZ5TNE7L.js +0 -5128
  108. package/dist/chunk-DDB6QOKJ.cjs +0 -1252
  109. package/dist/chunk-HEKQCI7B.cjs +0 -224
  110. package/dist/chunk-IK4EWJBP.cjs +0 -203
  111. package/dist/chunk-ILHE7XLT.cjs +0 -107
  112. package/dist/chunk-JMR33QVF.cjs +0 -169
  113. package/dist/chunk-KAQHULYN.js +0 -54
  114. package/dist/chunk-KE4EQOWA.js +0 -294
  115. package/dist/chunk-KOVYSDHZ.cjs +0 -340
  116. package/dist/chunk-KS3RYAYL.cjs +0 -45
  117. package/dist/chunk-MD32R22I.js +0 -50
  118. package/dist/chunk-MV7YI4WO.cjs +0 -293
  119. package/dist/chunk-MY5XHADU.cjs +0 -216
  120. package/dist/chunk-NUNC3VFB.cjs +0 -307
  121. package/dist/chunk-PKGRTCCY.js +0 -9092
  122. package/dist/chunk-QARL3IDQ.js +0 -1252
  123. package/dist/chunk-S754JHLR.cjs +0 -54
  124. package/dist/chunk-SFXHZSRF.js +0 -101
  125. package/dist/chunk-SIHHIQLO.js +0 -224
  126. package/dist/chunk-T6VYG46N.js +0 -105
  127. package/dist/chunk-TNLGBJYS.cjs +0 -44
  128. package/dist/chunk-TUY2T5KP.cjs +0 -105
  129. package/dist/chunk-UXOCVJJ6.cjs +0 -9092
  130. package/dist/chunk-VIAGTYYW.js +0 -169
  131. package/dist/chunk-WASS5YWB.js +0 -215
  132. package/dist/chunk-WZJV6DJC.cjs +0 -5128
  133. package/dist/chunk-YIQBXAYU.cjs +0 -264
  134. package/dist/chunk-YKIAELDZ.cjs +0 -4711
  135. package/dist/chunk-ZBPSQCPU.js +0 -264
  136. package/dist/cli/main.cjs +0 -22156
  137. package/dist/client-base-HTF236ZD.cjs +0 -9
  138. package/dist/client-base-QKRKCOWB.js +0 -9
  139. package/dist/compaction-6VU2T643.js +0 -33
  140. package/dist/compaction-OKUNTCA7.cjs +0 -33
  141. package/dist/devtools-T2NIZBJK.cjs +0 -6
  142. package/dist/devtools-YXWHOVKR.js +0 -6
  143. package/dist/export-md-RXDW6F5W.cjs +0 -135
  144. package/dist/export-md-XXKZANW5.js +0 -135
  145. package/dist/file-history-KYPE3ECT.cjs +0 -7
  146. package/dist/file-history-LF4F7X26.js +0 -7
  147. package/dist/index.cjs +0 -347
  148. package/dist/manager-D65VFAPX.js +0 -7
  149. package/dist/manager-TTF5VHJC.cjs +0 -7
  150. package/dist/mcp-manager-QMKWPBZ4.js +0 -8
  151. package/dist/mcp-manager-Z3OKI74O.cjs +0 -8
  152. package/dist/memory-5LWZ6FI2.cjs +0 -9
  153. package/dist/memory-VIJLBAMQ.js +0 -9
  154. package/dist/model-cache-5KIYL5SL.js +0 -13
  155. package/dist/model-cache-OED3IM4R.cjs +0 -13
  156. package/dist/model-fetcher-HKGICACL.js +0 -8
  157. package/dist/model-fetcher-UR6WJOQP.cjs +0 -8
  158. package/dist/openai-JR2WEKOF.js +0 -10
  159. package/dist/openai-YBTOET4O.cjs +0 -10
  160. package/dist/openrouter-models-H56GHBHN.js +0 -15
  161. package/dist/openrouter-models-TWUFWZ5T.cjs +0 -15
  162. package/dist/openrouter-sync-5VMGN6C2.cjs +0 -11
  163. package/dist/openrouter-sync-ALEMF5IU.js +0 -11
  164. package/dist/product/index.cjs +0 -21
  165. package/dist/run/index.cjs +0 -48
  166. package/dist/session-manager-Q22BBMD3.js +0 -8
  167. package/dist/session-manager-XODQVL3C.cjs +0 -8
  168. package/dist/tool-summary-63DPIS7G.cjs +0 -31
  169. package/dist/tool-summary-NP5CDBKG.js +0 -31
  170. package/dist/updater-I7QBW4DP.cjs +0 -17
  171. package/dist/updater-NVME5S3Z.js +0 -17
@@ -23,9 +23,14 @@ export interface ProviderDef {
23
23
  envKey: string;
24
24
  provider: string;
25
25
  baseUrl: string;
26
- defaultModel: string;
27
26
  keyUrl: string;
28
27
  keyPrefix: string;
28
+ /**
29
+ * The catalog of model IDs to register for this provider. The first
30
+ * entry doubles as the zero-config default — auto-activated when the
31
+ * user boots with just an env key (no onboarding). Users override by
32
+ * picking in the wizard or running `/model`.
33
+ */
29
34
  models: string[];
30
35
  /** When true, skip API key prompt (e.g. local providers like Ollama). */
31
36
  noKey?: boolean;
@@ -77,7 +82,7 @@ export declare function findSavedKeyForProvider(provider: ProviderDef): {
77
82
  * Return the list of model IDs previously saved under this provider
78
83
  * (matched by baseUrl). Used by the onboarding wizard to pre-populate the
79
84
  * "model pool" step with the user's prior choices instead of resetting to
80
- * just provider.defaultModel.
85
+ * just the provider's first model.
81
86
  */
82
87
  export declare function loadSavedModelsForProvider(provider: ProviderDef): string[];
83
88
  export declare function hasApiKey(): boolean;
@@ -0,0 +1 @@
1
+ export{a as LLMClientBase}from'./chunk-2EUIMKJA.js';import'./chunk-FU7AHZNN.js';import'./chunk-ZSAONDT6.js';import'./chunk-3QP5BQ3L.js';
@@ -0,0 +1 @@
1
+ import {p}from'./chunk-M7VU4YVY.js';export{e as COMPACTABLE_TOOL_NAMES,b as adjustIndexToPreserveAPIInvariants,k as applySummaryCompaction,g as applyToolResultBudget,i as buildSummarizationPrompt,m as dropOldestRounds,a as estimateTokens,j as extractAnchoredSummary,n as extractReferencedFilePaths,l as groupMessagesByApiRound,f as microcompact,c as snipCompact,h as truncateToolResult,d as windowCompact}from'./chunk-M7VU4YVY.js';import'./chunk-3QP5BQ3L.js';p();
@@ -89,7 +89,8 @@ export declare function truncateToolResult(result: string, maxChars?: number): s
89
89
  * Build a structured summarization prompt from messages to be compacted.
90
90
  * Produces a 9-section summary preserving key details.
91
91
  */
92
- export declare function buildSummarizationPrompt(messagesToSummarize: Message[]): string;
92
+ export declare function buildSummarizationPrompt(messagesToSummarize: Message[], priorSummary?: string): string;
93
+ export declare function extractAnchoredSummary(messages: Message[]): string | undefined;
93
94
  /**
94
95
  * Apply LLM-generated summary compaction (hybrid mode).
95
96
  *
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Hand-maintained static model catalogs for providers whose /v1/models
3
+ * endpoint returns only ids — no context window, max output, or pricing.
4
+ *
5
+ * At runtime we still call the live /models endpoint to discover ids
6
+ * (so newly-released models work without a code update), then left-join
7
+ * this table on `id` to fill in metadata. Edit the JSONs in src/data/
8
+ * when a vendor ships a new model.
9
+ *
10
+ * OpenRouter is NOT here — its catalog is generated at build time by
11
+ * scripts/sync-models.ts because OpenRouter exposes full metadata.
12
+ */
13
+ import type { ProviderKindName } from "../llm/provider-kinds.js";
14
+ export interface StaticModel {
15
+ id: string;
16
+ name: string;
17
+ contextLength: number;
18
+ maxOutputTokens: number;
19
+ inputPricePerMillion: number;
20
+ outputPricePerMillion: number;
21
+ modalities: string[];
22
+ thinking?: boolean;
23
+ }
24
+ export declare function listStaticModels(kind: ProviderKindName): StaticModel[];
25
+ export declare function hasStaticCatalog(kind: ProviderKindName): boolean;
@@ -0,0 +1 @@
1
+ import {h}from'./chunk-3QP5BQ3L.js';h();
@@ -10,6 +10,7 @@ import type { HookHandler } from "../hooks/registry.js";
10
10
  import { SessionManager } from "../session/session-manager.js";
11
11
  import type { CostStateStore } from "./cost-store.js";
12
12
  import type { AskUserFn } from "../tool-system/builtin/ask-user.js";
13
+ import { type SandboxConfig } from "../tool-system/sandbox/index.js";
13
14
  import { type AgentPresetName } from "../preset/index.js";
14
15
  import { ModelPool, type ModelEntry } from "../llm/model-pool.js";
15
16
  export interface EngineConfig {
@@ -43,6 +44,13 @@ export interface EngineConfig {
43
44
  * Defaults to false.
44
45
  */
45
46
  headless?: boolean;
47
+ /**
48
+ * Sandbox configuration for shell-tool execution. When omitted, headless
49
+ * runs default to "auto" (Seatbelt on macOS / bwrap on Linux when
50
+ * available) and interactive runs default to "off" because a human is in
51
+ * the loop to approve commands.
52
+ */
53
+ sandbox?: SandboxConfig;
46
54
  }
47
55
  export interface EngineHookConfig {
48
56
  event: HookEventName;
@@ -70,6 +78,22 @@ export declare class Engine {
70
78
  private lastMessages;
71
79
  private lastSessionId;
72
80
  private compactedMessagesBySession;
81
+ /**
82
+ * SIDs whose ctx-bar seed we've already emitted in this process. The seed
83
+ * is a rough char/4 estimate; only useful before the first real
84
+ * usage_update arrives (cold start or cross-process resume). On subsequent
85
+ * turns the UI already shows the previous turn's accurate ctx — re-seeding
86
+ * would visibly drop the bar on every submit.
87
+ */
88
+ private ctxSeedSent;
89
+ /**
90
+ * Per-sid cache of "non-messages overhead" (system prompt + tool defs, in
91
+ * tokens). Survives across turns so each fresh TurnLoop instance can seed
92
+ * its first pre-llm emit with the right offset — without this the ctx bar
93
+ * visibly drops on every user submit (e.g. from ~20k → 3k) until the next
94
+ * LLM response arrives.
95
+ */
96
+ private ctxOverheadBySid;
73
97
  private activePermission;
74
98
  /** Public accessor so UI/clients can read the resolved per-model window. */
75
99
  get maxContextTokens(): number;
@@ -23,6 +23,11 @@ export interface TurnLoopConfig {
23
23
  */
24
24
  onTurnBoundary?: (turnCount: number) => void;
25
25
  }
26
+ export interface CtxOverheadStore {
27
+ /** Tokens for system prompt + tool defs, derived from provider's promptTokens. */
28
+ get(sid: string): number;
29
+ set(sid: string, tokens: number): void;
30
+ }
26
31
  export interface TurnLoopDeps {
27
32
  model: ModelFacade;
28
33
  toolExecutor: ToolExecutor;
@@ -31,6 +36,10 @@ export interface TurnLoopDeps {
31
36
  transcript: Transcript;
32
37
  systemPrompt: string;
33
38
  tools: import("../types.js").ToolDefinition[];
39
+ /** Per-sid overhead cache so the ctx bar doesn't drop between turns. */
40
+ ctxOverheadStore: CtxOverheadStore;
41
+ /** Current session id, used to key the overhead store. */
42
+ sessionId: string;
34
43
  }
35
44
  export interface TurnLoopResult {
36
45
  text: string;
@@ -50,7 +59,18 @@ export declare class TurnLoop {
50
59
  * every line they write is tagged with the current turn/turnId.
51
60
  */
52
61
  private currentTurnLog;
62
+ /** Last emitted ctx token estimate; used to skip no-op usage_update events. */
63
+ private lastCtxEmit;
53
64
  constructor(deps: TurnLoopDeps, config: TurnLoopConfig);
65
+ /**
66
+ * Emit a usage_update so the UI ctx bar reflects current message-array
67
+ * size. Called at every point where messages mutate: after a tool_result
68
+ * is appended, after context management (which may shrink), and after an
69
+ * LLM response (which we also feed through with the provider's authoritative
70
+ * promptTokens to override our estimate).
71
+ */
72
+ private emitCtxFromMessages;
73
+ private emitCtxFromUsage;
54
74
  /**
55
75
  * Run the multi-turn agent loop until completion.
56
76
  */
@@ -0,0 +1,22 @@
1
+ import {h as h$1,a}from'./chunk-3QP5BQ3L.js';import {join,basename}from'path';h$1();var h=2e3,_=800,w=/^[A-Za-z0-9_-]+$/;function R(n,r,e){if(!w.test(n))throw new Error(`renderSessionMarkdown: invalid sessionId ${JSON.stringify(n)} \u2014 expected [A-Za-z0-9_-]+`);let t=[],s=[],u=`session-${n}-attachments`;t.push(`# Session ${n}`),t.push("");let i=0;for(let d of r){let o=d;if(o.type!=="message")continue;i+=1;let $=o.data?.role??"unknown",a=o.data?.content;if(t.push(`## turn ${i} \xB7 ${$}`),t.push(""),typeof a=="string"){t.push(a),t.push("");continue}if(!Array.isArray(a)){t.push("```json"),t.push(JSON.stringify(a,null,2)),t.push("```"),t.push("");continue}let l=0;for(let m of a){l+=1;let g=I(m,{turnNumber:i,itemIdx:l,sidecarDir:u,cwd:e,sidecars:s});g&&(t.push(g),t.push(""));}}return {md:t.join(`
2
+ `),sidecars:s}}a(R,"renderSessionMarkdown");function I(n,r){let e=n.type;if(e==="reasoning"){let t=n.reasoningContent??"";return y("reasoning",t)}if(e==="text")return n.text??"";if(e==="tool_use"){let t=n.name??"?",s=JSON.stringify(n.input??{},null,2)??"{}",u=`**\u{1F6E0} tool_use** \xB7 \`${t}\``;return s.length<=_?`${u}
3
+
4
+ \`\`\`json
5
+ ${s}
6
+ \`\`\``:y(`${t} args (${s.length} bytes)`,s,"json")}if(e==="tool_result"){let t=n.tool_use_id??n.id??"?",s=N(n.content);if(s.length<=h)return `**\u25C0 tool_result** \xB7 ${t}
7
+
8
+ \`\`\`
9
+ ${s}
10
+ \`\`\``;let u=`t${r.turnNumber}-i${r.itemIdx}-${t.slice(0,12)}.txt`,i=join(r.cwd,r.sidecarDir,u);r.sidecars.push({path:i,content:s});let d=s.slice(0,h),o=join(r.sidecarDir,basename(i));return `**\u25C0 tool_result** \xB7 ${t} \xB7 ${s.length.toLocaleString()} bytes \xB7 [full \u2192 ${o}](./${o})
11
+
12
+ \`\`\`
13
+ ${d}
14
+ \u2026(truncated, see sidecar)
15
+ \`\`\``}return "```json\n"+JSON.stringify(n,null,2)+"\n```"}a(I,"renderBlock");function y(n,r,e=""){let t=e?"```"+e:"```";return `<details><summary>${n}</summary>
16
+
17
+ ${t}
18
+ ${r}
19
+ \`\`\`
20
+
21
+ </details>`}a(y,"collapsible");function N(n){if(n==null)return "";if(typeof n=="string")return n;if(Array.isArray(n)){let r=[];for(let e of n)e&&typeof e=="object"&&"text"in e&&typeof e.text=="string"?r.push(e.text):r.push(JSON.stringify(e));return r.join(`
22
+ `)}return JSON.stringify(n,null,2)}a(N,"stringifyResult");export{R as renderSessionMarkdown};
@@ -0,0 +1 @@
1
+ export{a as FileHistory}from'./chunk-WI6FSWGU.js';import'./chunk-3QP5BQ3L.js';
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Public API exports.
5
5
  */
6
- export declare const VERSION = "0.1.0";
6
+ export declare const VERSION = "0.2.0";
7
7
  export type { Message, ContentBlock, ToolDefinition, ToolCall, ToolResult, RegisteredTool, TranscriptEvent, TranscriptEventType, SessionState, TokenUsage, CompiledInput, PermissionDecision, PermissionMode, PermissionRule, TurnPhase, TurnResult, TerminalReason, StreamEvent, StreamCallback, LLMConfig, LLMResponse, Settings, MCPServerConfig, } from "./types.js";
8
8
  export { FrameworkError, LLMError, LLMRateLimitError, ContextLimitError, ToolError, ToolNotFoundError, ToolExecutionError, ToolTimeoutError, PermissionDeniedError, SessionError, TranscriptError, ConfigError, } from "./exceptions.js";
9
9
  export { Engine } from "./engine/engine.js";
package/dist/index.js CHANGED
@@ -1,347 +1 @@
1
- import {
2
- defineProduct
3
- } from "./chunk-ABRRONJ7.js";
4
- import {
5
- createRunManager
6
- } from "./chunk-7QIM3BKD.js";
7
- import {
8
- ArtifactTracker,
9
- AutoApprovalBackend,
10
- BUILTIN_AGENT_PRESETS,
11
- BUILTIN_TOOLS,
12
- CheckpointWriter,
13
- CompositeEvaluator,
14
- ContextManager,
15
- DEFAULT_AGENT_PRESET,
16
- DEFAULT_CLI_PRESET,
17
- DEFAULT_PERSIST_THRESHOLD,
18
- Engine,
19
- EngineRunner,
20
- FileRunStore,
21
- HeadlessApprovalBackend,
22
- Heartbeat,
23
- HookRegistry,
24
- NoopEvaluator,
25
- PER_MESSAGE_AGGREGATE_CAP,
26
- PREVIEW_SIZE,
27
- PermissionClassifier,
28
- PromptComposer,
29
- RunApprovalBackend,
30
- RunLock,
31
- RunManager,
32
- RunQueue,
33
- SectionCache,
34
- ToolExecutor,
35
- ToolRegistry,
36
- VALID_TRANSITIONS,
37
- applyToolResultPersistence,
38
- availableSections,
39
- buildPresetSystemPrompt,
40
- buildSkillListing,
41
- combineInstructions,
42
- createContentReplacementState,
43
- createRunAskUserFn,
44
- isPersistedReplacement,
45
- listPresetNames,
46
- loadSection,
47
- loadSections,
48
- matchSkillsByInput,
49
- matchSkillsByTool,
50
- reconstructContentReplacementState,
51
- registerPreset,
52
- registerSection,
53
- resolveAgentPreset,
54
- resolveBuiltinToolNames,
55
- resolveToolResultsDir,
56
- scanInstructions,
57
- scanSkills,
58
- taskManager
59
- } from "./chunk-PKGRTCCY.js";
60
- import {
61
- ModelPool
62
- } from "./chunk-BSW22MPA.js";
63
- import "./chunk-3OA5G4TM.js";
64
- import {
65
- MCPManager
66
- } from "./chunk-SIHHIQLO.js";
67
- import {
68
- COMPACTABLE_TOOL_NAMES,
69
- applySummaryCompaction,
70
- buildSummarizationPrompt,
71
- estimateTokens,
72
- init_compaction,
73
- microcompact,
74
- truncateToolResult,
75
- windowCompact
76
- } from "./chunk-7Y6S3OCX.js";
77
- import {
78
- MemoryManager
79
- } from "./chunk-VIAGTYYW.js";
80
- import {
81
- SessionManager,
82
- Transcript
83
- } from "./chunk-76HYEPDM.js";
84
- import {
85
- SettingsManager,
86
- SettingsSchema,
87
- validateSettings
88
- } from "./chunk-3SBSUOWZ.js";
89
- import {
90
- FileHistory
91
- } from "./chunk-T6VYG46N.js";
92
- import {
93
- IterativeArena,
94
- codeFormat,
95
- defaultConvergence,
96
- diffRatio,
97
- documentFormat,
98
- getFormat
99
- } from "./chunk-QARL3IDQ.js";
100
- import {
101
- Arena,
102
- ArenaLedger,
103
- DiscussionStrategy,
104
- MODEL_PRESETS,
105
- PlanningStrategy,
106
- ReviewStrategy,
107
- applyReviewResult,
108
- buildDigest,
109
- collectEvidence,
110
- createLLMClient,
111
- formatDigest,
112
- getMaxOutputTokens,
113
- getStrategy,
114
- getStrategyForPlan,
115
- hasTools,
116
- isTerminal,
117
- markUnderReview,
118
- markUnresolved,
119
- planArena,
120
- registerClaims,
121
- registerProvider,
122
- resolveClaimStatus,
123
- selectClaimsForReview,
124
- selectTools,
125
- transitionClaim,
126
- validTransitions
127
- } from "./chunk-BZ5TNE7L.js";
128
- import "./chunk-3QO25N6E.js";
129
- import {
130
- AnthropicClient
131
- } from "./chunk-ZBPSQCPU.js";
132
- import {
133
- OpenAIClient
134
- } from "./chunk-7JVTYEEC.js";
135
- import {
136
- LLMClientBase
137
- } from "./chunk-6S4BJ65N.js";
138
- import {
139
- ConfigError,
140
- ContextLimitError,
141
- FrameworkError,
142
- LLMError,
143
- LLMRateLimitError,
144
- PermissionDeniedError,
145
- SessionError,
146
- ToolError,
147
- ToolExecutionError,
148
- ToolNotFoundError,
149
- ToolTimeoutError,
150
- TranscriptError
151
- } from "./chunk-SFXHZSRF.js";
152
- import {
153
- logger
154
- } from "./chunk-BXCY2FSE.js";
155
- import {
156
- init_esm_shims
157
- } from "./chunk-MD32R22I.js";
158
-
159
- // src/index.ts
160
- init_esm_shims();
161
- init_compaction();
162
-
163
- // src/arena/detect-mode.ts
164
- init_esm_shims();
165
- var MODE_SIGNALS = {
166
- review: [
167
- { patterns: [/\breview\b/i, /\baudit\b/i, /\binspect\b/i, /\bcheck\b/i], weight: 2 },
168
- { patterns: [/\bcode\s*quality\b/i, /\bbug\b/i, /\bvulnerab/i, /\bsecur/i] },
169
- { patterns: [/\bpr\b/i, /\bpull\s*request\b/i, /\bdiff\b/i, /\bchanges?\b/i] },
170
- { patterns: [/\brefactor/i, /\bclean\s*up\b/i, /\bimprove\b/i] }
171
- ],
172
- discussion: [
173
- { patterns: [/\bdiscuss\b/i, /\bdebate\b/i, /\bcompare\b/i], weight: 2 },
174
- { patterns: [/\bpros?\s*(and|&|\/)\s*cons?\b/i, /\btrade\s*-?\s*offs?\b/i] },
175
- { patterns: [/\bshould\s+we\b/i, /\bwhich\s+(is|approach|way)\b/i, /\bvs\.?\b/i] },
176
- { patterns: [/\bopinion\b/i, /\bthoughts?\b/i, /\badvice\b/i] }
177
- ],
178
- planning: [
179
- { patterns: [/\bplan\b/i, /\bplanning\b/i, /\broadmap\b/i, /\bstrategy\b/i], weight: 2 },
180
- { patterns: [/\barchitect/i, /\bdesign\b/i, /\bproposal\b/i] },
181
- { patterns: [/\bimplement(ation)?\s+(plan|strategy|approach)\b/i], weight: 2 },
182
- { patterns: [/\bphase\b/i, /\bmilestone\b/i, /\btimeline\b/i, /\bprioritiz/i] },
183
- { patterns: [/\bbuild\b/i, /\bcreate\b/i, /\bsetup\b/i, /\bbootstrap\b/i] }
184
- ]
185
- };
186
- var HIGH_CONFIDENCE_THRESHOLD = 3;
187
- var MIN_LEAD = 2;
188
- function detectArenaMode(topic) {
189
- const scores = { review: 0, discussion: 0, planning: 0 };
190
- for (const [mode, signals] of Object.entries(MODE_SIGNALS)) {
191
- for (const signal of signals) {
192
- const weight = signal.weight ?? 1;
193
- for (const pattern of signal.patterns) {
194
- if (pattern.test(topic)) {
195
- scores[mode] += weight;
196
- }
197
- }
198
- }
199
- }
200
- const ranked = Object.entries(scores).sort((a, b) => b[1] - a[1]);
201
- const [bestMode, bestScore] = ranked[0];
202
- const [, runnerUpScore] = ranked[1];
203
- const lead = bestScore - runnerUpScore;
204
- if (bestScore >= HIGH_CONFIDENCE_THRESHOLD && lead >= MIN_LEAD) {
205
- return {
206
- mode: bestMode,
207
- confidence: "high",
208
- reason: `Topic strongly matches "${bestMode}" (score: ${bestScore}, lead: +${lead})`
209
- };
210
- }
211
- if (bestScore > 0 && lead > 0) {
212
- return {
213
- mode: bestMode,
214
- confidence: "low",
215
- reason: `Topic weakly matches "${bestMode}" (score: ${bestScore}, lead: +${lead})`
216
- };
217
- }
218
- return {
219
- mode: "review",
220
- confidence: "low",
221
- reason: "No strong mode signal detected, defaulting to review"
222
- };
223
- }
224
-
225
- // src/index.ts
226
- var VERSION = "0.1.0";
227
- export {
228
- AnthropicClient,
229
- Arena,
230
- ArenaLedger,
231
- ArtifactTracker,
232
- AutoApprovalBackend,
233
- BUILTIN_AGENT_PRESETS,
234
- BUILTIN_TOOLS,
235
- COMPACTABLE_TOOL_NAMES,
236
- CheckpointWriter,
237
- CompositeEvaluator,
238
- ConfigError,
239
- ContextLimitError,
240
- ContextManager,
241
- DEFAULT_AGENT_PRESET,
242
- DEFAULT_CLI_PRESET,
243
- DEFAULT_PERSIST_THRESHOLD,
244
- DiscussionStrategy,
245
- Engine,
246
- EngineRunner,
247
- FileHistory,
248
- FileRunStore,
249
- FrameworkError,
250
- HeadlessApprovalBackend,
251
- Heartbeat,
252
- HookRegistry,
253
- IterativeArena,
254
- LLMClientBase,
255
- LLMError,
256
- LLMRateLimitError,
257
- MCPManager,
258
- MODEL_PRESETS,
259
- MemoryManager,
260
- ModelPool,
261
- NoopEvaluator,
262
- OpenAIClient,
263
- PER_MESSAGE_AGGREGATE_CAP,
264
- PREVIEW_SIZE,
265
- PermissionClassifier,
266
- PermissionDeniedError,
267
- PlanningStrategy,
268
- PromptComposer,
269
- ReviewStrategy,
270
- RunApprovalBackend,
271
- RunLock,
272
- RunManager,
273
- RunQueue,
274
- SectionCache,
275
- SessionError,
276
- SessionManager,
277
- SettingsManager,
278
- SettingsSchema,
279
- ToolError,
280
- ToolExecutionError,
281
- ToolExecutor,
282
- ToolNotFoundError,
283
- ToolRegistry,
284
- ToolTimeoutError,
285
- Transcript,
286
- TranscriptError,
287
- VALID_TRANSITIONS,
288
- VERSION,
289
- applyReviewResult,
290
- applySummaryCompaction,
291
- applyToolResultPersistence,
292
- availableSections,
293
- buildDigest,
294
- buildPresetSystemPrompt,
295
- buildSkillListing,
296
- buildSummarizationPrompt,
297
- collectEvidence,
298
- combineInstructions,
299
- createContentReplacementState,
300
- createLLMClient,
301
- createRunAskUserFn,
302
- createRunManager,
303
- defaultConvergence as defaultIterateConvergence,
304
- defineProduct,
305
- detectArenaMode,
306
- estimateTokens,
307
- formatDigest,
308
- getFormat as getIterateFormat,
309
- getMaxOutputTokens,
310
- getStrategy,
311
- getStrategyForPlan,
312
- hasTools,
313
- isPersistedReplacement,
314
- isTerminal,
315
- codeFormat as iterateCodeFormat,
316
- diffRatio as iterateDiffRatio,
317
- documentFormat as iterateDocumentFormat,
318
- listPresetNames,
319
- loadSection,
320
- loadSections,
321
- logger,
322
- markUnderReview,
323
- markUnresolved,
324
- matchSkillsByInput,
325
- matchSkillsByTool,
326
- microcompact,
327
- planArena,
328
- reconstructContentReplacementState,
329
- registerClaims,
330
- registerPreset,
331
- registerProvider,
332
- registerSection,
333
- resolveAgentPreset,
334
- resolveBuiltinToolNames,
335
- resolveClaimStatus,
336
- resolveToolResultsDir,
337
- scanInstructions,
338
- scanSkills,
339
- selectClaimsForReview,
340
- selectTools,
341
- taskManager,
342
- transitionClaim,
343
- truncateToolResult,
344
- validTransitions,
345
- validateSettings,
346
- windowCompact
347
- };
1
+ export{a as defineProduct}from'./chunk-Q3RSX66I.js';export{a as createRunManager}from'./chunk-EU3J7TBP.js';export{$ as ArtifactTracker,j as AutoApprovalBackend,J as BUILTIN_AGENT_PRESETS,e as BUILTIN_TOOLS,_ as CheckpointWriter,da as CompositeEvaluator,x as ContextManager,K as DEFAULT_AGENT_PRESET,L as DEFAULT_CLI_PRESET,p as DEFAULT_PERSIST_THRESHOLD,U as Engine,ea as EngineRunner,W as FileRunStore,i as HeadlessApprovalBackend,ba as Heartbeat,o as HookRegistry,ca as NoopEvaluator,q as PER_MESSAGE_AGGREGATE_CAP,r as PREVIEW_SIZE,n as PermissionClassifier,R as PromptComposer,Y as RunApprovalBackend,aa as RunLock,fa as RunManager,X as RunQueue,y as SectionCache,h as ToolExecutor,f as ToolRegistry,V as VALID_TRANSITIONS,v as applyToolResultPersistence,I as availableSections,P as buildPresetSystemPrompt,E as buildSkillListing,A as combineInstructions,s as createContentReplacementState,Z as createRunAskUserFn,w as isPersistedReplacement,N as listPresetNames,G as loadSection,H as loadSections,C as matchSkillsByInput,D as matchSkillsByTool,t as reconstructContentReplacementState,M as registerPreset,F as registerSection,O as resolveAgentPreset,Q as resolveBuiltinToolNames,u as resolveToolResultsDir,z as scanInstructions,B as scanSkills,c as taskManager}from'./chunk-MGP35GKD.js';export{a as ModelPool}from'./chunk-MLCTC53I.js';export{a as FileHistory}from'./chunk-WI6FSWGU.js';import'./chunk-P6JSTIFM.js';import'./chunk-SNFAPSLA.js';export{a as MCPManager}from'./chunk-L7B2ORID.js';import {p}from'./chunk-M7VU4YVY.js';export{e as COMPACTABLE_TOOL_NAMES,k as applySummaryCompaction,i as buildSummarizationPrompt,a as estimateTokens,f as microcompact,h as truncateToolResult,d as windowCompact}from'./chunk-M7VU4YVY.js';export{b as MemoryManager}from'./chunk-T222K6IV.js';export{b as SessionManager,a as Transcript}from'./chunk-QTWU7UNA.js';export{c as SettingsManager,a as SettingsSchema,b as validateSettings}from'./chunk-DTPABBSV.js';export{j as IterativeArena,f as defaultIterateConvergence,i as getIterateFormat,g as iterateCodeFormat,e as iterateDiffRatio,h as iterateDocumentFormat}from'./chunk-RERBX75D.js';export{J as Arena,I as ArenaLedger,e as DiscussionStrategy,Q as MODEL_PRESETS,f as PlanningStrategy,d as ReviewStrategy,z as applyReviewResult,u as buildDigest,n as collectEvidence,b as createLLMClient,v as formatDigest,R as getMaxOutputTokens,k as getStrategy,l as getStrategyForPlan,p as hasTools,B as isTerminal,y as markUnderReview,A as markUnresolved,m as planArena,s as registerClaims,a as registerProvider,x as resolveClaimStatus,t as selectClaimsForReview,o as selectTools,w as transitionClaim,C as validTransitions}from'./chunk-2GJ7H5NC.js';import'./chunk-A4M2Y42L.js';export{a as AnthropicClient}from'./chunk-DEYFK6FP.js';export{a as OpenAIClient}from'./chunk-VKKU4LOM.js';import'./chunk-O5HFCH2U.js';export{a as LLMClientBase}from'./chunk-2EUIMKJA.js';export{l as ConfigError,d as ContextLimitError,a as FrameworkError,b as LLMError,c as LLMRateLimitError,i as PermissionDeniedError,j as SessionError,e as ToolError,g as ToolExecutionError,f as ToolNotFoundError,h as ToolTimeoutError,k as TranscriptError}from'./chunk-FU7AHZNN.js';export{b as logger}from'./chunk-ZSAONDT6.js';import {h,a}from'./chunk-3QP5BQ3L.js';h();p();h();var vt={review:[{patterns:[/\breview\b/i,/\baudit\b/i,/\binspect\b/i,/\bcheck\b/i],weight:2},{patterns:[/\bcode\s*quality\b/i,/\bbug\b/i,/\bvulnerab/i,/\bsecur/i]},{patterns:[/\bpr\b/i,/\bpull\s*request\b/i,/\bdiff\b/i,/\bchanges?\b/i]},{patterns:[/\brefactor/i,/\bclean\s*up\b/i,/\bimprove\b/i]}],discussion:[{patterns:[/\bdiscuss\b/i,/\bdebate\b/i,/\bcompare\b/i],weight:2},{patterns:[/\bpros?\s*(and|&|\/)\s*cons?\b/i,/\btrade\s*-?\s*offs?\b/i]},{patterns:[/\bshould\s+we\b/i,/\bwhich\s+(is|approach|way)\b/i,/\bvs\.?\b/i]},{patterns:[/\bopinion\b/i,/\bthoughts?\b/i,/\badvice\b/i]}],planning:[{patterns:[/\bplan\b/i,/\bplanning\b/i,/\broadmap\b/i,/\bstrategy\b/i],weight:2},{patterns:[/\barchitect/i,/\bdesign\b/i,/\bproposal\b/i]},{patterns:[/\bimplement(ation)?\s+(plan|strategy|approach)\b/i],weight:2},{patterns:[/\bphase\b/i,/\bmilestone\b/i,/\btimeline\b/i,/\bprioritiz/i]},{patterns:[/\bbuild\b/i,/\bcreate\b/i,/\bsetup\b/i,/\bbootstrap\b/i]}]},kt=3,Mt=2;function Pt(m){let a={review:0,discussion:0,planning:0};for(let[n,i]of Object.entries(vt))for(let p of i){let u=p.weight??1;for(let d of p.patterns)d.test(m)&&(a[n]+=u);}let s=Object.entries(a).sort((n,i)=>i[1]-n[1]),[t,e]=s[0],[,l]=s[1],r=e-l;return e>=kt&&r>=Mt?{mode:t,confidence:"high",reason:`Topic strongly matches "${t}" (score: ${e}, lead: +${r})`}:e>0&&r>0?{mode:t,confidence:"low",reason:`Topic weakly matches "${t}" (score: ${e}, lead: +${r})`}:{mode:"review",confidence:"low",reason:"No strong mode signal detected, defaulting to review"}}a(Pt,"detectArenaMode");var wt="0.2.0";export{wt as VERSION,Pt as detectArenaMode};
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Capability layer — single entry point.
3
+ *
4
+ * `capabilitiesFor(kind, model)` walks the rules in `rules.ts`, returns
5
+ * a `Capability` describing what params the (provider, model) pair will
6
+ * accept. Clients spread the result into their request-build code.
7
+ *
8
+ * Pure function. No I/O, no caching beyond the rules array.
9
+ */
10
+ import type { ProviderKindName } from "../provider-kinds.js";
11
+ import { type Capability } from "./types.js";
12
+ export { DEFAULT_CAPABILITY } from "./types.js";
13
+ export type { Capability, ReasoningShape, ReasoningEffort, ThinkingSwitch, EchoReasoning, ParallelToolCallsShape, StreamUsageShape, } from "./types.js";
14
+ /**
15
+ * Resolve the capability for a given (provider kind, model id).
16
+ *
17
+ * First matching rule for the kind wins — rules.ts is ordered so that
18
+ * more specific patterns come before catch-alls.
19
+ */
20
+ export declare function capabilitiesFor(kind: ProviderKindName, model: string): Capability;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Per-(provider kind, model family) capability overrides.
3
+ *
4
+ * Each rule patches the conservative DEFAULT_CAPABILITY. First match per
5
+ * kind wins — order matters for overlapping families.
6
+ *
7
+ * Authority for every entry is the vendor's own docs; the `why` field
8
+ * cites the specific page. When a model 400s on something not captured
9
+ * here, add a rule, don't patch the client.
10
+ *
11
+ * Sources audited 2026-05-15:
12
+ * OpenAI: https://platform.openai.com/docs/guides/reasoning
13
+ * https://learn.microsoft.com/en-us/azure/foundry/openai/how-to/reasoning
14
+ * Anthropic: https://platform.claude.com/docs/en/build-with-claude/extended-thinking
15
+ * DeepSeek: https://api-docs.deepseek.com/guides/reasoning_model
16
+ * https://api-docs.deepseek.com/guides/thinking_mode
17
+ * Z.AI: https://docs.z.ai/guides/llm/glm-4.6
18
+ * Gemini: https://ai.google.dev/gemini-api/docs/openai
19
+ * https://ai.google.dev/gemini-api/docs/thinking
20
+ * OpenRouter: https://openrouter.ai/docs/guides/best-practices/reasoning-tokens
21
+ * xAI: https://docs.x.ai/docs/guides/reasoning
22
+ * Mistral: https://docs.mistral.ai/api/
23
+ * Groq: https://console.groq.com/docs/reasoning
24
+ */
25
+ import type { CapabilityRule } from "./types.js";
26
+ export declare const RULES: ReadonlyArray<CapabilityRule>;