2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import type Anthropic from '@anthropic-ai/sdk';
7
>
import type { SDKAssistantMessage, SDKPartialAssistantMessage, SDKResultError, SDKResultSuccess, SDKSystemMessage, SDKUserMessage } from '@anthropic-ai/claude-agent-sdk';
8
>
9
>
// Beta event-stream type aliases. The `Anthropic` namespace re-exports
10
>
// these from `@anthropic-ai/sdk/resources/beta/messages.js`, but
11
>
// importing that subpath directly trips the `local/code-import-patterns`
12
>
// allowlist (the agentHost rule only permits the bare
13
>
// `@anthropic-ai/sdk` specifier). Local aliases via the `Anthropic`
14
>
// import keep the body of this file readable without extending the
15
>
// allowlist.
16
>
export type BetaRawContentBlockDeltaEvent = Anthropic.Beta.BetaRawContentBlockDeltaEvent;
17
>
export type BetaRawContentBlockStartEvent = Anthropic.Beta.BetaRawContentBlockStartEvent;
18
>
export type BetaRawContentBlockStopEvent = Anthropic.Beta.BetaRawContentBlockStopEvent;
19
>
export type BetaRawMessageStartEvent = Anthropic.Beta.BetaRawMessageStartEvent;
20
>
export type BetaRawMessageStopEvent = Anthropic.Beta.BetaRawMessageStopEvent;
21
>
export type BetaContentBlock = Anthropic.Beta.BetaContentBlock;
22
>
23
>
/**
24
>
* Static fixture uuid used by every helper that needs to emit a
25
>
* `${string}-${string}-${string}-${string}-${string}`-shaped value.
26
>
* Tests that exercise uuid-sensitive logic (e.g. the Cycle C send-seam
27
>
* test) construct their own uuids instead of relying on this constant.
28
>
*/
29
>
export const TEST_UUID = '11111111-2222-3333-4444-555555555555';
30
>
31
>
/**
32
>
* Builds the non-nullable shape of {@link SDKResultSuccess.usage}. Most
33
>
* fields are zeroed; the mapper only reads `input_tokens`,
34
>
* `output_tokens`, and `cache_read_input_tokens`.
35
>
*/
36
>
export function makeNonNullableUsage(): SDKResultSuccess['usage'] {
37
return {
38
cache_creation: { ephemeral_1h_input_tokens: 0, ephemeral_5m_input_tokens: 0 },