@tencent-ai/agent-sdk 0.3.11 → 0.3.12
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/cli/CHANGELOG.md +6 -0
- package/cli/dist/codebuddy.js +1 -1
- package/cli/package.json +1 -1
- package/cli/product.cloudhosted.json +2 -2
- package/cli/product.internal.json +2 -2
- package/cli/product.ioa.json +2 -2
- package/cli/product.json +2 -2
- package/cli/product.selfhosted.json +2 -2
- package/lib/acp/agent.d.ts +226 -11
- package/lib/acp/agent.d.ts.map +1 -1
- package/lib/acp/agent.js +302 -21
- package/lib/acp/agent.js.map +1 -1
- package/lib/acp/converter.d.ts +77 -0
- package/lib/acp/converter.d.ts.map +1 -0
- package/lib/acp/converter.js +613 -0
- package/lib/acp/converter.js.map +1 -0
- package/lib/acp/index.d.ts +4 -14
- package/lib/acp/index.d.ts.map +1 -1
- package/lib/acp/index.js +4 -15
- package/lib/acp/index.js.map +1 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -4
- package/lib/index.js.map +1 -1
- package/lib/session.d.ts +13 -9
- package/lib/session.d.ts.map +1 -1
- package/lib/session.js +18 -107
- package/lib/session.js.map +1 -1
- package/lib/types.d.ts +15 -7
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +1 -1
- package/lib/acp/tool-converter.d.ts +0 -152
- package/lib/acp/tool-converter.d.ts.map +0 -1
- package/lib/acp/tool-converter.js +0 -806
- package/lib/acp/tool-converter.js.map +0 -1
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ACP Message Transformer
|
|
3
|
-
*
|
|
4
|
-
* Converts SDK internal tool formats to ACP (Agent Client Protocol) format and vice versa.
|
|
5
|
-
*
|
|
6
|
-
* Uses official @agentclientprotocol/sdk types for compatibility with the ACP specification.
|
|
7
|
-
*
|
|
8
|
-
* Critical Design Principle: NO DATA LOSS
|
|
9
|
-
* - SDK tool inputs are preserved completely in rawInput
|
|
10
|
-
* - Tool IDs are maintained throughout the conversion
|
|
11
|
-
* - Tool results are preserved with error state tracking
|
|
12
|
-
*/
|
|
13
|
-
import type { ToolUseContentBlock, ToolResultContentBlock, Message } from '../types';
|
|
14
|
-
import type { ToolCall, ToolKind, ToolCallStatus, ToolCallLocation, ToolCallContent } from '@agentclientprotocol/sdk';
|
|
15
|
-
import type { ControlRequest } from '../types';
|
|
16
|
-
/**
|
|
17
|
-
* ACP message types (JSON-RPC 2.0 messages)
|
|
18
|
-
*/
|
|
19
|
-
export interface AcpMessage {
|
|
20
|
-
jsonrpc: '2.0';
|
|
21
|
-
id?: string | number;
|
|
22
|
-
method?: string;
|
|
23
|
-
params?: unknown;
|
|
24
|
-
result?: unknown;
|
|
25
|
-
error?: {
|
|
26
|
-
code: number;
|
|
27
|
-
message: string;
|
|
28
|
-
data?: unknown;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* ACP Tool Call representation using official @agentclientprotocol/sdk types.
|
|
33
|
-
*
|
|
34
|
-
* See: https://agentclientprotocol.com/protocol/tool-calls
|
|
35
|
-
*/
|
|
36
|
-
export type AcpToolCall = ToolCall;
|
|
37
|
-
/**
|
|
38
|
-
* Tool kind categories using official ACP types.
|
|
39
|
-
* Includes: 'read', 'edit', 'delete', 'move', 'search', 'execute', 'think', 'fetch', 'switch_mode', 'other'
|
|
40
|
-
*
|
|
41
|
-
* See: https://agentclientprotocol.com/protocol/tool-calls#creating
|
|
42
|
-
*/
|
|
43
|
-
export type AcpToolKind = ToolKind;
|
|
44
|
-
/**
|
|
45
|
-
* Tool call status using official ACP types.
|
|
46
|
-
*/
|
|
47
|
-
export type AcpToolStatus = ToolCallStatus;
|
|
48
|
-
/**
|
|
49
|
-
* File location information using official ACP types.
|
|
50
|
-
*/
|
|
51
|
-
export type AcpLocation = ToolCallLocation;
|
|
52
|
-
/**
|
|
53
|
-
* Tool call content using official ACP types.
|
|
54
|
-
*/
|
|
55
|
-
export type AcpToolCallContent = ToolCallContent;
|
|
56
|
-
/**
|
|
57
|
-
* ACP Tool Result representation for reporting tool execution results.
|
|
58
|
-
*/
|
|
59
|
-
export interface AcpToolResult {
|
|
60
|
-
toolCallId: string;
|
|
61
|
-
status: 'completed' | 'failed';
|
|
62
|
-
content?: ToolCallContent[];
|
|
63
|
-
locations?: AcpLocation[];
|
|
64
|
-
rawOutput?: unknown;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Bidirectional converter between SDK internal format (JSON Lines) and ACP (Agent Client Protocol) format.
|
|
68
|
-
*
|
|
69
|
-
* This is an abstract utility class with only static methods - do not instantiate.
|
|
70
|
-
*
|
|
71
|
-
* Key features:
|
|
72
|
-
* - Converts SDK tool use/result to ACP format
|
|
73
|
-
* - Converts ACP messages to SDK format
|
|
74
|
-
* - Extracts and manipulates tool/text blocks
|
|
75
|
-
* - Complete data preservation in roundtrip conversions
|
|
76
|
-
* - Type-safe message routing
|
|
77
|
-
*/
|
|
78
|
-
export declare abstract class AcpTransformer {
|
|
79
|
-
/**
|
|
80
|
-
* Convert SDK ToolUseContentBlock to complete session/update params
|
|
81
|
-
* Returns an object that can be spread directly into AcpMessage params
|
|
82
|
-
*
|
|
83
|
-
* This is the preferred method for creating tool call messages that comply with ACP spec.
|
|
84
|
-
*
|
|
85
|
-
* @param toolUse - SDK tool use block
|
|
86
|
-
* @param sessionId - Session ID for the message
|
|
87
|
-
* @param messageId - Optional message ID (defaults to toolUse.id)
|
|
88
|
-
* @returns Complete params object ready to be used in session/update message
|
|
89
|
-
*/
|
|
90
|
-
static convertSdkToolUseToSessionUpdate(toolUse: ToolUseContentBlock, sessionId: string, messageId?: string): {
|
|
91
|
-
sessionId: string;
|
|
92
|
-
update: {
|
|
93
|
-
sessionUpdate: "tool_call";
|
|
94
|
-
toolCallId: string;
|
|
95
|
-
status: "pending";
|
|
96
|
-
title: string;
|
|
97
|
-
kind: ToolKind;
|
|
98
|
-
rawInput: Record<string, unknown>;
|
|
99
|
-
content: ToolCallContent[] | undefined;
|
|
100
|
-
locations: ToolCallLocation[] | undefined;
|
|
101
|
-
};
|
|
102
|
-
_meta: {
|
|
103
|
-
'codebuddy.ai': {
|
|
104
|
-
toolName: string;
|
|
105
|
-
messageId: string;
|
|
106
|
-
};
|
|
107
|
-
};
|
|
108
|
-
};
|
|
109
|
-
/**
|
|
110
|
-
* Convert ACP Tool Result to SDK ToolResultContentBlock
|
|
111
|
-
* Preserves tool_use_id and ensures error state is tracked
|
|
112
|
-
*/
|
|
113
|
-
static convertAcpToolResultToSdk(toolCallId: string, acpResult: AcpToolResult): ToolResultContentBlock;
|
|
114
|
-
/**
|
|
115
|
-
* Convert SDK ToolResultContentBlock to ACP ToolResult
|
|
116
|
-
* Enables bidirectional conversion for tool results
|
|
117
|
-
*/
|
|
118
|
-
static convertSdkToolResultToAcpToolResult(toolResult: ToolResultContentBlock): AcpToolResult;
|
|
119
|
-
/**
|
|
120
|
-
* Convert ACP message to SDK internal format (JSON Lines)
|
|
121
|
-
*
|
|
122
|
-
* Converts all ACP message types to corresponding SDK messages:
|
|
123
|
-
* - session/prompt: User input → UserMessage
|
|
124
|
-
* - session/cancel: Cancellation request → ControlRequest
|
|
125
|
-
* - session/update (tool_call_update): Tool result → UserMessage with tool_result block
|
|
126
|
-
*/
|
|
127
|
-
static acpToSdk(acpMessage: AcpMessage): Message | ControlRequest | null;
|
|
128
|
-
/**
|
|
129
|
-
* Convert SDK internal message to ACP format
|
|
130
|
-
*
|
|
131
|
-
* @param message - SDK message to convert
|
|
132
|
-
* @param mode - Conversion mode:
|
|
133
|
-
* - 'stream': Real-time streaming mode (session/prompt) - converts to incremental chunks
|
|
134
|
-
* - 'history': History replay mode (session/load) - converts to complete messages
|
|
135
|
-
*
|
|
136
|
-
* Converts all SDK message types to corresponding ACP messages:
|
|
137
|
-
* - Stream mode: PartialAssistantMessage (stream_event) → streaming text/tool deltas
|
|
138
|
-
* - History mode: AssistantMessage/UserMessage → complete message objects
|
|
139
|
-
*/
|
|
140
|
-
static sdkToAcp(message: Message, mode?: 'stream' | 'history'): AcpMessage[];
|
|
141
|
-
private static generateToolTitle;
|
|
142
|
-
private static getToolKind;
|
|
143
|
-
private static generateToolContent;
|
|
144
|
-
private static extractToolLocations;
|
|
145
|
-
private static formatAcpContentForSdk;
|
|
146
|
-
private static formatDiffHunk;
|
|
147
|
-
private static privateExtractPromptText;
|
|
148
|
-
private static privateExtractToolUseBlocks;
|
|
149
|
-
private static privateExtractTextContent;
|
|
150
|
-
private static privateCreateToolResultMessage;
|
|
151
|
-
}
|
|
152
|
-
//# sourceMappingURL=tool-converter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-converter.d.ts","sourceRoot":"","sources":["../../src/acp/tool-converter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACR,mBAAmB,EACnB,sBAAsB,EAItB,OAAO,EAGV,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EACR,QAAQ,EACR,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,eAAe,EAElB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAI/C;;GAEG;AACH,MAAM,WAAW,UAAU;IACvB,OAAO,EAAE,KAAK,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,OAAO,CAAC;KAClB,CAAC;CACL;AAED;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC;AAEnC;;;;;G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