pullfrog 0.0.200 → 0.0.202

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.
@@ -2,5 +2,5 @@ import type { Agent } from "./shared.ts";
2
2
  export type { Agent, AgentUsage } from "./shared.ts";
3
3
  export declare const agents: {
4
4
  claude: Agent;
5
- opentoad: Agent;
5
+ opencode: Agent;
6
6
  };
@@ -0,0 +1 @@
1
+ export declare const opencode: import("./shared.ts").Agent;
@@ -7,16 +7,31 @@ export declare const MAX_COMMIT_RETRIES = 3;
7
7
  export declare function getGitStatus(): string;
8
8
  export declare function buildCommitPrompt(_agentId: AgentId, status: string): string;
9
9
  /**
10
- * token/cost usage data from a single agent run
10
+ * token/cost usage data from a single agent run.
11
+ *
12
+ * NOTE on semantics: `inputTokens` here is the *total* billable input for the
13
+ * run — non-cached input + cache read + cache write — matching the per-agent
14
+ * SDK conventions. This is what gets persisted to `WorkflowRun.inputTokens`.
15
+ *
16
+ * The stdout token table and markdown step summary display a different "Input"
17
+ * column that shows only the non-cached portion (derivable as
18
+ * `inputTokens - cacheReadTokens - cacheWriteTokens`) so humans can see the
19
+ * cache hit ratio at a glance. Dashboards that query `WorkflowRun.inputTokens`
20
+ * directly are seeing the full total, not the log column.
11
21
  */
12
22
  export interface AgentUsage {
13
23
  agent: string;
24
+ /** full billable input: non-cached + cache read + cache write */
14
25
  inputTokens: number;
15
26
  outputTokens: number;
16
27
  cacheReadTokens?: number | undefined;
17
28
  cacheWriteTokens?: number | undefined;
18
29
  costUsd?: number | undefined;
19
30
  }
31
+ export interface AgentToolUseEvent {
32
+ toolName: string;
33
+ input: unknown;
34
+ }
20
35
  /**
21
36
  * Result returned by agent execution
22
37
  */
@@ -37,6 +52,13 @@ export interface AgentRunContext {
37
52
  tmpdir: string;
38
53
  instructions: ResolvedInstructions;
39
54
  todoTracker?: TodoTracker | undefined;
55
+ /**
56
+ * called synchronously when the agent subprocess is killed for inner
57
+ * activity timeout. lets main.ts tear down shared resources (MCP HTTP
58
+ * server) so lingering SSE reconnects don't keep the outer timer alive.
59
+ */
60
+ onActivityTimeout?: (() => void) | undefined;
61
+ onToolUse?: ((event: AgentToolUseEvent) => void) | undefined;
40
62
  }
41
63
  export interface Agent {
42
64
  name: AgentId;
@@ -44,3 +66,45 @@ export interface Agent {
44
66
  run: (ctx: AgentRunContext) => Promise<AgentResult>;
45
67
  }
46
68
  export declare const agent: (input: Agent) => Agent;
69
+ /** format a USD cost to 4 decimal places, always showing the leading zero */
70
+ export declare function formatCostUsd(costUsd: number): string;
71
+ /**
72
+ * merge two AgentUsage snapshots into one running total.
73
+ *
74
+ * both agent harnesses invoke their runner multiple times per `run()` when the
75
+ * post-run dirty-tree loop kicks in (MAX_COMMIT_RETRIES). each invocation
76
+ * produces its own AgentUsage; we sum them so downstream callers (usage
77
+ * summary, WorkflowRun persistence) see the whole session — not just the
78
+ * final retry's slice.
79
+ *
80
+ * returns `undefined` when both sides are empty so callers can short-circuit
81
+ * without a special case. zero-valued cache / cost fields are dropped to
82
+ * `undefined` for symmetry with each harness's `buildUsage`.
83
+ */
84
+ export declare function mergeAgentUsage(a: AgentUsage | undefined, b: AgentUsage | undefined): AgentUsage | undefined;
85
+ /**
86
+ * unified per-run token table used by every agent harness.
87
+ *
88
+ * columns are kept stable across agents and models so downstream log parsers
89
+ * (scripts/token-usage.ts, cost dashboards) only have to understand one format:
90
+ *
91
+ * Input non-cached input tokens sent this run
92
+ * Cache Read input tokens served from prompt cache (Anthropic, etc.)
93
+ * Cache Write input tokens written to prompt cache this run
94
+ * Output assistant output tokens
95
+ * Total sum of the four columns — the real billable quantity
96
+ * Cost ($) USD cost reported by the provider (only rendered when known)
97
+ *
98
+ * models that don't report prompt caching leave Cache Read / Write at 0.
99
+ * OpenCode emits per-step `part.cost` sourced from models.dev (works across
100
+ * Anthropic, OpenAI, Google, xAI, DeepSeek, Moonshot, OpenRouter, etc.);
101
+ * Claude CLI emits `total_cost_usd` on its final `result` event. pass the
102
+ * accumulated value via `costUsd` to render the Cost column.
103
+ */
104
+ export declare function logTokenTable(t: {
105
+ input: number;
106
+ cacheRead: number;
107
+ cacheWrite: number;
108
+ output: number;
109
+ costUsd?: number | undefined;
110
+ }): void;