@cjhyy/code-shell-core 0.6.0-rc.4 → 0.6.0-rc.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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.0-rc.4";
6
+ export declare const VERSION = "0.6.0-rc.5";
7
7
  export type { Message, ContentBlock, ToolDefinition, ToolCall, ToolResult, RegisteredTool, TranscriptEvent, TranscriptEventType, SessionState, SessionStatus, TokenUsage, CompiledInput, PermissionDecision, PermissionMode, PermissionRule, TurnPhase, TurnResult, TerminalReason, StreamEvent, StreamCallback, LLMConfig, ClientDefaults, LLMResponse, Settings, MCPServerConfig, } from "./types.js";
8
8
  export { FrameworkError, LLMError, LLMRateLimitError, ContextLimitError, ToolError, ToolNotFoundError, ToolExecutionError, ToolTimeoutError, PermissionDeniedError, SessionError, TranscriptError, ConfigError, SandboxUnavailableError, } from "./exceptions.js";
9
9
  export { Engine, loadAgentDefinitionsForCwd } from "./engine/engine.js";
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Public API exports.
5
5
  */
6
- export const VERSION = "0.6.0-rc.4";
6
+ export const VERSION = "0.6.0-rc.5";
7
7
  // ─── Exceptions ──────────────────────────────────────────────────
8
8
  export { FrameworkError, LLMError, LLMRateLimitError, ContextLimitError, ToolError, ToolNotFoundError, ToolExecutionError, ToolTimeoutError, PermissionDeniedError, SessionError, TranscriptError, ConfigError, SandboxUnavailableError, } from "./exceptions.js";
9
9
  // ─── Engine (primary API) ────────────────────────────────────────
@@ -31,6 +31,7 @@ When you encounter an obstacle, do not use destructive actions as a shortcut to
31
31
  - To search for files use Glob instead of find or ls
32
32
  - To search the content of files, use Grep instead of grep or rg
33
33
  - Reserve using the Bash exclusively for system commands and terminal operations that require shell execution.
34
+ - Shell choice: when Bash is available, use it for ordinary shell commands, git operations, package-manager commands, test/build scripts, and POSIX-style command lines. On Windows, Bash uses Git Bash when it is available, so do not choose PowerShell merely because the OS is Windows. Use PowerShell only when the user explicitly asks for it or the task requires PowerShell-specific cmdlets, Windows APIs, registry access, or `.ps1` behavior.
34
35
  - For long-lived processes that don't exit on their own — a dev server (`npm run dev`, `vite`), a watcher, a tunnel — call Bash with `run_in_background: true`. It returns a `shell_id` immediately instead of blocking until a timeout. Then use `BashOutput(shell_id)` to read its logs (e.g. to confirm it started or to see an error), `ListShells()` to see what's running, and `KillShell(shell_id)` to stop it. Never run such a command in the foreground — it will just block until it's killed. Plain one-shot commands (build, test, git) stay foreground.
35
36
  - Break down and manage multi-step work with the TodoWrite tool. Pass the complete todo list each call; rewrite it as items move pending → in_progress → completed.
36
37
  - You can call multiple tools in a single response. If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel.
@@ -23,6 +23,7 @@ export interface AgentRunOptions {
23
23
  cwd?: string;
24
24
  sessionId?: string;
25
25
  permissionMode?: PermissionMode;
26
+ model?: string;
26
27
  planMode?: boolean;
27
28
  }
28
29
  export type BackgroundAgentCompletedHandler = (sessionId: string, event: BackgroundAgentCompletedEvent) => void;
@@ -307,6 +307,19 @@ export class AgentServer {
307
307
  this.transport.send(createErrorResponse(req.id, ErrorCodes.SessionNotFound, `session ${params.sessionId} does not exist`));
308
308
  return;
309
309
  }
