@rcrsr/rill-ext-claude-code 0.9.0 → 0.11.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.
- package/dist/index.d.ts +254 -9
- package/dist/index.js +646 -25
- package/package.json +11 -6
- package/dist/factory.d.ts +0 -26
- package/dist/factory.d.ts.map +0 -1
- package/dist/factory.js +0 -376
- package/dist/factory.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/process.d.ts +0 -44
- package/dist/process.d.ts.map +0 -1
- package/dist/process.js +0 -125
- package/dist/process.js.map +0 -1
- package/dist/result.d.ts +0 -14
- package/dist/result.d.ts.map +0 -1
- package/dist/result.js +0 -93
- package/dist/result.js.map +0 -1
- package/dist/stream-parser.d.ts +0 -36
- package/dist/stream-parser.d.ts.map +0 -1
- package/dist/stream-parser.js +0 -96
- package/dist/stream-parser.js.map +0 -1
- package/dist/types.d.ts +0 -153
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -6
- package/dist/types.js.map +0 -1
package/dist/result.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Result extraction from Claude Code message streams.
|
|
3
|
-
* Accumulates tokens, costs, and text from parsed messages.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Extracts complete ClaudeCodeResult from parsed message stream.
|
|
7
|
-
* Accumulates token counts across assistant messages and extracts cost/duration from final result message.
|
|
8
|
-
*
|
|
9
|
-
* @param messages - Parsed stream messages (ClaudeMessage[])
|
|
10
|
-
* @returns Complete result dict with text, tokens, cost, and exitCode
|
|
11
|
-
*/
|
|
12
|
-
export function extractResult(messages) {
|
|
13
|
-
// Initialize accumulation state
|
|
14
|
-
const tokens = {
|
|
15
|
-
prompt: 0,
|
|
16
|
-
cacheWrite5m: 0,
|
|
17
|
-
cacheWrite1h: 0,
|
|
18
|
-
cacheRead: 0,
|
|
19
|
-
output: 0,
|
|
20
|
-
};
|
|
21
|
-
const textParts = [];
|
|
22
|
-
let cost = 0;
|
|
23
|
-
let duration = 0;
|
|
24
|
-
let exitCode = 0;
|
|
25
|
-
// Iterate messages and accumulate
|
|
26
|
-
for (const msg of messages) {
|
|
27
|
-
if (msg.type === 'assistant') {
|
|
28
|
-
// Accumulate token counts from usage field
|
|
29
|
-
if (msg.message.usage) {
|
|
30
|
-
accumulateTokens(tokens, msg.message.usage);
|
|
31
|
-
}
|
|
32
|
-
// Extract text content from content blocks
|
|
33
|
-
for (const block of msg.message.content) {
|
|
34
|
-
if (block.type === 'text') {
|
|
35
|
-
textParts.push(block.text);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
else if (msg.type === 'result') {
|
|
40
|
-
// Extract cost and duration from final result message
|
|
41
|
-
cost = msg.cost_usd;
|
|
42
|
-
duration = msg.duration_ms;
|
|
43
|
-
exitCode = msg.is_error ? 1 : 0;
|
|
44
|
-
// Include final usage from result message
|
|
45
|
-
accumulateTokens(tokens, msg.usage);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return {
|
|
49
|
-
result: textParts.join(''),
|
|
50
|
-
tokens,
|
|
51
|
-
cost,
|
|
52
|
-
exitCode,
|
|
53
|
-
duration,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Accumulates token counts from usage field into TokenCounts structure.
|
|
58
|
-
* Maps usage fields to TokenCounts fields:
|
|
59
|
-
* - input_tokens -> prompt
|
|
60
|
-
* - output_tokens -> output
|
|
61
|
-
* - cache_creation.ephemeral_5m_input_tokens -> cacheWrite5m
|
|
62
|
-
* - cache_creation.ephemeral_1h_input_tokens -> cacheWrite1h
|
|
63
|
-
* - cache_read_input_tokens -> cacheRead
|
|
64
|
-
*
|
|
65
|
-
* @param tokens - TokenCounts accumulator (mutated)
|
|
66
|
-
* @param usage - TokenUsage from assistant message or result message
|
|
67
|
-
*/
|
|
68
|
-
function accumulateTokens(tokens, usage) {
|
|
69
|
-
// Accumulate input tokens (non-cached prompt)
|
|
70
|
-
if (usage.input_tokens !== undefined) {
|
|
71
|
-
tokens.prompt += usage.input_tokens;
|
|
72
|
-
}
|
|
73
|
-
// Accumulate output tokens
|
|
74
|
-
if (usage.output_tokens !== undefined) {
|
|
75
|
-
tokens.output += usage.output_tokens;
|
|
76
|
-
}
|
|
77
|
-
// Accumulate cache write tokens (5-minute)
|
|
78
|
-
if (usage.cache_creation?.ephemeral_5m_input_tokens !== undefined) {
|
|
79
|
-
tokens.cacheWrite5m +=
|
|
80
|
-
usage.cache_creation.ephemeral_5m_input_tokens;
|
|
81
|
-
}
|
|
82
|
-
// Accumulate cache write tokens (1-hour)
|
|
83
|
-
if (usage.cache_creation?.ephemeral_1h_input_tokens !== undefined) {
|
|
84
|
-
tokens.cacheWrite1h +=
|
|
85
|
-
usage.cache_creation.ephemeral_1h_input_tokens;
|
|
86
|
-
}
|
|
87
|
-
// Accumulate cache read tokens
|
|
88
|
-
if (usage.cache_read_input_tokens !== undefined) {
|
|
89
|
-
tokens.cacheRead +=
|
|
90
|
-
usage.cache_read_input_tokens;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
//# sourceMappingURL=result.js.map
|
package/dist/result.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result.js","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAC3B,QAAkC;IAElC,gCAAgC;IAChC,MAAM,MAAM,GAAgB;QAC1B,MAAM,EAAE,CAAC;QACT,YAAY,EAAE,CAAC;QACf,YAAY,EAAE,CAAC;QACf,SAAS,EAAE,CAAC;QACZ,MAAM,EAAE,CAAC;KACV,CAAC;IACF,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,I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AC;IAC9D,CAAC;IAED,2BAA2B;IAC3B,IAAI,KAAK,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;QACrC,MAA6B,CAAC,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC;IAC/D,CAAC;IAED,2CAA2C;IAC3C,IAAI,KAAK,CAAC,cAAc,EAAE,yBAAyB,KAAK,SAAS,EAAE,CAAC;QACjE,MAAmC,CAAC,YAAY;YAC/C,KAAK,CAAC,cAAc,CAAC,yBAAyB,CAAC;IACnD,CAAC;IAED,yCAAyC;IACzC,IAAI,KAAK,CAAC,cAAc,EAAE,yBAAyB,KAAK,SAAS,EAAE,CAAC;QACjE,MAAmC,CAAC,YAAY;YAC/C,KAAK,CAAC,cAAc,CAAC,yBAAyB,CAAC;IACnD,CAAC;IAED,+BAA+B;IAC/B,IAAI,KAAK,CAAC,uBAAuB,KAAK,SAAS,EAAE,CAAC;QAC/C,MAAgC,CAAC,SAAS;YACzC,KAAK,CAAC,uBAAuB,CAAC;IAClC,CAAC;AACH,CAAC"}
|
package/dist/stream-parser.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Stream parser for line-delimited JSON from Claude CLI.
|
|
3
|
-
* Handles chunked PTY output with ANSI escape sequences.
|
|
4
|
-
*/
|
|
5
|
-
import type { ClaudeMessage } from './types.js';
|
|
6
|
-
/**
|
|
7
|
-
* Stream parser for line-delimited JSON.
|
|
8
|
-
* Buffers incomplete lines across chunks.
|
|
9
|
-
*/
|
|
10
|
-
export interface StreamParser {
|
|
11
|
-
/**
|
|
12
|
-
* Process a chunk of raw PTY output.
|
|
13
|
-
* Emits parsed messages via callback.
|
|
14
|
-
* Throws RuntimeError RILL-R004 for invalid JSON on complete lines.
|
|
15
|
-
*
|
|
16
|
-
* @param chunk - Raw data from PTY (Buffer or string)
|
|
17
|
-
* @param onMessage - Callback for each parsed message
|
|
18
|
-
* @throws RuntimeError with code RILL-R004 for invalid JSON
|
|
19
|
-
*/
|
|
20
|
-
processChunk(chunk: Buffer | string, onMessage: (message: ClaudeMessage) => void): void;
|
|
21
|
-
/**
|
|
22
|
-
* Flush remaining buffered data.
|
|
23
|
-
* Call when stream ends to process incomplete lines.
|
|
24
|
-
*
|
|
25
|
-
* @param onMessage - Callback for final parsed messages
|
|
26
|
-
* @throws RuntimeError with code RILL-R004 for invalid JSON
|
|
27
|
-
*/
|
|
28
|
-
flush(onMessage: (message: ClaudeMessage) => void): void;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Create a new stream parser instance.
|
|
32
|
-
*
|
|
33
|
-
* @returns Stream parser with buffering state
|
|
34
|
-
*/
|
|
35
|
-
export declare function createStreamParser(): StreamParser;
|
|
36
|
-
//# sourceMappingURL=stream-parser.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stream-parser.d.ts","sourceRoot":"","sources":["../src/stream-parser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAMhD;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;;;;OAQG;IACH,YAAY,CACV,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,SAAS,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,GAC1C,IAAI,CAAC;IAER;;;;;;OAMG;IACH,KAAK,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,GAAG,IAAI,CAAC;CAC1D;AAuCD;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,YAAY,CAwEjD"}
|
package/dist/stream-parser.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Stream parser for line-delimited JSON from Claude CLI.
|
|
3
|
-
* Handles chunked PTY output with ANSI escape sequences.
|
|
4
|
-
*/
|
|
5
|
-
// ============================================================
|
|
6
|
-
// ANSI ESCAPE SEQUENCE REMOVAL
|
|
7
|
-
// ============================================================
|
|
8
|
-
/**
|
|
9
|
-
* Regular expression matching ANSI escape sequences.
|
|
10
|
-
* Matches CSI sequences (ESC[...m) and other control codes.
|
|
11
|
-
* Uses String.fromCharCode to avoid ESLint no-control-regex errors.
|
|
12
|
-
*/
|
|
13
|
-
const ANSI_ESCAPE_PATTERN = new RegExp([
|
|
14
|
-
// CSI sequences: ESC [ ... letter
|
|
15
|
-
`${String.fromCharCode(0x1b)}\\[[0-9;]*[A-Za-z]`,
|
|
16
|
-
// OSC sequences: ESC ] ... BEL
|
|
17
|
-
`${String.fromCharCode(0x1b)}\\][^${String.fromCharCode(0x07)}]*${String.fromCharCode(0x07)}`,
|
|
18
|
-
// ESC = and ESC >
|
|
19
|
-
`${String.fromCharCode(0x1b)}[=>]`,
|
|
20
|
-
// Character set selection: ESC ( or ESC ) followed by code
|
|
21
|
-
`${String.fromCharCode(0x1b)}[()][AB012]`,
|
|
22
|
-
].join('|'), 'g');
|
|
23
|
-
/**
|
|
24
|
-
* Strip ANSI escape sequences from text.
|
|
25
|
-
*
|
|
26
|
-
* @param text - Raw text with potential ANSI codes
|
|
27
|
-
* @returns Clean text with ANSI sequences removed
|
|
28
|
-
*/
|
|
29
|
-
function stripAnsi(text) {
|
|
30
|
-
return text.replace(ANSI_ESCAPE_PATTERN, '');
|
|
31
|
-
}
|
|
32
|
-
// ============================================================
|
|
33
|
-
// PARSER FACTORY
|
|
34
|
-
// ============================================================
|
|
35
|
-
/**
|
|
36
|
-
* Create a new stream parser instance.
|
|
37
|
-
*
|
|
38
|
-
* @returns Stream parser with buffering state
|
|
39
|
-
*/
|
|
40
|
-
export function createStreamParser() {
|
|
41
|
-
let buffer = '';
|
|
42
|
-
/**
|
|
43
|
-
* Process a single complete line.
|
|
44
|
-
* Skips non-JSON lines (terminal control codes, progress indicators).
|
|
45
|
-
*/
|
|
46
|
-
function processLine(line, onMessage) {
|
|
47
|
-
// Skip empty lines
|
|
48
|
-
if (line.trim().length === 0) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
// Strip terminal artifacts beyond ANSI sequences
|
|
52
|
-
const cleaned = line.trim().replace(/\[<u/g, '');
|
|
53
|
-
if (cleaned.length === 0) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
try {
|
|
57
|
-
const parsed = JSON.parse(cleaned);
|
|
58
|
-
// Validate parsed object has 'type' discriminant
|
|
59
|
-
if (typeof parsed !== 'object' ||
|
|
60
|
-
parsed === null ||
|
|
61
|
-
!('type' in parsed)) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
onMessage(parsed);
|
|
65
|
-
}
|
|
66
|
-
catch {
|
|
67
|
-
// Skip non-JSON lines (terminal control codes, progress indicators)
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return {
|
|
71
|
-
processChunk(chunk, onMessage) {
|
|
72
|
-
// Convert Buffer to string if needed
|
|
73
|
-
const text = typeof chunk === 'string' ? chunk : chunk.toString('utf8');
|
|
74
|
-
// Append to buffer (ANSI codes included for now)
|
|
75
|
-
buffer += text;
|
|
76
|
-
// Process complete lines
|
|
77
|
-
let newlineIndex;
|
|
78
|
-
while ((newlineIndex = buffer.indexOf('\n')) !== -1) {
|
|
79
|
-
const rawLine = buffer.slice(0, newlineIndex);
|
|
80
|
-
buffer = buffer.slice(newlineIndex + 1);
|
|
81
|
-
// Strip ANSI from complete line before parsing
|
|
82
|
-
const cleanLine = stripAnsi(rawLine);
|
|
83
|
-
processLine(cleanLine, onMessage);
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
flush(onMessage) {
|
|
87
|
-
// Process remaining buffer as final line
|
|
88
|
-
if (buffer.trim().length > 0) {
|
|
89
|
-
const cleanLine = stripAnsi(buffer);
|
|
90
|
-
processLine(cleanLine, onMessage);
|
|
91
|
-
buffer = '';
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
//# sourceMappingURL=stream-parser.js.map
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SAAS,EAAE,SAAS,CAAC,CAAC;gBAClC,MAAM,GAAG,EAAE,CAAC;YACd,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type definitions for Claude Code extension.
|
|
3
|
-
* Defines message types, token tracking, and result structures.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Token count breakdown from Claude Code CLI.
|
|
7
|
-
* Tracks prompt tokens, cache operations, and output tokens.
|
|
8
|
-
*/
|
|
9
|
-
export interface TokenCounts {
|
|
10
|
-
/** Non-cached prompt tokens */
|
|
11
|
-
readonly prompt: number;
|
|
12
|
-
/** Tokens written to 5-minute cache */
|
|
13
|
-
readonly cacheWrite5m: number;
|
|
14
|
-
/** Tokens written to 1-hour cache */
|
|
15
|
-
readonly cacheWrite1h: number;
|
|
16
|
-
/** Tokens read from cache */
|
|
17
|
-
readonly cacheRead: number;
|
|
18
|
-
/** Output tokens generated */
|
|
19
|
-
readonly output: number;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Token usage data from Claude API response.
|
|
23
|
-
* Maps to TokenCounts fields via extraction logic.
|
|
24
|
-
*/
|
|
25
|
-
export interface TokenUsage {
|
|
26
|
-
/** Non-cached input tokens */
|
|
27
|
-
readonly input_tokens?: number | undefined;
|
|
28
|
-
/** Generated output tokens */
|
|
29
|
-
readonly output_tokens?: number | undefined;
|
|
30
|
-
/** Cache read tokens */
|
|
31
|
-
readonly cache_read_input_tokens?: number | undefined;
|
|
32
|
-
/** Structured cache creation tracking */
|
|
33
|
-
readonly cache_creation?: {
|
|
34
|
-
/** 5-minute cache write tokens */
|
|
35
|
-
readonly ephemeral_5m_input_tokens?: number | undefined;
|
|
36
|
-
/** 1-hour cache write tokens */
|
|
37
|
-
readonly ephemeral_1h_input_tokens?: number | undefined;
|
|
38
|
-
} | undefined;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Text content block.
|
|
42
|
-
*/
|
|
43
|
-
export interface TextBlock {
|
|
44
|
-
readonly type: 'text';
|
|
45
|
-
readonly text: string;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Tool use request block.
|
|
49
|
-
*/
|
|
50
|
-
export interface ToolUseBlock {
|
|
51
|
-
readonly type: 'tool_use';
|
|
52
|
-
readonly id: string;
|
|
53
|
-
readonly name: string;
|
|
54
|
-
readonly input: Record<string, unknown>;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Tool result response block.
|
|
58
|
-
*/
|
|
59
|
-
export interface ToolResultBlock {
|
|
60
|
-
readonly type: 'tool_result';
|
|
61
|
-
readonly tool_use_id: string;
|
|
62
|
-
readonly content: string | unknown;
|
|
63
|
-
readonly is_error?: boolean | undefined;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Content block variants for message content arrays.
|
|
67
|
-
*/
|
|
68
|
-
export type ContentBlock = TextBlock | ToolUseBlock | ToolResultBlock;
|
|
69
|
-
/**
|
|
70
|
-
* System initialization message.
|
|
71
|
-
* First message in stream, establishes session config.
|
|
72
|
-
*/
|
|
73
|
-
export interface SystemMessage {
|
|
74
|
-
readonly type: 'system';
|
|
75
|
-
readonly subtype: 'init';
|
|
76
|
-
readonly model: string;
|
|
77
|
-
readonly tools?: readonly unknown[] | undefined;
|
|
78
|
-
readonly mcp_servers?: readonly unknown[] | undefined;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Assistant response message.
|
|
82
|
-
* Contains text and tool use blocks.
|
|
83
|
-
*/
|
|
84
|
-
export interface AssistantMessage {
|
|
85
|
-
readonly type: 'assistant';
|
|
86
|
-
readonly message: {
|
|
87
|
-
readonly content: readonly ContentBlock[];
|
|
88
|
-
readonly usage?: TokenUsage | undefined;
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* User message with tool results.
|
|
93
|
-
* Contains tool result blocks.
|
|
94
|
-
*/
|
|
95
|
-
export interface UserMessage {
|
|
96
|
-
readonly type: 'user';
|
|
97
|
-
readonly message: {
|
|
98
|
-
readonly content: readonly ContentBlock[];
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Result message with cost and duration.
|
|
103
|
-
* Final message in stream with aggregated metrics.
|
|
104
|
-
*/
|
|
105
|
-
export interface ResultMessage {
|
|
106
|
-
readonly type: 'result';
|
|
107
|
-
readonly cost_usd: number;
|
|
108
|
-
readonly duration_ms: number;
|
|
109
|
-
readonly is_error: boolean;
|
|
110
|
-
readonly usage: TokenUsage;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Discriminated union of all Claude Code message types.
|
|
114
|
-
* Discriminant field: `type`
|
|
115
|
-
*/
|
|
116
|
-
export type ClaudeMessage = SystemMessage | AssistantMessage | UserMessage | ResultMessage;
|
|
117
|
-
/**
|
|
118
|
-
* Configuration options for Claude Code integration.
|
|
119
|
-
*/
|
|
120
|
-
export interface ClaudeCodeConfig {
|
|
121
|
-
/** Path to Claude Code CLI binary (default: 'claude') */
|
|
122
|
-
readonly binaryPath?: string | undefined;
|
|
123
|
-
/** Default timeout in milliseconds (default: 1800000) */
|
|
124
|
-
readonly defaultTimeout?: number | undefined;
|
|
125
|
-
/** Skip permission checks (default: true) */
|
|
126
|
-
readonly dangerouslySkipPermissions?: boolean | undefined;
|
|
127
|
-
/** Setting sources to load: 'user', 'project', 'local' (default: '') */
|
|
128
|
-
readonly settingSources?: string | undefined;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Options for prompt execution.
|
|
132
|
-
*/
|
|
133
|
-
export interface PromptOptions {
|
|
134
|
-
/** Execution timeout in milliseconds (overrides defaultTimeout) */
|
|
135
|
-
readonly timeout?: number | undefined;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Complete result from Claude Code prompt execution.
|
|
139
|
-
* Aggregates all stream messages into single structure.
|
|
140
|
-
*/
|
|
141
|
-
export interface ClaudeCodeResult {
|
|
142
|
-
/** Combined text result from all assistant messages */
|
|
143
|
-
readonly result: string;
|
|
144
|
-
/** Token count breakdown */
|
|
145
|
-
readonly tokens: TokenCounts;
|
|
146
|
-
/** Total cost in USD */
|
|
147
|
-
readonly cost: number;
|
|
148
|
-
/** Exit code from CLI process (0 = success) */
|
|
149
|
-
readonly exitCode: number;
|
|
150
|
-
/** Total execution duration in milliseconds */
|
|
151
|
-
readonly duration: number;
|
|
152
|
-
}
|
|
153
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,+BAA+B;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,uCAAuC;IACvC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,qCAAqC;IACrC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,6BAA6B;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,8BAA8B;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,8BAA8B;IAC9B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3C,8BAA8B;IAC9B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5C,wBAAwB;IACxB,QAAQ,CAAC,uBAAuB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtD,yCAAyC;IACzC,QAAQ,CAAC,cAAc,CAAC,EACpB;QACE,kCAAkC;QAClC,QAAQ,CAAC,yBAAyB,CAAC,EAAE,MAAM,GAAG,SAAS,CA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