wave-agent-sdk 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.d.ts +11 -0
- package/dist/agent.js +15 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -1
- package/dist/managers/aiManager.js +0 -3
- package/dist/managers/messageManager.d.ts +1 -1
- package/dist/managers/messageManager.js +1 -1
- package/dist/services/aiService.d.ts +2 -3
- package/dist/services/aiService.js +4 -18
- package/dist/services/configurationService.d.ts +7 -0
- package/dist/services/configurationService.js +10 -0
- package/dist/types/core.d.ts +1 -34
- package/dist/types/index.d.ts +1 -0
- package/dist/utils/cacheControlUtils.d.ts +5 -27
- package/dist/utils/cacheControlUtils.js +12 -73
- package/package.json +1 -1
package/dist/agent.d.ts
CHANGED
|
@@ -413,6 +413,17 @@ export declare class Agent {
|
|
|
413
413
|
* @returns The subagent instance or null if not found
|
|
414
414
|
*/
|
|
415
415
|
getSubagentInstance(subagentId: string): import("./managers/subagentManager.js").SubagentInstance | null;
|
|
416
|
+
/**
|
|
417
|
+
* Get all subagent configurations visible in this session (built-in,
|
|
418
|
+
* user, project, and plugin agents).
|
|
419
|
+
* @returns The list of subagent configurations
|
|
420
|
+
*/
|
|
421
|
+
getSubagentConfigurations(): import("./utils/subagentParser.js").SubagentConfiguration[];
|
|
422
|
+
/**
|
|
423
|
+
* Get currently active subagent instances (status active/initializing).
|
|
424
|
+
* @returns The list of active subagent instances
|
|
425
|
+
*/
|
|
426
|
+
getActiveSubagentInstances(): import("./managers/subagentManager.js").SubagentInstance[];
|
|
416
427
|
/**
|
|
417
428
|
* Get the current task list ID
|
|
418
429
|
*/
|
package/dist/agent.js
CHANGED
|
@@ -973,6 +973,21 @@ export class Agent {
|
|
|
973
973
|
getSubagentInstance(subagentId) {
|
|
974
974
|
return this.subagentManager.getInstance(subagentId);
|
|
975
975
|
}
|
|
976
|
+
/**
|
|
977
|
+
* Get all subagent configurations visible in this session (built-in,
|
|
978
|
+
* user, project, and plugin agents).
|
|
979
|
+
* @returns The list of subagent configurations
|
|
980
|
+
*/
|
|
981
|
+
getSubagentConfigurations() {
|
|
982
|
+
return this.subagentManager.getConfigurations();
|
|
983
|
+
}
|
|
984
|
+
/**
|
|
985
|
+
* Get currently active subagent instances (status active/initializing).
|
|
986
|
+
* @returns The list of active subagent instances
|
|
987
|
+
*/
|
|
988
|
+
getActiveSubagentInstances() {
|
|
989
|
+
return this.subagentManager.getActiveInstances();
|
|
990
|
+
}
|
|
976
991
|
/**
|
|
977
992
|
* Get the current task list ID
|
|
978
993
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -23,7 +23,9 @@ export * from "./utils/gitUtils.js";
|
|
|
23
23
|
export * from "./utils/nameGenerator.js";
|
|
24
24
|
export * from "./utils/worktreeSession.js";
|
|
25
25
|
export * from "./utils/worktreeUtils.js";
|
|
26
|
-
export { loadMergedWaveConfig } from "./services/configurationService.js";
|
|
26
|
+
export { loadMergedWaveConfig, loadUserConfigEnv, } from "./services/configurationService.js";
|
|
27
27
|
export * from "./types/index.js";
|
|
28
|
+
export type { SubagentConfiguration } from "./utils/subagentParser.js";
|
|
29
|
+
export type { SubagentInstance } from "./managers/subagentManager.js";
|
|
28
30
|
export * from "./tools/buildTool.js";
|
|
29
31
|
export type { ToolPlugin, ToolResult, ToolContext } from "./tools/types.js";
|
package/dist/index.js
CHANGED
|
@@ -27,7 +27,7 @@ export * from "./utils/gitUtils.js";
|
|
|
27
27
|
export * from "./utils/nameGenerator.js";
|
|
28
28
|
export * from "./utils/worktreeSession.js";
|
|
29
29
|
export * from "./utils/worktreeUtils.js";
|
|
30
|
-
export { loadMergedWaveConfig } from "./services/configurationService.js";
|
|
30
|
+
export { loadMergedWaveConfig, loadUserConfigEnv, } from "./services/configurationService.js";
|
|
31
31
|
export * from "./types/index.js";
|
|
32
32
|
// Export tool building utilities
|
|
33
33
|
export * from "./tools/buildTool.js";
|
|
@@ -1383,9 +1383,6 @@ ${question}`;
|
|
|
1383
1383
|
...(result.usage.cache_creation_input_tokens !== undefined && {
|
|
1384
1384
|
cache_creation_input_tokens: result.usage.cache_creation_input_tokens,
|
|
1385
1385
|
}),
|
|
1386
|
-
...(result.usage.cache_creation && {
|
|
1387
|
-
cache_creation: result.usage.cache_creation,
|
|
1388
|
-
}),
|
|
1389
1386
|
};
|
|
1390
1387
|
}
|
|
1391
1388
|
// Set usage on the assistant message if available
|
|
@@ -26,7 +26,7 @@ export interface MessageManagerCallbacks {
|
|
|
26
26
|
onCompactionStateChange?: (isCompacting: boolean) => void;
|
|
27
27
|
onAddBangMessage?: (command: string, messageId: string) => void;
|
|
28
28
|
onUpdateBangMessage?: (command: string, output: string, messageId: string) => void;
|
|
29
|
-
onCompleteBangMessage?: (command: string, exitCode: number, messageId: string) => void;
|
|
29
|
+
onCompleteBangMessage?: (command: string, exitCode: number, messageId: string, output?: string) => void;
|
|
30
30
|
onInfoBlockAdded?: (content: string) => void;
|
|
31
31
|
onShowRewind?: () => void;
|
|
32
32
|
onFileHistoryBlockAdded?: (snapshots: import("../types/reversion.js").FileSnapshot[]) => void;
|
|
@@ -446,7 +446,7 @@ export class MessageManager {
|
|
|
446
446
|
});
|
|
447
447
|
this.setMessages(updatedMessages);
|
|
448
448
|
const messageId = this.findBangMessageId(command) ?? "";
|
|
449
|
-
this.callbacks.onCompleteBangMessage?.(command, exitCode, messageId);
|
|
449
|
+
this.callbacks.onCompleteBangMessage?.(command, exitCode, messageId, output?.trim());
|
|
450
450
|
}
|
|
451
451
|
/**
|
|
452
452
|
* Find the message ID of the most recent message containing a bang block
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ChatCompletionMessageToolCall } from "openai/resources";
|
|
2
2
|
import { ChatCompletionMessageParam, ChatCompletionFunctionTool } from "openai/resources.js";
|
|
3
|
-
import type { GatewayConfig, ModelConfig } from "../types/index.js";
|
|
4
|
-
import { type ClaudeUsage } from "../utils/cacheControlUtils.js";
|
|
3
|
+
import type { GatewayConfig, ModelConfig, Usage } from "../types/index.js";
|
|
5
4
|
import { type SystemPromptBlock } from "../prompts/index.js";
|
|
6
5
|
/**
|
|
7
6
|
* Resets the rate limiter state. Primarily used for testing.
|
|
@@ -40,7 +39,7 @@ export interface CallAgentResult {
|
|
|
40
39
|
content?: string;
|
|
41
40
|
tool_calls?: ChatCompletionMessageToolCall[];
|
|
42
41
|
reasoning_content?: string;
|
|
43
|
-
usage?:
|
|
42
|
+
usage?: Usage;
|
|
44
43
|
finish_reason?: "stop" | "length" | "tool_calls" | "content_filter" | "function_call" | null;
|
|
45
44
|
response_headers?: Record<string, string>;
|
|
46
45
|
additionalFields?: Record<string, unknown>;
|
|
@@ -202,17 +202,9 @@ export async function callAgent(options) {
|
|
|
202
202
|
});
|
|
203
203
|
const finalMessage = response.choices[0]?.message;
|
|
204
204
|
const finishReason = response.choices[0]?.finish_reason || null;
|
|
205
|
-
|
|
206
|
-
?
|
|
207
|
-
prompt_tokens: response.usage.prompt_tokens,
|
|
208
|
-
completion_tokens: response.usage.completion_tokens,
|
|
209
|
-
total_tokens: response.usage.total_tokens,
|
|
210
|
-
}
|
|
205
|
+
const totalUsage = response.usage
|
|
206
|
+
? extendUsageWithCacheMetrics(response.usage)
|
|
211
207
|
: undefined;
|
|
212
|
-
// Extend usage with cache metrics (Claude top-level + OpenAI prompt_tokens_details)
|
|
213
|
-
if (totalUsage && response.usage) {
|
|
214
|
-
totalUsage = extendUsageWithCacheMetrics(totalUsage, response.usage);
|
|
215
|
-
}
|
|
216
208
|
const result = {};
|
|
217
209
|
if (finalMessage) {
|
|
218
210
|
const { content: finalContent, tool_calls: finalToolCalls, reasoning_content: finalReasoningContent, ...otherFields } = finalMessage;
|
|
@@ -353,14 +345,8 @@ async function processStreamingResponse(stream, onContentUpdate, onToolUpdate, o
|
|
|
353
345
|
}
|
|
354
346
|
// Check for usage information in any chunk
|
|
355
347
|
if (chunk.usage) {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
completion_tokens: chunk.usage.completion_tokens,
|
|
359
|
-
total_tokens: chunk.usage.total_tokens,
|
|
360
|
-
};
|
|
361
|
-
// Extend usage with cache metrics (Claude top-level + OpenAI prompt_tokens_details)
|
|
362
|
-
chunkUsage = extendUsageWithCacheMetrics(chunkUsage, chunk.usage);
|
|
363
|
-
usage = chunkUsage;
|
|
348
|
+
// Extend usage with cache metrics from OpenAI prompt_tokens_details
|
|
349
|
+
usage = extendUsageWithCacheMetrics(chunk.usage);
|
|
364
350
|
}
|
|
365
351
|
// Check for finish_reason in the choice
|
|
366
352
|
const choice = chunk.choices?.[0];
|
|
@@ -196,6 +196,13 @@ export declare function mergeEnvironmentConfig(userEnv: Record<string, string> |
|
|
|
196
196
|
* Supports both hooks and environment variables with proper validation
|
|
197
197
|
*/
|
|
198
198
|
export declare function loadWaveConfigFromFile(filePath: string): WaveConfiguration | null;
|
|
199
|
+
/**
|
|
200
|
+
* Load the user-level (~/.wave/settings.json) `env` block only — no workdir
|
|
201
|
+
* dependency. Used at daemon startup to apply WAVE_SERVER_URL before any agent
|
|
202
|
+
* initializes: auth queries (getAuthStatus) can run before the first agent,
|
|
203
|
+
* and AuthService falls back to the default URL otherwise.
|
|
204
|
+
*/
|
|
205
|
+
export declare function loadUserConfigEnv(): Record<string, string>;
|
|
199
206
|
/**
|
|
200
207
|
* Load and merge Wave configuration from both user and project sources
|
|
201
208
|
* Project configuration takes precedence over user configuration
|
|
@@ -1079,6 +1079,16 @@ export function loadWaveConfigFromFile(filePath) {
|
|
|
1079
1079
|
throw error;
|
|
1080
1080
|
}
|
|
1081
1081
|
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Load the user-level (~/.wave/settings.json) `env` block only — no workdir
|
|
1084
|
+
* dependency. Used at daemon startup to apply WAVE_SERVER_URL before any agent
|
|
1085
|
+
* initializes: auth queries (getAuthStatus) can run before the first agent,
|
|
1086
|
+
* and AuthService falls back to the default URL otherwise.
|
|
1087
|
+
*/
|
|
1088
|
+
export function loadUserConfigEnv() {
|
|
1089
|
+
const config = loadWaveConfigFromFile(getUserConfigPaths()[0]);
|
|
1090
|
+
return config?.env ?? {};
|
|
1091
|
+
}
|
|
1082
1092
|
/**
|
|
1083
1093
|
* Load and merge Wave configuration from both user and project sources
|
|
1084
1094
|
* Project configuration takes precedence over user configuration
|
package/dist/types/core.d.ts
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Core foundational types used across multiple domains
|
|
3
3
|
* Dependencies: None (foundation layer)
|
|
4
4
|
*/
|
|
5
|
-
import type { CompletionUsage } from "openai/resources";
|
|
6
5
|
/**
|
|
7
6
|
* Logger interface definition
|
|
8
7
|
* Compatible with OpenAI package Logger interface
|
|
@@ -15,7 +14,7 @@ export interface Logger {
|
|
|
15
14
|
}
|
|
16
15
|
/**
|
|
17
16
|
* Usage statistics for AI operations
|
|
18
|
-
* Extends OpenAI's Usage format with
|
|
17
|
+
* Extends OpenAI's Usage format with normalized cache fields
|
|
19
18
|
*/
|
|
20
19
|
export interface Usage {
|
|
21
20
|
prompt_tokens: number;
|
|
@@ -25,38 +24,6 @@ export interface Usage {
|
|
|
25
24
|
operation_type?: "agent" | "compact";
|
|
26
25
|
cache_read_input_tokens?: number;
|
|
27
26
|
cache_creation_input_tokens?: number;
|
|
28
|
-
cache_creation?: {
|
|
29
|
-
ephemeral_5m_input_tokens: number;
|
|
30
|
-
ephemeral_1h_input_tokens: number;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Enhanced usage metrics including Claude cache information
|
|
35
|
-
* Backward compatible with standard OpenAI CompletionUsage
|
|
36
|
-
*/
|
|
37
|
-
export interface ClaudeUsage extends CompletionUsage {
|
|
38
|
-
prompt_tokens: number;
|
|
39
|
-
completion_tokens: number;
|
|
40
|
-
total_tokens: number;
|
|
41
|
-
/**
|
|
42
|
-
* Number of tokens read from existing cache
|
|
43
|
-
* Indicates cost savings from cache hits
|
|
44
|
-
*/
|
|
45
|
-
cache_read_input_tokens?: number;
|
|
46
|
-
/**
|
|
47
|
-
* Number of tokens used to create new cache entries
|
|
48
|
-
* Investment in future cache hits
|
|
49
|
-
*/
|
|
50
|
-
cache_creation_input_tokens?: number;
|
|
51
|
-
/**
|
|
52
|
-
* Detailed breakdown of cache creation by duration
|
|
53
|
-
*/
|
|
54
|
-
cache_creation?: {
|
|
55
|
-
/** Tokens cached for 5 minute duration */
|
|
56
|
-
ephemeral_5m_input_tokens: number;
|
|
57
|
-
/** Tokens cached for 1 hour duration */
|
|
58
|
-
ephemeral_1h_input_tokens: number;
|
|
59
|
-
};
|
|
60
27
|
}
|
|
61
28
|
/**
|
|
62
29
|
* Represents a diff change for tool parameter-based diff display
|
package/dist/types/index.d.ts
CHANGED
|
@@ -38,3 +38,4 @@ export * from "./workflow.js";
|
|
|
38
38
|
export type { SessionMetadata, SessionData } from "../services/session.js";
|
|
39
39
|
export type { ToolBlockUpdateCallbackParams } from "../utils/messageOperations.js";
|
|
40
40
|
export type { QueuedMessage } from "../managers/messageQueue.js";
|
|
41
|
+
export type { SubagentConfiguration } from "../utils/subagentParser.js";
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { ChatCompletionMessageParam, ChatCompletionContentPart, ChatCompletionContentPartText, CompletionUsage } from "openai/resources";
|
|
9
9
|
import type { ModelCapabilities } from "../types/config.js";
|
|
10
|
+
import type { Usage } from "../types/core.js";
|
|
10
11
|
/**
|
|
11
12
|
* Cache control directive for Claude models
|
|
12
13
|
*/
|
|
@@ -28,22 +29,6 @@ export interface ClaudeChatCompletionContentPartText extends ChatCompletionConte
|
|
|
28
29
|
export interface ExtendedPromptTokensDetails extends CompletionUsage.PromptTokensDetails {
|
|
29
30
|
cache_creation_input_tokens?: number;
|
|
30
31
|
}
|
|
31
|
-
/**
|
|
32
|
-
* Enhanced usage metrics including cache information
|
|
33
|
-
* Supports both Claude-specific top-level fields and OpenAI-standard prompt_tokens_details
|
|
34
|
-
*/
|
|
35
|
-
export interface ClaudeUsage extends CompletionUsage {
|
|
36
|
-
prompt_tokens: number;
|
|
37
|
-
completion_tokens: number;
|
|
38
|
-
total_tokens: number;
|
|
39
|
-
cache_read_input_tokens?: number;
|
|
40
|
-
cache_creation_input_tokens?: number;
|
|
41
|
-
cache_creation?: {
|
|
42
|
-
ephemeral_5m_input_tokens: number;
|
|
43
|
-
ephemeral_1h_input_tokens: number;
|
|
44
|
-
};
|
|
45
|
-
prompt_tokens_details?: ExtendedPromptTokensDetails;
|
|
46
|
-
}
|
|
47
32
|
/**
|
|
48
33
|
* Validates cache control structure
|
|
49
34
|
* @param control - Object to validate
|
|
@@ -85,16 +70,9 @@ export declare function countContentBlocks(messages: ChatCompletionMessageParam[
|
|
|
85
70
|
export declare function transformMessagesForExplicitCache(messages: ChatCompletionMessageParam[], capabilities?: ModelCapabilities): ChatCompletionMessageParam[];
|
|
86
71
|
/**
|
|
87
72
|
* Extends standard usage with cache metrics
|
|
88
|
-
* Extracts cache tokens from
|
|
89
|
-
*
|
|
90
|
-
* @param
|
|
91
|
-
* @param cacheMetrics - Additional cache metrics from the API response
|
|
73
|
+
* Extracts cache tokens from OpenAI-standard prompt_tokens_details
|
|
74
|
+
* (cached_tokens and the gateway-provided cache_creation_input_tokens)
|
|
75
|
+
* @param usage - OpenAI usage response
|
|
92
76
|
* @returns Extended usage with cache information
|
|
93
77
|
*/
|
|
94
|
-
export declare function extendUsageWithCacheMetrics(
|
|
95
|
-
/**
|
|
96
|
-
* Validates Claude usage structure
|
|
97
|
-
* @param usage - Usage object to validate
|
|
98
|
-
* @returns True if usage structure is valid
|
|
99
|
-
*/
|
|
100
|
-
export declare function isValidClaudeUsage(usage: unknown): usage is ClaudeUsage;
|
|
78
|
+
export declare function extendUsageWithCacheMetrics(usage: CompletionUsage): Usage;
|
|
@@ -207,84 +207,23 @@ export function transformMessagesForExplicitCache(messages, capabilities) {
|
|
|
207
207
|
}
|
|
208
208
|
/**
|
|
209
209
|
* Extends standard usage with cache metrics
|
|
210
|
-
* Extracts cache tokens from
|
|
211
|
-
*
|
|
212
|
-
* @param
|
|
213
|
-
* @param cacheMetrics - Additional cache metrics from the API response
|
|
210
|
+
* Extracts cache tokens from OpenAI-standard prompt_tokens_details
|
|
211
|
+
* (cached_tokens and the gateway-provided cache_creation_input_tokens)
|
|
212
|
+
* @param usage - OpenAI usage response
|
|
214
213
|
* @returns Extended usage with cache information
|
|
215
214
|
*/
|
|
216
|
-
export function extendUsageWithCacheMetrics(
|
|
215
|
+
export function extendUsageWithCacheMetrics(usage) {
|
|
217
216
|
const baseUsage = {
|
|
218
|
-
prompt_tokens:
|
|
219
|
-
completion_tokens:
|
|
220
|
-
total_tokens:
|
|
217
|
+
prompt_tokens: usage.prompt_tokens,
|
|
218
|
+
completion_tokens: usage.completion_tokens,
|
|
219
|
+
total_tokens: usage.total_tokens,
|
|
221
220
|
};
|
|
222
|
-
|
|
223
|
-
|
|
221
|
+
const details = usage.prompt_tokens_details;
|
|
222
|
+
if (details?.cached_tokens != null) {
|
|
223
|
+
baseUsage.cache_read_input_tokens = details.cached_tokens;
|
|
224
224
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
baseUsage.cache_read_input_tokens = cacheMetrics.cache_read_input_tokens;
|
|
228
|
-
}
|
|
229
|
-
// Fallback to prompt_tokens_details.cached_tokens (OpenAI standard)
|
|
230
|
-
else if (cacheMetrics.prompt_tokens_details?.cached_tokens != null) {
|
|
231
|
-
baseUsage.cache_read_input_tokens =
|
|
232
|
-
cacheMetrics.prompt_tokens_details.cached_tokens;
|
|
233
|
-
}
|
|
234
|
-
// Extract cache_creation_input_tokens from Claude top-level field
|
|
235
|
-
if (typeof cacheMetrics.cache_creation_input_tokens === "number") {
|
|
236
|
-
baseUsage.cache_creation_input_tokens =
|
|
237
|
-
cacheMetrics.cache_creation_input_tokens;
|
|
238
|
-
}
|
|
239
|
-
// Fallback to prompt_tokens_details.cache_creation_input_tokens
|
|
240
|
-
else if (cacheMetrics.prompt_tokens_details?.cache_creation_input_tokens != null) {
|
|
241
|
-
baseUsage.cache_creation_input_tokens =
|
|
242
|
-
cacheMetrics.prompt_tokens_details.cache_creation_input_tokens;
|
|
243
|
-
}
|
|
244
|
-
// Extract cache_creation breakdown (Claude-specific)
|
|
245
|
-
if (cacheMetrics.cache_creation &&
|
|
246
|
-
typeof cacheMetrics.cache_creation.ephemeral_5m_input_tokens === "number" &&
|
|
247
|
-
typeof cacheMetrics.cache_creation.ephemeral_1h_input_tokens === "number") {
|
|
248
|
-
baseUsage.cache_creation = {
|
|
249
|
-
ephemeral_5m_input_tokens: cacheMetrics.cache_creation.ephemeral_5m_input_tokens,
|
|
250
|
-
ephemeral_1h_input_tokens: cacheMetrics.cache_creation.ephemeral_1h_input_tokens,
|
|
251
|
-
};
|
|
225
|
+
if (details?.cache_creation_input_tokens != null) {
|
|
226
|
+
baseUsage.cache_creation_input_tokens = details.cache_creation_input_tokens;
|
|
252
227
|
}
|
|
253
228
|
return baseUsage;
|
|
254
229
|
}
|
|
255
|
-
/**
|
|
256
|
-
* Validates Claude usage structure
|
|
257
|
-
* @param usage - Usage object to validate
|
|
258
|
-
* @returns True if usage structure is valid
|
|
259
|
-
*/
|
|
260
|
-
export function isValidClaudeUsage(usage) {
|
|
261
|
-
if (!usage || typeof usage !== "object") {
|
|
262
|
-
return false;
|
|
263
|
-
}
|
|
264
|
-
const usageObj = usage;
|
|
265
|
-
// Check required standard fields
|
|
266
|
-
const hasStandardFields = typeof usageObj.prompt_tokens === "number" &&
|
|
267
|
-
typeof usageObj.completion_tokens === "number" &&
|
|
268
|
-
typeof usageObj.total_tokens === "number";
|
|
269
|
-
if (!hasStandardFields) {
|
|
270
|
-
return false;
|
|
271
|
-
}
|
|
272
|
-
// Check optional cache fields
|
|
273
|
-
const hasCacheFields = (usageObj.cache_read_input_tokens === undefined ||
|
|
274
|
-
typeof usageObj.cache_read_input_tokens === "number") &&
|
|
275
|
-
(usageObj.cache_creation_input_tokens === undefined ||
|
|
276
|
-
typeof usageObj.cache_creation_input_tokens === "number");
|
|
277
|
-
if (!hasCacheFields) {
|
|
278
|
-
return false;
|
|
279
|
-
}
|
|
280
|
-
// Check cache_creation object if present
|
|
281
|
-
if (usageObj.cache_creation !== undefined) {
|
|
282
|
-
const cacheCreation = usageObj.cache_creation;
|
|
283
|
-
if (typeof cacheCreation !== "object" ||
|
|
284
|
-
typeof cacheCreation.ephemeral_5m_input_tokens !== "number" ||
|
|
285
|
-
typeof cacheCreation.ephemeral_1h_input_tokens !== "number") {
|
|
286
|
-
return false;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
return true;
|
|
290
|
-
}
|