@stigmer/protos 0.3.3 → 0.4.0

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.
Files changed (60) hide show
  1. package/ai/stigmer/agentic/agentexecution/v1/command_connect.js +2 -2
  2. package/ai/stigmer/agentic/agentexecution/v1/command_connect.js.map +1 -1
  3. package/ai/stigmer/agentic/agentexecution/v1/command_pb.d.ts +2 -2
  4. package/ai/stigmer/agentic/agentexecution/v1/command_pb.js +1 -1
  5. package/ai/stigmer/agentic/agentexecution/v1/command_pb.js.map +1 -1
  6. package/ai/stigmer/agentic/agentexecution/v1/enum_pb.d.ts +38 -0
  7. package/ai/stigmer/agentic/agentexecution/v1/enum_pb.js +41 -2
  8. package/ai/stigmer/agentic/agentexecution/v1/enum_pb.js.map +1 -1
  9. package/ai/stigmer/agentic/agentexecution/v1/io_pb.d.ts +167 -58
  10. package/ai/stigmer/agentic/agentexecution/v1/io_pb.js +44 -24
  11. package/ai/stigmer/agentic/agentexecution/v1/io_pb.js.map +1 -1
  12. package/ai/stigmer/agentic/agentexecution/v1/message_pb.d.ts +0 -10
  13. package/ai/stigmer/agentic/agentexecution/v1/message_pb.js +1 -2
  14. package/ai/stigmer/agentic/agentexecution/v1/message_pb.js.map +1 -1
  15. package/ai/stigmer/agentic/agentexecution/v1/query_connect.d.ts +14 -1
  16. package/ai/stigmer/agentic/agentexecution/v1/query_connect.js +15 -2
  17. package/ai/stigmer/agentic/agentexecution/v1/query_connect.js.map +1 -1
  18. package/ai/stigmer/agentic/agentexecution/v1/query_pb.d.ts +14 -2
  19. package/ai/stigmer/agentic/agentexecution/v1/query_pb.js +1 -1
  20. package/ai/stigmer/agentic/agentexecution/v1/query_pb.js.map +1 -1
  21. package/ai/stigmer/agentic/agentexecution/v1/usage_pb.d.ts +701 -262
  22. package/ai/stigmer/agentic/agentexecution/v1/usage_pb.js +271 -9
  23. package/ai/stigmer/agentic/agentexecution/v1/usage_pb.js.map +1 -1
  24. package/ai/stigmer/billing/v1/billing_account_pb.d.ts +245 -0
  25. package/ai/stigmer/billing/v1/billing_account_pb.js +31 -0
  26. package/ai/stigmer/billing/v1/billing_account_pb.js.map +1 -0
  27. package/ai/stigmer/billing/v1/command_connect.d.ts +135 -0
  28. package/ai/stigmer/billing/v1/command_connect.js +144 -0
  29. package/ai/stigmer/billing/v1/command_connect.js.map +1 -0
  30. package/ai/stigmer/billing/v1/command_pb.d.ts +132 -0
  31. package/ai/stigmer/billing/v1/command_pb.js +23 -0
  32. package/ai/stigmer/billing/v1/command_pb.js.map +1 -0
  33. package/ai/stigmer/billing/v1/credit_pb.d.ts +492 -0
  34. package/ai/stigmer/billing/v1/credit_pb.js +47 -0
  35. package/ai/stigmer/billing/v1/credit_pb.js.map +1 -0
  36. package/ai/stigmer/billing/v1/enum_pb.d.ts +318 -0
  37. package/ai/stigmer/billing/v1/enum_pb.js +329 -0
  38. package/ai/stigmer/billing/v1/enum_pb.js.map +1 -0
  39. package/ai/stigmer/billing/v1/io_pb.d.ts +801 -0
  40. package/ai/stigmer/billing/v1/io_pb.js +130 -0
  41. package/ai/stigmer/billing/v1/io_pb.js.map +1 -0
  42. package/ai/stigmer/billing/v1/policy_pb.d.ts +138 -0
  43. package/ai/stigmer/billing/v1/policy_pb.js +20 -0
  44. package/ai/stigmer/billing/v1/policy_pb.js.map +1 -0
  45. package/ai/stigmer/billing/v1/query_connect.d.ts +68 -0
  46. package/ai/stigmer/billing/v1/query_connect.js +76 -0
  47. package/ai/stigmer/billing/v1/query_connect.js.map +1 -0
  48. package/ai/stigmer/billing/v1/query_pb.d.ts +67 -0
  49. package/ai/stigmer/billing/v1/query_pb.js +20 -0
  50. package/ai/stigmer/billing/v1/query_pb.js.map +1 -0
  51. package/ai/stigmer/iam/identityaccount/v1/command_connect.d.ts +9 -9
  52. package/ai/stigmer/iam/identityaccount/v1/command_connect.js +12 -12
  53. package/ai/stigmer/iam/identityaccount/v1/command_connect.js.map +1 -1
  54. package/ai/stigmer/iam/identityaccount/v1/command_pb.d.ts +11 -11
  55. package/ai/stigmer/iam/identityaccount/v1/command_pb.js +1 -1
  56. package/ai/stigmer/iam/identityaccount/v1/command_pb.js.map +1 -1
  57. package/ai/stigmer/iam/v1/enum_pb.d.ts +18 -1
  58. package/ai/stigmer/iam/v1/enum_pb.js +18 -1
  59. package/ai/stigmer/iam/v1/enum_pb.js.map +1 -1
  60. package/package.json +1 -1
@@ -1,421 +1,860 @@
1
- import type { GenFile, GenMessage } from "@bufbuild/protobuf/codegenv1";
1
+ import type { GenEnum, GenFile, GenMessage } from "@bufbuild/protobuf/codegenv1";
2
+ import type { Timestamp } from "@bufbuild/protobuf/wkt";
2
3
  import type { Message } from "@bufbuild/protobuf";
3
4
  /**
4
5
  * Describes the file ai/stigmer/agentic/agentexecution/v1/usage.proto.
5
6
  */
6
7
  export declare const file_ai_stigmer_agentic_agentexecution_v1_usage: GenFile;
