refactor(sdk): introduce session-based architecture (#19180)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
Michael Bleigh
2026-02-19 16:47:35 -08:00
committed by GitHub
parent 6351352e54
commit f1c0a695f8
21 changed files with 612 additions and 268 deletions
+12 -6
View File
@@ -8,7 +8,8 @@
## `Simple Example`
> **Status:** Implemented. `GeminiCliAgent` supports `cwd` and `sendStream`.
> **Status:** Implemented. `GeminiCliAgent` supports `session()` and
> `resumeSession()`.
Equivalent to `gemini -p "what does this project do?"`. Loads all workspace and
user settings.
@@ -20,10 +21,14 @@ const simpleAgent = new GeminiCliAgent({
cwd: '/path/to/some/dir',
});
for await (const chunk of simpleAgent.sendStream(
'what does this project do?',
)) {
console.log(chunk); // equivalent to JSON streaming chunks (probably?) for now
// Create a new empty session
const session = simpleAgent.session();
// Resume a specific session by ID
// const session = await simpleAgent.resumeSession('some-session-id');
for await (const chunk of session.sendStream('what does this project do?')) {
console.log(chunk); // equivalent to JSON streaming chunks
}
```
@@ -268,8 +273,9 @@ export interface SessionContext {
// helpers to access files and run shell commands while adhering to policies/validation
fs: AgentFilesystem;
shell: AgentShell;
// the agent itself is passed as context
// the agent and session are passed as context
agent: GeminiCliAgent;
session: GeminiCliSession;
}
export interface AgentFilesystem {