@cjhyy/code-shell 0.1.7 → 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.
- package/dist/anthropic-OVRWAZRD.js +1 -0
- package/dist/arena/index.js +1 -1
- package/dist/{arena-OW55ZCHT.js → arena-64T2EQD4.js} +1 -1
- package/dist/{chunk-HIJ2XXGX.js → chunk-2EUIMKJA.js} +1 -1
- package/dist/{chunk-Y2NS6HPO.js → chunk-2GJ7H5NC.js} +17 -17
- package/dist/chunk-2OD6VR4N.js +2 -0
- package/dist/chunk-A4M2Y42L.js +2 -0
- package/dist/{chunk-WOP6MJKW.js → chunk-DEYFK6FP.js} +1 -1
- package/dist/chunk-DTPABBSV.js +2 -0
- package/dist/{chunk-RP26WO4R.js → chunk-EU3J7TBP.js} +1 -1
- package/dist/{chunk-XDOWC7EG.js → chunk-L7B2ORID.js} +1 -1
- package/dist/chunk-M7VU4YVY.js +49 -0
- package/dist/{chunk-NMBYBGC7.js → chunk-MGP35GKD.js} +87 -83
- package/dist/chunk-MLCTC53I.js +1 -0
- package/dist/{chunk-KCXSARAA.js → chunk-Q3RSX66I.js} +1 -1
- package/dist/{chunk-Q4O2HGWS.js → chunk-RERBX75D.js} +1 -1
- package/dist/chunk-VKKU4LOM.js +3 -0
- package/dist/{chunk-NFH3UQ3E.js → chunk-XXCZE2U2.js} +1 -1
- package/dist/chunk-ZSAONDT6.js +2 -0
- package/dist/cli/main.js +104 -104
- package/dist/cli/onboarding.d.ts +7 -2
- package/dist/client-base-F5FCRSB3.js +1 -0
- package/dist/compaction-L3Y6NG4N.js +1 -0
- package/dist/context/compaction.d.ts +2 -1
- package/dist/data/static-catalogs.d.ts +25 -0
- package/dist/engine/engine.d.ts +16 -0
- package/dist/engine/turn-loop.d.ts +20 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/llm/capabilities/index.d.ts +20 -0
- package/dist/llm/capabilities/rules.d.ts +26 -0
- package/dist/llm/capabilities/types.d.ts +108 -0
- package/dist/llm/model-pool.d.ts +7 -0
- package/dist/llm/provider-catalog.d.ts +2 -0
- package/dist/llm/provider-kinds.d.ts +1 -1
- package/dist/llm/providers/openai.d.ts +22 -0
- package/dist/llm/types.d.ts +8 -0
- package/dist/logging/logger.d.ts +10 -2
- package/dist/logging/session-recorder.d.ts +16 -3
- package/dist/manager-J6FXEUEK.js +1 -0
- package/dist/mcp-manager-27EVBKRT.js +1 -0
- package/dist/model-fetcher-X5W5EASG.js +1 -0
- package/dist/openai-3QEADSYL.js +1 -0
- package/dist/{openrouter-models-AM6M52D6.js → openrouter-models-GZVCRWD2.js} +1 -1
- package/dist/openrouter-sync-WG4AG5NC.js +1 -0
- package/dist/product/index.js +1 -1
- package/dist/protocol/client.d.ts +1 -1
- package/dist/run/index.js +1 -1
- package/dist/{seatbelt-WBYROQT6.js → seatbelt-L54CNI2Y.js} +5 -5
- package/dist/settings/schema.d.ts +75 -15
- package/dist/{tool-summary-5UE62VU4.js → tool-summary-V2B3MD5N.js} +1 -1
- package/dist/tool-system/executor.d.ts +4 -0
- package/dist/tool-system/sandbox/index.d.ts +7 -0
- package/dist/tool-system/task-guard.d.ts +30 -0
- package/dist/types.d.ts +13 -0
- package/dist/ui/components/SpinnerWithVerb.d.ts +5 -0
- package/dist/ui/components/StatusLine.d.ts +5 -1
- package/package.json +1 -1
- package/dist/anthropic-UBSB5AQH.js +0 -1
- package/dist/chunk-2NS3JMNK.js +0 -1
- package/dist/chunk-B7K2OWKC.js +0 -2
- package/dist/chunk-EWWK56K6.js +0 -2
- package/dist/chunk-NVAZJ5XS.js +0 -2
- package/dist/chunk-PGANL6F2.js +0 -3
- package/dist/chunk-UDPUTFQT.js +0 -2
- package/dist/chunk-W47Z7MGS.js +0 -33
- package/dist/client-base-6ZZJJYDY.js +0 -1
- package/dist/compaction-ECVQVOCT.js +0 -1
- package/dist/manager-C3TDN6MS.js +0 -1
- package/dist/mcp-manager-OP4XYV53.js +0 -1
- package/dist/model-fetcher-BJ64META.js +0 -1
- package/dist/openai-KEWQ54TM.js +0 -1
- package/dist/openrouter-sync-5JNBL3Z6.js +0 -1
package/dist/cli/onboarding.d.ts
CHANGED
|
@@ -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.
|
|
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;
|
package/dist/engine/engine.d.ts
CHANGED
|
@@ -78,6 +78,22 @@ export declare class Engine {
|
|
|
78
78
|
private lastMessages;
|
|
79
79
|
private lastSessionId;
|
|
80
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;
|
|
81
97
|
private activePermission;
|
|
82
98
|
/** Public accessor so UI/clients can read the resolved per-model window. */
|
|
83
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
|
*/
|
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.
|
|
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 +1 @@
|
|
|
1
|
-
export{a as defineProduct}from'./chunk-
|
|
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>;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-(provider, model) capability descriptor.
|
|
3
|
+
*
|
|
4
|
+
* Captures the subset of request-shape divergence we've actually observed
|
|
5
|
+
* cause HTTP 400s or behavior changes. Each rule in `rules.ts` produces
|
|
6
|
+
* one of these; clients spread it into the outgoing request.
|
|
7
|
+
*
|
|
8
|
+
* Sources for every field are documented next to the matching rule in
|
|
9
|
+
* `rules.ts` — vendor docs, not folklore.
|
|
10
|
+
*/
|
|
11
|
+
import type { ProviderKindName } from "../provider-kinds.js";
|
|
12
|
+
/** OpenAI-style reasoning effort levels — shared by several vendors. */
|
|
13
|
+
export type ReasoningEffort = "minimal" | "low" | "medium" | "high";
|
|
14
|
+
/** A binary thinking switch, like DeepSeek V4 and Z.AI GLM use. */
|
|
15
|
+
export type ThinkingSwitch = "enabled" | "disabled";
|
|
16
|
+
/**
|
|
17
|
+
* How the vendor exposes a "think harder / think less" knob (or none).
|
|
18
|
+
* Each kind has different field names and value shapes — we keep them
|
|
19
|
+
* separate so the engine can't accidentally cross-pollinate.
|
|
20
|
+
*/
|
|
21
|
+
export type ReasoningShape = {
|
|
22
|
+
kind: "none";
|
|
23
|
+
}
|
|
24
|
+
/** DeepSeek V4, Z.AI GLM-4.5+ — `{thinking: {type: "enabled"|"disabled"}}` at top level. */
|
|
25
|
+
| {
|
|
26
|
+
kind: "deepseek-thinking";
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* OpenAI o-series & gpt-5+ — `reasoning_effort: "minimal"|"low"|"medium"|"high"`.
|
|
30
|
+
* `disabledEffort` is the value we send when the caller asks for thinking
|
|
31
|
+
* "disabled" — defaults to `"minimal"` (OpenAI), but vendors with a
|
|
32
|
+
* narrower vocabulary override it (e.g. xAI Grok 4.3 has no `"minimal"`;
|
|
33
|
+
* Mistral Magistral only accepts `"high"` and `"none"`).
|
|
34
|
+
*/
|
|
35
|
+
| {
|
|
36
|
+
kind: "openai-effort";
|
|
37
|
+
disabledEffort?: ReasoningEffort | "none";
|
|
38
|
+
}
|
|
39
|
+
/** Anthropic Claude 4.x ≤ 4.5 — `{thinking: {type: "enabled", budget_tokens: N}}`. */
|
|
40
|
+
| {
|
|
41
|
+
kind: "anthropic-budget";
|
|
42
|
+
minBudgetTokens: number;
|
|
43
|
+
}
|
|
44
|
+
/** Anthropic Claude 4.6+ — no opt-in, thinking is adaptive. Sending `type: "enabled"` 400s. */
|
|
45
|
+
| {
|
|
46
|
+
kind: "anthropic-adaptive";
|
|
47
|
+
}
|
|
48
|
+
/** OpenRouter normalized — `{reasoning: {effort, max_tokens, exclude, enabled}}`. */
|
|
49
|
+
| {
|
|
50
|
+
kind: "openrouter-reasoning";
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* How prior `reasoning_content` (or `thinking` blocks) must be threaded
|
|
54
|
+
* back into the next request.
|
|
55
|
+
*/
|
|
56
|
+
export type EchoReasoning =
|
|
57
|
+
/** DeepSeek `deepseek-reasoner`: 400 if you echo it back at all. */
|
|
58
|
+
"never"
|
|
59
|
+
/** DeepSeek V4 + tools, Claude 4.x + tools: must echo or 400. */
|
|
60
|
+
| "when-tools"
|
|
61
|
+
/** Optional — echo if you have it, but absence is fine. */
|
|
62
|
+
| "optional";
|
|
63
|
+
/**
|
|
64
|
+
* Parallel-tool-call shape. OpenAI exposes `parallel_tool_calls: bool`.
|
|
65
|
+
* Anthropic exposes it inside `tool_choice.disable_parallel_tool_use`.
|
|
66
|
+
* Some endpoints don't support it at all.
|
|
67
|
+
*/
|
|
68
|
+
export type ParallelToolCallsShape = "openai-flag" | "anthropic-disable-flag" | "unsupported";
|
|
69
|
+
/**
|
|
70
|
+
* Streaming usage signal. OpenAI-compat needs `stream_options:
|
|
71
|
+
* {include_usage: true}`; Anthropic always emits usage in
|
|
72
|
+
* `message_delta`; some endpoints reject the field.
|
|
73
|
+
*/
|
|
74
|
+
export type StreamUsageShape = "include-usage-flag" | "auto" | "none";
|
|
75
|
+
export interface Capability {
|
|
76
|
+
/** Token-limit request field. */
|
|
77
|
+
tokenLimitField: "max_tokens" | "max_completion_tokens";
|
|
78
|
+
/**
|
|
79
|
+
* Request fields the model 400s on (or silently drops). We just don't
|
|
80
|
+
* send them. Names are in OpenAI-compat spelling; clients translate
|
|
81
|
+
* for native protocols.
|
|
82
|
+
*/
|
|
83
|
+
rejectedParams: ReadonlySet<"temperature" | "top_p" | "presence_penalty" | "frequency_penalty" | "logit_bias" | "logprobs" | "top_logprobs">;
|
|
84
|
+
/** How thinking is exposed (or not). */
|
|
85
|
+
reasoning: ReasoningShape;
|
|
86
|
+
/** Echo-back contract for prior reasoning. */
|
|
87
|
+
echoReasoning: EchoReasoning;
|
|
88
|
+
/** Parallel-tool-calls flag shape. */
|
|
89
|
+
parallelToolCalls: ParallelToolCallsShape;
|
|
90
|
+
/** Streaming usage reporting shape. */
|
|
91
|
+
streamUsage: StreamUsageShape;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Conservative default — used when no rule matches. Picks "send everything
|
|
95
|
+
* the vanilla OpenAI Chat Completions spec accepts," because that's what
|
|
96
|
+
* every OpenAI-compat endpoint at minimum understands.
|
|
97
|
+
*/
|
|
98
|
+
export declare const DEFAULT_CAPABILITY: Capability;
|
|
99
|
+
export interface CapabilityRule {
|
|
100
|
+
/** Which provider kind this rule applies to. */
|
|
101
|
+
kind: ProviderKindName;
|
|
102
|
+
/** Model-id matcher. First matching rule wins (per kind). */
|
|
103
|
+
match: RegExp;
|
|
104
|
+
/** Patch applied on top of DEFAULT_CAPABILITY. */
|
|
105
|
+
capability: Partial<Capability>;
|
|
106
|
+
/** Free-text reason — shown in logs, helps future-you. */
|
|
107
|
+
why: string;
|
|
108
|
+
}
|
package/dist/llm/model-pool.d.ts
CHANGED
|
@@ -29,6 +29,13 @@ export interface ModelEntry {
|
|
|
29
29
|
/** Optional reference into ProviderCatalog. When set, baseUrl/apiKey
|
|
30
30
|
* come from the catalog unless the entry overrides them. */
|
|
31
31
|
providerKey?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Per-model thinking override. Wins over the provider-level setting
|
|
34
|
+
* (ProviderCatalog entry's `thinking`). Useful when models in the same
|
|
35
|
+
* provider need different defaults — e.g. DeepSeek V4 Pro off but
|
|
36
|
+
* V4 Flash on.
|
|
37
|
+
*/
|
|
38
|
+
thinking?: "enabled" | "disabled";
|
|
32
39
|
}
|
|
33
40
|
export declare class ModelPool {
|
|
34
41
|
private models;
|
|
@@ -13,6 +13,8 @@ export interface ProviderConfig {
|
|
|
13
13
|
apiKey?: string;
|
|
14
14
|
protocol?: "openai-compat" | "anthropic-style";
|
|
15
15
|
modelsPath?: string;
|
|
16
|
+
/** Default DeepSeek V4 thinking-mode for this provider. See LLMConfig. */
|
|
17
|
+
thinking?: "enabled" | "disabled";
|
|
16
18
|
}
|
|
17
19
|
export declare class ProviderCatalog {
|
|
18
20
|
private byKey;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* (chat-completion only — embeddings / TTS / image generation are
|
|
7
7
|
* filtered out so they don't show up in the model picker).
|
|
8
8
|
*/
|
|
9
|
-
export type ProviderKindName = "openai" | "anthropic" | "deepseek" | "xai" | "mistral" | "groq" | "google" | "openrouter" | "ollama" | "custom";
|
|
9
|
+
export type ProviderKindName = "openai" | "anthropic" | "deepseek" | "zai" | "xai" | "mistral" | "groq" | "google" | "openrouter" | "ollama" | "custom";
|
|
10
10
|
export type ProviderProtocol = "openai-compat" | "anthropic-style" | "gemini" | "ollama";
|
|
11
11
|
export interface ProviderKindMeta {
|
|
12
12
|
label: string;
|
|
@@ -1,15 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* OpenAI GPT provider using openai SDK.
|
|
3
|
+
*
|
|
4
|
+
* Serves every OpenAI-compatible endpoint we support (OpenAI, DeepSeek,
|
|
5
|
+
* OpenRouter, Z.AI, xAI, Mistral, Groq, Gemini-OpenAI-compat, Ollama,
|
|
6
|
+
* custom). Per-(provider, model) request-shape divergence — token-limit
|
|
7
|
+
* field name, rejected sampling params, thinking knob, reasoning echo —
|
|
8
|
+
* is resolved through `capabilitiesFor()`, not hardcoded.
|
|
3
9
|
*/
|
|
4
10
|
import type { LLMConfig, LLMResponse } from "../../types.js";
|
|
5
11
|
import type { CreateMessageOptions } from "../types.js";
|
|
6
12
|
import { LLMClientBase } from "../client-base.js";
|
|
7
13
|
export declare class OpenAIClient extends LLMClientBase {
|
|
8
14
|
private _client;
|
|
15
|
+
private _forceMaxCompletionTokens;
|
|
9
16
|
constructor(config: LLMConfig);
|
|
10
17
|
protected initClient(): void;
|
|
11
18
|
private get client();
|
|
19
|
+
/**
|
|
20
|
+
* Resolve the capability descriptor for the current (provider kind, model)
|
|
21
|
+
* pair. Cached for the lifetime of the client — model never changes
|
|
22
|
+
* mid-client. `providerKind` defaults to "openai" because legacy LLMConfig
|
|
23
|
+
* paths (arena, env-derived) don't always populate it; for those, the
|
|
24
|
+
* built-in rules table treats them as plain OpenAI.
|
|
25
|
+
*/
|
|
26
|
+
private _capability;
|
|
27
|
+
private get capability();
|
|
12
28
|
createMessage(options: CreateMessageOptions): Promise<LLMResponse>;
|
|
29
|
+
/**
|
|
30
|
+
* Build the request body honoring the model's capability descriptor.
|
|
31
|
+
* Centralized so both streaming and non-streaming paths agree on the
|
|
32
|
+
* exact shape.
|
|
33
|
+
*/
|
|
34
|
+
private buildRequestBody;
|
|
13
35
|
private nonStreamMessage;
|
|
14
36
|
private streamMessage;
|
|
15
37
|
private processChoice;
|
package/dist/llm/types.d.ts
CHANGED
|
@@ -19,6 +19,14 @@ export interface CreateMessageOptions {
|
|
|
19
19
|
* @default true
|
|
20
20
|
*/
|
|
21
21
|
recordUsage?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* DeepSeek V4 thinking-mode switch. "enabled" is the endpoint default;
|
|
24
|
+
* "disabled" turns reasoning off (faster, cheaper, no `reasoning_content`
|
|
25
|
+
* on the reply). Ignored by every provider except DeepSeek V4 — the OpenAI
|
|
26
|
+
* SDK forwards unknown top-level fields verbatim, so it's harmless on
|
|
27
|
+
* other compatible endpoints.
|
|
28
|
+
*/
|
|
29
|
+
thinking?: "enabled" | "disabled";
|
|
22
30
|
}
|
|
23
31
|
export interface LLMUsageTracker {
|
|
24
32
|
records: TokenUsage[];
|
package/dist/logging/logger.d.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Unified file logger for code-shell.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Sinks (JSON Lines), routed by `cat`:
|
|
5
|
+
* ~/.code-shell/logs/ui-ink-YYYY-MM-DD.log
|
|
6
|
+
* — UI/ink chatter: stream events, ctx render, ink screen diffs.
|
|
7
|
+
* ~/.code-shell/logs/engine-YYYY-MM-DD.log
|
|
8
|
+
* — everything else: engine, llm, tool, context, mcp, sandbox, ...
|
|
9
|
+
*
|
|
10
|
+
* Routing is by entry `cat`: cat ∈ {ui, ink, render, stream} → ui-ink bucket;
|
|
11
|
+
* anything else → engine bucket. Run scripts/logs.sh to query both at once
|
|
12
|
+
* (merge sorted by timestamp, filter by sid, etc).
|
|
5
13
|
*
|
|
6
14
|
* Level defaults:
|
|
7
15
|
* - Local dev (CODE_SHELL_DEV=1, or running from src/, or --debug) → "debug"
|
|
@@ -9,7 +17,7 @@
|
|
|
9
17
|
* - CODE_SHELL_LOG_LEVEL overrides everything.
|
|
10
18
|
*
|
|
11
19
|
* Category filter (--debug=mcp,api or CODE_SHELL_DEBUG=mcp,api):
|
|
12
|
-
* When set, only logs whose `cat` matches are written.
|
|
20
|
+
* When set, only debug logs whose `cat` matches are written.
|
|
13
21
|
*
|
|
14
22
|
* Disable entirely: CODE_SHELL_LOG=0
|
|
15
23
|
*/
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Per-session verbose recorder for local-dev runs.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Layout (per day, split by bucket):
|
|
5
|
+
* <repo>/log/<YYYY-MM-DD>/engine/session-<sid>.jsonl
|
|
6
|
+
* — unified timeline: LLM, tools, session events, AND UI events
|
|
7
|
+
* (UI events are dual-written so this file is the full story.)
|
|
8
|
+
* <repo>/log/<YYYY-MM-DD>/ui/session-<sid>.jsonl
|
|
9
|
+
* — UI-only events (stream events received, ctx renders, chatStore
|
|
10
|
+
* mutations). Open when chasing a display bug.
|
|
11
|
+
*
|
|
12
|
+
* Same sid → same filename in both folders. Diff/merge by sid to align
|
|
13
|
+
* "what the model said" with "what the UI did about it."
|
|
7
14
|
*
|
|
8
15
|
* Why a separate sink from logger.ts?
|
|
9
16
|
* - logger.ts is the terse process-wide log (~/.code-shell/logs/) and stays
|
|
@@ -69,6 +76,12 @@ export declare function recordToolResult(sid: string, result: {
|
|
|
69
76
|
error?: string;
|
|
70
77
|
}): void;
|
|
71
78
|
export declare function recordEvent(sid: string, name: string, data?: Record<string, unknown>): void;
|
|
79
|
+
/**
|
|
80
|
+
* Record a UI-side event. Goes into both engine.jsonl (unified timeline) and
|
|
81
|
+
* ui.jsonl (focused view). Use from the UI when chasing display bugs — pass
|
|
82
|
+
* the current sessionId.
|
|
83
|
+
*/
|
|
84
|
+
export declare function recordUIEvent(sid: string | undefined, name: string, data?: Record<string, unknown>): void;
|
|
72
85
|
export declare function recordSessionEnd(sid: string, info: {
|
|
73
86
|
reason?: string;
|
|
74
87
|
turns?: number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{c as SettingsManager}from'./chunk-DTPABBSV.js';import'./chunk-3QP5BQ3L.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{a as MCPManager}from'./chunk-L7B2ORID.js';import'./chunk-ZSAONDT6.js';import'./chunk-3QP5BQ3L.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{b as fetchModelList}from'./chunk-2OD6VR4N.js';import'./chunk-P6JSTIFM.js';import'./chunk-3QP5BQ3L.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{a as OpenAIClient}from'./chunk-VKKU4LOM.js';import'./chunk-O5HFCH2U.js';import'./chunk-2EUIMKJA.js';import'./chunk-FU7AHZNN.js';import'./chunk-ZSAONDT6.js';import'./chunk-3QP5BQ3L.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{d as findOpenRouterModel,c as getOpenRouterModels,b as getOpenRouterSnapshot,e as listOpenRouterModelsByVendor,a as setOpenRouterSnapshot}from'./chunk-
|
|
1
|
+
export{d as findOpenRouterModel,c as getOpenRouterModels,b as getOpenRouterSnapshot,e as listOpenRouterModelsByVendor,a as setOpenRouterSnapshot}from'./chunk-A4M2Y42L.js';import'./chunk-3QP5BQ3L.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{a as syncOpenRouterCatalog}from'./chunk-XXCZE2U2.js';export{b as getOpenRouterSnapshot}from'./chunk-A4M2Y42L.js';import'./chunk-3QP5BQ3L.js';
|
package/dist/product/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as defineProduct}from'../chunk-
|
|
1
|
+
export{a as defineProduct}from'../chunk-Q3RSX66I.js';import'../chunk-MGP35GKD.js';import'../chunk-MLCTC53I.js';import'../chunk-WI6FSWGU.js';import'../chunk-P6JSTIFM.js';import'../chunk-SNFAPSLA.js';import'../chunk-L7B2ORID.js';import'../chunk-M7VU4YVY.js';import'../chunk-T222K6IV.js';import'../chunk-QTWU7UNA.js';import'../chunk-DTPABBSV.js';import'../chunk-RERBX75D.js';import'../chunk-2GJ7H5NC.js';import'../chunk-A4M2Y42L.js';import'../chunk-FU7AHZNN.js';import'../chunk-ZSAONDT6.js';import'../chunk-3QP5BQ3L.js';
|
|
@@ -45,7 +45,7 @@ export declare class AgentClient {
|
|
|
45
45
|
/**
|
|
46
46
|
* Query server state.
|
|
47
47
|
*/
|
|
48
|
-
query(type: QueryParams["type"],
|
|
48
|
+
query(type: QueryParams["type"], arg?: string | Record<string, unknown>, ...extra: unknown[]): Promise<QueryResult>;
|
|
49
49
|
/**
|
|
50
50
|
* Inject context into the session transcript without triggering a LLM turn.
|
|
51
51
|
* Used to make arena results, tool outputs, etc. visible to subsequent LLM calls.
|
package/dist/run/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as createRunManager}from'../chunk-
|
|
1
|
+
export{a as createRunManager}from'../chunk-EU3J7TBP.js';export{$ as ArtifactTracker,_ as CheckpointWriter,da as CompositeEvaluator,ea as EngineRunner,W as FileRunStore,ba as Heartbeat,ca as NoopEvaluator,Y as RunApprovalBackend,aa as RunLock,fa as RunManager,X as RunQueue,V as VALID_TRANSITIONS,Z as createRunAskUserFn}from'../chunk-MGP35GKD.js';import'../chunk-MLCTC53I.js';import'../chunk-WI6FSWGU.js';import'../chunk-P6JSTIFM.js';import'../chunk-SNFAPSLA.js';import'../chunk-L7B2ORID.js';import'../chunk-M7VU4YVY.js';import'../chunk-T222K6IV.js';import'../chunk-QTWU7UNA.js';import'../chunk-DTPABBSV.js';import'../chunk-RERBX75D.js';import'../chunk-2GJ7H5NC.js';import'../chunk-A4M2Y42L.js';import'../chunk-FU7AHZNN.js';import'../chunk-ZSAONDT6.js';import'../chunk-3QP5BQ3L.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {h,a}from'./chunk-3QP5BQ3L.js';import {mkdtempSync,writeFileSync}from'fs';import {tmpdir}from'os';import {join}from'path';h();function
|
|
2
|
-
[sandbox:seatbelt] A syscall was blocked by the sandbox. If this path should be writable or this network call legitimate, ask the user to update sandbox.writableRoots / sandbox.network in settings.json.`}}}a(
|
|
1
|
+
import {h,a}from'./chunk-3QP5BQ3L.js';import {mkdtempSync,writeFileSync,rmSync}from'fs';import {tmpdir}from'os';import {join}from'path';h();function y(e){return {name:"seatbelt",wrap(o,l){let n=b(e),t=mkdtempSync(join(tmpdir(),"codeshell-sandbox-")),a$1=join(t,"profile.sb");return writeFileSync(a$1,n,"utf-8"),{file:"/usr/bin/sandbox-exec",args:["-f",a$1,l.shell,"-c",o],cleanup:a(()=>{try{rmSync(t,{recursive:!0,force:!0});}catch{}},"cleanup")}},hintForBlockedOutput(o){if(/Operation not permitted|sandbox/.test(o))return `
|
|
2
|
+
[sandbox:seatbelt] A syscall was blocked by the sandbox. If this path should be writable or this network call legitimate, ask the user to update sandbox.writableRoots / sandbox.network in settings.json.`}}}a(y,"createSeatbeltBackend");function b(e){let o=e.writableRoots.map(t=>` (subpath ${d(t)})`).join(`
|
|
3
3
|
`),l=e.deniedReads.map(t=>` (subpath ${d(t)})`).join(`
|
|
4
|
-
`),
|
|
4
|
+
`),n=e.network==="deny"?"(deny network-outbound)":"(allow network*)";return `(version 1)
|
|
5
5
|
(deny default)
|
|
6
6
|
|
|
7
7
|
;; Process control
|
|
@@ -33,5 +33,5 @@ ${o})
|
|
|
33
33
|
(allow iokit-open)
|
|
34
34
|
|
|
35
35
|
;; Network
|
|
36
|
-
${
|
|
37
|
-
`}a(b,"buildProfile");function d(e){return `"${e.replace(/"/g,'\\"')}"`}a(d,"quote");export{
|
|
36
|
+
${n}
|
|
37
|
+
`}a(b,"buildProfile");function d(e){return `"${e.replace(/"/g,'\\"')}"`}a(d,"quote");export{y as createSeatbeltBackend};
|