agentenkit 0.1.5 → 0.2.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 (118) hide show
  1. package/README.md +48 -2
  2. package/dist/adapters/memory.d.ts +2 -2
  3. package/dist/adapters/memory.d.ts.map +1 -1
  4. package/dist/adapters/memory.js +3 -9
  5. package/dist/adapters/memory.js.map +1 -1
  6. package/dist/adapters/prisma.d.ts +61 -18
  7. package/dist/adapters/prisma.d.ts.map +1 -1
  8. package/dist/adapters/prisma.js +65 -16
  9. package/dist/adapters/prisma.js.map +1 -1
  10. package/dist/adapters/sqlite.d.ts +3 -2
  11. package/dist/adapters/sqlite.d.ts.map +1 -1
  12. package/dist/adapters/sqlite.js +82 -11
  13. package/dist/adapters/sqlite.js.map +1 -1
  14. package/dist/admin/default.d.ts +11 -4
  15. package/dist/admin/default.d.ts.map +1 -1
  16. package/dist/admin/default.js +11 -6
  17. package/dist/admin/default.js.map +1 -1
  18. package/dist/admin/memory.d.ts.map +1 -1
  19. package/dist/admin/memory.js +8 -2
  20. package/dist/admin/memory.js.map +1 -1
  21. package/dist/admin/migrations/postgres/0001-init.d.ts +10 -0
  22. package/dist/admin/migrations/postgres/0001-init.d.ts.map +1 -0
  23. package/dist/admin/migrations/postgres/0001-init.js +56 -0
  24. package/dist/admin/migrations/postgres/0001-init.js.map +1 -0
  25. package/dist/admin/migrations/postgres/index.d.ts +9 -0
  26. package/dist/admin/migrations/postgres/index.d.ts.map +1 -0
  27. package/dist/admin/migrations/postgres/index.js +17 -0
  28. package/dist/admin/migrations/postgres/index.js.map +1 -0
  29. package/dist/admin/migrations/runner.d.ts +81 -0
  30. package/dist/admin/migrations/runner.d.ts.map +1 -0
  31. package/dist/admin/migrations/runner.js +137 -0
  32. package/dist/admin/migrations/runner.js.map +1 -0
  33. package/dist/admin/migrations/sqlite/0001-init.d.ts +11 -0
  34. package/dist/admin/migrations/sqlite/0001-init.d.ts.map +1 -0
  35. package/dist/admin/migrations/sqlite/0001-init.js +44 -0
  36. package/dist/admin/migrations/sqlite/0001-init.js.map +1 -0
  37. package/dist/admin/migrations/sqlite/index.d.ts +7 -0
  38. package/dist/admin/migrations/sqlite/index.d.ts.map +1 -0
  39. package/dist/admin/migrations/sqlite/index.js +38 -0
  40. package/dist/admin/migrations/sqlite/index.js.map +1 -0
  41. package/dist/admin/postgres.d.ts +27 -4
  42. package/dist/admin/postgres.d.ts.map +1 -1
  43. package/dist/admin/postgres.js +49 -55
  44. package/dist/admin/postgres.js.map +1 -1
  45. package/dist/admin/sqlite.d.ts +18 -2
  46. package/dist/admin/sqlite.d.ts.map +1 -1
  47. package/dist/admin/sqlite.js +51 -54
  48. package/dist/admin/sqlite.js.map +1 -1
  49. package/dist/core/admin.d.ts +8 -1
  50. package/dist/core/admin.d.ts.map +1 -1
  51. package/dist/core/admin.js +21 -2
  52. package/dist/core/admin.js.map +1 -1
  53. package/dist/core/agent.d.ts +3 -0
  54. package/dist/core/agent.d.ts.map +1 -1
  55. package/dist/core/agent.js +4 -4
  56. package/dist/core/agent.js.map +1 -1
  57. package/dist/core/context.d.ts +5 -0
  58. package/dist/core/context.d.ts.map +1 -1
  59. package/dist/core/context.js +38 -9
  60. package/dist/core/context.js.map +1 -1
  61. package/dist/core/engine.d.ts +4 -1
  62. package/dist/core/engine.d.ts.map +1 -1
  63. package/dist/core/engine.js +93 -20
  64. package/dist/core/engine.js.map +1 -1
  65. package/dist/core/hitl.d.ts.map +1 -1
  66. package/dist/core/hitl.js +6 -0
  67. package/dist/core/hitl.js.map +1 -1
  68. package/dist/core/loop.d.ts +35 -0
  69. package/dist/core/loop.d.ts.map +1 -1
  70. package/dist/core/loop.js +134 -19
  71. package/dist/core/loop.js.map +1 -1
  72. package/dist/core/messages.d.ts +48 -0
  73. package/dist/core/messages.d.ts.map +1 -0
  74. package/dist/core/messages.js +74 -0
  75. package/dist/core/messages.js.map +1 -0
  76. package/dist/core/publish.d.ts +21 -1
  77. package/dist/core/publish.d.ts.map +1 -1
  78. package/dist/core/publish.js +57 -3
  79. package/dist/core/publish.js.map +1 -1
  80. package/dist/core/run.d.ts.map +1 -1
  81. package/dist/core/run.js +44 -4
  82. package/dist/core/run.js.map +1 -1
  83. package/dist/core/stop.d.ts.map +1 -1
  84. package/dist/core/stop.js +42 -0
  85. package/dist/core/stop.js.map +1 -1
  86. package/dist/core/subagent.d.ts +5 -0
  87. package/dist/core/subagent.d.ts.map +1 -1
  88. package/dist/core/subagent.js +23 -10
  89. package/dist/core/subagent.js.map +1 -1
  90. package/dist/core/tools.d.ts +12 -0
  91. package/dist/core/tools.d.ts.map +1 -1
  92. package/dist/core/tools.js.map +1 -1
  93. package/dist/core/types.d.ts +164 -9
  94. package/dist/core/types.d.ts.map +1 -1
  95. package/dist/core/types.js +9 -0
  96. package/dist/core/types.js.map +1 -1
  97. package/dist/core/usage.d.ts +47 -2
  98. package/dist/core/usage.d.ts.map +1 -1
  99. package/dist/core/usage.js +130 -2
  100. package/dist/core/usage.js.map +1 -1
  101. package/dist/index.d.ts +11 -3
  102. package/dist/index.d.ts.map +1 -1
  103. package/dist/index.js +6 -1
  104. package/dist/index.js.map +1 -1
  105. package/dist/ports/admin.d.ts +18 -0
  106. package/dist/ports/admin.d.ts.map +1 -1
  107. package/dist/ports/runtime.d.ts +78 -4
  108. package/dist/ports/runtime.d.ts.map +1 -1
  109. package/dist/ports/storage.d.ts +16 -4
  110. package/dist/ports/storage.d.ts.map +1 -1
  111. package/dist/pricing.d.ts +66 -0
  112. package/dist/pricing.d.ts.map +1 -0
  113. package/dist/pricing.js +98 -0
  114. package/dist/pricing.js.map +1 -0
  115. package/dist/runtime.d.ts.map +1 -1
  116. package/dist/runtime.js +7 -2
  117. package/dist/runtime.js.map +1 -1
  118. package/package.json +1 -1