7
8
  /**
8
- * UsageMetrics tracks token consumption, cost, and LLM resource usage.
9
- * Provides execution-level aggregation for cost tracking, billing, and analytics.
9
+ * Normalized token usage from a single LLM call.
10
+ * Disjoint buckets: every token falls into exactly one category for cost calculation.
10
11
  *
11
- * ## Scope
12
- *
13
- * Each UsageMetrics instance represents direct LLM usage within its context:
14
- * - AgentExecutionStatus.usage: Main agent's LLM calls (excludes sub-agents)
15
- * - SubAgentExecution.usage: That sub-agent's LLM calls
16
- *
17
- * To calculate total execution cost, sum: status.usage + sum(sub_agent.usage)
18
- *
19
- * ## Token Counting
20
- *
21
- * - prompt_tokens: Total input tokens sent to the LLM (includes cached tokens)
22
- * - completion_tokens: Output tokens generated by the LLM (response)
23
- * - cache_creation_tokens / cache_read_tokens: Cache-aware breakdown
24
- * - Extracted from on_chat_model_end events via LangChain usage_metadata
12
+ * @generated from message ai.stigmer.agentic.agentexecution.v1.TokenUsage
13
+ */
14
+ export type TokenUsage = Message<"ai.stigmer.agentic.agentexecution.v1.TokenUsage"> & {
15
+ /**
16
+ * Regular input tokens (non-cached, non-tool, billed at standard input rate).
17
+ *
18
+ * @generated from field: int64 input_tokens = 1;
19
+ */
20
+ inputTokens: bigint;
21
+ /**
22
+ * Output/completion tokens generated by the model.
23
+ *
24
+ * @generated from field: int64 output_tokens = 2;
25
+ */
26
+ outputTokens: bigint;
27
+ /**
28
+ * Provider-reported total tokens. May differ from sum of other fields
29
+ * because providers include reasoning/overhead differently.
30
+ *
31
+ * @generated from field: int64 total_tokens = 3;
32
+ */
33
+ totalTokens: bigint;
34
+ /**
35
+ * Tokens written to prompt cache (Anthropic cache_creation_input_tokens).
36
+ *
37
+ * @generated from field: int64 cache_creation_input_tokens = 4;
38
+ */
39
+ cacheCreationInputTokens: bigint;
40
+ /**
41
+ * Tokens read from prompt cache (cache hits).
42
+ *
43
+ * @generated from field: int64 cache_read_input_tokens = 5;
44
+ */
45
+ cacheReadInputTokens: bigint;
46
+ /**
47
+ * Reasoning/thinking tokens (OpenAI reasoning_tokens, Vertex thoughtsTokenCount).
48
+ *
49
+ * @generated from field: int64 reasoning_tokens = 6;
50
+ */
51
+ reasoningTokens: bigint;
52
+ /**
53
+ * Tool-use prompt tokens (Vertex toolUsePromptTokenCount).
54
+ *
55
+ * @generated from field: int64 tool_use_prompt_tokens = 7;
56
+ */
57
+ toolUsePromptTokens: bigint;
58
+ /**
59
+ * Audio tokens (future multimodal billing).
60
+ *
61
+ * @generated from field: int64 audio_input_tokens = 8;
62
+ */
63
+ audioInputTokens: bigint;
64
+ /**
65
+ * @generated from field: int64 audio_output_tokens = 9;
66
+ */
67
+ audioOutputTokens: bigint;
68
+ /**
69
+ * Provider-specific token details not yet normalized.
70
+ *
71
+ * @generated from field: map<string, int64> provider_token_details = 20;
72
+ */
73
+ providerTokenDetails: {
74
+ [key: string]: bigint;
75
+ };
76
+ };
77
+ /**
78
+ * Describes the message ai.stigmer.agentic.agentexecution.v1.TokenUsage.
79
+ * Use `create(TokenUsageSchema)` to create a new message.
80
+ */
81
+ export declare const TokenUsageSchema: GenMessage<TokenUsage>;
82
+ /**
83
+ * Pricing rates snapshot at the time of the LLM call.
25
84
  *
26
- * ## Relationship Between Token Fields
85
+ * @generated from message ai.stigmer.agentic.agentexecution.v1.PricingSnapshot
86
+ */
87
+ export type PricingSnapshot = Message<"ai.stigmer.agentic.agentexecution.v1.PricingSnapshot"> & {
88
+ /**
89
+ * Version of the model pricing registry used.
90
+ *
91
+ * @generated from field: string pricing_registry_version = 1;
92
+ */
93
+ pricingRegistryVersion: string;
94
+ /**
95
+ * When this pricing became effective.
96
+ *
97
+ * @generated from field: google.protobuf.Timestamp pricing_effective_at = 2;
98
+ */
99
+ pricingEffectiveAt?: Timestamp;
100
+ /**
101
+ * Currency (always "USD" for now).
102
+ *
103
+ * @generated from field: string currency = 3;
104
+ */
105
+ currency: string;
106
+ /**
107
+ * Provider cost rates (micro-USD per million tokens).
108
+ *
109
+ * @generated from field: int64 input_price_micros_per_million = 10;
110
+ */
111
+ inputPriceMicrosPerMillion: bigint;
112
+ /**
113
+ * @generated from field: int64 output_price_micros_per_million = 11;
114
+ */
115
+ outputPriceMicrosPerMillion: bigint;
116
+ /**
117
+ * @generated from field: int64 cache_creation_price_micros_per_million = 12;
118
+ */
119
+ cacheCreationPriceMicrosPerMillion: bigint;
120
+ /**
121
+ * @generated from field: int64 cache_read_price_micros_per_million = 13;
122
+ */
123
+ cacheReadPriceMicrosPerMillion: bigint;
124
+ /**
125
+ * @generated from field: int64 reasoning_price_micros_per_million = 14;
126
+ */
127
+ reasoningPriceMicrosPerMillion: bigint;
128
+ /**
129
+ * Customer billing policy applied.
130
+ *
131
+ * @generated from field: string markup_policy_version = 30;
132
+ */
133
+ markupPolicyVersion: string;
134
+ /**
135
+ * @generated from field: string cost_tier = 31;
136
+ */
137
+ costTier: string;
138
+ };
139
+ /**
140
+ * Describes the message ai.stigmer.agentic.agentexecution.v1.PricingSnapshot.
141
+ * Use `create(PricingSnapshotSchema)` to create a new message.
142
+ */
143
+ export declare const PricingSnapshotSchema: GenMessage<PricingSnapshot>;
144
+ /**
145
+ * Cost computation result stamped on each usage record.
27
146
  *
28
- * prompt_tokens is the total across all input token types:
29
- * prompt_tokens = sum(model_breakdown[].input_tokens
30
- * + model_breakdown[].cache_creation_tokens
31
- * + model_breakdown[].cache_read_tokens)
147
+ * @generated from message ai.stigmer.agentic.agentexecution.v1.CostStamp
148
+ */
149
+ export type CostStamp = Message<"ai.stigmer.agentic.agentexecution.v1.CostStamp"> & {
150
+ /**
151
+ * Currency (always "USD").
152
+ *
153
+ * @generated from field: string currency = 1;
154
+ */
155
+ currency: string;
156
+ /**
157
+ * Raw provider cost computed server-side from pricing registry.
158
+ *
159
+ * @generated from field: int64 provider_cost_micros = 2;
160
+ */
161
+ providerCostMicros: bigint;
162
+ /**
163
+ * Amount debited from customer credits (after markup policy).
164
+ *
165
+ * @generated from field: int64 customer_billable_amount_micros = 3;
166
+ */
167
+ customerBillableAmountMicros: bigint;
168
+ /**
169
+ * How cost was computed.
170
+ *
171
+ * @generated from field: ai.stigmer.agentic.agentexecution.v1.CostCalculationStatus calculation_status = 4;
172
+ */
173
+ calculationStatus: CostCalculationStatus;
174
+ /**
175
+ * Full pricing snapshot for historical reproducibility.
176
+ *
177
+ * @generated from field: ai.stigmer.agentic.agentexecution.v1.PricingSnapshot pricing = 5;
178
+ */
179
+ pricing?: PricingSnapshot;
180
+ };
181
+ /**
182
+ * Describes the message ai.stigmer.agentic.agentexecution.v1.CostStamp.
183
+ * Use `create(CostStampSchema)` to create a new message.
184
+ */
185
+ export declare const CostStampSchema: GenMessage<CostStamp>;
186
+ /**
187
+ * Proxy-observed timing for a single LLM call.
188
+ * These are server-side measurements, not client-perceived latency.
32
189
  *
33
- * At the aggregate level, cache_creation_tokens and cache_read_tokens are the
34
- * sums of their respective fields across all model breakdowns. The "fresh"
35
- * (non-cached) input portion equals:
36
- * prompt_tokens - cache_creation_tokens - cache_read_tokens
190
+ * @generated from message ai.stigmer.agentic.agentexecution.v1.ProxyTiming
191
+ */
192
+ export type ProxyTiming = Message<"ai.stigmer.agentic.agentexecution.v1.ProxyTiming"> & {
193
+ /**
194
+ * When the proxy received the runner's request.
195
+ *
196
+ * @generated from field: google.protobuf.Timestamp proxy_received_at = 1;
197
+ */
198
+ proxyReceivedAt?: Timestamp;
199
+ /**
200
+ * When the proxy sent the request to the upstream provider.
201
+ *
202
+ * @generated from field: google.protobuf.Timestamp upstream_request_started_at = 2;
203
+ */
204
+ upstreamRequestStartedAt?: Timestamp;
205
+ /**
206
+ * When the first response byte arrived from the provider.
207
+ *
208
+ * @generated from field: google.protobuf.Timestamp first_response_byte_at = 3;
209
+ */
210
+ firstResponseByteAt?: Timestamp;
211
+ /**
212
+ * When the last response byte arrived from the provider.
213
+ *
214
+ * @generated from field: google.protobuf.Timestamp last_response_byte_at = 4;
215
+ */
216
+ lastResponseByteAt?: Timestamp;
217
+ /**
218
+ * When the proxy completed its handling.
219
+ *
220
+ * @generated from field: google.protobuf.Timestamp proxy_completed_at = 5;
221
+ */
222
+ proxyCompletedAt?: Timestamp;
223
+ /**
224
+ * Derived durations in milliseconds.
225
+ *
226
+ * @generated from field: int64 upstream_ttfb_ms = 10;
227
+ */
228
+ upstreamTtfbMs: bigint;
229
+ /**
230
+ * @generated from field: int64 upstream_ttlb_ms = 11;
231
+ */
232
+ upstreamTtlbMs: bigint;
233
+ /**
234
+ * @generated from field: int64 stream_duration_ms = 12;
235
+ */
236
+ streamDurationMs: bigint;
237
+ /**
238
+ * @generated from field: int64 proxy_total_duration_ms = 13;
239
+ */
240
+ proxyTotalDurationMs: bigint;
241
+ /**
242
+ * Transfer sizes.
243
+ *
244
+ * @generated from field: int64 request_bytes = 20;
245
+ */
246
+ requestBytes: bigint;
247
+ /**
248
+ * @generated from field: int64 response_bytes = 21;
249
+ */
250
+ responseBytes: bigint;
251
+ };
252
+ /**
253
+ * Describes the message ai.stigmer.agentic.agentexecution.v1.ProxyTiming.
254
+ * Use `create(ProxyTimingSchema)` to create a new message.
255
+ */
256
+ export declare const ProxyTimingSchema: GenMessage<ProxyTiming>;
257
+ /**
258
+ * Links a usage record to its billing debit in the credit ledger.
37
259
  *
38
- * ## Cost Computation
260
+ * @generated from message ai.stigmer.agentic.agentexecution.v1.BillingLink
261
+ */
262
+ export type BillingLink = Message<"ai.stigmer.agentic.agentexecution.v1.BillingLink"> & {
263
+ /**
264
+ * Current debit status.
265
+ *
266
+ * @generated from field: ai.stigmer.agentic.agentexecution.v1.BillingDebitStatus debit_status = 1;
267
+ */
268
+ debitStatus: BillingDebitStatus;
269
+ /**
270
+ * Execution reservation ID (from authorizeExecution).
271
+ *
272
+ * @generated from field: string reservation_id = 2;
273
+ */
274
+ reservationId: string;
275
+ /**
276
+ * Billing ledger debit ID (from reportLlmCallUsage).
277
+ *
278
+ * @generated from field: string billing_debit_id = 3;
279
+ */
280
+ billingDebitId: string;
281
+ /**
282
+ * When the debit was applied.
283
+ *
284
+ * @generated from field: google.protobuf.Timestamp debited_at = 4;
285
+ */
286
+ debitedAt?: Timestamp;
287
+ /**
288
+ * Operational visibility.
289
+ *
290
+ * @generated from field: int32 billing_attempt_count = 5;
291
+ */
292
+ billingAttemptCount: number;
293
+ /**
294
+ * @generated from field: string last_billing_error = 6;
295
+ */
296
+ lastBillingError: string;
297
+ };
298
+ /**
299
+ * Describes the message ai.stigmer.agentic.agentexecution.v1.BillingLink.
300
+ * Use `create(BillingLinkSchema)` to create a new message.
301
+ */
302
+ export declare const BillingLinkSchema: GenMessage<BillingLink>;
303
+ /**
304
+ * Immutable, billing-authoritative record for a single LLM API call.
39
305
  *
40
- * estimated_cost_usd is computed at execution time using pricing rates stamped
41
- * on each ModelUsage entry. This makes historical data self-contained — an
42
- * execution from January 2026 carries January 2026 rates even if prices change.
306
+ * Written by the proxy after each SSE stream completes (cloud mode) or by
307
+ * the runner directly (OSS mode). Stored in the `llm_call_usage_record`
308
+ * MongoDB collection, never embedded in the execution document.
43
309
  *
44
- * ## Model Tracking
310
+ * ## Lifecycle
311
+ * 1. Proxy observes SSE stream completion and extracts final usage
312
+ * 2. Server inserts LlmCallUsageRecord (idempotent by idempotency_key)
313
+ * 3. Server computes cost and triggers billing debit
314
+ * 4. billing_link.debit_status transitions to DEBITED
45
315
  *
46
- * primary_model reflects the configured model from ExecutionConfig.model_name.
47
- * When model is auto-selected or varies per call, this captures the first/main model used.
48
- * model_breakdown provides per-model detail when multiple models are used.
316
+ * ## Idempotency
317
+ * Unique on (execution_id, sequence, metering_source). Insert-only; never mutated
318
+ * except for billing_link status transitions.
49
319
  *
50
- * @generated from message ai.stigmer.agentic.agentexecution.v1.UsageMetrics
320
+ * @generated from message ai.stigmer.agentic.agentexecution.v1.LlmCallUsageRecord
51
321
  */
