@google/gemini-cli 0.1.19-nightly.250814.514e883a → 0.1.20
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/README.md +1 -1
- package/dist/package.json +3 -3
- package/dist/src/acp/acp.d.ts +208 -0
- package/dist/src/{zed-integration → acp}/acp.js +44 -76
- package/dist/src/acp/acp.js.map +1 -0
- package/dist/src/acp/acpPeer.d.ts +8 -0
- package/dist/src/{zed-integration/zedIntegration.js → acp/acpPeer.js} +187 -333
- package/dist/src/acp/acpPeer.js.map +1 -0
- package/dist/src/config/config.d.ts +1 -1
- package/dist/src/config/config.js +8 -11
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/keyBindings.js +0 -4
- package/dist/src/config/keyBindings.js.map +1 -1
- package/dist/src/gemini.js +3 -6
- package/dist/src/gemini.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +1 -1
- package/dist/src/generated/git-commit.js +1 -1
- package/dist/src/nonInteractiveCli.js +2 -1
- package/dist/src/nonInteractiveCli.js.map +1 -1
- package/dist/src/services/BuiltinCommandLoader.js +0 -2
- package/dist/src/services/BuiltinCommandLoader.js.map +1 -1
- package/dist/src/ui/App.js +2 -8
- package/dist/src/ui/App.js.map +1 -1
- package/dist/src/ui/commands/directoryCommand.js +4 -2
- package/dist/src/ui/commands/directoryCommand.js.map +1 -1
- package/dist/src/ui/commands/mcpCommand.js +0 -4
- package/dist/src/ui/commands/mcpCommand.js.map +1 -1
- package/dist/src/ui/commands/types.d.ts +0 -1
- package/dist/src/ui/commands/types.js.map +1 -1
- package/dist/src/ui/components/InputPrompt.js +1 -7
- package/dist/src/ui/components/InputPrompt.js.map +1 -1
- package/dist/src/ui/components/shared/vim-buffer-actions.js +1 -2
- package/dist/src/ui/components/shared/vim-buffer-actions.js.map +1 -1
- package/dist/src/ui/hooks/slashCommandProcessor.js +46 -67
- package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/useFocus.d.ts +0 -4
- package/dist/src/ui/hooks/useFocus.js +4 -4
- package/dist/src/ui/hooks/useFocus.js.map +1 -1
- package/dist/src/ui/hooks/useFolderTrust.d.ts +2 -3
- package/dist/src/ui/hooks/useFolderTrust.js +9 -24
- package/dist/src/ui/hooks/useFolderTrust.js.map +1 -1
- package/dist/src/ui/hooks/useGeminiStream.js +2 -1
- package/dist/src/ui/hooks/useGeminiStream.js.map +1 -1
- package/dist/src/ui/hooks/useKeypress.d.ts +1 -9
- package/dist/src/ui/hooks/useKeypress.js +8 -197
- package/dist/src/ui/hooks/useKeypress.js.map +1 -1
- package/dist/src/ui/utils/errorParsing.d.ts +7 -0
- package/dist/src/ui/utils/errorParsing.js +90 -0
- package/dist/src/ui/utils/errorParsing.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/dist/src/config/trustedFolders.d.ts +0 -36
- package/dist/src/config/trustedFolders.js +0 -112
- package/dist/src/config/trustedFolders.js.map +0 -1
- package/dist/src/ui/commands/terminalSetupCommand.d.ts +0 -13
- package/dist/src/ui/commands/terminalSetupCommand.js +0 -41
- package/dist/src/ui/commands/terminalSetupCommand.js.map +0 -1
- package/dist/src/ui/hooks/useKittyKeyboardProtocol.d.ts +0 -15
- package/dist/src/ui/hooks/useKittyKeyboardProtocol.js +0 -20
- package/dist/src/ui/hooks/useKittyKeyboardProtocol.js.map +0 -1
- package/dist/src/ui/utils/kittyProtocolDetector.d.ts +0 -13
- package/dist/src/ui/utils/kittyProtocolDetector.js +0 -88
- package/dist/src/ui/utils/kittyProtocolDetector.js.map +0 -1
- package/dist/src/ui/utils/platformConstants.d.ts +0 -38
- package/dist/src/ui/utils/platformConstants.js +0 -39
- package/dist/src/ui/utils/platformConstants.js.map +0 -1
- package/dist/src/ui/utils/terminalSetup.d.ts +0 -30
- package/dist/src/ui/utils/terminalSetup.js +0 -281
- package/dist/src/ui/utils/terminalSetup.js.map +0 -1
- package/dist/src/utils/checks.d.ts +0 -19
- package/dist/src/utils/checks.js +0 -24
- package/dist/src/utils/checks.js.map +0 -1
- package/dist/src/zed-integration/acp.d.ts +0 -63
- package/dist/src/zed-integration/acp.js.map +0 -1
- package/dist/src/zed-integration/schema.d.ts +0 -11679
- package/dist/src/zed-integration/schema.js +0 -305
- package/dist/src/zed-integration/schema.js.map +0 -1
- package/dist/src/zed-integration/zedIntegration.d.ts +0 -10
- package/dist/src/zed-integration/zedIntegration.js.map +0 -1
package/README.md
CHANGED
|
@@ -214,7 +214,7 @@ Integrate Gemini CLI directly into your GitHub workflows with the [**Gemini CLI
|
|
|
214
214
|
### Advanced Topics
|
|
215
215
|
|
|
216
216
|
- [**Architecture Overview**](./docs/architecture.md) - How Gemini CLI works
|
|
217
|
-
- [**IDE Integration**](./docs/
|
|
217
|
+
- [**IDE Integration**](./docs/extension.md) - VS Code companion
|
|
218
218
|
- [**Sandboxing & Security**](./docs/sandbox.md) - Safe execution environments
|
|
219
219
|
- [**Enterprise Deployment**](./docs/deployment.md) - Docker, system-wide config
|
|
220
220
|
- [**Telemetry & Monitoring**](./docs/telemetry.md) - Usage tracking
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@google/gemini-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
4
4
|
"description": "Gemini CLI",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"config": {
|
|
28
|
-
"sandboxImageUri": "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.1.
|
|
28
|
+
"sandboxImageUri": "us-docker.pkg.dev/gemini-code-dev/gemini-cli/sandbox:0.1.20"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@google/gemini-cli-core": "file:../core",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"dotenv": "^17.1.0",
|
|
39
39
|
"glob": "^10.4.1",
|
|
40
40
|
"highlight.js": "^11.11.1",
|
|
41
|
-
"ink": "^6.
|
|
41
|
+
"ink": "^6.0.1",
|
|
42
42
|
"ink-big-text": "^2.0.0",
|
|
43
43
|
"ink-gradient": "^3.0.0",
|
|
44
44
|
"ink-link": "^4.1.0",
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Icon } from '@google/gemini-cli-core';
|
|
7
|
+
import { WritableStream, ReadableStream } from 'node:stream/web';
|
|
8
|
+
export declare class ClientConnection implements Client {
|
|
9
|
+
#private;
|
|
10
|
+
constructor(agent: (client: Client) => Agent, input: WritableStream<Uint8Array>, output: ReadableStream<Uint8Array>);
|
|
11
|
+
/**
|
|
12
|
+
* Streams part of an assistant response to the client
|
|
13
|
+
*/
|
|
14
|
+
streamAssistantMessageChunk(params: StreamAssistantMessageChunkParams): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Request confirmation before running a tool
|
|
17
|
+
*
|
|
18
|
+
* When allowed, the client returns a [`ToolCallId`] which can be used
|
|
19
|
+
* to update the tool call's `status` and `content` as it runs.
|
|
20
|
+
*/
|
|
21
|
+
requestToolCallConfirmation(params: RequestToolCallConfirmationParams): Promise<RequestToolCallConfirmationResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* pushToolCall allows the agent to start a tool call
|
|
24
|
+
* when it does not need to request permission to do so.
|
|
25
|
+
*
|
|
26
|
+
* The returned id can be used to update the UI for the tool
|
|
27
|
+
* call as needed.
|
|
28
|
+
*/
|
|
29
|
+
pushToolCall(params: PushToolCallParams): Promise<PushToolCallResponse>;
|
|
30
|
+
/**
|
|
31
|
+
* updateToolCall allows the agent to update the content and status of the tool call.
|
|
32
|
+
*
|
|
33
|
+
* The new content replaces what is currently displayed in the UI.
|
|
34
|
+
*
|
|
35
|
+
* The [`ToolCallId`] is included in the response of
|
|
36
|
+
* `pushToolCall` or `requestToolCallConfirmation` respectively.
|
|
37
|
+
*/
|
|
38
|
+
updateToolCall(params: UpdateToolCallParams): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
type Result<T> = {
|
|
41
|
+
result: T;
|
|
42
|
+
} | {
|
|
43
|
+
error: ErrorResponse;
|
|
44
|
+
};
|
|
45
|
+
type ErrorResponse = {
|
|
46
|
+
code: number;
|
|
47
|
+
message: string;
|
|
48
|
+
data?: {
|
|
49
|
+
details?: string;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export declare class RequestError extends Error {
|
|
53
|
+
code: number;
|
|
54
|
+
data?: {
|
|
55
|
+
details?: string;
|
|
56
|
+
};
|
|
57
|
+
constructor(code: number, message: string, details?: string);
|
|
58
|
+
static parseError(details?: string): RequestError;
|
|
59
|
+
static invalidRequest(details?: string): RequestError;
|
|
60
|
+
static methodNotFound(details?: string): RequestError;
|
|
61
|
+
static invalidParams(details?: string): RequestError;
|
|
62
|
+
static internalError(details?: string): RequestError;
|
|
63
|
+
toResult<T>(): Result<T>;
|
|
64
|
+
}
|
|
65
|
+
export declare const LATEST_PROTOCOL_VERSION = "0.0.9";
|
|
66
|
+
export type AssistantMessageChunk = {
|
|
67
|
+
text: string;
|
|
68
|
+
} | {
|
|
69
|
+
thought: string;
|
|
70
|
+
};
|
|
71
|
+
export type ToolCallConfirmation = {
|
|
72
|
+
description?: string | null;
|
|
73
|
+
type: 'edit';
|
|
74
|
+
} | {
|
|
75
|
+
description?: string | null;
|
|
76
|
+
type: 'execute';
|
|
77
|
+
command: string;
|
|
78
|
+
rootCommand: string;
|
|
79
|
+
} | {
|
|
80
|
+
description?: string | null;
|
|
81
|
+
type: 'mcp';
|
|
82
|
+
serverName: string;
|
|
83
|
+
toolDisplayName: string;
|
|
84
|
+
toolName: string;
|
|
85
|
+
} | {
|
|
86
|
+
description?: string | null;
|
|
87
|
+
type: 'fetch';
|
|
88
|
+
urls: string[];
|
|
89
|
+
} | {
|
|
90
|
+
description: string;
|
|
91
|
+
type: 'other';
|
|
92
|
+
};
|
|
93
|
+
export type ToolCallContent = {
|
|
94
|
+
type: 'markdown';
|
|
95
|
+
markdown: string;
|
|
96
|
+
} | {
|
|
97
|
+
type: 'diff';
|
|
98
|
+
newText: string;
|
|
99
|
+
oldText: string | null;
|
|
100
|
+
path: string;
|
|
101
|
+
};
|
|
102
|
+
export type ToolCallStatus = 'running' | 'finished' | 'error';
|
|
103
|
+
export type ToolCallId = number;
|
|
104
|
+
export type ToolCallConfirmationOutcome = 'allow' | 'alwaysAllow' | 'alwaysAllowMcpServer' | 'alwaysAllowTool' | 'reject' | 'cancel';
|
|
105
|
+
/**
|
|
106
|
+
* A part in a user message
|
|
107
|
+
*/
|
|
108
|
+
export type UserMessageChunk = {
|
|
109
|
+
text: string;
|
|
110
|
+
} | {
|
|
111
|
+
path: string;
|
|
112
|
+
};
|
|
113
|
+
export interface StreamAssistantMessageChunkParams {
|
|
114
|
+
chunk: AssistantMessageChunk;
|
|
115
|
+
}
|
|
116
|
+
export interface RequestToolCallConfirmationParams {
|
|
117
|
+
confirmation: ToolCallConfirmation;
|
|
118
|
+
content?: ToolCallContent | null;
|
|
119
|
+
icon: Icon;
|
|
120
|
+
label: string;
|
|
121
|
+
locations?: ToolCallLocation[];
|
|
122
|
+
}
|
|
123
|
+
export interface ToolCallLocation {
|
|
124
|
+
line?: number | null;
|
|
125
|
+
path: string;
|
|
126
|
+
}
|
|
127
|
+
export interface PushToolCallParams {
|
|
128
|
+
content?: ToolCallContent | null;
|
|
129
|
+
icon: Icon;
|
|
130
|
+
label: string;
|
|
131
|
+
locations?: ToolCallLocation[];
|
|
132
|
+
}
|
|
133
|
+
export interface UpdateToolCallParams {
|
|
134
|
+
content: ToolCallContent | null;
|
|
135
|
+
status: ToolCallStatus;
|
|
136
|
+
toolCallId: ToolCallId;
|
|
137
|
+
}
|
|
138
|
+
export interface RequestToolCallConfirmationResponse {
|
|
139
|
+
id: ToolCallId;
|
|
140
|
+
outcome: ToolCallConfirmationOutcome;
|
|
141
|
+
}
|
|
142
|
+
export interface PushToolCallResponse {
|
|
143
|
+
id: ToolCallId;
|
|
144
|
+
}
|
|
145
|
+
export interface InitializeParams {
|
|
146
|
+
/**
|
|
147
|
+
* The version of the protocol that the client supports.
|
|
148
|
+
* This should be the latest version supported by the client.
|
|
149
|
+
*/
|
|
150
|
+
protocolVersion: string;
|
|
151
|
+
}
|
|
152
|
+
export interface SendUserMessageParams {
|
|
153
|
+
chunks: UserMessageChunk[];
|
|
154
|
+
}
|
|
155
|
+
export interface InitializeResponse {
|
|
156
|
+
/**
|
|
157
|
+
* Indicates whether the agent is authenticated and
|
|
158
|
+
* ready to handle requests.
|
|
159
|
+
*/
|
|
160
|
+
isAuthenticated: boolean;
|
|
161
|
+
/**
|
|
162
|
+
* The version of the protocol that the agent supports.
|
|
163
|
+
* If the agent supports the requested version, it should respond with the same version.
|
|
164
|
+
* Otherwise, the agent should respond with the latest version it supports.
|
|
165
|
+
*/
|
|
166
|
+
protocolVersion: string;
|
|
167
|
+
}
|
|
168
|
+
export interface Error {
|
|
169
|
+
code: number;
|
|
170
|
+
data?: unknown;
|
|
171
|
+
message: string;
|
|
172
|
+
}
|
|
173
|
+
export interface Client {
|
|
174
|
+
streamAssistantMessageChunk(params: StreamAssistantMessageChunkParams): Promise<void>;
|
|
175
|
+
requestToolCallConfirmation(params: RequestToolCallConfirmationParams): Promise<RequestToolCallConfirmationResponse>;
|
|
176
|
+
pushToolCall(params: PushToolCallParams): Promise<PushToolCallResponse>;
|
|
177
|
+
updateToolCall(params: UpdateToolCallParams): Promise<void>;
|
|
178
|
+
}
|
|
179
|
+
export interface Agent {
|
|
180
|
+
/**
|
|
181
|
+
* Initializes the agent's state. It should be called before any other method,
|
|
182
|
+
* and no other methods should be called until it has completed.
|
|
183
|
+
*
|
|
184
|
+
* If the agent is not authenticated, then the client should prompt the user to authenticate,
|
|
185
|
+
* and then call the `authenticate` method.
|
|
186
|
+
* Otherwise the client can send other messages to the agent.
|
|
187
|
+
*/
|
|
188
|
+
initialize(params: InitializeParams): Promise<InitializeResponse>;
|
|
189
|
+
/**
|
|
190
|
+
* Begins the authentication process.
|
|
191
|
+
*
|
|
192
|
+
* This method should only be called if `initialize` indicates the user isn't already authenticated.
|
|
193
|
+
* The Promise MUST not resolve until authentication is complete.
|
|
194
|
+
*/
|
|
195
|
+
authenticate(): Promise<void>;
|
|
196
|
+
/**
|
|
197
|
+
* Allows the user to send a message to the agent.
|
|
198
|
+
* This method should complete after the agent is finished, during
|
|
199
|
+
* which time the agent may update the client by calling
|
|
200
|
+
* streamAssistantMessageChunk and other methods.
|
|
201
|
+
*/
|
|
202
|
+
sendUserMessage(params: SendUserMessageParams): Promise<void>;
|
|
203
|
+
/**
|
|
204
|
+
* Cancels the current generation.
|
|
205
|
+
*/
|
|
206
|
+
cancelSendMessage(): Promise<void>;
|
|
207
|
+
}
|
|
208
|
+
export {};
|
|
@@ -3,82 +3,59 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
import { z } from 'zod';
|
|
8
|
-
import * as schema from './schema.js';
|
|
9
|
-
export * from './schema.js';
|
|
10
|
-
export class AgentSideConnection {
|
|
6
|
+
export class ClientConnection {
|
|
11
7
|
#connection;
|
|
12
|
-
constructor(
|
|
13
|
-
|
|
14
|
-
const handler = async (method, params) => {
|
|
15
|
-
switch (method) {
|
|
16
|
-
case schema.AGENT_METHODS.initialize: {
|
|
17
|
-
const validatedParams = schema.initializeRequestSchema.parse(params);
|
|
18
|
-
return agent.initialize(validatedParams);
|
|
19
|
-
}
|
|
20
|
-
case schema.AGENT_METHODS.session_new: {
|
|
21
|
-
const validatedParams = schema.newSessionRequestSchema.parse(params);
|
|
22
|
-
return agent.newSession(validatedParams);
|
|
23
|
-
}
|
|
24
|
-
case schema.AGENT_METHODS.session_load: {
|
|
25
|
-
if (!agent.loadSession) {
|
|
26
|
-
throw RequestError.methodNotFound();
|
|
27
|
-
}
|
|
28
|
-
const validatedParams = schema.loadSessionRequestSchema.parse(params);
|
|
29
|
-
return agent.loadSession(validatedParams);
|
|
30
|
-
}
|
|
31
|
-
case schema.AGENT_METHODS.authenticate: {
|
|
32
|
-
const validatedParams = schema.authenticateRequestSchema.parse(params);
|
|
33
|
-
return agent.authenticate(validatedParams);
|
|
34
|
-
}
|
|
35
|
-
case schema.AGENT_METHODS.session_prompt: {
|
|
36
|
-
const validatedParams = schema.promptRequestSchema.parse(params);
|
|
37
|
-
return agent.prompt(validatedParams);
|
|
38
|
-
}
|
|
39
|
-
case schema.AGENT_METHODS.session_cancel: {
|
|
40
|
-
const validatedParams = schema.cancelNotificationSchema.parse(params);
|
|
41
|
-
return agent.cancel(validatedParams);
|
|
42
|
-
}
|
|
43
|
-
default:
|
|
44
|
-
throw RequestError.methodNotFound(method);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
this.#connection = new Connection(handler, input, output);
|
|
8
|
+
constructor(agent, input, output) {
|
|
9
|
+
this.#connection = new Connection(agent(this), input, output);
|
|
48
10
|
}
|
|
49
11
|
/**
|
|
50
|
-
* Streams
|
|
12
|
+
* Streams part of an assistant response to the client
|
|
51
13
|
*/
|
|
52
|
-
async
|
|
53
|
-
|
|
14
|
+
async streamAssistantMessageChunk(params) {
|
|
15
|
+
await this.#connection.sendRequest('streamAssistantMessageChunk', params);
|
|
54
16
|
}
|
|
55
17
|
/**
|
|
56
|
-
* Request
|
|
18
|
+
* Request confirmation before running a tool
|
|
57
19
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
20
|
+
* When allowed, the client returns a [`ToolCallId`] which can be used
|
|
21
|
+
* to update the tool call's `status` and `content` as it runs.
|
|
60
22
|
*/
|
|
61
|
-
|
|
62
|
-
return
|
|
23
|
+
requestToolCallConfirmation(params) {
|
|
24
|
+
return this.#connection.sendRequest('requestToolCallConfirmation', params);
|
|
63
25
|
}
|
|
64
|
-
|
|
65
|
-
|
|
26
|
+
/**
|
|
27
|
+
* pushToolCall allows the agent to start a tool call
|
|
28
|
+
* when it does not need to request permission to do so.
|
|
29
|
+
*
|
|
30
|
+
* The returned id can be used to update the UI for the tool
|
|
31
|
+
* call as needed.
|
|
32
|
+
*/
|
|
33
|
+
pushToolCall(params) {
|
|
34
|
+
return this.#connection.sendRequest('pushToolCall', params);
|
|
66
35
|
}
|
|
67
|
-
|
|
68
|
-
|
|
36
|
+
/**
|
|
37
|
+
* updateToolCall allows the agent to update the content and status of the tool call.
|
|
38
|
+
*
|
|
39
|
+
* The new content replaces what is currently displayed in the UI.
|
|
40
|
+
*
|
|
41
|
+
* The [`ToolCallId`] is included in the response of
|
|
42
|
+
* `pushToolCall` or `requestToolCallConfirmation` respectively.
|
|
43
|
+
*/
|
|
44
|
+
async updateToolCall(params) {
|
|
45
|
+
await this.#connection.sendRequest('updateToolCall', params);
|
|
69
46
|
}
|
|
70
47
|
}
|
|
71
48
|
class Connection {
|
|
72
49
|
#pendingResponses = new Map();
|
|
73
50
|
#nextRequestId = 0;
|
|
74
|
-
#
|
|
51
|
+
#delegate;
|
|
75
52
|
#peerInput;
|
|
76
53
|
#writeQueue = Promise.resolve();
|
|
77
54
|
#textEncoder;
|
|
78
|
-
constructor(
|
|
79
|
-
this.#handler = handler;
|
|
55
|
+
constructor(delegate, peerInput, peerOutput) {
|
|
80
56
|
this.#peerInput = peerInput;
|
|
81
57
|
this.#textEncoder = new TextEncoder();
|
|
58
|
+
this.#delegate = delegate;
|
|
82
59
|
this.#receive(peerOutput);
|
|
83
60
|
}
|
|
84
61
|
async #receive(output) {
|
|
@@ -98,36 +75,31 @@ class Connection {
|
|
|
98
75
|
}
|
|
99
76
|
}
|
|
100
77
|
async #processMessage(message) {
|
|
101
|
-
if ('method' in message
|
|
102
|
-
|
|
103
|
-
const response = await this.#tryCallHandler(message.method, message.params);
|
|
78
|
+
if ('method' in message) {
|
|
79
|
+
const response = await this.#tryCallDelegateMethod(message.method, message.params);
|
|
104
80
|
await this.#sendMessage({
|
|
105
81
|
jsonrpc: '2.0',
|
|
106
82
|
id: message.id,
|
|
107
83
|
...response,
|
|
108
84
|
});
|
|
109
85
|
}
|
|
110
|
-
else
|
|
111
|
-
// It's a notification
|
|
112
|
-
await this.#tryCallHandler(message.method, message.params);
|
|
113
|
-
}
|
|
114
|
-
else if ('id' in message) {
|
|
115
|
-
// It's a response
|
|
86
|
+
else {
|
|
116
87
|
this.#handleResponse(message);
|
|
117
88
|
}
|
|
118
89
|
}
|
|
119
|
-
async #
|
|
90
|
+
async #tryCallDelegateMethod(method, params) {
|
|
91
|
+
const methodName = method;
|
|
92
|
+
if (typeof this.#delegate[methodName] !== 'function') {
|
|
93
|
+
return RequestError.methodNotFound(method).toResult();
|
|
94
|
+
}
|
|
120
95
|
try {
|
|
121
|
-
const result = await this.#
|
|
96
|
+
const result = await this.#delegate[methodName](params);
|
|
122
97
|
return { result: result ?? null };
|
|
123
98
|
}
|
|
124
99
|
catch (error) {
|
|
125
100
|
if (error instanceof RequestError) {
|
|
126
101
|
return error.toResult();
|
|
127
102
|
}
|
|
128
|
-
if (error instanceof z.ZodError) {
|
|
129
|
-
return RequestError.invalidParams(JSON.stringify(error.format(), undefined, 2)).toResult();
|
|
130
|
-
}
|
|
131
103
|
let details;
|
|
132
104
|
if (error instanceof Error) {
|
|
133
105
|
details = error.message;
|
|
@@ -161,9 +133,6 @@ class Connection {
|
|
|
161
133
|
await this.#sendMessage({ jsonrpc: '2.0', id, method, params });
|
|
162
134
|
return responsePromise;
|
|
163
135
|
}
|
|
164
|
-
async sendNotification(method, params) {
|
|
165
|
-
await this.#sendMessage({ jsonrpc: '2.0', method, params });
|
|
166
|
-
}
|
|
167
136
|
async #sendMessage(json) {
|
|
168
137
|
const content = JSON.stringify(json) + '\n';
|
|
169
138
|
this.#writeQueue = this.#writeQueue
|
|
@@ -209,9 +178,6 @@ export class RequestError extends Error {
|
|
|
209
178
|
static internalError(details) {
|
|
210
179
|
return new RequestError(-32603, 'Internal error', details);
|
|
211
180
|
}
|
|
212
|
-
static authRequired(details) {
|
|
213
|
-
return new RequestError(-32000, 'Authentication required', details);
|
|
214
|
-
}
|
|
215
181
|
toResult() {
|
|
216
182
|
return {
|
|
217
183
|
error: {
|
|
@@ -222,4 +188,6 @@ export class RequestError extends Error {
|
|
|
222
188
|
};
|
|
223
189
|
}
|
|
224
190
|
}
|
|
191
|
+
// Protocol types
|
|
192
|
+
export const LATEST_PROTOCOL_VERSION = '0.0.9';
|
|
225
193
|
//# sourceMappingURL=acp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acp.js","sourceRoot":"","sources":["../../../src/acp/acp.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,MAAM,OAAO,gBAAgB;IAC3B,WAAW,CAAoB;IAE/B,YACE,KAAgC,EAChC,KAAiC,EACjC,MAAkC;QAElC,IAAI,CAAC,WAAW,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAChE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,2BAA2B,CAC/B,MAAyC;QAEzC,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,6BAA6B,EAAE,MAAM,CAAC,CAAC;IAC5E,CAAC;IAED;;;;;OAKG;IACH,2BAA2B,CACzB,MAAyC;QAEzC,OAAO,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,6BAA6B,EAAE,MAAM,CAAC,CAAC;IAC7E,CAAC;IAED;;;;;;OAMG;IACH,YAAY,CAAC,MAA0B;QACrC,OAAO,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;IAC9D,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,cAAc,CA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K,EAAE,kBAAkB,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,OAAgB;QACnC,OAAO,IAAI,YAAY,CAAC,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAC;IAC7D,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,OAAgB;QACnC,OAAO,IAAI,YAAY,CAAC,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAC;IAC7D,CAAC;IAED,QAAQ;QACN,OAAO;YACL,KAAK,EAAE;gBACL,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB;SACF,CAAC;IACJ,CAAC;CACF;AAED,iBAAiB;AAEjB,MAAM,CAAC,MAAM,uBAAuB,GAAG,OAAO,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Config } from '@google/gemini-cli-core';
|
|
7
|
+
import { LoadedSettings } from '../config/settings.js';
|
|
8
|
+
export declare function runAcpPeer(config: Config, settings: LoadedSettings): Promise<void>;
|