@@ -84,6 +84,9 @@ export interface RunRecord {
84
84
  prompt?: string | null;
85
85
  tokenBudget?: number | null;
86
86
  runState?: Record<string, unknown> | null;
87
+ /** The provider options the run was dispatched with (§3.1), merged across
88
+ * config, spec and input. Present only when `recordPayloads` is on. */
89
+ providerOptions?: Record<string, unknown> | null;
87
90
  /** A nested run's capped result, handed back to its parent (§2.7). */
88
91
  result?: unknown;
89
92
  }
@@ -95,16 +98,15 @@ export interface NewRunRecord {
95
98
  prompt?: string | null;
96
99
  tokenBudget?: number | null;
97
100
  runState?: Record<string, unknown> | null;
101
+ providerOptions?: Record<string, unknown> | null;
98
102
  /** Defaults to 0 — a dispatched run. */
99
103
  depth?: number;
100
104
  parentRunId?: string | null;
101
105
  }
102
106
  export type RunPatch = Partial<Omit<RunRecord, 'id' | 'threadId'>>;
103
- /** Token attribution only (§4): total tokens used. USD/credit pricing is a
104
- * downstream concern computed over the recorded counters. */
105
- /** Token attribution (§4): the platform records the counters; USD/credit
106
- * pricing is a downstream concern computed over them. */
107
- /** Cumulative token attribution across every run on a thread (§4). */
107
+ /** Cumulative token AND money attribution across every run on a thread (§4).
108
+ * Tokens are what the provider reported; the money is what the Pricer put on
109
+ * each row as it was stored. */
108
110
  export interface UsageTotals {
109
111
  /** Fresh (uncached) prompt tokens. */
110
112
  inputTokens: number;
@@ -113,6 +115,76 @@ export interface UsageTotals {
113
115
  outputTokens: number;
114
116
  /** input + cached + output. */
115
117
  totalTokens: number;
118
+ /** Summed cost in millionths of one `currency` unit: 1_000_000 is one
119
+ * dollar when the currency is USD. */
120
+ costMicros: number;
121
+ /** The unit `costMicros` is in, absent when nothing was priced. One
122
+ * deployment should price in ONE currency: these are summed, not
123
+ * converted. */
124
+ currency?: string;
125
+ /** How many calls had no cost, because no pricer answered for them. Above
126
+ * zero, `costMicros` is a floor and not the whole bill. */
127
+ unpriced: number;
128
+ /** The same spend grouped by agent and model: one line per pair, which is
129
+ * the shape a bill wants. Summing the lines gives the totals above. */
130
+ lines: UsageLine[];
131
+ }
132
+ /** One agent's spend on one model, summed over its calls (§4). This is the
133
+ * bill line a credit system charges for. */
134
+ export interface UsageLine {
135
+ /** null for the main run, the nested run's id otherwise. */
136
+ agentId?: string | null;
137
+ agentName?: string | null;
138
+ /** The registry key; `modelId` is the wire id it resolved to. */
139
+ model?: string | null;
140
+ modelId?: string | null;
141
+ inputTokens: number;
142
+ cacheReadInputTokens: number;
143
+ cacheWriteInputTokens: number;
144
+ outputTokens: number;
145
+ reasoningTokens: number;
146
+ /** How many model calls this line covers. */
147
+ calls: number;
148
+ /** How many of those had estimated tokens, because they were cut off
149
+ * before the provider reported real ones. */
150
+ estimated: number;
151
+ costMicros: number;
152
+ }
153
+ /** Narrows a usage read (§4). */
154
+ export interface UsageFilter {
155
+ /** Limit the read to one dispatched run, nested runs included. Omitted
156
+ * reads the whole thread. */
157
+ runId?: string;
158
+ }
159
+ /** How the model call that produced a usage row ended. */
160
+ export type UsageOutcome =
161
+ /** Ran to its finish; the provider reported the counters itself. */
162
+ 'finished'
163
+ /** A user stop cut the call mid-stream, so no finish arrived and the
164
+ * tokens are estimated. */
165
+ | 'aborted'
166
+ /** The provider failed mid-call. What it had already streamed was still
167
+ * billed, so the row is kept. */
168
+ | 'error';
169
+ /** Which part of the platform made the call. */
170
+ export type UsageKind =
171
+ /** A step of an agent loop, main run or nested (§2.1, §2.7). */
172
+ 'step'
173
+ /** The summary the platform writes to keep the prompt inside the model's
174
+ * window (§2.6). Nobody asked for it, so it is worth being able to see
175
+ * what it costs on its own. */
176
+ | 'compaction';
177
+ /** The money one model call cost. */
178
+ export interface Cost {
179
+ /** Millionths of one `currency` unit: 1_000_000 is one dollar when the
180
+ * currency is USD. Integers, because money summed as a float drifts. */
181
+ micros: number;
182
+ /** ISO-4217 code — 'USD' for the shipped table pricer. */
183
+ currency: string;
184
+ /** Where the number came from: 'receipt' when the provider computed it,
185
+ * 'table' from a price list, 'estimate' for anything a pricer worked out
186
+ * itself. It rides along so a bill can be audited. */
187
+ source: 'receipt' | 'table' | 'estimate';
116
188
  }
117
189
  /** How full the next run's prompt would be (§2.6). Token counts are the same
118
190
  * rough estimate the engine itself compacts on, so the number a user sees is
@@ -127,15 +199,61 @@ export interface ContextUsage {
127
199
  /** Messages currently in the thread, summaries included. */
128
200
  messages: number;
129
201
  }