52
- export type UsageMetrics = Message<"ai.stigmer.agentic.agentexecution.v1.UsageMetrics"> & {
322
+ export type LlmCallUsageRecord = Message<"ai.stigmer.agentic.agentexecution.v1.LlmCallUsageRecord"> & {
53
323
  /**
54
- * Total input tokens (prompts) consumed across all LLM calls in this context.
55
- * Includes all input token types: regular, cache writes, and cache reads.
56
- * Accumulated from each on_chat_model_end event's usage_metadata.input_tokens.
324
+ * ─── Identity ───────────────────────────────────────────────────────────────
325
+ * Stable unique ID for this record (ULID).
57
326
  *
58
- * @generated from field: int32 prompt_tokens = 1;
327
+ * @generated from field: string usage_record_id = 1;
59
328
  */
60
- promptTokens: number;
329
+ usageRecordId: string;
61
330
  /**
62
- * Total output tokens (completions) generated across all LLM calls in this context.
63
- * Accumulated from each on_chat_model_end event's usage_metadata.output_tokens.
331
+ * Execution this call belongs to.
64
332
  *
65
- * @generated from field: int32 completion_tokens = 2;
333
+ * @generated from field: string execution_id = 2;
66
334
  */
67
- completionTokens: number;
335
+ executionId: string;
68
336
  /**
69
- * Total tokens (prompt + completion). Convenience field for quick reference.
70
- * Equals: prompt_tokens + completion_tokens
337
+ * For sub-agent rollups: root execution of the tree.
71
338
  *
72
- * @generated from field: int32 total_tokens = 3;
339
+ * @generated from field: string root_execution_id = 3;
73
340
  */
74
- totalTokens: number;
341
+ rootExecutionId: string;
75
342
  /**
76
- * Number of LLM API calls made in this context.
77
- * Incremented for each on_chat_model_end event.
78
- * Useful for: average tokens per call, call frequency analysis.
343
+ * 1-based call ordering within the execution.
79
344
  *
80
- * @generated from field: int32 llm_call_count = 4;
345
+ * @generated from field: int32 sequence = 4;
81
346
  */
82
- llmCallCount: number;
347
+ sequence: number;
83
348
  /**
84
- * Primary model used for this execution.
85
- * Typically matches ExecutionConfig.model_name or the first model detected.
86
- * Examples: "claude-sonnet-4-20250514", "gpt-4o", "gemini-1.5-pro"
349
+ * Deduplication key: execution_id + sequence + metering_source.
87
350
  *
88
- * @generated from field: string primary_model = 5;
351
+ * @generated from field: string idempotency_key = 5;
89
352
  */
90
- primaryModel: string;
353
+ idempotencyKey: string;
354
+ /**
355
+ * Hash of normalized payload for conflict detection on retries.
356
+ *
357
+ * @generated from field: string canonical_payload_hash = 6;
358
+ */
359
+ canonicalPayloadHash: string;
91
360
  /**
92
- * Tokens written to provider prompt cache across all LLM calls.
93
- * Anthropic: cache_creation_input_tokens (billed at 1.25x input rate)
94
- * OpenAI: N/A (caching is automatic, no separate write metric)
95
- * Zero if prompt caching is not active or not supported by provider.
361
+ * ─── Timestamps ─────────────────────────────────────────────────────────────
362
+ * When the proxy observed stream completion.
96
363
  *
97
- * @generated from field: int32 cache_creation_tokens = 6;
364
+ * @generated from field: google.protobuf.Timestamp observed_at = 10;
98
365
  */
99
- cacheCreationTokens: number;
366
+ observedAt?: Timestamp;
100
367
  /**
101
- * Tokens read from provider prompt cache (cache hits) across all LLM calls.
102
- * Anthropic: cache_read_input_tokens (billed at 0.1x input rate)
103
- * OpenAI: prompt_tokens_details.cached_tokens (billed at 0.5x input rate)
104
- * Zero if no cache hits occurred.
368
+ * When this record was created in the database.
105
369
  *
106
- * @generated from field: int32 cache_read_tokens = 7;
370
+ * @generated from field: google.protobuf.Timestamp created_at = 11;
107
371
  */
108
- cacheReadTokens: number;
372
+ createdAt?: Timestamp;
109
373
  /**
110
- * Breakdown of token usage and cost per model.
111
- * Each entry aggregates all LLM calls for a specific model within this context.
112
- * Used for cost reports: "claude-sonnet-4 used 50K input tokens = $0.15."
374
+ * ─── Trust / Source ─────────────────────────────────────────────────────────
375
+ * Who wrote this record and at what trust level.
113
376
  *
114
- * @generated from field: repeated ai.stigmer.agentic.agentexecution.v1.ModelUsage model_breakdown = 8;
377
+ * @generated from field: ai.stigmer.agentic.agentexecution.v1.UsageMeteringSource metering_source = 20;
378
+ */
379
+ meteringSource: UsageMeteringSource;
380
+ /**
381
+ * @generated from field: ai.stigmer.agentic.agentexecution.v1.UsageTrustLevel trust_level = 21;
382
+ */
383
+ trustLevel: UsageTrustLevel;
384
+ /**
385
+ * @generated from field: ai.stigmer.agentic.agentexecution.v1.UsageCompletionStatus usage_status = 22;
115
386
  */
116
- modelBreakdown: ModelUsage[];
387
+ usageStatus: UsageCompletionStatus;
117
388
  /**
118
- * Total estimated cost in USD for this execution context.
119
- * Computed at execution time using the pricing rates stamped on each ModelUsage.
120
- * Equals: sum(model_breakdown[].estimated_cost_usd)
389
+ * Whether this record should produce a billing debit.
121
390
  *
122
- * Captured at write time because pricing changes over time — storing the
123
- * computed cost makes historical data self-contained and accurate without
124
- * needing a pricing history table.
391
+ * @generated from field: bool is_billable = 23;
392
+ */
393
+ isBillable: boolean;
394
+ /**
395
+ * ─── Provider / Request Metadata ────────────────────────────────────────────
125
396
  *
126
- * @generated from field: double estimated_cost_usd = 9;
397
+ * @generated from field: string provider = 30;
398
+ */
399
+ provider: string;
400
+ /**
401
+ * @generated from field: string requested_model = 31;
402
+ */
403
+ requestedModel: string;
404
+ /**
405
+ * @generated from field: string resolved_model = 32;
406
+ */
407
+ resolvedModel: string;
408
+ /**
409
+ * @generated from field: string endpoint = 33;
410
+ */
411
+ endpoint: string;
412
+ /**
413
+ * @generated from field: bool streaming = 34;
414
+ */
415
+ streaming: boolean;
416
+ /**
417
+ * @generated from field: string service_tier = 35;
418
+ */
419
+ serviceTier: string;
420
+ /**
421
+ * @generated from field: string provider_request_id = 36;
422
+ */
423
+ providerRequestId: string;
424
+ /**
425
+ * @generated from field: string harness = 37;
426
+ */
427
+ harness: string;
428
+ /**
429
+ * @generated from field: int32 http_status_code = 40;
127
430
  */
128
- estimatedCostUsd: number;
431
+ httpStatusCode: number;
129
432
  /**
130
- * Total characters truncated from tool results during this execution.
131
- * Non-zero indicates the agent received tool outputs that exceeded the
132
- * configured max_tool_result_chars limit.
133
- * Useful for: tuning truncation limits, identifying verbose tools.
433
+ * @generated from field: string finish_reason = 41;
434
+ */
435
+ finishReason: string;
436
+ /**
437
+ * @generated from field: string error_code = 42;
438
+ */
439
+ errorCode: string;
440
+ /**
441
+ * ─── Token Usage ────────────────────────────────────────────────────────────
134
442
  *
135
- * @generated from field: int64 tool_result_chars_truncated = 10;
443
+ * @generated from field: ai.stigmer.agentic.agentexecution.v1.TokenUsage tokens = 50;
136
444
  */
137
- toolResultCharsTruncated: bigint;
445
+ tokens?: TokenUsage;
138
446
  /**
139
- * Per-call breakdown of every LLM API call in this context.
140
- * Ordered chronologically (call 1, call 2, ...).
141
- * Enables debugging expensive calls, tracking token growth across calls,
142
- * and verifying cache hit patterns.
447
+ * ─── Cost ───────────────────────────────────────────────────────────────────
143
448
  *
144
- * This is the detailed view model_breakdown is the per-model aggregate.
145
- * Both are populated: model_breakdown for reports, llm_calls for debugging.
449
+ * @generated from field: ai.stigmer.agentic.agentexecution.v1.CostStamp cost = 51;
450
+ */
451
+ cost?: CostStamp;
452
+ /**
453
+ * ─── Proxy Timing ──────────────────────────────────────────────────────────
454
+ * Present when metering_source is PROXY_PROVIDER_REPORTED.
146
455
  *
147
- * @generated from field: repeated ai.stigmer.agentic.agentexecution.v1.LlmCallMetrics llm_calls = 11;
456
+ * @generated from field: ai.stigmer.agentic.agentexecution.v1.ProxyTiming proxy_timing = 60;
148
457
  */
149
- llmCalls: LlmCallMetrics[];
458
+ proxyTiming?: ProxyTiming;
150
459
  /**
151
- * Total wall-clock duration of the execution in milliseconds.
152
- * Convenience field equivalent to (completed_at - started_at).
153
- * Includes all time: LLM calls, tool execution, approval waits, overhead.
460
+ * ─── Raw Provider Usage ─────────────────────────────────────────────────────
461
+ * Compact JSON of provider's raw usage object for audit/debug.
154
462
  *
155
- * @generated from field: int32 total_duration_ms = 12;
463
+ * @generated from field: string provider_usage_json = 70;
156
464
  */
157
- totalDurationMs: number;
465
+ providerUsageJson: string;
158
466
  /**
159
- * Time spent waiting for LLM responses in milliseconds.
160
- * Sum of all LLM call durations (llm_calls[].duration_ms).
161
- * Directly correlates with token generation cost.
467
+ * ─── Billing Handoff ────────────────────────────────────────────────────────
162
468
  *
163
- * @generated from field: int32 llm_duration_ms = 13;
469
+ * @generated from field: ai.stigmer.agentic.agentexecution.v1.BillingLink billing = 80;
164
470
  */
165
- llmDurationMs: number;
471
+ billing?: BillingLink;
166
472
  /**
167
- * Time spent executing tools in milliseconds.
168
- * Sum of all tool execution durations (tool start to tool complete).
169
- * Represents compute resource usage in the sandbox.
473
+ * Organization that owns this execution.
170
474
  *
171
- * @generated from field: int32 tool_duration_ms = 14;
475
+ * @generated from field: string org_id = 7;
172
476
  */
173
- toolDurationMs: number;
477
+ orgId: string;
174
478
  /**
175
- * Time spent waiting for user approval in milliseconds.
176
- * Sum of all approval wait times (approval_requested_at to approval_decided_at).
177
- * This is idle time — no LLM or compute resources consumed.
178
- * Useful for excluding from "active execution cost" calculations.
479
+ * Session this execution belongs to.
179
480
  *
180
- * @generated from field: int32 approval_wait_duration_ms = 15;
481
+ * @generated from field: string session_id = 8;
181
482
  */
182
- approvalWaitDurationMs: number;
483
+ sessionId: string;
183
484
  /**
184
- * Provider that served the primary model.
185
- * Examples: "anthropic", "openai", "google", "ollama", "aws-bedrock"
186
- * Matches the provider field in model_breakdown for the primary model.
187
- * Useful for quick display without diving into model_breakdown.
485
+ * ─── Labels ─────────────────────────────────────────────────────────────────
486
+ * Custom metadata for filtering (e.g., agent_path, node_path).
188
487
  *
189
- * @generated from field: string primary_provider = 16;
488
+ * @generated from field: map<string, string> labels = 90;
190
489
  */
191
- primaryProvider: string;
490
+ labels: {
491
+ [key: string]: string;
492
+ };
192
493
  };
193
494
  /**
194
- * Describes the message ai.stigmer.agentic.agentexecution.v1.UsageMetrics.
195
- * Use `create(UsageMetricsSchema)` to create a new message.
495
+ * Describes the message ai.stigmer.agentic.agentexecution.v1.LlmCallUsageRecord.
496
+ * Use `create(LlmCallUsageRecordSchema)` to create a new message.
196
497
  */
197
- export declare const UsageMetricsSchema: GenMessage<UsageMetrics>;
498
+ export declare const LlmCallUsageRecordSchema: GenMessage<LlmCallUsageRecord>;
198
499
  /**
199
- * ModelUsage captures token usage and cost for a single model within an execution.
200
- * Provides the per-model breakdown needed for accurate cost calculation when
201
- * multiple models are used (e.g., main model + summarization model).
202
- *
203
- * ## Token Bucket Design
204
- *
205
- * The four token fields (input_tokens, output_tokens, cache_creation_tokens,
206
- * cache_read_tokens) are disjoint, non-overlapping buckets. Every token falls
207
- * into exactly one bucket, making cost calculation straightforward:
208
- * cost = (input_tokens * input_price / 1M)
209
- * + (output_tokens * output_price / 1M)
210
- * + (cache_creation_tokens * cache_creation_price / 1M)
211
- * + (cache_read_tokens * cache_read_price / 1M)
212
- *
213
- * ## input_tokens Semantics
500
+ * Aggregated usage across a scope (execution, session, agent, or org).
214
501
  *
215
- * input_tokens represents regular (non-cached) input tokens only tokens
216
- * billed at the standard input rate. This follows the Anthropic provider
217
- * convention where input_tokens excludes cache tokens.
502
+ * Used as the `total_usage` field in session and agent usage report responses.
503
+ * All token fields are int64 to support large aggregates (org-wide, multi-day).
504
+ * Cost fields are int64 micro-USD for precision.
218
505
  *
219
- * Total input for this model = input_tokens + cache_creation_tokens + cache_read_tokens
220
- *
221
- * ## Pricing Rates
506
+ * @generated from message ai.stigmer.agentic.agentexecution.v1.UsageReportAggregate
507
+ */
508
+ export type UsageReportAggregate = Message<"ai.stigmer.agentic.agentexecution.v1.UsageReportAggregate"> & {
509
+ /**
510
+ * Token counts.
511
+ *
512
+ * @generated from field: int64 input_tokens = 1;
513
+ */
514
+ inputTokens: bigint;
515
+ /**
516
+ * @generated from field: int64 output_tokens = 2;
517
+ */
518
+ outputTokens: bigint;
519
+ /**
520
+ * @generated from field: int64 total_tokens = 3;
521
+ */
522
+ totalTokens: bigint;
523
+ /**
524
+ * @generated from field: int64 cache_creation_input_tokens = 4;
525
+ */
526
+ cacheCreationInputTokens: bigint;
527
+ /**
528
+ * @generated from field: int64 cache_read_input_tokens = 5;
529
+ */
530
+ cacheReadInputTokens: bigint;
531
+ /**
532
+ * @generated from field: int64 reasoning_tokens = 6;
533
+ */
534
+ reasoningTokens: bigint;
535
+ /**
536
+ * Number of LLM API calls in this aggregate.
537
+ *
538
+ * @generated from field: int32 llm_call_count = 10;
539
+ */
540
+ llmCallCount: number;
541
+ /**
542
+ * Cost in micro-USD (1 USD = 1,000,000 micros).
543
+ * billable = what the customer pays (with markup).
544
+ * provider = what Stigmer pays the LLM provider (raw).
545
+ *
546
+ * @generated from field: int64 billable_cost_micros = 20;
547
+ */
548
+ billableCostMicros: bigint;
549
+ /**
550
+ * @generated from field: int64 provider_cost_micros = 21;
551
+ */
552
+ providerCostMicros: bigint;
553
+ /**
554
+ * Primary model and provider (most-used by call count).
555
+ *
556
+ * @generated from field: string primary_model = 30;
557
+ */
558
+ primaryModel: string;
559
+ /**
560
+ * @generated from field: string primary_provider = 31;
561
+ */
562
+ primaryProvider: string;
563
+ };
564
+ /**
565
+ * Describes the message ai.stigmer.agentic.agentexecution.v1.UsageReportAggregate.
566
+ * Use `create(UsageReportAggregateSchema)` to create a new message.
567
+ */
568
+ export declare const UsageReportAggregateSchema: GenMessage<UsageReportAggregate>;
569
+ /**
570
+ * Per-model usage breakdown within a report scope.
222
571
  *
223
- * Pricing fields are stamped at execution time from the Model Pricing Registry.
224
- * This makes historical data self-contained: an execution from January 2026
225
- * carries January 2026 rates even if provider pricing changes later.
572
+ * Groups token counts and cost by (model, provider) pair. Used in
573
+ * model_breakdown repeated fields on report responses.
226
574
  *
227
575
  * @generated from message ai.stigmer.agentic.agentexecution.v1.ModelUsage
228
576
  */
229
577
  export type ModelUsage = Message<"ai.stigmer.agentic.agentexecution.v1.ModelUsage"> & {
230
578
  /**
231
- * Model identifier as returned by the provider.
232
- * Example: "claude-sonnet-4-20250514", "gpt-4o-2024-08-06"
579
+ * Model identifier as resolved by the provider.
233
580
  *
234
581
  * @generated from field: string model = 1;
235
582
  */
236
583
  model: string;
237
584
  /**
238
- * Provider identifier. Determines which pricing table to use.
239
- * Examples: "anthropic", "openai", "google", "ollama", "aws-bedrock"
585
+ * LLM provider (e.g., "openai", "anthropic", "cursor").
240
586
  *
241
587
  * @generated from field: string provider = 2;
242
588
  */
243
589
  provider: string;
244
590
  /**
245
- * Regular input tokens (non-cached) billed at the standard input rate.
246
- * Anthropic: input_tokens (excludes cache tokens)
247
- * OpenAI: prompt_tokens - cached_tokens
591
+ * Token counts for this model.
248
592
  *
249
- * Total input = input_tokens + cache_creation_tokens + cache_read_tokens
593
+ * @generated from field: int64 input_tokens = 3;
594
+ */
595
+ inputTokens: bigint;
596
+ /**
597
+ * @generated from field: int64 output_tokens = 4;
598
+ */
599
+ outputTokens: bigint;
600
+ /**
601
+ * @generated from field: int64 cache_creation_input_tokens = 5;
602
+ */
603
+ cacheCreationInputTokens: bigint;
604
+ /**
605
+ * @generated from field: int64 cache_read_input_tokens = 6;
606
+ */
607
+ cacheReadInputTokens: bigint;
608
+ /**
609
+ * Number of LLM API calls to this model.
250
610
  *
251
- * @generated from field: int32 input_tokens = 3;
611
+ * @generated from field: int32 call_count = 7;
252
612
  */
253
- inputTokens: number;
613
+ callCount: number;
254
614
  /**
255
- * Output tokens generated by the model.
615
+ * Cost in micro-USD for this model.
256
616
  *
257
- * @generated from field: int32 output_tokens = 4;
617
+ * @generated from field: int64 billable_cost_micros = 8;
258
618
  */
259
- outputTokens: number;
619
+ billableCostMicros: bigint;
260
620
  /**
261
- * Tokens written to prompt cache during this execution.
262
- * Anthropic: cache_creation_input_tokens (billed at 1.25x input rate)
263
- * OpenAI: N/A (caching is automatic, no separate write metric)
621
+ * @generated from field: int64 provider_cost_micros = 9;
622
+ */
623
+ providerCostMicros: bigint;
624
+ };
625
+ /**
626
+ * Describes the message ai.stigmer.agentic.agentexecution.v1.ModelUsage.
627
+ * Use `create(ModelUsageSchema)` to create a new message.
628
+ */
629
+ export declare const ModelUsageSchema: GenMessage<ModelUsage>;
630
+ /**
631
+ * Identifies who wrote the usage record and under what conditions.
632
+ *
633
+ * @generated from enum ai.stigmer.agentic.agentexecution.v1.UsageMeteringSource
634
+ */
635
+ export declare enum UsageMeteringSource {
636
+ /**
637
+ * @generated from enum value: USAGE_METERING_SOURCE_UNSPECIFIED = 0;
638
+ */
639
+ UNSPECIFIED = 0,
640
+ /**
641
+ * Cloud mode: Stigmer proxy observed provider-reported final usage from SSE stream.
264
642
  *
265
- * @generated from field: int32 cache_creation_tokens = 5;
643
+ * @generated from enum value: USAGE_METERING_SOURCE_PROXY_PROVIDER_REPORTED = 1;
266
644
  */
267
- cacheCreationTokens: number;
645
+ PROXY_PROVIDER_REPORTED = 1,
268
646
  /**
269
- * Tokens read from prompt cache (cache hits).
270
- * Anthropic: cache_read_input_tokens (billed at 0.1x input rate)
271
- * OpenAI: prompt_tokens_details.cached_tokens (billed at 0.5x input rate)
647
+ * OSS/BYOK mode: runner reports provider response usage directly.
272
648
  *
273
- * @generated from field: int32 cache_read_tokens = 6;
649
+ * @generated from enum value: USAGE_METERING_SOURCE_RUNNER_PROVIDER_REPORTED_OSS = 2;
274
650
  */
275
- cacheReadTokens: number;
651
+ RUNNER_PROVIDER_REPORTED_OSS = 2,
276
652
  /**
277
- * Number of LLM API calls made with this model.
653
+ * Estimate from tokenizer/preflight/local accounting. Never billing-authoritative in cloud mode.
278
654
  *
279
- * @generated from field: int32 call_count = 7;
655
+ * @generated from enum value: USAGE_METERING_SOURCE_ESTIMATED = 3;
280
656
  */
281
- callCount: number;
657
+ ESTIMATED = 3,
282
658
  /**
283
- * Input token price per million tokens (USD) at execution time.
659
+ * Reconciliation from provider admin usage/cost reports.
284
660
  *
285
- * @generated from field: double input_price_per_million = 8;
661
+ * @generated from enum value: USAGE_METERING_SOURCE_PROVIDER_ADMIN_RECONCILED = 4;
286
662
  */
287
- inputPricePerMillion: number;
663
+ PROVIDER_ADMIN_RECONCILED = 4,
288
664
  /**
289
- * Output token price per million tokens (USD) at execution time.
665
+ * Human/system manual adjustment.
290
666
  *
291
- * @generated from field: double output_price_per_million = 9;
667
+ * @generated from enum value: USAGE_METERING_SOURCE_MANUAL_ADJUSTMENT = 5;
668
+ */
669
+ MANUAL_ADJUSTMENT = 5
670
+ }
671
+ /**
672
+ * Describes the enum ai.stigmer.agentic.agentexecution.v1.UsageMeteringSource.
673
+ */
674
+ export declare const UsageMeteringSourceSchema: GenEnum<UsageMeteringSource>;
675
+ /**
676
+ * Declares what the record can be used for.
677
+ *
678
+ * @generated from enum ai.stigmer.agentic.agentexecution.v1.UsageTrustLevel
679
+ */
680
+ export declare enum UsageTrustLevel {
681
+ /**
682
+ * @generated from enum value: USAGE_TRUST_LEVEL_UNSPECIFIED = 0;
292
683
  */
293
- outputPricePerMillion: number;
684
+ UNSPECIFIED = 0,
294
685
  /**
295
- * Cache write token price per million tokens (USD) at execution time.
296
- * Anthropic: 1.25x of input_price. OpenAI: same as input.
686
+ * Billing-authoritative: safe to debit credits from.
297
687
  *
298
- * @generated from field: double cache_creation_price_per_million = 10;
688
+ * @generated from enum value: USAGE_TRUST_LEVEL_BILLING_AUTHORITY = 1;
299
689
  */
300
- cacheCreationPricePerMillion: number;
690
+ BILLING_AUTHORITY = 1,
301
691
  /**
302
- * Cache read token price per million tokens (USD) at execution time.
303
- * Anthropic: 0.1x of input_price. OpenAI: 0.5x of input_price.
692
+ * Server-observed but not billing (e.g., proxy timing).
304
693
  *
305
- * @generated from field: double cache_read_price_per_million = 11;
694
+ * @generated from enum value: USAGE_TRUST_LEVEL_SERVER_OBSERVED = 2;
306
695
  */
307
- cacheReadPricePerMillion: number;
696
+ SERVER_OBSERVED = 2,
308
697
  /**
309
- * Computed cost in USD for this model's usage in this execution.
310
- * = (input_tokens * input_price / 1M)
311
- * + (output_tokens * output_price / 1M)
312
- * + (cache_creation_tokens * cache_creation_price / 1M)
313
- * + (cache_read_tokens * cache_read_price / 1M)
698
+ * Display-only: runner-reported, never used for billing.
314
699
  *
315
- * @generated from field: double estimated_cost_usd = 12;
700
+ * @generated from enum value: USAGE_TRUST_LEVEL_DISPLAY_ONLY = 3;
316
701
  */
317
- estimatedCostUsd: number;
318
- };
702
+ DISPLAY_ONLY = 3
703
+ }
319
704
  /**
320
- * Describes the message ai.stigmer.agentic.agentexecution.v1.ModelUsage.
321
- * Use `create(ModelUsageSchema)` to create a new message.
705
+ * Describes the enum ai.stigmer.agentic.agentexecution.v1.UsageTrustLevel.
322
706
  */
