goatchain 0.0.7 → 0.0.8
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 +34 -62
- package/README.zh.md +39 -0
- package/dist/acp-adapter/types.d.ts +1 -0
- package/dist/agent/agent.d.ts +6 -4
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/types.d.ts +13 -6
- package/dist/index.d.ts +3 -2
- package/dist/index.js +136 -137
- package/dist/middleware/checkpointMiddleware.d.ts +19 -0
- package/dist/middleware/utils.d.ts +79 -0
- package/dist/model/createModel.d.ts +4 -70
- package/dist/model/index.d.ts +1 -1
- package/dist/model/types.d.ts +1 -7
- package/dist/session/executors/ToolExecutor.d.ts +2 -0
- package/dist/session/session.d.ts +32 -1
- package/dist/state/FileStateStore.d.ts +0 -1
- package/dist/state/InMemoryStateStore.d.ts +0 -1
- package/dist/state/stateStore.d.ts +0 -4
- package/dist/state/types.d.ts +0 -7
- package/dist/tool/builtin/read.d.ts +1 -1
- package/dist/tool/builtin/write.d.ts +1 -1
- package/package.json +23 -8
- package/dist/model/health.d.ts +0 -35
- package/dist/model/router.d.ts +0 -17
package/README.md
CHANGED
|
@@ -62,77 +62,51 @@ for await (const event of session.receive()) {
|
|
|
62
62
|
|
|
63
63
|
## 🧰 CLI
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
GoatChain CLI is a terminal UI (TUI) built on `@simon_he/vue-tui`.
|
|
66
|
+
|
|
67
|
+
### Installation
|
|
68
|
+
|
|
69
|
+
**Global installation (recommended):**
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npm install -g goatchain-cli@latest
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Or use npx without installation:**
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
npx goatchain-cli@latest
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Usage
|
|
82
|
+
|
|
83
|
+
After installation, simply run:
|
|
66
84
|
|
|
67
85
|
```bash
|
|
68
86
|
goatchain
|
|
69
87
|
```
|
|
70
88
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
-
|
|
74
|
-
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
- `/set <k> <v>` set request params (e.g. `temperature`, `maxTokens`)
|
|
86
|
-
- `/unset <k>` clear a request param
|
|
87
|
-
- `/params` show current request params
|
|
88
|
-
- `/base-url <url>` set base URL
|
|
89
|
-
- `/api-key <key>` set API key (not printed)
|
|
90
|
-
- `/web-search-key <key>` set Serper API key for WebSearch tool (not printed)
|
|
91
|
-
- `/tools` list enabled tools (Read/Write/Edit/Glob/Grep/WebSearch*)
|
|
92
|
-
- `/sessions` list and pick a saved session
|
|
93
|
-
- `/use <sessionId>` restore a saved session (prints recent history)
|
|
94
|
-
- `/save` persist current config/session
|
|
95
|
-
- `/status` show current model/session info
|
|
96
|
-
- `/new` start a new conversation (clears history)
|
|
97
|
-
|
|
98
|
-
Requires `OPENAI_API_KEY` in the environment.
|
|
99
|
-
|
|
100
|
-
Web search (optional):
|
|
101
|
-
|
|
102
|
-
- Set `SERPER_API_KEY` (or `GOATCHAIN_SERPER_API_KEY`) to enable the builtin `WebSearch` tool for up-to-date info like weather.
|
|
103
|
-
- In interactive mode, you can also run `/web-search-key <key>` to persist the key into the workspace config.
|
|
104
|
-
- You can also set it in `./.goatchain/config.json` (workspace-scoped, gitignored):
|
|
105
|
-
- `{"tools":{"webSearch":{"apiKey":"...","apiEndpoint":"...","numResults":10}}}`
|
|
106
|
-
|
|
107
|
-
Plan mode (interactive planning):
|
|
108
|
-
|
|
109
|
-
- Enable with `/plan on` to enter a plan-first workflow:
|
|
110
|
-
1. Agent explores the codebase and researches your request
|
|
111
|
-
2. Agent may ask clarifying questions using the `AskUserQuestion` tool to understand your preferences (e.g., library choices, architectural decisions)
|
|
112
|
-
3. Agent creates a structured plan using `TodoPlan` (3-8 steps)
|
|
113
|
-
4. You review and approve the plan
|
|
114
|
-
5. Agent executes the approved plan
|
|
115
|
-
- During planning, file modifications are blocked (read-only phase)
|
|
116
|
-
- Set `GOATCHAIN_PLAN_MODE=1` or configure in `.goatchain/config.json` to enable by default
|
|
117
|
-
|
|
118
|
-
Local persistence (workspace-scoped):
|
|
119
|
-
|
|
120
|
-
- Config and sessions are saved under `./.goatchain/` (auto-created).
|
|
121
|
-
- `.goatchain/` is gitignored to avoid accidentally committing secrets.
|
|
122
|
-
|
|
123
|
-
DeepSeek thinking mode compatibility:
|
|
124
|
-
|
|
125
|
-
- Some OpenAI-compatible gateways (e.g. DeepSeek thinking mode) require `reasoning_content` to be present on assistant messages that contain `tool_calls` (and may reject empty strings). GoatChain will attach the accumulated thinking content when available.
|
|
126
|
-
- If you use DeepSeek via a proxy where GoatChain can't detect it from `baseUrl`/`modelId`, you can enable this explicitly:
|
|
127
|
-
- Interactive: Run `/settings` and toggle "Interleaved Thinking"
|
|
128
|
-
- Config file: Set `openai.compat.interleavedThinking=true` in `./.goatchain/config.json`
|
|
89
|
+
Inside the TUI:
|
|
90
|
+
|
|
91
|
+
- `Ctrl+P` opens the command palette (Sessions / New Session / Settings / Tool Approvals; Chat also has Theme)
|
|
92
|
+
- Slash commands in the input: `/settings`, `/approvals`, `/sessions`, `/new` (Chat also supports `/redo`)
|
|
93
|
+
|
|
94
|
+
### Development
|
|
95
|
+
|
|
96
|
+
Run it from this repo:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
bun run cli
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
See `docs/cli.md` for the full feature list and flowcharts.
|
|
129
103
|
|
|
130
104
|
## 🔌 ACP Server
|
|
131
105
|
|
|
132
106
|
GoatChain can be exposed as an ACP (Agent Client Protocol) server for integration with editors like Zed.
|
|
133
107
|
|
|
134
108
|
```bash
|
|
135
|
-
|
|
109
|
+
bun run acp-server
|
|
136
110
|
```
|
|
137
111
|
|
|
138
112
|
**Configuration for Zed** (`settings.json`):
|
|
@@ -190,7 +164,6 @@ classDiagram
|
|
|
190
164
|
|
|
191
165
|
class StateStore {
|
|
192
166
|
<<interface>>
|
|
193
|
-
+savePoint: string
|
|
194
167
|
+deleteOnComplete: boolean
|
|
195
168
|
+saveCheckpoint(checkpoint): Promise~void~
|
|
196
169
|
+loadCheckpoint(sessionId): Promise~AgentLoopCheckpoint~
|
|
@@ -404,7 +377,6 @@ import { Agent, FileStateStore } from 'goatchain'
|
|
|
404
377
|
// Create state store with configuration
|
|
405
378
|
const stateStore = new FileStateStore({
|
|
406
379
|
dir: './checkpoints',
|
|
407
|
-
savePoint: 'before', // Save before each iteration
|
|
408
380
|
deleteOnComplete: true, // Clean up after successful completion
|
|
409
381
|
})
|
|
410
382
|
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# GoatChain(中文)
|
|
2
|
+
|
|
3
|
+
GoatChain 是一个轻量、可扩展的 TypeScript Agent SDK,包含一个基于终端 UI 的 CLI(TUI)。
|
|
4
|
+
|
|
5
|
+
- CLI(TUI)能力说明与流程图:`docs/cli.md`
|
|
6
|
+
- 英文 README:`README.md`
|
|
7
|
+
|
|
8
|
+
## CLI 安装和使用
|
|
9
|
+
|
|
10
|
+
### 安装
|
|
11
|
+
|
|
12
|
+
**全局安装(推荐):**
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install -g goatchain-cli@latest
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
**或使用 npx(无需安装):**
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npx goatchain-cli@latest
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### 使用
|
|
25
|
+
|
|
26
|
+
安装完成后,直接运行:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
goatchain
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### TUI 快捷键
|
|
33
|
+
|
|
34
|
+
- `Ctrl+P` 打开命令面板(会话 / 新建会话 / 设置 / 工具批准;聊天界面还有主题)
|
|
35
|
+
- 输入框中的斜杠命令:`/settings`、`/approvals`、`/sessions`、`/new`(聊天界面还支持 `/redo`)
|
|
36
|
+
|
|
37
|
+
详细功能列表和流程图请查看 [docs/cli.md](./docs/cli.md)。
|
|
38
|
+
|
|
39
|
+
|
package/dist/agent/agent.d.ts
CHANGED
|
@@ -26,7 +26,13 @@ export declare class Agent {
|
|
|
26
26
|
private _middlewares;
|
|
27
27
|
private _middlewareCounter;
|
|
28
28
|
private _middlewareTools;
|
|
29
|
+
private _enableLogging;
|
|
29
30
|
constructor(options: AgentOptions);
|
|
31
|
+
/**
|
|
32
|
+
* Internal logging method
|
|
33
|
+
* @private
|
|
34
|
+
*/
|
|
35
|
+
private _log;
|
|
30
36
|
/**
|
|
31
37
|
* Get the model client
|
|
32
38
|
*/
|
|
@@ -42,10 +48,6 @@ export declare class Agent {
|
|
|
42
48
|
* - Otherwise, returns the model client's default `modelRef` (if supported).
|
|
43
49
|
*/
|
|
44
50
|
get modelRef(): ModelRef | undefined;
|
|
45
|
-
/**
|
|
46
|
-
* Get the available model references (e.g. routing fallback order), if supported by the model client.
|
|
47
|
-
*/
|
|
48
|
-
get modelRefs(): ModelRef[];
|
|
49
51
|
/**
|
|
50
52
|
* Get the tool registry
|
|
51
53
|
*/
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { fromLoopCheckpoint, toLoopCheckpoint } from '../middleware/checkpointMiddleware';
|
|
1
|
+
export { extractPersistentMetadata, extractPersistentState, fromLoopCheckpoint, toLoopCheckpoint, } from '../middleware/checkpointMiddleware';
|
|
2
2
|
export type { ToCheckpointOptions } from '../middleware/checkpointMiddleware';
|
|
3
3
|
export { compressSessionManually, createContextCompressionMiddleware } from '../middleware/contextCompressionMiddleware';
|
|
4
4
|
export type { ManualCompressionOptions, ManualCompressionResult } from '../middleware/contextCompressionMiddleware';
|
package/dist/agent/types.d.ts
CHANGED
|
@@ -143,10 +143,21 @@ export interface AgentOptions {
|
|
|
143
143
|
* A SessionManager is automatically created to manage sessions.
|
|
144
144
|
* Sessions will be stored in the StateStore.
|
|
145
145
|
*
|
|
146
|
-
* The state store
|
|
147
|
-
*
|
|
146
|
+
* The state store can be configured with deleteOnComplete to control
|
|
147
|
+
* whether checkpoints are deleted after successful completion.
|
|
148
148
|
*/
|
|
149
149
|
stateStore?: StateStore;
|
|
150
|
+
/**
|
|
151
|
+
* Enable console logging for debugging (default: false).
|
|
152
|
+
*
|
|
153
|
+
* When enabled, the agent will output logs for key operations:
|
|
154
|
+
* - Agent and session creation
|
|
155
|
+
* - Message sending and receiving
|
|
156
|
+
* - Model calls and responses
|
|
157
|
+
* - Tool executions
|
|
158
|
+
* - Middleware execution
|
|
159
|
+
*/
|
|
160
|
+
enableLogging?: boolean;
|
|
150
161
|
}
|
|
151
162
|
/**
|
|
152
163
|
* Input for agent execution
|
|
@@ -239,10 +250,6 @@ export interface CreateSessionOptions extends SessionHandleOptions {
|
|
|
239
250
|
maxIterations?: number;
|
|
240
251
|
}
|
|
241
252
|
export interface SendOptions {
|
|
242
|
-
/**
|
|
243
|
-
* AbortSignal for cancellation support
|
|
244
|
-
*/
|
|
245
|
-
signal?: AbortSignal;
|
|
246
253
|
/**
|
|
247
254
|
* Optional tool execution context input
|
|
248
255
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Agent, AgentAbortError, AgentMaxIterationsError, compose, compressSessionManually, createContextCompressionMiddleware, createInitialLoopState, ensureNotAborted, fromLoopCheckpoint, HookManager, toLoopCheckpoint, } from './agent';
|
|
1
|
+
export { Agent, AgentAbortError, AgentMaxIterationsError, compose, compressSessionManually, createContextCompressionMiddleware, createInitialLoopState, ensureNotAborted, extractPersistentMetadata, extractPersistentState, fromLoopCheckpoint, HookManager, toLoopCheckpoint, } from './agent';
|
|
2
2
|
export type { AgentInput, AgentLoopState, AgentOptions, CompressionStats, ContextCompressionOptions, CreateSessionOptions, HookContext, ManualCompressionOptions, ManualCompressionResult, Middleware, NextFunction, PostToolUseFailureHook, PostToolUseHook, PreToolUseHook, PreToolUseResult, SendOptions, SessionHandleOptions, ToCheckpointOptions, ToolCallWithResult, ToolHooks, } from './agent';
|
|
3
3
|
export { createCommitModeMiddleware } from './middleware/commitModeMiddleware';
|
|
4
4
|
export type { CommitModeMiddlewareOptions } from './middleware/commitModeMiddleware';
|
|
@@ -6,7 +6,8 @@ export { createPlanModeMiddleware } from './middleware/planModeMiddleware';
|
|
|
6
6
|
export type { PlanModeMiddlewareOptions } from './middleware/planModeMiddleware';
|
|
7
7
|
export { createParallelSubagentMiddleware } from './middleware/parallelSubagentMiddleware';
|
|
8
8
|
export type { ParallelSubagentMiddlewareOptions } from './middleware/parallelSubagentMiddleware';
|
|
9
|
-
export { injectSystemReminderToLastUserMessage } from './middleware/utils';
|
|
9
|
+
export { createMessageSnapshot, injectSystemReminderToLastUserMessage, restoreMessageAt, restoreMessages, snapshotMessageByRole, } from './middleware/utils';
|
|
10
|
+
export type { MessageRestoration } from './middleware/utils';
|
|
10
11
|
export * from './subagent';
|
|
11
12
|
export * from './acp-adapter';
|
|
12
13
|
export { runAcpServer } from './acp-server';
|