202
+ /** ONE model call, recorded by the engine after every call it makes: a step
203
+ * of the main run, a step of a nested run, a compaction pass, streamed or
204
+ * not, finished or cut short.
205
+ *
206
+ * It carries everything a Pricer needs to put a price on the call, so pricing
207
+ * never has to reach back into the run to find out what happened. */
130
208
  export interface NewUsage {
209
+ /** The DISPATCHED run this call belongs to (§2.9). A nested run's calls
210
+ * carry their parent's run id, so one run's bill is one query. */
211
+ runId?: string | null;
212
+ /** Whose stream made the call (§2.7): null is the main run, otherwise the
213
+ * nested run's id. */
131
214
  agentId?: string | null;
215
+ /** The registered handle for the main run, the delegation's name for a
216
+ * nested one. What a bill line should say. */
217
+ agentName?: string | null;
218
+ kind: UsageKind;
219
+ /** 1-based iteration inside its loop; 0 for a compaction. */
220
+ step: number;
221
+ /** The registry key the call was made with, e.g. 'claude-sonnet-4@high' —
222
+ * what a price list is usually keyed by. */
223
+ model?: string | null;
224
+ /** The wire id the provider reported back, which can differ from the key
225
+ * that asked for it (an alias, a dated snapshot). */
226
+ modelId?: string | null;
132
227
  /** Fresh (uncached) prompt tokens. */
133
228
  inputTokens: number;
134
229
  /** Prompt tokens served from the provider's prompt cache (§2.6 caching). */
135
- cachedInputTokens: number;
230
+ cacheReadInputTokens: number;
231
+ /** Prompt tokens WRITTEN into that cache — a separate line on the
232
+ * provider's bill, and not part of `totalTokens`. */
233
+ cacheWriteInputTokens: number;
136
234
  outputTokens: number;
137
- /** input + cached + output. */
235
+ /** Thinking tokens. Most providers already count these inside
236
+ * `outputTokens`, so price them at zero unless yours bills them
237
+ * separately (see the pricing module). */
238
+ reasoningTokens: number;
239
+ /** input + cache reads + output: the counter the token budget is measured
240
+ * against. Cache writes and reasoning are deliberately outside it — cache
241
+ * writes are their own bill line, and reasoning tokens are usually already
242
+ * inside the output count. */
138
243
  totalTokens: number;
244
+ outcome: UsageOutcome;
245
+ /** True when no finish arrived and the counters are the platform's own
246
+ * estimate over what it does know: the prompt it sent and the text that did
247
+ * stream, measured the same way compaction measures context fill. */
248
+ estimated?: boolean;
249
+ /** Whatever the provider attached to the finish: a gateway receipt, a
250
+ * generation id, anything a Pricer wants to read. Two reserved keys are
251
+ * added by the platform: `responseId` and `responseHeaders`, because a
252
+ * gateway bills through a header. */
253
+ providerMetadata?: Record<string, unknown> | null;
254
+ /** Filled by the Pricer before the row is stored. Absent means the call
255
+ * went unpriced, and any total over it is a floor. */
256
+ cost?: Cost | null;
139
257
  }