323
- export declare const ModelUsageSchema: GenMessage<ModelUsage>;
707
+ export declare const UsageTrustLevelSchema: GenEnum<UsageTrustLevel>;
324
708
  /**
325
- * Metrics for a single LLM API call during execution.
326
- * Provides per-call granularity for debugging, optimization, and cost attribution.
327
- *
328
- * One entry is created for each on_chat_model_end event.
329
- * Ordered chronologically — the Nth entry corresponds to the Nth LLM call.
330
- *
331
- * ## Cache Verification
332
- *
333
- * Especially valuable for verifying prompt caching: you expect call 1 to be a
334
- * cache miss (or cache write), and calls 2+ to have high cache_read_tokens.
335
- * If they don't, something is wrong with cache breakpoint placement.
709
+ * Status of provider-reported token usage extraction.
336
710
  *
337
- * ## Size Consideration
338
- *
339
- * A typical execution has 3-15 LLM calls. Each LlmCallMetrics is ~10 fields /
340
- * ~80 bytes. Even a 50-call execution adds only ~4KB — negligible compared to
341
- * the messages[] and tool_calls[] arrays which carry full content strings.
711
+ * @generated from enum ai.stigmer.agentic.agentexecution.v1.UsageCompletionStatus
712
+ */
713
+ export declare enum UsageCompletionStatus {
714
+ /**
715
+ * @generated from enum value: USAGE_COMPLETION_STATUS_UNSPECIFIED = 0;
716
+ */
717
+ UNSPECIFIED = 0,
718
+ /**
719
+ * Provider reported complete final usage (normal case).
720
+ *
721
+ * @generated from enum value: USAGE_COMPLETION_STATUS_COMPLETE = 1;
722
+ */
723
+ COMPLETE = 1,
724
+ /**
725
+ * Stream ended without final usage event (e.g., connection interrupted).
726
+ *
727
+ * @generated from enum value: USAGE_COMPLETION_STATUS_STREAM_INTERRUPTED = 2;
728
+ */
729
+ STREAM_INTERRUPTED = 2,
730
+ /**
731
+ * Provider returned error but included partial usage data.
732
+ *
733
+ * @generated from enum value: USAGE_COMPLETION_STATUS_PROVIDER_ERROR_WITH_USAGE = 3;
734
+ */
735
+ PROVIDER_ERROR_WITH_USAGE = 3,
736
+ /**
737
+ * Provider returned error with no usage data.
738
+ *
739
+ * @generated from enum value: USAGE_COMPLETION_STATUS_PROVIDER_ERROR_NO_USAGE = 4;
740
+ */
741
+ PROVIDER_ERROR_NO_USAGE = 4,
742
+ /**
743
+ * Usage is estimated (tokenizer/preflight), not provider-reported.
744
+ *
745
+ * @generated from enum value: USAGE_COMPLETION_STATUS_ESTIMATED_ONLY = 5;
746
+ */
747
+ ESTIMATED_ONLY = 5,
748
+ /**
749
+ * Reconciled against provider admin reports.
750
+ *
751
+ * @generated from enum value: USAGE_COMPLETION_STATUS_RECONCILED = 6;
752
+ */
753
+ RECONCILED = 6,
754
+ /**
755
+ * Conflict: retry with different payload detected.
756
+ *
757
+ * @generated from enum value: USAGE_COMPLETION_STATUS_CONFLICT = 7;
758
+ */
759
+ CONFLICT = 7
760
+ }
761
+ /**
762
+ * Describes the enum ai.stigmer.agentic.agentexecution.v1.UsageCompletionStatus.
763
+ */
764
+ export declare const UsageCompletionStatusSchema: GenEnum<UsageCompletionStatus>;
765
+ /**
766
+ * Status of the billing debit for a usage record.
342
767
  *
343
- * @generated from message ai.stigmer.agentic.agentexecution.v1.LlmCallMetrics
768
+ * @generated from enum ai.stigmer.agentic.agentexecution.v1.BillingDebitStatus
344
769
  */
