agent-sh 0.12.19 → 0.12.20

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.
@@ -1527,6 +1527,7 @@ export class AgentLoop {
1527
1527
  messages,
1528
1528
  tools: apiTools,
1529
1529
  model: this.currentModel,
1530
+ max_tokens: this.currentMode.maxTokens ?? 65536,
1530
1531
  ...this.reasoningParams(),
1531
1532
  };
1532
1533
  this.bus.emit("llm:request", requestParams);
@@ -69,6 +69,7 @@ export interface ShellEvents {
69
69
  messages: unknown[];
70
70
  tools?: unknown;
71
71
  model?: string;
72
+ max_tokens?: number;
72
73
  reasoning_effort?: string;
73
74
  };
74
75
  "llm:chunk": {
@@ -318,6 +319,7 @@ export interface ShellEvents {
318
319
  id: string;
319
320
  reasoning?: boolean;
320
321
  contextWindow?: number;
322
+ maxTokens?: number;
321
323
  echoReasoning?: boolean;
322
324
  })[];
323
325
  /** Provider supports the reasoning_effort parameter. Default: true. */
@@ -36,6 +36,7 @@ export default function agentBackend(ctx) {
36
36
  provider: id,
37
37
  providerConfig: { apiKey: p.apiKey, baseURL: p.baseURL },
38
38
  contextWindow: mc?.contextWindow ?? p.contextWindow,
39
+ maxTokens: mc?.maxTokens ?? (mc?.contextWindow ? Math.min(Math.floor(mc.contextWindow * 0.4), 65536) : undefined),
39
40
  reasoning: mc?.reasoning,
40
41
  supportsReasoningEffort: p.supportsReasoningEffort,
41
42
  echoReasoning: mc?.echoReasoning,
@@ -149,7 +150,7 @@ export default function agentBackend(ctx) {
149
150
  }
150
151
  else {
151
152
  modelIds.push(m.id);
152
- caps.set(m.id, { reasoning: m.reasoning, contextWindow: m.contextWindow, echoReasoning: m.echoReasoning });
153
+ caps.set(m.id, { reasoning: m.reasoning, contextWindow: m.contextWindow, maxTokens: m.maxTokens, echoReasoning: m.echoReasoning });
153
154
  }
154
155
  }