140
258
  /** Additional provider-specific options, passed through to the provider from
141
259
  * the AI SDK. Namespaced per provider — the platform never inspects them. */
@@ -163,6 +281,9 @@ export interface RunJob {
163
281
  * attached — hours later, in another process, after an approval. */
164
282
  state?: AgentRunState;
165
283
  tokenBudget?: number;
284
+ /** The money cap for this run (§4), carried so the worker enforces the same
285
+ * cap the caller asked for. */
286
+ costBudgetMicros?: number;
166
287
  providerOptions?: ProviderOptions;
167
288
  }
168
289
  /** Identifies a nested run well enough to re-enter its loop (§2.7). Persisted
@@ -182,6 +303,7 @@ export interface ResumeInfo {
182
303
  /** The run these segments belong to (§2.9). */
183
304
  runId?: string;
184
305
  tokenBudget?: number;
306
+ costBudgetMicros?: number;
185
307
  providerOptions?: ProviderOptions;
186
308
  /** The run's state (§2.10). A park can outlive the process that made it, so
187
309
  * the state has to travel on the ticket — rebuilt from here, not from a
@@ -195,7 +317,14 @@ export interface ResumeInfo {
195
317
  export interface ResolvedModel {
196
318
  instance: () => LanguageModel;
197
319
  contextWindow?: number;
320
+ /** The wire id this key resolves to, e.g. 'gpt-4o-2024-11-20' for the key
321
+ * 'gpt-4o'. It goes onto every usage row, so a price list keyed by wire
322
+ * ids can match one (§4). Omitted means the key IS the id. */
323
+ modelId?: string;
198
324
  }
325
+ /** The model id to record for a registry key: what `resolveModel` declared,
326
+ * or the key itself when it declared nothing. */
327
+ export declare const wireId: (model: ResolvedModel, key: string) => string;
199
328
  /** Opt-in subagent delegation config (§2.7): the platform constructs the
200
329
  * run-scoped spawnSubagent tool — users cannot build it themselves. */
