thinkwell 0.1.0

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.
@@ -0,0 +1,322 @@
1
+ import { mcpServer, } from "@thinkwell/acp";
2
+ /**
3
+ * Internal session handler for ThinkBuilder
4
+ */
5
+ class ThinkSession {
6
+ sessionId;
7
+ _conn;
8
+ _pendingUpdates = [];
9
+ _updateResolvers = [];
10
+ _closed = false;
11
+ constructor(sessionId, conn) {
12
+ this.sessionId = sessionId;
13
+ this._conn = conn;
14
+ }
15
+ async sendPrompt(content) {
16
+ const response = await this._conn.connection.prompt({
17
+ sessionId: this.sessionId,
18
+ prompt: [{ type: "text", text: content }],
19
+ });
20
+ if (response.stopReason) {
21
+ this.pushUpdate({ type: "stop", reason: response.stopReason });
22
+ }
23
+ }
24
+ pushUpdate(update) {
25
+ if (this._updateResolvers.length > 0) {
26
+ const resolver = this._updateResolvers.shift();
27
+ resolver(update);
28
+ }
29
+ else {
30
+ this._pendingUpdates.push(update);
31
+ }
32
+ }
33
+ async readUpdate() {
34
+ if (this._pendingUpdates.length > 0) {
35
+ return this._pendingUpdates.shift();
36
+ }
37
+ if (this._closed) {
38
+ return { type: "stop", reason: "session_closed" };
39
+ }
40
+ return new Promise((resolve) => {
41
+ this._updateResolvers.push(resolve);
42
+ });
43
+ }
44
+ close() {
45
+ this._closed = true;
46
+ for (const resolver of this._updateResolvers) {
47
+ resolver({ type: "stop", reason: "session_closed" });
48
+ }
49
+ this._updateResolvers = [];
50
+ }
51
+ }
52
+ /**
53
+ * Fluent builder for composing prompts with tools.
54
+ *
55
+ * ThinkBuilder provides a chainable API for:
56
+ * - Adding literal text to the prompt
57
+ * - Interpolating values
58
+ * - Registering tools the LLM can call
59
+ * - Executing the prompt and returning a typed result
60
+ */
61
+ export class ThinkBuilder {
62
+ _conn;
63
+ _promptParts = [];
64
+ _tools = new Map();
65
+ _schemaProvider;
66
+ _cwd;
67
+ _existingSessionId;
68
+ constructor(conn, schema, existingSessionId) {
69
+ this._conn = conn;
70
+ this._schemaProvider = schema;
71
+ this._existingSessionId = existingSessionId;
72
+ }
73
+ /**
74
+ * Add literal text to the prompt
75
+ */
76
+ text(content) {
77
+ this._promptParts.push(content);
78
+ return this;
79
+ }
80
+ /**
81
+ * Add a line of text with newline
82
+ */
83
+ textln(content) {
84
+ this._promptParts.push(content + "\n");
85
+ return this;
86
+ }
87
+ /**
88
+ * Quote some content delimited by XML-style tags.
89
+ */
90
+ quote(content, tag = "quote") {
91
+ if (!content.includes("\n")) {
92
+ this._promptParts.push(`<${tag}>${content}</${tag}>\n`);
93
+ }
94
+ else {
95
+ this._promptParts.push(`<${tag}>\n${content}\n</${tag}>\n`);
96
+ }
97
+ return this;
98
+ }
99
+ /**
100
+ * Quote some content as a Markdown-style code block.
101
+ */
102
+ code(content, language = "") {
103
+ this._promptParts.push(`\`\`\`${language}\n${content}\n\`\`\`\n`);
104
+ return this;
105
+ }
106
+ /**
107
+ * Interpolate a value using toString()
108
+ *
109
+ * @deprecated Use `text()` or `quote()` instead for clearer intent.
110
+ */
111
+ display(value) {
112
+ const text = value === null || value === undefined
113
+ ? ""
114
+ : typeof value === "object"
115
+ ? JSON.stringify(value, null, 2)
116
+ : String(value);
117
+ this._promptParts.push(text);
118
+ return this;
119
+ }
120
+ tool(name, description, inputSchemaOrHandler, outputSchemaOrHandler, handler) {
121
+ let inputSchema;
122
+ let outputSchema;
123
+ let actualHandler;
124
+ if (typeof inputSchemaOrHandler === "function") {
125
+ // Overload 3: tool(name, description, handler)
126
+ inputSchema = { toJsonSchema: () => ({ type: "object" }) };
127
+ outputSchema = { toJsonSchema: () => ({ type: "object" }) };
128
+ actualHandler = inputSchemaOrHandler;
129
+ }
130
+ else if (typeof outputSchemaOrHandler === "function") {
131
+ // Overload 2: tool(name, description, inputSchema, handler)
132
+ inputSchema = inputSchemaOrHandler;
133
+ outputSchema = { toJsonSchema: () => ({ type: "object" }) };
134
+ actualHandler = outputSchemaOrHandler;
135
+ }
136
+ else {
137
+ // Overload 1: tool(name, description, inputSchema, outputSchema, handler)
138
+ inputSchema = inputSchemaOrHandler;
139
+ outputSchema = outputSchemaOrHandler;
140
+ actualHandler = handler;
141
+ }
142
+ this._tools.set(name, {
143
+ name,
144
+ description,
145
+ handler: actualHandler,
146
+ inputSchema,
147
+ outputSchema,
148
+ includeInPrompt: true,
149
+ });
150
+ return this;
151
+ }
152
+ defineTool(name, description, inputSchemaOrHandler, outputSchemaOrHandler, handler) {
153
+ let inputSchema;
154
+ let outputSchema;
155
+ let actualHandler;
156
+ if (typeof inputSchemaOrHandler === "function") {
157
+ // Overload 3: defineTool(name, description, handler)
158
+ inputSchema = { toJsonSchema: () => ({ type: "object" }) };
159
+ outputSchema = { toJsonSchema: () => ({ type: "object" }) };
160
+ actualHandler = inputSchemaOrHandler;
161
+ }
162
+ else if (typeof outputSchemaOrHandler === "function") {
163
+ // Overload 2: defineTool(name, description, inputSchema, handler)
164
+ inputSchema = inputSchemaOrHandler;
165
+ outputSchema = { toJsonSchema: () => ({ type: "object" }) };
166
+ actualHandler = outputSchemaOrHandler;
167
+ }
168
+ else {
169
+ // Overload 1: defineTool(name, description, inputSchema, outputSchema, handler)
170
+ inputSchema = inputSchemaOrHandler;
171
+ outputSchema = outputSchemaOrHandler;
172
+ actualHandler = handler;
173
+ }
174
+ this._tools.set(name, {
175
+ name,
176
+ description,
177
+ handler: actualHandler,
178
+ inputSchema,
179
+ outputSchema,
180
+ includeInPrompt: false,
181
+ });
182
+ return this;
183
+ }
184
+ /**
185
+ * Set the expected output schema.
186
+ *
187
+ * This generates a return_result tool that the LLM must call
188
+ * to provide the final output.
189
+ *
190
+ * @deprecated Use `agent.think(schemaOf<T>(schema))` instead to provide a typed schema at construction time.
191
+ */
192
+ outputSchema(schema) {
193
+ console.warn("ThinkBuilder.outputSchema() is deprecated. Use agent.think(schemaOf<T>(schema)) instead.");
194
+ this._schemaProvider = { toJsonSchema: () => schema };
195
+ return this;
196
+ }
197
+ /**
198
+ * Set the working directory for the session
199
+ */
200
+ cwd(path) {
201
+ this._cwd = path;
202
+ return this;
203
+ }
204
+ /**
205
+ * Execute the prompt and return the result.
206
+ *
207
+ * This method:
208
+ * 1. Builds the final prompt from all text parts
209
+ * 2. Creates an MCP server with all registered tools
210
+ * 3. Adds a return_result tool for the output
211
+ * 4. Sends the prompt to the agent
212
+ * 5. Handles tool calls until the agent returns a result
213
+ * 6. Returns the typed result
214
+ */
215
+ async run() {
216
+ return new Promise((resolve, reject) => {
217
+ this._executeRun(resolve, reject).catch(reject);
218
+ });
219
+ }
220
+ async _executeRun(resolve, reject) {
221
+ // Ensure initialized
222
+ if (!this._conn.initialized) {
223
+ await this._conn.connection.initialize({
224
+ protocolVersion: 1,
225
+ clientCapabilities: {},
226
+ });
227
+ this._conn.initialized = true;
228
+ }
229
+ // Build the prompt
230
+ let prompt = this._promptParts.join("");
231
+ // Add tool references to the prompt
232
+ const toolsWithPrompt = Array.from(this._tools.values()).filter((t) => t.includeInPrompt);
233
+ if (toolsWithPrompt.length > 0) {
234
+ prompt += "\n\nAvailable tools:\n";
235
+ for (const tool of toolsWithPrompt) {
236
+ prompt += `- ${tool.name}: ${tool.description}\n`;
237
+ }
238
+ }
239
+ // Create the MCP server builder
240
+ const serverBuilder = mcpServer("patchwork");
241
+ // Track if we've received a result
242
+ let resultReceived = false;
243
+ let result;
244
+ // Get the output schema for the return_result tool
245
+ const outputSchema = this._schemaProvider?.toJsonSchema() ?? { type: "object" };
246
+ // Add return instruction
247
+ prompt += "\n\nWhen you have your answer, call the `return_result` MCP tool with the result.";
248
+ // Add the return_result tool
249
+ serverBuilder.tool("return_result", "Return the final result", outputSchema, { type: "object", properties: { success: { type: "boolean" } } }, async (input) => {
250
+ result = input;
251
+ resultReceived = true;
252
+ return { success: true };
253
+ });
254
+ // Add all registered tools
255
+ for (const tool of this._tools.values()) {
256
+ serverBuilder.tool(tool.name, tool.description, tool.inputSchema.toJsonSchema(), tool.outputSchema.toJsonSchema(), async (input, _context) => {
257
+ return tool.handler(input);
258
+ });
259
+ }
260
+ const server = serverBuilder.build();
261
+ // Register the MCP server
262
+ this._conn.mcpHandler.register(server);
263
+ this._conn.mcpHandler.setSessionId(this._existingSessionId ?? "pending");
264
+ try {
265
+ // Create or reuse session
266
+ let sessionId;
267
+ if (this._existingSessionId) {
268
+ // Reuse existing session
269
+ sessionId = this._existingSessionId;
270
+ }
271
+ else {
272
+ // Create new ephemeral session
273
+ const mcpServers = [{
274
+ type: "http",
275
+ name: server.name,
276
+ url: server.acpUrl,
277
+ headers: [],
278
+ }];
279
+ const request = {
280
+ cwd: this._cwd ?? process.cwd(),
281
+ mcpServers,
282
+ };
283
+ const response = await this._conn.connection.newSession(request);
284
+ sessionId = response.sessionId;
285
+ }
286
+ // Update MCP handler with actual session ID
287
+ this._conn.mcpHandler.setSessionId(sessionId);
288
+ // Create internal session handler
289
+ const session = new ThinkSession(sessionId, this._conn);
290
+ this._conn.sessionHandlers.set(sessionId, session);
291
+ // Wait for MCP tools discovery
292
+ await this._conn.mcpHandler.waitForToolsDiscovery(sessionId, 2000);
293
+ try {
294
+ // Send the prompt
295
+ await session.sendPrompt(prompt);
296
+ // Read updates until we get a result or the session ends
297
+ while (!resultReceived) {
298
+ const update = await session.readUpdate();
299
+ if (update.type === "stop") {
300
+ if (!resultReceived) {
301
+ reject(new Error("Session ended without calling return_result"));
302
+ }
303
+ break;
304
+ }
305
+ // Tool calls are handled by the MCP server
306
+ }
307
+ if (resultReceived && result !== undefined) {
308
+ resolve(result);
309
+ }
310
+ }
311
+ finally {
312
+ session.close();
313
+ this._conn.sessionHandlers.delete(sessionId);
314
+ }
315
+ }
316
+ finally {
317
+ // Unregister MCP server
318
+ this._conn.mcpHandler.unregister(server);
319
+ }
320
+ }
321
+ }
322
+ //# sourceMappingURL=think-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"think-builder.js","sourceRoot":"","sources":["../src/think-builder.ts"],"names":[],"mappings":"AAAA,OA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T,OAAO,CAAC,KAAK,EAAE,CAAC;gBAChB,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,wBAAwB;YACxB,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;CACF"}
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "thinkwell",
3
+ "version": "0.1.0",
4
+ "description": "TypeScript library for blending deterministic code with LLM-powered reasoning",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc",
19
+ "clean": "rm -rf dist",
20
+ "test": "node --test --import tsx src/**/*.test.ts"
21
+ },
22
+ "keywords": [
23
+ "thinkwell",
24
+ "llm",
25
+ "ai",
26
+ "agent"
27
+ ],
28
+ "author": "David Herman",
29
+ "license": "MIT",
30
+ "dependencies": {
31
+ "@agentclientprotocol/sdk": "^0.12.0",
32
+ "@thinkwell/acp": "workspace:*"
33
+ },
34
+ "devDependencies": {
35
+ "@types/node": "^24.10.4",
36
+ "tsx": "^4.19.2",
37
+ "typescript": "^5.7.2"
38
+ }
39
+ }