155
156
  providerRegistry.set(p.id, {
@@ -169,6 +170,7 @@ export default function agentBackend(ctx) {
169
170
  provider: p.id,
170
171
  providerConfig: { apiKey: p.apiKey ?? "", baseURL: p.baseURL },
171
172
  contextWindow: mc?.contextWindow,
173
+ maxTokens: mc?.maxTokens,
172
174
  reasoning: mc?.reasoning,
173
175
  supportsReasoningEffort: p.supportsReasoningEffort,
174
176
  echoReasoning: mc?.echoReasoning,
@@ -212,6 +214,7 @@ export default function agentBackend(ctx) {
212
214
  provider: name,
213
215
  providerConfig: { apiKey: p.apiKey, baseURL: p.baseURL },
214
216
  contextWindow: mc?.contextWindow ?? p.contextWindow,
217
+ maxTokens: mc?.maxTokens ?? (mc?.contextWindow ? Math.min(Math.floor(mc.contextWindow * 0.4), 65536) : undefined),
215
218
  reasoning: mc?.reasoning,
216
219
  supportsReasoningEffort: p.supportsReasoningEffort,
217
220
  echoReasoning: mc?.echoReasoning,
@@ -654,26 +654,16 @@ export default function activate(ctx) {
654
654
  return [];
655
655
  const boxW = Math.min(120, width - 2);
656
656
  const contentW = boxW - 4;
657
- let body;
658
- if (diff.isNewFile) {
659
- const lines = diff.hunks.flatMap(h => h.lines.map(l => l.text));
660
- const preview = getSettings().newFilePreviewLines;
661
- const head = lines.slice(0, preview);
662
- const truncated = head.map(l => l.length > contentW ? l.slice(0, contentW - 1) + "…" : l);
663
- const more = lines.length > preview
664
- ? [`${p.dim}… ${lines.length - preview} more lines${p.reset}`]
665
- : [];
666
- body = ["", ...truncated, ...more, ""];
667
- }
668
- else {
669
- const diffLines = renderDiff(diff, {
670
- width: contentW,
671
- filePath,
672
- maxLines: getSettings().diffMaxLines,
673
- trueColor: true,
674
- });
675
- body = diffLines.length > 1 ? ["", ...diffLines.slice(1), ""] : diffLines;
676
- }
657
+ const maxLines = diff.isNewFile
658
+ ? getSettings().newFilePreviewLines
659
+ : getSettings().diffMaxLines;
660
+ const diffLines = renderDiff(diff, {
661
+ width: contentW,
662
+ filePath,
663
+ maxLines,
664
+ trueColor: true,
665
+ });
666
+ const body = diffLines.length > 1 ? ["", ...diffLines.slice(1), ""] : diffLines;
677
667
  return renderBoxFrame(body, {
678
668
  width: boxW,
679
669
  style: "rounded",
@@ -9,6 +9,8 @@ export interface ModelCapabilityConfig {
9
9
  reasoning?: boolean;
10
10
  /** Context window size in tokens for this specific model. */
11
11
  contextWindow?: number;
12
+ /** Max output tokens for this model. */
13
+ maxTokens?: number;
12
14
  /** Echo reasoning_content back on assistant turns. Required by DeepSeek. */
13
15
  echoReasoning?: boolean;
14
16
  }
@@ -148,6 +150,7 @@ export interface ResolvedProvider {
148
150
  modelCapabilities?: Map<string, {
149
151
  reasoning?: boolean;
150
152
  contextWindow?: number;
153
+ maxTokens?: number;
151
154
  echoReasoning?: boolean;
152
155
  }>;
153
156
  /** Borrow another registered provider's reasoning request shape by id. */
package/dist/settings.js CHANGED
@@ -148,8 +148,8 @@ export function resolveProvider(name) {
148
148
  }
149
149
  else {
150
150
  modelIds.push(m.id);
151
- if (m.reasoning !== undefined || m.contextWindow !== undefined || m.echoReasoning !== undefined) {
152
- caps.set(m.id, { reasoning: m.reasoning, contextWindow: m.contextWindow, echoReasoning: m.echoReasoning });
151
+ if (m.reasoning !== undefined || m.contextWindow !== undefined || m.maxTokens !== undefined || m.echoReasoning !== undefined) {
152
+ caps.set(m.id, { reasoning: m.reasoning, contextWindow: m.contextWindow, maxTokens: m.maxTokens, echoReasoning: m.echoReasoning });
153
153
  }
154
154
  }
155
155
  }
package/dist/types.d.ts CHANGED
@@ -41,6 +41,8 @@ export interface AgentMode {
41
41
  };
42
42
  /** Context window size in tokens (for usage display). */
43
43
  contextWindow?: number;
44
+ /** Max output tokens for this mode. */
45
+ maxTokens?: number;
44
46
  /** Model supports reasoning/thinking tokens. */
45
47
  reasoning?: boolean;
46
48
  /** Provider supports the reasoning_effort parameter. */
@@ -44,7 +44,7 @@ export class LlmClient {
44
44
  model: opts.model ?? this.model,
45
45
  messages: opts.messages,
46
46
  tools: opts.tools?.length ? opts.tools : undefined,
47
- max_tokens: opts.max_tokens ?? 8192,
47
+ max_tokens: opts.max_tokens ?? 65536,
48
48
  stream: true,
49
49
  stream_options: { include_usage: true },
50
50
  ...(opts.reasoning_effort
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-sh",
3
- "version": "0.12.19",
3
+ "version": "0.12.20",
4
4
  "description": "A shell-first terminal where AI is one keystroke away",
5
5
  "type": "module",
6
6
  "main": "dist/core.js",