castle-web-cli 0.4.256 → 0.4.258

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.
@@ -23,6 +23,7 @@ export declare function classifyProviderError(text: string | undefined, model?:
23
23
  */
24
24
  export declare function setReaderTimeZone(zone: string): void;
25
25
  export declare function failureLabel(failure: AgentFailure): string;
26
+ export declare function failureOffersCredits(failure: AgentFailure): boolean;
26
27
  export declare function routerTurnRetryable(failure: AgentFailure, opts: {
27
28
  text: string;
28
29
  textIsProviderError: boolean;
@@ -233,6 +233,15 @@ export function failureLabel(failure) {
233
233
  return "transient/upstream-flap";
234
234
  return failure.reason ? `${failure.kind}/${failure.reason}` : failure.kind;
235
235
  }
236
+ // Whether the failure's recovery is buying Castle credits, so the editor puts a
237
+ // Get credits button under the copy instead of leaving castle.xyz/credits as
238
+ // plain text (which the app shell cannot follow at all). Mirrors the order in
239
+ // failureCopy: the free model's own daily cap is not a credits problem.
240
+ export function failureOffersCredits(failure) {
241
+ if (failure.kind !== "limit" || failure.castleFreeModelLimit)
242
+ return false;
243
+ return failure.castleCreditsInsufficient === true || failure.castleCreditsExhausted === true;
244
+ }
236
245
  export function routerTurnRetryable(failure, opts) {
237
246
  const retryableFailure = failure.kind === "exit" || (failure.kind === "transient" && failure.upstreamFlap === true);
238
247
  return retryableFailure && !opts.spawnedTasks && opts.streamedChars === 0 &&
package/dist/agent.d.ts CHANGED
@@ -5,18 +5,11 @@ import { Duplex } from 'stream';
5
5
  import { extractDirectives, type AnswerDirective, type TaskDirective } from './routerFences.js';
6
6
  import { type SendDirective, type TaskSteer } from './taskSteer.js';
7
7
  import { type StopNote, type StopTarget } from './routerStops.js';
8
+ import { type AgentSettings, type ClaudeModel } from './agentSettings.js';
8
9
  import { type PlaytestExecutor, type PlaytestToolResult } from './native/playtest.js';
9
10
  export declare const AGENT_WS_PATH = "/__castle/agent";
10
- export type ClaudeModel = 'sonnet' | 'opus' | 'fable' | 'openrouter';
11
+ export type { ClaudeModel } from './agentSettings.js';
11
12
  export type { EffortLevel };
12
- interface AgentSettings {
13
- routerClaudeModel: ClaudeModel;
14
- tasksClaudeModel: ClaudeModel;
15
- routerOpenrouterModel: string;
16
- tasksOpenrouterModel: string;
17
- routerEffort: EffortLevel;
18
- tasksEffort: EffortLevel;
19
- }
20
13
  type OpenrouterSlugKey = 'routerOpenrouterModel' | 'tasksOpenrouterModel';
21
14
  type SettingsWarnings = Partial<Record<OpenrouterSlugKey, {
22
15
  model: string;
@@ -50,6 +43,7 @@ interface ChatMessage {
50
43
  hideFromUi?: boolean;
51
44
  planUpdated?: boolean;
52
45
  errorDetail?: string;
46
+ offersCredits?: boolean;
53
47
  }
54
48
  interface TaskUsage {
55
49
  input?: number;
@@ -91,6 +85,7 @@ interface TaskRecord {
91
85
  account?: string;
92
86
  errorCopy?: string;
93
87
  errorDetail?: string;
88
+ offersCredits?: boolean;
94
89
  failure?: string;
95
90
  avatar?: string;
96
91
  phase?: string;
@@ -125,6 +120,7 @@ interface AgentRunHandle {
125
120
  spawnfile: string;
126
121
  kill(signal?: NodeJS.Signals): boolean;
127
122
  }
123
+ export declare function claudeActivityTrace(events: Record<string, unknown>[], labelUnknownTools?: boolean): (string | null)[];
128
124
  export declare const TASK_DIRS_KEPT = 200;
129
125
  export declare const TASK_ARCHIVE_BATCH = 250;
130
126
  export declare const TASK_ARCHIVE_SEGMENT_BYTES: number;
@@ -206,6 +202,7 @@ interface RouterCtx {
206
202
  taskOpenrouterModel: () => string;
207
203
  taskEffort: () => EffortLevel;
208
204
  freeModelPrefixes: () => readonly string[];
205
+ onFreeReply: (model: string) => void;
209
206
  canAutoRetry: () => boolean;
210
207
  onSettled: (retryable?: boolean) => void;
211
208
  }