botinabox 2.9.4 → 2.9.6

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.js CHANGED
@@ -4688,7 +4688,8 @@ var RunManager = class {
4688
4688
  cost_cents: result.costCents ?? 0,
4689
4689
  input_tokens: usage?.["inputTokens"] ?? 0,
4690
4690
  output_tokens: usage?.["outputTokens"] ?? 0,
4691
- error_message: result.exitCode !== 0 ? result.output : void 0
4691
+ error_message: result.exitCode !== 0 ? result.output : void 0,
4692
+ model: result.model ?? void 0
4692
4693
  });
4693
4694
  const agentId = run["agent_id"];
4694
4695
  this.locks.delete(agentId);
@@ -4759,7 +4760,10 @@ var RunManager = class {
4759
4760
  agentId,
4760
4761
  taskId,
4761
4762
  status,
4762
- exitCode: result.exitCode
4763
+ exitCode: result.exitCode,
4764
+ model: result.model,
4765
+ provider: result.provider,
4766
+ usage: result.usage
4763
4767
  });
4764
4768
  }
4765
4769
  async reapOrphans() {
@@ -6570,6 +6574,7 @@ async function registerExecutionEngine(opts) {
6570
6574
  }
6571
6575
  const prompt = task.description ?? task.title ?? "";
6572
6576
  try {
6577
+ const taskModel = config.resolveModel ? config.resolveModel({ agent, task }) ?? model : model;
6573
6578
  const contextFiles = config.resolveContextFiles ? await config.resolveContextFiles({ agent, task }) : [];
6574
6579
  const contextFilesBlock = formatContextFilesBlock(contextFiles);
6575
6580
  const toolListing = toolDefs.length > 0 ? `
@@ -6592,7 +6597,7 @@ ${contextFilesBlock}` : "",
6592
6597
  let totalOutput = 0;
6593
6598
  for (let i = 0; i < maxIterations; i++) {
6594
6599
  const createParams = {
6595
- model,
6600
+ model: taskModel,
6596
6601
  max_tokens: 4096,
6597
6602
  system: systemPrompt,
6598
6603
  messages
@@ -6635,7 +6640,9 @@ ${contextFilesBlock}` : "",
6635
6640
  exitCode: 0,
6636
6641
  output: finalOutput,
6637
6642
  costCents,
6638
- usage: { inputTokens: totalInput, outputTokens: totalOutput }
6643
+ usage: { inputTokens: totalInput, outputTokens: totalOutput },
6644
+ model: taskModel,
6645
+ provider: "anthropic"
6639
6646
  });
6640
6647
  } catch (err) {
6641
6648
  const msg = err instanceof Error ? err.message : String(err);
@@ -0,0 +1,89 @@
1
+ /** LLM provider types — Story 1.5 / 2.1 */
2
+ interface ToolDefinition {
3
+ name: string;
4
+ description: string;
5
+ parameters: Record<string, unknown>;
6
+ }
7
+ interface ChatMessage {
8
+ role: "user" | "assistant" | "system";
9
+ content: string | ContentBlock[];
10
+ }
11
+ type ContentBlock = {
12
+ type: "text";
13
+ text: string;
14
+ } | {
15
+ type: "tool_use";
16
+ id: string;
17
+ name: string;
18
+ input: unknown;
19
+ } | {
20
+ type: "tool_result";
21
+ tool_use_id: string;
22
+ content: string;
23
+ } | {
24
+ type: "image";
25
+ source: {
26
+ type: "base64";
27
+ media_type: string;
28
+ data: string;
29
+ };
30
+ } | {
31
+ type: "document";
32
+ source: {
33
+ type: "base64";
34
+ media_type: "application/pdf";
35
+ data: string;
36
+ };
37
+ };
38
+ interface ChatParams {
39
+ messages: ChatMessage[];
40
+ system?: string;
41
+ tools?: ToolDefinition[];
42
+ maxTokens?: number;
43
+ temperature?: number;
44
+ model: string;
45
+ abortSignal?: AbortSignal;
46
+ }
47
+ interface TokenUsage {
48
+ inputTokens: number;
49
+ outputTokens: number;
50
+ cacheReadTokens?: number;
51
+ cacheWriteTokens?: number;
52
+ }
53
+ interface ChatResult {
54
+ content: string;
55
+ toolUses?: ToolUse[];
56
+ usage: TokenUsage;
57
+ model: string;
58
+ stopReason: "end_turn" | "tool_use" | "max_tokens" | "stop_sequence";
59
+ }
60
+ interface ToolUse {
61
+ id: string;
62
+ name: string;
63
+ input: unknown;
64
+ }
65
+ interface ModelInfo {
66
+ id: string;
67
+ displayName: string;
68
+ contextWindow: number;
69
+ maxOutputTokens: number;
70
+ capabilities: Array<"chat" | "tools" | "vision" | "streaming">;
71
+ /** Cost in micro-cents per 1M tokens */
72
+ inputCostPerMToken?: number;
73
+ outputCostPerMToken?: number;
74
+ }
75
+ interface ResolvedModel {
76
+ provider: string;
77
+ model: string;
78
+ }
79
+ interface LLMProvider {
80
+ id: string;
81
+ displayName: string;
82
+ models: ModelInfo[];
83
+ chat(params: ChatParams): Promise<ChatResult>;
84
+ chatStream(params: ChatParams): AsyncGenerator<string, ChatResult, unknown>;
85
+ /** Convert ToolDefinition[] to provider-native format */
86
+ serializeTools(tools: ToolDefinition[]): unknown;
87
+ }
88
+
89
+ export type { ChatMessage as C, LLMProvider as L, ModelInfo as M, ResolvedModel as R, TokenUsage as T, ChatParams as a, ChatResult as b, ContentBlock as c, ToolUse as d, ToolDefinition as e };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "botinabox",
3
- "version": "2.9.4",
3
+ "version": "2.9.6",
4
4
  "description": "Bot in a Box — framework for building multi-agent bots",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",