claudeMapSessionEventsTestUtils.ts ×16

Frontier kind: Code frontier

unlabeled · c_651dff82609e

240 tests · 23892 LOC · 107 files · introduces 0 tests · 96 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
16 ranges96 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1868 ranges23892 lines · 107 files · Browse complete extent
All tests (intent)
240 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 96 introduced LOC across 16 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/test/node/claudeMapSessionEventsTestUtils.ts 96 introduced LOC · 16 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- claudeMapSessionEventsTestUtils.ts
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 },
87 };
88 }
90 > export function makeResultError(sessionId: string, errors: string[]): SDKResultError {
91 return {
92 type: 'result',
106 };
107 }
109 > // `stream_event` (SDKPartialAssistantMessage) builders. The SDK's
110 > // `Options.includePartialMessages: true` setting (Phase 6 §3.4) routes
111 > // raw `BetaRawMessageStreamEvent`s through to the agent so we can map
112 > // per-token. The deep `BetaMessage` shape on `message_start` carries
113 > // many required fields irrelevant to mapping; these helpers populate
114 > // only what the mapper reads, with everything else set to safe zero
115 > // values so the SDK type-checks pass without `as unknown` casts.
116 >
117 > export function makeStreamEvent(
118 sessionId: string,
119 event: SDKPartialAssistantMessage['event'],
127 };
128 }
130 > export function makeMessageStart(messageId: string = 'msg_test'): BetaRawMessageStartEvent {
131 return {
132 type: 'message_start',
157 };
158 }
160 > export function makeContentBlockStartText(index: number): BetaRawContentBlockStartEvent {
161 return {
162 type: 'content_block_start',
165 };
166 }
168 > export function makeContentBlockStartThinking(index: number): BetaRawContentBlockStartEvent {
169 return {
170 type: 'content_block_start',
185 };
186 }
188 > export function makeTextDelta(index: number, text: string): BetaRawContentBlockDeltaEvent {
189 return {
190 type: 'content_block_delta',
193 };
194 }
196 > export function makeThinkingDelta(index: number, thinking: string): BetaRawContentBlockDeltaEvent {
197 return {
198 type: 'content_block_delta',
201 };
202 }
204 > /**
205 > * Phase 7 §3.3: `content_block_delta` with `input_json_delta` is the
206 > * stream of partial parameter JSON for an open `tool_use` block.
207 > */
208 > export function makeInputJsonDelta(index: number, partialJson: string): BetaRawContentBlockDeltaEvent {
209 return {
210 type: 'content_block_delta',
213 };
214 }
216 > export function makeContentBlockStop(index: number): BetaRawContentBlockStopEvent {
217 return {
218 type: 'content_block_stop',
220 };
221 }
223 > export function makeMessageStop(): BetaRawMessageStopEvent {
224 return { type: 'message_stop' };
225 }
227 > /**
228 > * Builds the canonical {@link SDKAssistantMessage} envelope (`type:
229 > * 'assistant'`) the SDK delivers as the final, authoritative message
230 > * for a turn alongside its `'stream_event'` partials. The {@link
231 > * content} blocks mirror what the partial accumulator should already
232 > * have produced via `content_block_*` events. Only the fields the
233 > * mapper inspects are filled with real values; the rest are zeroed so
234 > * the SDK type-checks pass.
235 > */
236 > export function makeAssistantMessage(
237 sessionId: string,
238 content: BetaContentBlock[],
269 };
270 }
272 > /**
273 > * Builds the synthetic {@link SDKUserMessage} envelope (`type: 'user'`)
274 > * the SDK delivers as the response to a previously-emitted `tool_use`.
275 > * Phase 7 §3.3.4 — the mapper detects this by walking
276 > * `message.content` for `tool_result` blocks and emits a
277 > * `ChatToolCallComplete` per match. The `content` field is the SDK's
278 > * `string | (TextBlockParam | ImageBlockParam | ...)[]` shape; the
279 > * helper accepts a string or pre-built block array verbatim.
280 > */
281 > export function makeUserToolResultMessage(
282 sessionId: string,
283 toolUseId: string,