thinkwell 0.4.5 → 0.5.0-alpha.2
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 +3 -5
- package/bin/thinkwell +130 -174
- package/dist/agent.d.ts +82 -56
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +178 -174
- package/dist/agent.js.map +1 -1
- package/dist/cli/build.d.ts +15 -43
- package/dist/cli/build.d.ts.map +1 -1
- package/dist/cli/build.js +199 -1231
- package/dist/cli/build.js.map +1 -1
- package/dist/cli/bundle.d.ts +61 -0
- package/dist/cli/bundle.d.ts.map +1 -0
- package/dist/cli/bundle.js +1299 -0
- package/dist/cli/bundle.js.map +1 -0
- package/dist/cli/check.d.ts +19 -0
- package/dist/cli/check.d.ts.map +1 -0
- package/dist/cli/check.js +248 -0
- package/dist/cli/check.js.map +1 -0
- package/dist/cli/commands.d.ts +30 -0
- package/dist/cli/commands.d.ts.map +1 -0
- package/dist/cli/commands.js +64 -0
- package/dist/cli/commands.js.map +1 -0
- package/dist/cli/compiler-host.d.ts +109 -0
- package/dist/cli/compiler-host.d.ts.map +1 -0
- package/dist/cli/compiler-host.js +173 -0
- package/dist/cli/compiler-host.js.map +1 -0
- package/dist/cli/fmt.d.ts +13 -0
- package/dist/cli/fmt.d.ts.map +1 -0
- package/dist/cli/fmt.js +14 -0
- package/dist/cli/fmt.js.map +1 -0
- package/dist/cli/init-command.js +12 -12
- package/dist/cli/init-command.js.map +1 -1
- package/dist/cli/loader.d.ts +0 -21
- package/dist/cli/loader.d.ts.map +1 -1
- package/dist/cli/loader.js +1 -50
- package/dist/cli/loader.js.map +1 -1
- package/dist/cli/schema.d.ts +2 -0
- package/dist/cli/schema.d.ts.map +1 -1
- package/dist/cli/schema.js +11 -4
- package/dist/cli/schema.js.map +1 -1
- package/dist/cli/workspace.d.ts +82 -0
- package/dist/cli/workspace.d.ts.map +1 -0
- package/dist/cli/workspace.js +248 -0
- package/dist/cli/workspace.js.map +1 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/think-builder.d.ts +50 -2
- package/dist/think-builder.d.ts.map +1 -1
- package/dist/think-builder.js +137 -14
- package/dist/think-builder.js.map +1 -1
- package/dist/thought-event.d.ts +80 -0
- package/dist/thought-event.d.ts.map +1 -0
- package/dist/thought-event.js +2 -0
- package/dist/thought-event.js.map +1 -0
- package/dist/thought-stream.d.ts +45 -0
- package/dist/thought-stream.d.ts.map +1 -0
- package/dist/thought-stream.js +99 -0
- package/dist/thought-stream.js.map +1 -0
- package/dist-pkg/acp.cjs +37 -11
- package/dist-pkg/thinkwell.cjs +49 -18
- package/package.json +4 -9
- package/dist/cli/index.d.ts +0 -11
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/index.js +0 -11
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/main-pkg.d.ts +0 -18
- package/dist/cli/main-pkg.d.ts.map +0 -1
- package/dist/cli/main.d.ts +0 -14
- package/dist/cli/main.d.ts.map +0 -1
- package/dist/cli/main.js +0 -256
- package/dist/cli/main.js.map +0 -1
- package/dist/cli/types-command.d.ts +0 -8
- package/dist/cli/types-command.d.ts.map +0 -1
- package/dist/cli/types-command.js +0 -110
- package/dist/cli/types-command.js.map +0 -1
package/dist/agent.d.ts
CHANGED
|
@@ -1,21 +1,45 @@
|
|
|
1
|
-
import { ClientSideConnection } from "@agentclientprotocol/sdk";
|
|
1
|
+
import { ClientSideConnection, type SessionNotification } from "@agentclientprotocol/sdk";
|
|
2
2
|
import { Conductor } from "@thinkwell/conductor";
|
|
3
|
-
import { McpOverAcpHandler, type SchemaProvider
|
|
3
|
+
import { McpOverAcpHandler, type SchemaProvider } from "@thinkwell/acp";
|
|
4
4
|
import { ThinkBuilder } from "./think-builder.js";
|
|
5
5
|
import { Session } from "./session.js";
|
|
6
|
+
import type { ThoughtEvent, ToolContent, ContentBlock } from "./thought-event.js";
|
|
7
|
+
import type { ToolCallContent as AcpToolCallContent, ContentBlock as AcpContentBlock } from "@agentclientprotocol/sdk";
|
|
6
8
|
/**
|
|
7
|
-
*
|
|
9
|
+
* Known agent names that can be passed to `open()`.
|
|
8
10
|
*/
|
|
9
|
-
export
|
|
11
|
+
export type AgentName = 'claude' | 'codex' | 'gemini' | 'kiro' | 'opencode' | 'auggie';
|
|
12
|
+
/**
|
|
13
|
+
* Options for opening an agent connection.
|
|
14
|
+
*/
|
|
15
|
+
export interface AgentOptions {
|
|
10
16
|
/**
|
|
11
|
-
* Environment variables for the agent process
|
|
17
|
+
* Environment variables for the agent process.
|
|
12
18
|
*/
|
|
13
19
|
env?: Record<string, string>;
|
|
14
20
|
/**
|
|
15
|
-
* Connection timeout in milliseconds
|
|
21
|
+
* Connection timeout in milliseconds.
|
|
16
22
|
*/
|
|
17
23
|
timeout?: number;
|
|
18
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Options for opening an agent connection with a custom spawn command.
|
|
27
|
+
*
|
|
28
|
+
* Use this overload of `open()` when connecting to an agent that isn't
|
|
29
|
+
* in the built-in {@link AgentName} list.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const agent = await open({ cmd: 'my-custom-agent --acp' });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export interface CustomAgentOptions extends AgentOptions {
|
|
37
|
+
/**
|
|
38
|
+
* The shell command to spawn the agent process.
|
|
39
|
+
* The command is split on whitespace to extract the program and arguments.
|
|
40
|
+
*/
|
|
41
|
+
cmd: string;
|
|
42
|
+
}
|
|
19
43
|
/**
|
|
20
44
|
* Options for creating a session
|
|
21
45
|
*/
|
|
@@ -34,7 +58,7 @@ export interface SessionOptions {
|
|
|
34
58
|
* @internal
|
|
35
59
|
*/
|
|
36
60
|
export interface SessionHandler {
|
|
37
|
-
pushUpdate(update:
|
|
61
|
+
pushUpdate(update: ThoughtEvent): void;
|
|
38
62
|
}
|
|
39
63
|
/**
|
|
40
64
|
* Internal connection state shared between Agent and Session
|
|
@@ -46,29 +70,27 @@ export interface AgentConnection {
|
|
|
46
70
|
mcpHandler: McpOverAcpHandler;
|
|
47
71
|
sessionHandlers: Map<string, SessionHandler>;
|
|
48
72
|
initialized: boolean;
|
|
73
|
+
conductorPromise: Promise<void>;
|
|
49
74
|
}
|
|
50
75
|
/**
|
|
51
|
-
*
|
|
76
|
+
* A connection to an AI agent (like Claude Code) that provides a fluent API
|
|
77
|
+
* for blending deterministic code with LLM-powered reasoning.
|
|
52
78
|
*
|
|
53
|
-
*
|
|
54
|
-
* a fluent API for blending deterministic code with LLM-powered reasoning.
|
|
79
|
+
* Use the top-level `open()` function to create an Agent instance.
|
|
55
80
|
*
|
|
56
81
|
* @example Simple usage with ephemeral sessions
|
|
57
82
|
* ```typescript
|
|
58
|
-
* import {
|
|
59
|
-
* import { CLAUDE_CODE } from "thinkwell/connectors";
|
|
83
|
+
* import { open } from "thinkwell";
|
|
60
84
|
*
|
|
61
|
-
*
|
|
85
|
+
* /** @JSONSchema */
|
|
86
|
+
* interface Summary {
|
|
87
|
+
* title: string;
|
|
88
|
+
* points: string[];
|
|
89
|
+
* }
|
|
62
90
|
*
|
|
91
|
+
* const agent = await open('claude');
|
|
63
92
|
* const summary = await agent
|
|
64
|
-
* .think(
|
|
65
|
-
* type: "object",
|
|
66
|
-
* properties: {
|
|
67
|
-
* title: { type: "string" },
|
|
68
|
-
* points: { type: "array", items: { type: "string" } }
|
|
69
|
-
* },
|
|
70
|
-
* required: ["title", "points"]
|
|
71
|
-
* }))
|
|
93
|
+
* .think(Summary.Schema)
|
|
72
94
|
* .text("Summarize this document:")
|
|
73
95
|
* .quote(document)
|
|
74
96
|
* .run();
|
|
@@ -78,8 +100,8 @@ export interface AgentConnection {
|
|
|
78
100
|
*
|
|
79
101
|
* @example Multi-turn conversation with explicit session
|
|
80
102
|
* ```typescript
|
|
81
|
-
* import {
|
|
82
|
-
* const agent = await
|
|
103
|
+
* import { open } from "thinkwell";
|
|
104
|
+
* const agent = await open('claude');
|
|
83
105
|
* const session = await agent.createSession({ cwd: "/my/project" });
|
|
84
106
|
*
|
|
85
107
|
* const analysis = await session
|
|
@@ -97,23 +119,7 @@ export interface AgentConnection {
|
|
|
97
119
|
* agent.close();
|
|
98
120
|
* ```
|
|
99
121
|
*/
|
|
100
|
-
export
|
|
101
|
-
private readonly _conn;
|
|
102
|
-
private constructor();
|
|
103
|
-
/**
|
|
104
|
-
* Connect to an agent.
|
|
105
|
-
*
|
|
106
|
-
* @param command - The command to spawn the agent process (e.g., "npx -y @zed-industries/claude-code-acp")
|
|
107
|
-
* @param options - Connection options
|
|
108
|
-
* @returns A connected Agent instance
|
|
109
|
-
*
|
|
110
|
-
* @example
|
|
111
|
-
* ```typescript
|
|
112
|
-
* import { CLAUDE_CODE } from "thinkwell/connectors";
|
|
113
|
-
* const agent = await Agent.connect(CLAUDE_CODE);
|
|
114
|
-
* ```
|
|
115
|
-
*/
|
|
116
|
-
static connect(command: string, options?: ConnectOptions): Promise<Agent>;
|
|
122
|
+
export interface Agent {
|
|
117
123
|
/**
|
|
118
124
|
* Create a new think builder for constructing a prompt with tools.
|
|
119
125
|
*
|
|
@@ -125,12 +131,11 @@ export declare class Agent {
|
|
|
125
131
|
*
|
|
126
132
|
* @example
|
|
127
133
|
* ```typescript
|
|
134
|
+
* /** @JSONSchema */
|
|
135
|
+
* interface Answer { answer: string }
|
|
136
|
+
*
|
|
128
137
|
* const result = await agent
|
|
129
|
-
* .think(
|
|
130
|
-
* type: "object",
|
|
131
|
-
* properties: { answer: { type: "string" } },
|
|
132
|
-
* required: ["answer"]
|
|
133
|
-
* }))
|
|
138
|
+
* .think(Answer.Schema)
|
|
134
139
|
* .text("What is 2 + 2?")
|
|
135
140
|
* .run();
|
|
136
141
|
* ```
|
|
@@ -164,16 +169,37 @@ export declare class Agent {
|
|
|
164
169
|
*
|
|
165
170
|
* This shuts down the conductor. Any active sessions will be invalidated.
|
|
166
171
|
*/
|
|
167
|
-
close(): void
|
|
168
|
-
/**
|
|
169
|
-
* Get the internal connection for use by ThinkBuilder
|
|
170
|
-
* @internal
|
|
171
|
-
*/
|
|
172
|
-
get _connection(): AgentConnection;
|
|
173
|
-
/**
|
|
174
|
-
* Initialize the connection (negotiate protocol version)
|
|
175
|
-
* @internal
|
|
176
|
-
*/
|
|
177
|
-
_initialize(): Promise<void>;
|
|
172
|
+
close(): Promise<void>;
|
|
178
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* Convert an ACP ContentBlock to a Thinkwell ContentBlock, or null if unsupported.
|
|
176
|
+
* @internal Exported for testing.
|
|
177
|
+
*/
|
|
178
|
+
export declare function convertContentBlock(block: AcpContentBlock): ContentBlock | null;
|
|
179
|
+
/**
|
|
180
|
+
* Convert ACP ToolCallContent to Thinkwell ToolContent, or null if unsupported.
|
|
181
|
+
* @internal Exported for testing.
|
|
182
|
+
*/
|
|
183
|
+
export declare function convertToolCallContent(content: AcpToolCallContent): ToolContent | null;
|
|
184
|
+
/**
|
|
185
|
+
* Convert ACP notification to ThoughtEvent.
|
|
186
|
+
* @internal Exported for testing.
|
|
187
|
+
*/
|
|
188
|
+
export declare function convertNotification(notification: SessionNotification): ThoughtEvent | null;
|
|
189
|
+
/**
|
|
190
|
+
* Open a connection to an AI agent.
|
|
191
|
+
*
|
|
192
|
+
* @example Named agent (the common case)
|
|
193
|
+
* ```typescript
|
|
194
|
+
* import { open } from "thinkwell";
|
|
195
|
+
* const agent = await open('claude');
|
|
196
|
+
* ```
|
|
197
|
+
*
|
|
198
|
+
* @example Custom command
|
|
199
|
+
* ```typescript
|
|
200
|
+
* const agent = await open({ cmd: 'myagent --acp' });
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
export declare function open(name: AgentName, options?: AgentOptions): Promise<Agent>;
|
|
204
|
+
export declare function open(options: CustomAgentOptions): Promise<Agent>;
|
|
179
205
|
//# sourceMappingURL=agent.d.ts.map
|
package/dist/agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EAGpB,KAAK,mBAAmB,EAMzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,SAAS,EAOV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,iBAAiB,EACjB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,KAAK,EACV,eAAe,IAAI,kBAAkB,EACrC,YAAY,IAAI,eAAe,EAChC,MAAM,0BAA0B,CAAC;AAElC;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,CAAC;AAcvF;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE7B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,kBAAmB,SAAQ,YAAY;IACtD;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;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BAAkB,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC"}
|
package/dist/agent.js
CHANGED
|
@@ -4,157 +4,32 @@ import { McpOverAcpHandler, } from "@thinkwell/acp";
|
|
|
4
4
|
import { ThinkBuilder } from "./think-builder.js";
|
|
5
5
|
import { Session } from "./session.js";
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* Agent represents a connection to an AI agent (like Claude Code) and provides
|
|
10
|
-
* a fluent API for blending deterministic code with LLM-powered reasoning.
|
|
11
|
-
*
|
|
12
|
-
* @example Simple usage with ephemeral sessions
|
|
13
|
-
* ```typescript
|
|
14
|
-
* import { Agent, schemaOf } from "thinkwell";
|
|
15
|
-
* import { CLAUDE_CODE } from "thinkwell/connectors";
|
|
16
|
-
*
|
|
17
|
-
* const agent = await Agent.connect(CLAUDE_CODE);
|
|
18
|
-
*
|
|
19
|
-
* const summary = await agent
|
|
20
|
-
* .think(schemaOf<{ title: string; points: string[] }>({
|
|
21
|
-
* type: "object",
|
|
22
|
-
* properties: {
|
|
23
|
-
* title: { type: "string" },
|
|
24
|
-
* points: { type: "array", items: { type: "string" } }
|
|
25
|
-
* },
|
|
26
|
-
* required: ["title", "points"]
|
|
27
|
-
* }))
|
|
28
|
-
* .text("Summarize this document:")
|
|
29
|
-
* .quote(document)
|
|
30
|
-
* .run();
|
|
31
|
-
*
|
|
32
|
-
* agent.close();
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
|
-
* @example Multi-turn conversation with explicit session
|
|
36
|
-
* ```typescript
|
|
37
|
-
* import { CLAUDE_CODE } from "thinkwell/connectors";
|
|
38
|
-
* const agent = await Agent.connect(CLAUDE_CODE);
|
|
39
|
-
* const session = await agent.createSession({ cwd: "/my/project" });
|
|
40
|
-
*
|
|
41
|
-
* const analysis = await session
|
|
42
|
-
* .think(AnalysisSchema)
|
|
43
|
-
* .text("Analyze this codebase")
|
|
44
|
-
* .run();
|
|
45
|
-
*
|
|
46
|
-
* // Same session - agent remembers context
|
|
47
|
-
* const fixes = await session
|
|
48
|
-
* .think(FixesSchema)
|
|
49
|
-
* .text("Suggest fixes for the top issues")
|
|
50
|
-
* .run();
|
|
51
|
-
*
|
|
52
|
-
* session.close();
|
|
53
|
-
* agent.close();
|
|
54
|
-
* ```
|
|
7
|
+
* Maps agent names to their spawn commands.
|
|
55
8
|
*/
|
|
56
|
-
|
|
9
|
+
const AGENT_COMMANDS = {
|
|
10
|
+
claude: "npx -y @zed-industries/claude-code-acp",
|
|
11
|
+
codex: "npx -y @zed-industries/codex-acp",
|
|
12
|
+
gemini: "npx -y @google/gemini-cli --experimental-acp",
|
|
13
|
+
kiro: "kiro-cli acp",
|
|
14
|
+
opencode: "opencode acp",
|
|
15
|
+
auggie: "auggie --acp",
|
|
16
|
+
};
|
|
17
|
+
/** Symbol used to prevent external construction of AgentImpl. */
|
|
18
|
+
const AGENT_KEY = Symbol("Agent");
|
|
19
|
+
/**
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
class AgentImpl {
|
|
57
23
|
_conn;
|
|
58
|
-
constructor(conn) {
|
|
24
|
+
constructor(key, conn) {
|
|
25
|
+
if (key !== AGENT_KEY) {
|
|
26
|
+
throw new Error("Agent cannot be constructed directly. Use open() instead.");
|
|
27
|
+
}
|
|
59
28
|
this._conn = conn;
|
|
60
29
|
}
|
|
61
|
-
/**
|
|
62
|
-
* Connect to an agent.
|
|
63
|
-
*
|
|
64
|
-
* @param command - The command to spawn the agent process (e.g., "npx -y @zed-industries/claude-code-acp")
|
|
65
|
-
* @param options - Connection options
|
|
66
|
-
* @returns A connected Agent instance
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* ```typescript
|
|
70
|
-
* import { CLAUDE_CODE } from "thinkwell/connectors";
|
|
71
|
-
* const agent = await Agent.connect(CLAUDE_CODE);
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
static async connect(command, options) {
|
|
75
|
-
// Create a conductor that spawns the agent as a subprocess
|
|
76
|
-
// The command string is passed as a single agent command - fromCommands
|
|
77
|
-
// will parse it internally to extract command and arguments
|
|
78
|
-
const conductor = new Conductor({
|
|
79
|
-
instantiator: fromCommands([command]),
|
|
80
|
-
});
|
|
81
|
-
// Create an in-memory channel pair for client ↔ conductor communication
|
|
82
|
-
const pair = createChannelPair();
|
|
83
|
-
// Create a Stream adapter from the ComponentConnection
|
|
84
|
-
const stream = componentConnectionToStream(pair.left);
|
|
85
|
-
// Create the MCP handler
|
|
86
|
-
const mcpHandler = new McpOverAcpHandler();
|
|
87
|
-
// Build the connection state
|
|
88
|
-
const conn = {
|
|
89
|
-
conductor,
|
|
90
|
-
connection: null, // Set below after creating the client
|
|
91
|
-
mcpHandler,
|
|
92
|
-
sessionHandlers: new Map(),
|
|
93
|
-
initialized: false,
|
|
94
|
-
};
|
|
95
|
-
// Create the ACP client connection
|
|
96
|
-
const clientConnection = new ClientSideConnection((_agent) => createClient(conn, mcpHandler), stream);
|
|
97
|
-
conn.connection = clientConnection;
|
|
98
|
-
// Create a connector that provides the other end of the channel
|
|
99
|
-
const clientConnector = {
|
|
100
|
-
async connect() {
|
|
101
|
-
return pair.right;
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
// Start the conductor's message loop in the background
|
|
105
|
-
const conductorPromise = conductor.connect(clientConnector);
|
|
106
|
-
// Handle conductor errors/completion
|
|
107
|
-
conductorPromise.catch((error) => {
|
|
108
|
-
console.error("Conductor error:", error);
|
|
109
|
-
});
|
|
110
|
-
return new Agent(conn);
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Create a new think builder for constructing a prompt with tools.
|
|
114
|
-
*
|
|
115
|
-
* Each call to `think()` creates an ephemeral session that is automatically
|
|
116
|
-
* closed when the prompt completes. For multi-turn conversations, use
|
|
117
|
-
* `createSession()` instead.
|
|
118
|
-
*
|
|
119
|
-
* @param schema - A SchemaProvider that defines the expected output structure
|
|
120
|
-
*
|
|
121
|
-
* @example
|
|
122
|
-
* ```typescript
|
|
123
|
-
* const result = await agent
|
|
124
|
-
* .think(schemaOf<{ answer: string }>({
|
|
125
|
-
* type: "object",
|
|
126
|
-
* properties: { answer: { type: "string" } },
|
|
127
|
-
* required: ["answer"]
|
|
128
|
-
* }))
|
|
129
|
-
* .text("What is 2 + 2?")
|
|
130
|
-
* .run();
|
|
131
|
-
* ```
|
|
132
|
-
*/
|
|
133
30
|
think(schema) {
|
|
134
31
|
return new ThinkBuilder(this._conn, schema);
|
|
135
32
|
}
|
|
136
|
-
/**
|
|
137
|
-
* Create a new session for multi-turn conversations.
|
|
138
|
-
*
|
|
139
|
-
* Sessions maintain conversation context across multiple `think()` calls,
|
|
140
|
-
* allowing the agent to remember previous interactions.
|
|
141
|
-
*
|
|
142
|
-
* @param options - Session configuration options
|
|
143
|
-
* @returns A Session instance
|
|
144
|
-
*
|
|
145
|
-
* @example
|
|
146
|
-
* ```typescript
|
|
147
|
-
* const session = await agent.createSession({ cwd: "/my/project" });
|
|
148
|
-
*
|
|
149
|
-
* // First turn
|
|
150
|
-
* const result1 = await session.think(Schema1).text("...").run();
|
|
151
|
-
*
|
|
152
|
-
* // Second turn - agent remembers context
|
|
153
|
-
* const result2 = await session.think(Schema2).text("...").run();
|
|
154
|
-
*
|
|
155
|
-
* session.close();
|
|
156
|
-
* ```
|
|
157
|
-
*/
|
|
158
33
|
async createSession(options) {
|
|
159
34
|
await this._initialize();
|
|
160
35
|
const request = {
|
|
@@ -164,27 +39,16 @@ export class Agent {
|
|
|
164
39
|
const response = await this._conn.connection.newSession(request);
|
|
165
40
|
return new Session(this._conn, response.sessionId, options);
|
|
166
41
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
console.error(
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Get the internal connection for use by ThinkBuilder
|
|
179
|
-
* @internal
|
|
180
|
-
*/
|
|
181
|
-
get _connection() {
|
|
182
|
-
return this._conn;
|
|
42
|
+
async close() {
|
|
43
|
+
await this._conn.conductor.shutdown();
|
|
44
|
+
try {
|
|
45
|
+
await this._conn.conductorPromise;
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
// Conductor errors are already logged, just ensure we don't throw
|
|
49
|
+
console.error('[Agent.close] Conductor promise error:', error);
|
|
50
|
+
}
|
|
183
51
|
}
|
|
184
|
-
/**
|
|
185
|
-
* Initialize the connection (negotiate protocol version)
|
|
186
|
-
* @internal
|
|
187
|
-
*/
|
|
188
52
|
async _initialize() {
|
|
189
53
|
if (this._conn.initialized)
|
|
190
54
|
return;
|
|
@@ -266,34 +130,174 @@ function createClient(conn, mcpHandler) {
|
|
|
266
130
|
};
|
|
267
131
|
}
|
|
268
132
|
/**
|
|
269
|
-
* Convert ACP
|
|
133
|
+
* Convert an ACP ContentBlock to a Thinkwell ContentBlock, or null if unsupported.
|
|
134
|
+
* @internal Exported for testing.
|
|
270
135
|
*/
|
|
271
|
-
function
|
|
136
|
+
export function convertContentBlock(block) {
|
|
137
|
+
switch (block.type) {
|
|
138
|
+
case "text":
|
|
139
|
+
return { type: "text", text: block.text };
|
|
140
|
+
case "image":
|
|
141
|
+
return { type: "image", data: block.data, mimeType: block.mimeType };
|
|
142
|
+
case "resource_link":
|
|
143
|
+
return { type: "resource_link", uri: block.uri, name: block.name ?? undefined };
|
|
144
|
+
default:
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Convert ACP ToolCallContent to Thinkwell ToolContent, or null if unsupported.
|
|
150
|
+
* @internal Exported for testing.
|
|
151
|
+
*/
|
|
152
|
+
export function convertToolCallContent(content) {
|
|
153
|
+
switch (content.type) {
|
|
154
|
+
case "diff":
|
|
155
|
+
return { type: "diff", path: content.path, oldText: content.oldText ?? "", newText: content.newText };
|
|
156
|
+
case "terminal":
|
|
157
|
+
return { type: "terminal", terminalId: content.terminalId };
|
|
158
|
+
case "content": {
|
|
159
|
+
const block = convertContentBlock(content.content);
|
|
160
|
+
if (!block)
|
|
161
|
+
return null;
|
|
162
|
+
return { type: "content", content: block };
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Convert ACP notification to ThoughtEvent.
|
|
168
|
+
* @internal Exported for testing.
|
|
169
|
+
*/
|
|
170
|
+
export function convertNotification(notification) {
|
|
272
171
|
const { update } = notification;
|
|
273
172
|
switch (update.sessionUpdate) {
|
|
274
|
-
case "agent_message_chunk":
|
|
275
|
-
case "user_message_chunk":
|
|
276
173
|
case "agent_thought_chunk": {
|
|
277
174
|
const content = update.content;
|
|
278
175
|
if (content.type === "text") {
|
|
279
|
-
return { type: "
|
|
176
|
+
return { type: "thought", text: content.text };
|
|
177
|
+
}
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
case "agent_message_chunk": {
|
|
181
|
+
const content = update.content;
|
|
182
|
+
if (content.type === "text") {
|
|
183
|
+
return { type: "message", text: content.text };
|
|
280
184
|
}
|
|
281
185
|
break;
|
|
282
186
|
}
|
|
283
187
|
case "tool_call": {
|
|
284
188
|
return {
|
|
285
|
-
type: "
|
|
189
|
+
type: "tool_start",
|
|
286
190
|
id: update.toolCallId,
|
|
287
|
-
|
|
288
|
-
|
|
191
|
+
title: update.title,
|
|
192
|
+
kind: update.kind,
|
|
289
193
|
};
|
|
290
194
|
}
|
|
291
|
-
case "
|
|
292
|
-
|
|
195
|
+
case "tool_call_update": {
|
|
196
|
+
const status = update.status ?? "in_progress";
|
|
197
|
+
if (status === "completed" || status === "failed") {
|
|
198
|
+
return { type: "tool_done", id: update.toolCallId, status };
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
type: "tool_update",
|
|
202
|
+
id: update.toolCallId,
|
|
203
|
+
status,
|
|
204
|
+
content: update.content?.map(convertToolCallContent).filter((c) => c !== null),
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
case "plan": {
|
|
208
|
+
return {
|
|
209
|
+
type: "plan",
|
|
210
|
+
entries: update.entries.map((e) => ({
|
|
211
|
+
content: e.content,
|
|
212
|
+
status: e.status,
|
|
213
|
+
priority: e.priority,
|
|
214
|
+
})),
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
case "user_message_chunk":
|
|
293
218
|
case "available_commands_update":
|
|
294
219
|
case "current_mode_update":
|
|
295
220
|
break;
|
|
296
221
|
}
|
|
297
222
|
return null;
|
|
298
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* Parse a command string into a CommandSpec with env vars attached.
|
|
226
|
+
*/
|
|
227
|
+
function parseCommandWithEnv(command, env) {
|
|
228
|
+
const parts = command.split(/\s+/);
|
|
229
|
+
return {
|
|
230
|
+
command: parts[0],
|
|
231
|
+
args: parts.slice(1),
|
|
232
|
+
env,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Resolve the agent command string from the arguments to `open()`,
|
|
237
|
+
* applying environment variable overrides.
|
|
238
|
+
*/
|
|
239
|
+
function resolveCommand(nameOrOptions, options) {
|
|
240
|
+
// Environment variable overrides take precedence
|
|
241
|
+
const envCmd = process.env.THINKWELL_AGENT_CMD;
|
|
242
|
+
const envAgent = process.env.THINKWELL_AGENT;
|
|
243
|
+
if (envCmd) {
|
|
244
|
+
const opts = typeof nameOrOptions === "string" ? options : nameOrOptions;
|
|
245
|
+
return { command: envCmd, options: opts };
|
|
246
|
+
}
|
|
247
|
+
if (envAgent) {
|
|
248
|
+
if (!(envAgent in AGENT_COMMANDS)) {
|
|
249
|
+
throw new Error(`Unknown agent name in $THINKWELL_AGENT: '${envAgent}'. ` +
|
|
250
|
+
`Valid names: ${Object.keys(AGENT_COMMANDS).join(", ")}`);
|
|
251
|
+
}
|
|
252
|
+
const opts = typeof nameOrOptions === "string" ? options : nameOrOptions;
|
|
253
|
+
return { command: AGENT_COMMANDS[envAgent], options: opts };
|
|
254
|
+
}
|
|
255
|
+
// No env override — resolve from arguments
|
|
256
|
+
if (typeof nameOrOptions === "string") {
|
|
257
|
+
return { command: AGENT_COMMANDS[nameOrOptions], options };
|
|
258
|
+
}
|
|
259
|
+
return { command: nameOrOptions.cmd, options: nameOrOptions };
|
|
260
|
+
}
|
|
261
|
+
export async function open(nameOrOptions, maybeOptions) {
|
|
262
|
+
const { command, options } = resolveCommand(nameOrOptions, maybeOptions);
|
|
263
|
+
// When env is provided, we need to pass a CommandOptions object.
|
|
264
|
+
// Otherwise a plain string works (fromCommands parses it internally).
|
|
265
|
+
const commandSpec = options?.env
|
|
266
|
+
? parseCommandWithEnv(command, options.env)
|
|
267
|
+
: command;
|
|
268
|
+
const conductor = new Conductor({
|
|
269
|
+
instantiator: fromCommands([commandSpec]),
|
|
270
|
+
});
|
|
271
|
+
// Create an in-memory channel pair for client ↔ conductor communication
|
|
272
|
+
const pair = createChannelPair();
|
|
273
|
+
// Create a Stream adapter from the ComponentConnection
|
|
274
|
+
const stream = componentConnectionToStream(pair.left);
|
|
275
|
+
// Create the MCP handler
|
|
276
|
+
const mcpHandler = new McpOverAcpHandler();
|
|
277
|
+
// Build the connection state
|
|
278
|
+
const conn = {
|
|
279
|
+
conductor,
|
|
280
|
+
connection: null, // Set below after creating the client
|
|
281
|
+
mcpHandler,
|
|
282
|
+
sessionHandlers: new Map(),
|
|
283
|
+
initialized: false,
|
|
284
|
+
conductorPromise: null, // Set below after starting the conductor
|
|
285
|
+
};
|
|
286
|
+
// Create the ACP client connection
|
|
287
|
+
const clientConnection = new ClientSideConnection((_agent) => createClient(conn, mcpHandler), stream);
|
|
288
|
+
conn.connection = clientConnection;
|
|
289
|
+
// Create a connector that provides the other end of the channel
|
|
290
|
+
const clientConnector = {
|
|
291
|
+
async connect() {
|
|
292
|
+
return pair.right;
|
|
293
|
+
},
|
|
294
|
+
};
|
|
295
|
+
// Start the conductor's message loop in the background
|
|
296
|
+
conn.conductorPromise = conductor.connect(clientConnector);
|
|
297
|
+
// Handle conductor errors/completion
|
|
298
|
+
conn.conductorPromise.catch((error) => {
|
|
299
|
+
console.error("Conductor error:", error);
|
|
300
|
+
});
|
|
301
|
+
return new AgentImpl(AGENT_KEY, conn);
|
|
302
|
+
}
|
|
299
303
|
//# sourceMappingURL=agent.js.map
|
package/dist/agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,GASrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,SAAS,EACT,YAAY,EACZ,iBAAiB,
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,GASrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,SAAS,EACT,YAAY,EACZ,iBAAiB,GAKlB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,iBAAiB,GAElB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAYvC;;GAEG;AACH,MAAM,cAAc,GAA8B;IAChD,MAAM,EAAE,wCAAwC;IAChD,KAAK,EAAE,kCAAkC;IACzC,MAAM,EAAE,8CAA8C;IACtD,IAAI,EAAE,cAAc;IACpB,QAAQ,EAAE,cAAc;IACxB,MAAM,EAAE,cAAc;CACvB,CAAC;AA8KF,iEAAiE;AACjE,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;AAElC;;GAEG;AACH,MAAM,SAAS;IACI,KAAK,CAAkB;IAExC,YAAY,GAAW,EAAE,IAAqB;QAC5C,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;QAC/E,CAAC;QACD,IAAI,C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