345
- export type LlmCallMetrics = Message<"ai.stigmer.agentic.agentexecution.v1.LlmCallMetrics"> & {
770
+ export declare enum BillingDebitStatus {
346
771
  /**
347
- * Sequence number of this LLM call within the execution (1-based).
772
+ * @generated from enum value: BILLING_DEBIT_STATUS_UNSPECIFIED = 0;
773
+ */
774
+ UNSPECIFIED = 0,
775
+ /**
776
+ * No billing applicable (e.g., OSS mode, $0 cost, incomplete usage).
348
777
  *
349
- * @generated from field: int32 sequence = 1;
778
+ * @generated from enum value: BILLING_DEBIT_STATUS_NOT_APPLICABLE = 1;
350
779
  */
351
- sequence: number;
780
+ NOT_APPLICABLE = 1,
352
781
  /**
353
- * Model used for this specific call.
354
- * May differ from primary_model if model fallback or routing occurred.
782
+ * Debit pending (usage written, billing not yet attempted).
355
783
  *
356
- * @generated from field: string model = 2;
784
+ * @generated from enum value: BILLING_DEBIT_STATUS_PENDING = 2;
357
785
  */
358
- model: string;
786
+ PENDING = 2,
359
787
  /**
360
- * Provider for this call.
788
+ * Credits successfully debited.
361
789
  *
362
- * @generated from field: string provider = 3;
790
+ * @generated from enum value: BILLING_DEBIT_STATUS_DEBITED = 3;
363
791
  */
364
- provider: string;
792
+ DEBITED = 3,
365
793
  /**
366
- * Input tokens for this call (total prompt size sent to the model).
794
+ * Debit failed but retryable (transient error).
367
795
  *
368
- * @generated from field: int32 input_tokens = 4;
796
+ * @generated from enum value: BILLING_DEBIT_STATUS_FAILED_RETRYABLE = 4;
369
797
  */
370
- inputTokens: number;
798
+ FAILED_RETRYABLE = 4,
371
799
  /**
372
- * Output tokens generated by the model in this call.
800
+ * Debit failed terminally (e.g., no reservation found).
373
801
  *
374
- * @generated from field: int32 output_tokens = 5;
802
+ * @generated from enum value: BILLING_DEBIT_STATUS_FAILED_TERMINAL = 5;
375
803
  */
376
- outputTokens: number;
804
+ FAILED_TERMINAL = 5,
377
805
  /**
378
- * Cache tokens written during this call.
806
+ * Conflict detected (duplicate with different payload).
379
807
  *
380
- * @generated from field: int32 cache_creation_tokens = 6;
808
+ * @generated from enum value: BILLING_DEBIT_STATUS_CONFLICT = 6;
381
809
  */
382
- cacheCreationTokens: number;
810
+ CONFLICT = 6
811
+ }
812
+ /**
813
+ * Describes the enum ai.stigmer.agentic.agentexecution.v1.BillingDebitStatus.
814
+ */
815
+ export declare const BillingDebitStatusSchema: GenEnum<BillingDebitStatus>;
816
+ /**
817
+ * Status of cost calculation for a usage record.
818
+ *
819
+ * @generated from enum ai.stigmer.agentic.agentexecution.v1.CostCalculationStatus
820
+ */
821
+ export declare enum CostCalculationStatus {
822
+ /**
823
+ * @generated from enum value: COST_CALCULATION_STATUS_UNSPECIFIED = 0;
824
+ */
825
+ UNSPECIFIED = 0,
383
826
  /**
384
- * Cache tokens read (cache hits) during this call.
827
+ * Cost computed from pricing registry at write time.
385
828
  *
386
- * @generated from field: int32 cache_read_tokens = 7;
829
+ * @generated from enum value: COST_CALCULATION_STATUS_COMPUTED = 1;
387
830
  */
388
- cacheReadTokens: number;
831
+ COMPUTED = 1,
389
832
  /**
390
- * Computed cost in USD for this single call.
833
+ * Cost is an estimate (model not found in registry).
391
834
  *
392
- * @generated from field: double estimated_cost_usd = 8;
835
+ * @generated from enum value: COST_CALCULATION_STATUS_ESTIMATED = 2;
393
836
  */
394
- estimatedCostUsd: number;
837
+ ESTIMATED = 2,
395
838
  /**
396
- * Wall-clock duration of this LLM call in milliseconds.
397
- * From request sent to response complete.
839
+ * Model pricing not found; cost is zero.
398
840
  *
399
- * @generated from field: int32 duration_ms = 9;
841
+ * @generated from enum value: COST_CALCULATION_STATUS_PRICE_NOT_FOUND = 3;
400
842
  */
401
- durationMs: number;
843
+ PRICE_NOT_FOUND = 3,
402
844
  /**
403
- * ISO 8601 timestamp when this LLM call started.
845
+ * Cost was reconciled against provider reports.
404
846
  *
405
- * @generated from field: string timestamp = 10;
847
+ * @generated from enum value: COST_CALCULATION_STATUS_RECONCILED = 4;
406
848
  */
407
- timestamp: string;
849
+ RECONCILED = 4,
408
850
  /**
409
- * Total tokens involved in this call. Convenience field for quick reference.
410
- * Equals: input_tokens + output_tokens + cache_creation_tokens + cache_read_tokens
411
- * Consistent with UsageMetrics.total_tokens (prompt_tokens + completion_tokens).
851
+ * Cost was manually adjusted.
412
852
  *
413
- * @generated from field: int32 total_tokens = 11;
853
+ * @generated from enum value: COST_CALCULATION_STATUS_MANUAL_ADJUSTED = 5;
414
854
  */
415
- totalTokens: number;
416
- };
855
+ MANUAL_ADJUSTED = 5
856
+ }
417
857
  /**
418
- * Describes the message ai.stigmer.agentic.agentexecution.v1.LlmCallMetrics.
419
- * Use `create(LlmCallMetricsSchema)` to create a new message.
858
+ * Describes the enum ai.stigmer.agentic.agentexecution.v1.CostCalculationStatus.
420
859
  */
421
- export declare const LlmCallMetricsSchema: GenMessage<LlmCallMetrics>;
860
+ export declare const CostCalculationStatusSchema: GenEnum<CostCalculationStatus>;