201
330
  export interface SubagentsConfig {
@@ -232,6 +361,13 @@ export interface AgentConfig {
232
361
  * input nor the agent spec declares one. `undefined` = unbounded apart
233
362
  * from `maxSteps` (§2.1 safety cap). */
234
363
  tokenBudget?: number;
364
+ /** Default per-run money cap (§4), in millionths of the pricer's currency:
365
+ * 250_000 is roughly a quarter of a dollar when the pricer works in USD.
366
+ * `undefined` = unbounded. Checked between steps, exactly like
367
+ * `tokenBudget`, so the step that crossed the line is always kept in full.
368
+ * Needs a pricer: an unpriced call spends no money and so can never
369
+ * exhaust it. */
370
+ costBudgetMicros?: number;
235
371
  /** Subagent nesting cap (§2.7) */
236
372
  subagentMaxDepth: number;
237
373
  /** Concurrent subagents per run (§2.7) */
@@ -259,6 +395,12 @@ export interface AgentConfig {
259
395
  compactionTrigger: number;
260
396
  /** Share of budget kept verbatim as the recent tail (§2.6) */
261
397
  contextTailShare: number;
398
+ /** Registry key of the cheap model that writes the context summary (§2.6).
399
+ * It is resolved through your own `resolveModel`, so it must be a key that
400
+ * resolver knows — a registry with no 'gpt-4o-mini' in it has to name its
401
+ * own. The call is billed like any other, under `kind: 'compaction'` (§4).
402
+ * Default: 'gpt-4o-mini'. */
403
+ compactionModel: string;
262
404
  /** Prompt caching (§2.6): when true, the engine stamps Anthropic-style
263
405
  * ephemeral cache breakpoints on the prompt prefix so providers that
264
406
  * support marking cache it. OpenAI models cache automatically (≥1024
@@ -270,8 +412,11 @@ export interface AgentConfig {
270
412
  /** Lease (seconds) for the per-thread run lock — must exceed the longest
271
413
  * possible run segment; parked HITL waits hold NO lock (§2.8, §3.4). */
272
414
  runLockLeaseSeconds: number;
273
- /** Billing pre-execution check (§4). Return `{ ok: false, error }` to reject a run. */
274
- billingPreCheck?: (threadId: string) => Promise<{
415
+ /** Billing pre-execution check (§4). Return `{ ok: false, error }` to reject
416
+ * a run. The check can publish on the thread (a credit warning, a reset
417
+ * date) so every client sees why; the platform also publishes RUN_REFUSED
418
+ * with the error. */
419
+ billingPreCheck?: (check: BillingCheck) => Promise<{
275
420
  ok: boolean;
276
421
  error?: string;
277
422
  }>;
@@ -281,6 +426,16 @@ export interface AgentConfig {
281
426
  * provider namespace. */
282
427
  providerOptions?: ProviderOptions;
283
428
  }
429
+ /** What `billingPreCheck` receives: the thread about to run, the run's state
430
+ * (§2.10), and a way to publish on the thread before the refusal reaches the
431
+ * caller. `publishEvent(type, payload, { durable })` — durable by default. */
432
+ export interface BillingCheck {
433
+ threadId: string;
434
+ state: AgentRunState;
435
+ publishEvent: (type: string, payload: unknown, options?: {
436
+ durable?: boolean;
437
+ }) => Promise<AgentEvent>;
438
+ }
284
439
  export declare const DEFAULT_CONFIG: AgentConfig;
285
440
  export declare function resolveConfig(partial?: Partial<AgentConfig>): AgentConfig;
286
441
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;+EAC+E;AAC/E,MAAM,MAAM,cAAc,GACtB,MAAM,GACN,SAAS,GACT,mBAAmB,GACnB,WAAW,GACX,WAAW,GACX,QAAQ,CAAC;AAEb,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEnE,6DAA6D;AAC7D,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,eAAe,CAAC;AAExD,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,cAAc,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,EAAE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
+ /** The model id to record for a registry key: what `resolveModel` declared,
10
+ * or the key itself when it declared nothing. */
11
+ export const wireId = (model, key) => model.modelId && model.modelId.length > 0 ? model.modelId : key;
9
12
  export const DEFAULT_CONFIG = {
10
13
  hitlTtlMs: 15 * 60_000,
11
14
  reclaimGraceMs: 60_000,
@@ -23,6 +26,7 @@ export const DEFAULT_CONFIG = {
23
26
  contextOutputReserveTokens: 16_000,
24
27
  compactionTrigger: 0.8,
25
28
  contextTailShare: 0.25,
29
+ compactionModel: 'gpt-4o-mini',
26
30
  promptCaching: true,
27
31
  runLockLeaseSeconds: 30 * 60,
28
32
  };
@@ -32,6 +36,11 @@ export function resolveConfig(partial) {
32
36
  // A subagent must never get a looser step ceiling than its parent run (§2.7)
33
37
  throw new Error(`Invalid config: subagentMaxSteps (${config.subagentMaxSteps}) must be between 1 and maxSteps (${config.maxSteps})`);
34
38
  }
39
+ if (!config.compactionModel) {
40
+ // Compaction has no fallback: without a model to summarize with, a thread
41
+ // that outgrows its window cannot run at all (§2.6).
42
+ throw new Error('Invalid config: compactionModel must be a non-empty registry key');
43
+ }
35
44
  if (!Number.isInteger(config.stopPollMs) || config.stopPollMs < 1) {
36
45
  // The poll is the only thing that delivers a stop to a running worker (§2.1)
37
46
  throw new Error(`Invalid config: stopPollMs (${config.stopPollMs}) must be an integer of at least 1`);
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAqKA,gFAAgF;AAChF,MAAM,UAAU,oBAAoB,CAClC,IAAsB,EACtB,QAA0B;IAE1B,IAAI,CAAC,IAAI;QAAE,OAAO,QAAQ,CAAC;IAC3B,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3B,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,EAAE,CAAC;AAClC,CAAC;AA8ID,MAAM,CAAC,MAAM,cAAc,GAAgB;IACzC,SAAS,EAAE,EAAE,GAAG,MAAM;IACtB,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b,wCAAwC,MAAM,CAAC,mBAAmB,oCAAoC,CACvG,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,5 +1,7 @@
1
- /** Token attribution (§4): the platform records the counters; USD/credit
2
- * pricing is a downstream concern computed over them. */
1
+ import type { NewUsage, UsageTotals } from './types.js';
2
+ import type { RuntimePorts } from '../ports/runtime.js';
3
+ /** Token attribution (§4): the four canonical counters. Same shape as
4
+ * UsageTotals. */
3
5
  export interface TokenAttribution {
4
6
  /** Fresh (uncached) prompt tokens. */
5
7
  inputTokens: number;
@@ -36,5 +38,48 @@ type UsageLike = {
36
38
  export declare function attributeTokens(usage: UsageLike, meta?: ProviderMetadataLike): TokenAttribution;
37
39
  /** Total tokens used — input + cached + output, NaN-guarded. */
38
40
  export declare function countTokens(usage: UsageLike, meta?: ProviderMetadataLike): number;
41
+ /** Cache WRITE tokens, which no provider reports in `usage`: Anthropic puts
42
+ * them in provider metadata, and they are a separate line on the bill — a
43
+ * cache write costs more than a fresh input token, so a pricer needs them
44
+ * apart from the rest. */
45
+ export declare function cacheWriteTokens(meta?: ProviderMetadataLike): number;
46
+ /** Reasoning tokens, where the provider separates them out. Usually already
47
+ * inside the output count, which is why the shipped price table prices them
48
+ * at zero by default. */
49
+ export declare function reasoningTokens(usage: UsageLike, meta?: ProviderMetadataLike): number;
50
+ /** Everything a pricer needs from one model call, in the shape a usage row
51
+ * carries it. `attributeTokens` already sorts out the providers'
52
+ * disagreements about input and cache reads; this adds the two counters that
53
+ * only pricing cares about. */
54
+ export declare function fillTokens(usage: UsageLike, meta?: ProviderMetadataLike): Pick<NewUsage, 'inputTokens' | 'cacheReadInputTokens' | 'cacheWriteInputTokens' | 'outputTokens' | 'reasoningTokens' | 'totalTokens'>;
55
+ /** Flatten what the AI SDK reports into the single map a pricer reads.
56
+ * Provider namespaces keep their names; the response id and headers get
57
+ * reserved keys, because an AI gateway bills through a header and a receipt
58
+ * pricer has to be able to find it. */
59
+ export declare function providerMeta(meta?: ProviderMetadataLike, response?: {
60
+ id?: string;
61
+ headers?: Record<string, string>;
62
+ }): Record<string, unknown> | undefined;
63
+ /** Price one model call and store its usage row (§4). Called after every call
64
+ * the platform makes: a step of the main run, a step of a nested run, a
65
+ * compaction pass, streamed or not, finished or cut short.
66
+ *
67
+ * Pricing happens here, before the row is stored, so cost sits on the row
68
+ * beside the tokens and no reader has to work it out again. A pricer that
69
+ * fails, or has nothing to say, leaves the row unpriced rather than failing
70
+ * the run: a bill that is short a line is recoverable, a run that died over a
71
+ * price list is not. Storage failures are logged for the same reason — the
72
+ * tokens of a stopped run were still spent. */
73
+ export declare function recordCall(deps: RuntimePorts, threadId: string, usage: NewUsage): Promise<NewUsage>;
74
+ /** Zero totals — what a thread with no usage rows reports. */
75
+ export declare const emptyTotals: () => UsageTotals;
76
+ /** Sum usage rows into the shape `total` must return: the four counters, the
77
+ * money, and one line per agent and model.
78
+ *
79
+ * A storage adapter that can group in the database should do that instead.
80
+ * This is for the ones that cannot, and for anyone writing their own adapter:
81
+ * feed every matching row through it and you get exactly what the port
82
+ * promises, lines in first-seen order. */
83
+ export declare function sumUsage(rows: Iterable<NewUsage>): UsageTotals;
39
84
  export {};
40
85
  //# sourceMappingURL=usage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../src/core/usage.ts"],"names":[],"mappings":"AAAA;0DAC0D;AAE1D,MAAM,WAAW,gBAAgB;IAC/B,sCAAsC;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,+BAA+B;IAC/B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;+CAE+C;AAC/C,MAAM,MAAM,oBAAoB,GAC5B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,GACnD,SAAS,CAAC;AAE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;AAEH;;;;;;2CAM2C;AAC3C,wBAAgB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAAG,WAAW,CAwC9D"}
@@ -1,5 +1,3 @@
1
- /** Token attribution (§4): the platform records the counters; USD/credit
2
- * pricing is a downstream concern computed over them. */
3
1
  const pick = (...vals) => {
4
2
  for (const v of vals) {
5
3
  if (typeof v === 'number' && Number.isFinite(v))
@@ -40,4 +38,134 @@ export function attributeTokens(usage, meta) {
40
38
  export function countTokens(usage, meta) {
41
39
  return attributeTokens(usage, meta).totalTokens;
42
40
  }
41
+ /** Cache WRITE tokens, which no provider reports in `usage`: Anthropic puts
42
+ * them in provider metadata, and they are a separate line on the bill — a
43
+ * cache write costs more than a fresh input token, so a pricer needs them
44
+ * apart from the rest. */
45
+ export function cacheWriteTokens(meta) {
46
+ return pick(meta?.anthropic?.cacheCreationInputTokens, meta?.bedrock?.cacheWriteInputTokens);
47
+ }
48
+ /** Reasoning tokens, where the provider separates them out. Usually already
49
+ * inside the output count, which is why the shipped price table prices them
50
+ * at zero by default. */
51
+ export function reasoningTokens(usage, meta) {
52
+ return pick(usage?.reasoningTokens, meta?.openai?.reasoningTokens);
53
+ }
54
+ /** Everything a pricer needs from one model call, in the shape a usage row
55
+ * carries it. `attributeTokens` already sorts out the providers'
56
+ * disagreements about input and cache reads; this adds the two counters that
57
+ * only pricing cares about. */
58
+ export function fillTokens(usage, meta) {
59
+ const a = attributeTokens(usage, meta);
60
+ return {
61
+ inputTokens: a.inputTokens,
62
+ cacheReadInputTokens: a.cachedInputTokens,
63
+ cacheWriteInputTokens: cacheWriteTokens(meta),
64
+ outputTokens: a.outputTokens,
65
+ reasoningTokens: reasoningTokens(usage, meta),
66
+ totalTokens: a.totalTokens,
67
+ };
68
+ }
69
+ /** Flatten what the AI SDK reports into the single map a pricer reads.
70
+ * Provider namespaces keep their names; the response id and headers get
71
+ * reserved keys, because an AI gateway bills through a header and a receipt
72
+ * pricer has to be able to find it. */
73
+ export function providerMeta(meta, response) {
74
+ const out = { ...(meta ?? {}) };
75
+ if (response?.id)
76
+ out.responseId = response.id;
77
+ if (response?.headers && Object.keys(response.headers).length > 0) {
78
+ out.responseHeaders = response.headers;
79
+ }
80
+ return Object.keys(out).length > 0 ? out : undefined;
81
+ }
82
+ /** Price one model call and store its usage row (§4). Called after every call
83
+ * the platform makes: a step of the main run, a step of a nested run, a
84
+ * compaction pass, streamed or not, finished or cut short.
85
+ *
86
+ * Pricing happens here, before the row is stored, so cost sits on the row
87
+ * beside the tokens and no reader has to work it out again. A pricer that
88
+ * fails, or has nothing to say, leaves the row unpriced rather than failing
89
+ * the run: a bill that is short a line is recoverable, a run that died over a
90
+ * price list is not. Storage failures are logged for the same reason — the
91
+ * tokens of a stopped run were still spent. */
92
+ export async function recordCall(deps, threadId, usage) {
93
+ const log = deps.log ?? console;
94
+ const priced = { ...usage };
95
+ if (deps.pricer && !priced.cost) {
96
+ try {
97
+ priced.cost = (await deps.pricer.price(priced)) ?? null;
98
+ }
99
+ catch (err) {
100
+ log.error('usage not priced', { run: priced.runId, model: priced.model, err });
101
+ }
102
+ }
103
+ try {
104
+ await deps.storage.usage.record(threadId, priced);
105
+ }
106
+ catch (err) {
107
+ log.error('usage not recorded', { run: priced.runId, thread: threadId, err });
108
+ }
109
+ return priced;
110
+ }
111
+ /** Zero totals — what a thread with no usage rows reports. */
112
+ export const emptyTotals = () => ({
113
+ inputTokens: 0,
114
+ cachedInputTokens: 0,
115
+ outputTokens: 0,
116
+ totalTokens: 0,
117
+ costMicros: 0,
118
+ unpriced: 0,
119
+ lines: [],
120
+ });
121
+ /** Sum usage rows into the shape `total` must return: the four counters, the
122
+ * money, and one line per agent and model.
123
+ *
124
+ * A storage adapter that can group in the database should do that instead.
125
+ * This is for the ones that cannot, and for anyone writing their own adapter:
126
+ * feed every matching row through it and you get exactly what the port
127
+ * promises, lines in first-seen order. */
128
+ export function sumUsage(rows) {
129
+ const out = emptyTotals();
130
+ const index = new Map();
131
+ for (const u of rows) {
132
+ out.inputTokens += u.inputTokens;
133
+ out.cachedInputTokens += u.cacheReadInputTokens;
134
+ out.outputTokens += u.outputTokens;
135
+ out.totalTokens += u.totalTokens;
136
+ if (u.cost) {
137
+ out.costMicros += u.cost.micros;
138
+ out.currency ??= u.cost.currency;
139
+ }
140
+ else {
141
+ out.unpriced += 1;
142
+ }
143
+ const key = [u.agentId ?? '', u.agentName ?? '', u.model ?? '', u.modelId ?? ''].join('\u0000');
144
+ let i = index.get(key);
145
+ if (i === undefined) {
146
+ i = out.lines.length;
147
+ index.set(key, i);
148
+ out.lines.push({
149
+ agentId: u.agentId ?? null,
150
+ agentName: u.agentName ?? null,
151
+ model: u.model ?? null,
152
+ modelId: u.modelId ?? null,
153
+ inputTokens: 0, cacheReadInputTokens: 0, cacheWriteInputTokens: 0,
154
+ outputTokens: 0, reasoningTokens: 0, calls: 0, estimated: 0, costMicros: 0,
155
+ });
156
+ }
157
+ const line = out.lines[i];
158
+ line.inputTokens += u.inputTokens;
159
+ line.cacheReadInputTokens += u.cacheReadInputTokens;
160
+ line.cacheWriteInputTokens += u.cacheWriteInputTokens;
161
+ line.outputTokens += u.outputTokens;
162
+ line.reasoningTokens += u.reasoningTokens;
163
+ line.calls += 1;
164
+ if (u.estimated)
165
+ line.estimated += 1;
166
+ if (u.cost)
167
+ line.costMicros += u.cost.micros;
168
+ }
169
+ return out;
170
+ }
43
171
  //# sourceMappingURL=usage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/core/usage.ts"],"names":[],"mappings":"AAAA;0DAC0D;AA4B1D,MAAM,IAAI,GAAG,CAAC,GAAG,IAA4B,EAAU,EAAE;IACvD,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;YAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,CA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AAO,GAAG,CAAC;AACb,CAAC"}
package/dist/index.d.ts CHANGED
@@ -2,21 +2,29 @@ export type { Storage } from './ports/storage.js';
2
2
  export type { EventBus } from './ports/bus.js';
3
3
  export type { EnqueueOptions, Queue } from './ports/queue.js';
4
4
  export type { Kv } from './ports/kv.js';
5
- export type { AgentCore, AgentHandle, AgentKind, DeleteThreadResult, GenerateTextAgentSpec, RespondInput, RespondResult, ResolvedModel, RunInput, RunResult, RuntimeOptions, RuntimePorts, StopResult, StreamTextAgentSpec, SubagentsConfig, ThreadSnapshot, ThreadUsage, } from './ports/runtime.js';
5
+ export type { AgentCore, AgentHandle, AgentKind, DeleteThreadResult, GenerateTextAgentSpec, RespondInput, RespondResult, ResolvedModel, RunInput, RunResult, RuntimeOptions, RuntimePorts, StopResult, StreamTextAgentSpec, SubagentsConfig, ThreadSnapshot, ThreadUsage, Pricer, Logger, RunFinishInfo, } from './ports/runtime.js';
6
6
  export { setupAgentCore } from './runtime.js';
7
7
  export { execute, executeStep, executeWithPolicy, finalize, markRequiresConfirmation, type ExecuteInput, type ExecuteOutcome, type FinalizeInput, type StepResult, } from './core/engine.js';
8
8
  export { agentTool, type ToolContext } from './core/tools.js';
9
9
  export { followEvents, toSseStream, sseFrame, SSE_HEADERS, type FollowOptions, type SseOptions, type SseStream, } from './core/follow.js';
10
10
  export type { AgentRunState, BoundStorage, StorageContext } from './core/state.js';
11
+ export type { AdminThread, ThreadStart, StepRecord, RunFilter, AdminThreadFilter } from './ports/admin.js';
12
+ export type { BillingCheck } from './core/types.js';
11
13
  export { claimRun, redriveKey, runIdKey } from './core/keys.js';
12
- export { countTokens } from './core/usage.js';
14
+ export { countTokens, sumUsage, emptyTotals } from './core/usage.js';
15
+ /** Pricing (§4): the pricers that ship with the platform. `pricing.table(...)`
16
+ * is the common case; see the module for `receipt` and `chain`. */
17
+ export * as pricing from './pricing.js';
18
+ export type { ModelPrice, PriceTable, ReceiptReader } from './pricing.js';
13
19
  export { respond, parkForApproval, loadPendingHitl, loadOpenHitls, withHitl, HITL_PARKED, HITL_TTL_MS, hitlKey, type HitlFrame, type HitlResponse, type ParkInput, type PendingHitl, } from './core/hitl.js';
14
20
  export { reclaimIfOrphaned } from './core/reclaim.js';
15
21
  export { contextBudget, contextUsage, compactContext, CONTEXT_TOKEN_CEILING } from './core/context.js';
16
22
  export { Semaphore, runNestedAgent, spawnSubagentTool, type SubagentCtx } from './core/subagent.js';
17
23
  export { run } from './core/run.js';
24
+ export { publishEvent, withPublishEvent, RESERVED_EVENT_TYPES, type PublishEventOptions, type ToolPublishEvent, } from './core/publish.js';
18
25
  export { stop } from './core/stop.js';
19
- export { DEFAULT_CONFIG, resolveConfig, type AgentConfig, type AgentEvent, type ExecutionState, type MessageDTO, type MessageRole, type NewMessage, type NewRunRecord, type NewUsage, type ResolvedModel as ResolvedModelDTO, type RunPatch, type RunRecord, type RunJob, type ResumeInfo, type ContextUsage, type NestedDescriptor, type ThreadDTO, type UsageTotals, } from './core/types.js';
26
+ export { repairDanglingToolCalls, DANGLING_CALL_RESULT } from './core/messages.js';
27
+ export { DEFAULT_CONFIG, resolveConfig, type AgentConfig, type AgentEvent, type ExecutionState, type MessageDTO, type MessageRole, type NewMessage, type NewRunRecord, type NewUsage, type UsageLine, type UsageFilter, type UsageKind, type UsageOutcome, type Cost, type ResolvedModel as ResolvedModelDTO, type RunPatch, type RunRecord, type RunJob, type ResumeInfo, type ContextUsage, type NestedDescriptor, type ThreadDTO, type UsageTotals, } from './core/types.js';
20
28
  export { PrismaStorage, type PrismaLike } from './adapters/prisma.js';
21
29
  export { UpstashBus, UpstashKv, THREAD_CHANNEL, type UpstashRedisLike, type UpstashSubscriberLike } from './adapters/upstash.js';
22
30
  export { RedisBus, RedisKv, type RedisClientLike, type RedisSubscriberLike } from './adapters/redis.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,OAAO,EAAE,MAAM,oBA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,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,MAAM,EACX,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,WAAW,GACjB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,KAAK,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACjI,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACxG,OAAO,EAAE,WAAW,EAAE,KAAK,UAAU,EAAE,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -5,13 +5,18 @@ export { execute, executeStep, executeWithPolicy, finalize, markRequiresConfirma
5
5
  export { agentTool } from './core/tools.js';
6
6
  export { followEvents, toSseStream, sseFrame, SSE_HEADERS, } from './core/follow.js';
7
7
  export { claimRun, redriveKey, runIdKey } from './core/keys.js';
8
- export { countTokens } from './core/usage.js';
8
+ export { countTokens, sumUsage, emptyTotals } from './core/usage.js';
9
+ /** Pricing (§4): the pricers that ship with the platform. `pricing.table(...)`
10
+ * is the common case; see the module for `receipt` and `chain`. */
11
+ export * as pricing from './pricing.js';
9
12
  export { respond, parkForApproval, loadPendingHitl, loadOpenHitls, withHitl, HITL_PARKED, HITL_TTL_MS, hitlKey, } from './core/hitl.js';
10
13
  export { reclaimIfOrphaned } from './core/reclaim.js';
11
14
  export { contextBudget, contextUsage, compactContext, CONTEXT_TOKEN_CEILING } from './core/context.js';
12
15
  export { Semaphore, runNestedAgent, spawnSubagentTool } from './core/subagent.js';
13
16
  export { run } from './core/run.js';
17
+ export { publishEvent, withPublishEvent, RESERVED_EVENT_TYPES, } from './core/publish.js';
14
18
  export { stop } from './core/stop.js';
19
+ export { repairDanglingToolCalls, DANGLING_CALL_RESULT } from './core/messages.js';
15
20
  // types
16
21
  export { DEFAULT_CONFIG, resolveConfig, } from './core/types.js';
17
22
  // reference adapters