310
+ if (params.model !== undefined) {
311
+ if (typeof params.model !== "string" || params.model.length === 0) {
312
+ this.transport.send(createErrorResponse(req.id, ErrorCodes.InvalidParams, "model must be a non-empty string"));
313
+ return;
314
+ }
315
+ try {
316
+ session.requestModelSwitch(params.model);
317
+ }
318
+ catch (err) {
319
+ this.transport.send(createErrorResponse(req.id, ErrorCodes.InvalidParams, err.message));
320
+ return;
321
+ }
322
+ }
310
323
  if (typeof params.planMode === "boolean") {
311
324
  session.engine.setPlanMode(params.planMode);
312
325
  }
@@ -387,6 +400,19 @@ export class AgentServer {
387
400
  // Engine.setPermissionMode now keeps this.permissionMode + this.planMode
388
401
  // in sync and tools read them via ToolContext.permissionMode/planMode.
389
402
  }
403
+ if (params.model !== undefined) {
404
+ if (typeof params.model !== "string" || params.model.length === 0) {
405
+ this.transport.send(createErrorResponse(req.id, ErrorCodes.InvalidParams, "model must be a non-empty string"));
406
+ return;
407
+ }
408
+ try {
409
+ this.legacyEngine.switchModel(params.model);
410
+ }
411
+ catch (err) {
412
+ this.transport.send(createErrorResponse(req.id, ErrorCodes.InvalidParams, err.message));
413
+ return;
414
+ }
415
+ }
390
416
  this.running = true;
391
417
  this.abortController = new AbortController();
392
418
  this.notify(Methods.Status, { status: "running" });
@@ -61,6 +61,12 @@ export interface RunParams {
61
61
  * When omitted, the engine keeps its configured default.
62
62
  */
63
63
  permissionMode?: PermissionMode;
64
+ /**
65
+ * Per-run model pool key. Applied after the session exists and before the
66
+ * turn starts, so cold desktop runs don't need a separate pre-run configure
67
+ * request to a worker that has not been spawned yet.
68
+ */
69
+ model?: string;
64
70
  /**
65
71
  * Workspace trust for this run's project (`cwd`), asserted by the host
66
72
  * (desktop main from its trust-store) — never by the renderer. When false,
@@ -29,8 +29,10 @@ function sandboxMark(backend) {
29
29
  export const bashToolDef = {
30
30
  name: "Bash",
31
31
  description: "Execute a shell command and return its output. " +
32
- "Commands run in the user's default shell. Use for system operations, " +
33
- "git commands, running tests, installing packages, etc.",
32
+ "Use for ordinary shell commands, system operations, git commands, " +
33
+ "package-manager commands, running tests, installing packages, etc. " +
34
+ "On Windows this tool prefers Git Bash when available, so prefer Bash over " +
35
+ "PowerShell unless the task needs PowerShell-specific syntax or APIs.",
34
36
  inputSchema: {
35
37
  type: "object",
36
38
  properties: {
@@ -8,7 +8,10 @@
8
8
  import { safeSpawn } from "../../runtime/safe-spawn.js";
9
9
  export const powershellToolDef = {
10
10
  name: "PowerShell",
11
- description: "Execute PowerShell commands. Available on Windows and cross-platform where PowerShell Core is installed.",
11
+ description: "Execute PowerShell commands. Use only when the user explicitly asks for PowerShell " +
12
+ "or the task requires PowerShell-specific cmdlets, Windows APIs, registry access, " +
13
+ "or .ps1 behavior. For ordinary shell/git/package/test commands, prefer Bash " +
14
+ "(Git Bash on Windows when available).",
12
15
  inputSchema: {
13
16
  type: "object",
14
17
  properties: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cjhyy/code-shell-core",
3
- "version": "0.6.0-rc.4",
3
+ "version": "0.6.0-rc.5",
4
4
  "description": "Core engine for code-shell — agent orchestration, tool execution, hooks, protocol. UI-agnostic.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",