thinkwell 0.1.4 → 0.2.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.
- package/README.md +2 -2
- package/dist/agent.d.ts +11 -20
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +73 -72
- package/dist/agent.js.map +1 -1
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +1 -1
- package/dist/session.d.ts +0 -6
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +20 -0
- package/dist/session.js.map +1 -1
- package/dist/think-builder.d.ts +2 -17
- package/dist/think-builder.d.ts.map +1 -1
- package/dist/think-builder.js +1 -28
- package/dist/think-builder.js.map +1 -1
- package/package.json +9 -8
- package/dist/patchwork.d.ts +0 -55
- package/dist/patchwork.d.ts.map +0 -1
- package/dist/patchwork.js +0 -64
- package/dist/patchwork.js.map +0 -1
package/README.md
CHANGED
|
@@ -26,8 +26,8 @@ try {
|
|
|
26
26
|
const greeting: Greeting = await agent
|
|
27
27
|
.think(GreetingSchema)
|
|
28
28
|
.text(`
|
|
29
|
-
Use the current_time tool to get the current time, and create a
|
|
30
|
-
greeting message appropriate for that time of day.
|
|
29
|
+
Use the current_time tool to get the current time, and create a
|
|
30
|
+
friendly greeting message appropriate for that time of day.
|
|
31
31
|
`)
|
|
32
32
|
|
|
33
33
|
.tool(
|
package/dist/agent.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type ChildProcess } from "node:child_process";
|
|
2
1
|
import { ClientSideConnection } from "@agentclientprotocol/sdk";
|
|
2
|
+
import { Conductor } from "@thinkwell/conductor";
|
|
3
3
|
import { McpOverAcpHandler, type SchemaProvider, type SessionUpdate } from "@thinkwell/acp";
|
|
4
4
|
import { ThinkBuilder } from "./think-builder.js";
|
|
5
5
|
import { Session } from "./session.js";
|
|
@@ -7,11 +7,6 @@ import { Session } from "./session.js";
|
|
|
7
7
|
* Options for connecting to an agent
|
|
8
8
|
*/
|
|
9
9
|
export interface ConnectOptions {
|
|
10
|
-
/**
|
|
11
|
-
* Path to the conductor binary.
|
|
12
|
-
* If not specified, uses SACP_CONDUCTOR_PATH env var or searches PATH.
|
|
13
|
-
*/
|
|
14
|
-
conductorPath?: string;
|
|
15
10
|
/**
|
|
16
11
|
* Environment variables for the agent process
|
|
17
12
|
*/
|
|
@@ -46,23 +41,24 @@ export interface SessionHandler {
|
|
|
46
41
|
* @internal
|
|
47
42
|
*/
|
|
48
43
|
export interface AgentConnection {
|
|
49
|
-
|
|
44
|
+
conductor: Conductor;
|
|
50
45
|
connection: ClientSideConnection;
|
|
51
46
|
mcpHandler: McpOverAcpHandler;
|
|
52
47
|
sessionHandlers: Map<string, SessionHandler>;
|
|
53
48
|
initialized: boolean;
|
|
54
49
|
}
|
|
55
50
|
/**
|
|
56
|
-
* The main entry point for
|
|
51
|
+
* The main entry point for Thinkwell.
|
|
57
52
|
*
|
|
58
53
|
* Agent represents a connection to an AI agent (like Claude Code) and provides
|
|
59
54
|
* a fluent API for blending deterministic code with LLM-powered reasoning.
|
|
60
55
|
*
|
|
61
56
|
* @example Simple usage with ephemeral sessions
|
|
62
57
|
* ```typescript
|
|
63
|
-
* import { Agent, schemaOf } from "
|
|
58
|
+
* import { Agent, schemaOf } from "thinkwell";
|
|
59
|
+
* import { CLAUDE_CODE } from "thinkwell/connectors";
|
|
64
60
|
*
|
|
65
|
-
* const agent = await Agent.connect(
|
|
61
|
+
* const agent = await Agent.connect(CLAUDE_CODE);
|
|
66
62
|
*
|
|
67
63
|
* const summary = await agent
|
|
68
64
|
* .think(schemaOf<{ title: string; points: string[] }>({
|
|
@@ -82,7 +78,8 @@ export interface AgentConnection {
|
|
|
82
78
|
*
|
|
83
79
|
* @example Multi-turn conversation with explicit session
|
|
84
80
|
* ```typescript
|
|
85
|
-
*
|
|
81
|
+
* import { CLAUDE_CODE } from "thinkwell/connectors";
|
|
82
|
+
* const agent = await Agent.connect(CLAUDE_CODE);
|
|
86
83
|
* const session = await agent.createSession({ cwd: "/my/project" });
|
|
87
84
|
*
|
|
88
85
|
* const analysis = await session
|
|
@@ -112,7 +109,8 @@ export declare class Agent {
|
|
|
112
109
|
*
|
|
113
110
|
* @example
|
|
114
111
|
* ```typescript
|
|
115
|
-
*
|
|
112
|
+
* import { CLAUDE_CODE } from "thinkwell/connectors";
|
|
113
|
+
* const agent = await Agent.connect(CLAUDE_CODE);
|
|
116
114
|
* ```
|
|
117
115
|
*/
|
|
118
116
|
static connect(command: string, options?: ConnectOptions): Promise<Agent>;
|
|
@@ -138,12 +136,6 @@ export declare class Agent {
|
|
|
138
136
|
* ```
|
|
139
137
|
*/
|
|
140
138
|
think<Output>(schema: SchemaProvider<Output>): ThinkBuilder<Output>;
|
|
141
|
-
/**
|
|
142
|
-
* Create a new think builder without a schema.
|
|
143
|
-
*
|
|
144
|
-
* @deprecated Use `think(schemaOf<T>(schema))` instead to provide a typed schema.
|
|
145
|
-
*/
|
|
146
|
-
think<Output>(): ThinkBuilder<Output>;
|
|
147
139
|
/**
|
|
148
140
|
* Create a new session for multi-turn conversations.
|
|
149
141
|
*
|
|
@@ -170,8 +162,7 @@ export declare class Agent {
|
|
|
170
162
|
/**
|
|
171
163
|
* Close the connection to the agent.
|
|
172
164
|
*
|
|
173
|
-
* This
|
|
174
|
-
* invalidated.
|
|
165
|
+
* This shuts down the conductor. Any active sessions will be invalidated.
|
|
175
166
|
*/
|
|
176
167
|
close(): void;
|
|
177
168
|
/**
|
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,
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EASrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,SAAS,EAMV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL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;;;;;OAqBG;IACG,aAAa,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC;IAY/D;;;;OAIG;IACH,KAAK,IAAI,IAAI;IAMb;;;OAGG;IACH,IAAI,WAAW,IAAI,eAAe,CAEjC;IAED;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;CAUnC"}
|
package/dist/agent.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ClientSideConnection, } from "@agentclientprotocol/sdk";
|
|
2
|
+
import { Conductor, fromCommands, createChannelPair, } from "@thinkwell/conductor";
|
|
3
3
|
import { McpOverAcpHandler, } from "@thinkwell/acp";
|
|
4
4
|
import { ThinkBuilder } from "./think-builder.js";
|
|
5
5
|
import { Session } from "./session.js";
|
|
6
6
|
/**
|
|
7
|
-
* The main entry point for
|
|
7
|
+
* The main entry point for Thinkwell.
|
|
8
8
|
*
|
|
9
9
|
* Agent represents a connection to an AI agent (like Claude Code) and provides
|
|
10
10
|
* a fluent API for blending deterministic code with LLM-powered reasoning.
|
|
11
11
|
*
|
|
12
12
|
* @example Simple usage with ephemeral sessions
|
|
13
13
|
* ```typescript
|
|
14
|
-
* import { Agent, schemaOf } from "
|
|
14
|
+
* import { Agent, schemaOf } from "thinkwell";
|
|
15
|
+
* import { CLAUDE_CODE } from "thinkwell/connectors";
|
|
15
16
|
*
|
|
16
|
-
* const agent = await Agent.connect(
|
|
17
|
+
* const agent = await Agent.connect(CLAUDE_CODE);
|
|
17
18
|
*
|
|
18
19
|
* const summary = await agent
|
|
19
20
|
* .think(schemaOf<{ title: string; points: string[] }>({
|
|
@@ -33,7 +34,8 @@ import { Session } from "./session.js";
|
|
|
33
34
|
*
|
|
34
35
|
* @example Multi-turn conversation with explicit session
|
|
35
36
|
* ```typescript
|
|
36
|
-
*
|
|
37
|
+
* import { CLAUDE_CODE } from "thinkwell/connectors";
|
|
38
|
+
* const agent = await Agent.connect(CLAUDE_CODE);
|
|
37
39
|
* const session = await agent.createSession({ cwd: "/my/project" });
|
|
38
40
|
*
|
|
39
41
|
* const analysis = await session
|
|
@@ -65,32 +67,26 @@ export class Agent {
|
|
|
65
67
|
*
|
|
66
68
|
* @example
|
|
67
69
|
* ```typescript
|
|
68
|
-
*
|
|
70
|
+
* import { CLAUDE_CODE } from "thinkwell/connectors";
|
|
71
|
+
* const agent = await Agent.connect(CLAUDE_CODE);
|
|
69
72
|
* ```
|
|
70
73
|
*/
|
|
71
74
|
static async connect(command, options) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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]),
|
|
77
80
|
});
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
childProcess.stderr?.on("data", (data) => {
|
|
83
|
-
console.error("[conductor stderr]", data.toString());
|
|
84
|
-
});
|
|
85
|
-
// Convert Node streams to Web streams for the SDK
|
|
86
|
-
const { readable, writable } = nodeToWebStreams(childProcess.stdout, childProcess.stdin);
|
|
87
|
-
// Create the ndjson stream
|
|
88
|
-
const stream = ndJsonStream(writable, readable);
|
|
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);
|
|
89
85
|
// Create the MCP handler
|
|
90
86
|
const mcpHandler = new McpOverAcpHandler();
|
|
91
87
|
// Build the connection state
|
|
92
88
|
const conn = {
|
|
93
|
-
|
|
89
|
+
conductor,
|
|
94
90
|
connection: null, // Set below after creating the client
|
|
95
91
|
mcpHandler,
|
|
96
92
|
sessionHandlers: new Map(),
|
|
@@ -99,8 +95,41 @@ export class Agent {
|
|
|
99
95
|
// Create the ACP client connection
|
|
100
96
|
const clientConnection = new ClientSideConnection((_agent) => createClient(conn, mcpHandler), stream);
|
|
101
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
|
+
});
|
|
102
110
|
return new Agent(conn);
|
|
103
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
|
+
*/
|
|
104
133
|
think(schema) {
|
|
105
134
|
return new ThinkBuilder(this._conn, schema);
|
|
106
135
|
}
|
|
@@ -138,11 +167,12 @@ export class Agent {
|
|
|
138
167
|
/**
|
|
139
168
|
* Close the connection to the agent.
|
|
140
169
|
*
|
|
141
|
-
* This
|
|
142
|
-
* invalidated.
|
|
170
|
+
* This shuts down the conductor. Any active sessions will be invalidated.
|
|
143
171
|
*/
|
|
144
172
|
close() {
|
|
145
|
-
this._conn.
|
|
173
|
+
this._conn.conductor.shutdown().catch((error) => {
|
|
174
|
+
console.error("Conductor shutdown error:", error);
|
|
175
|
+
});
|
|
146
176
|
}
|
|
147
177
|
/**
|
|
148
178
|
* Get the internal connection for use by ThinkBuilder
|
|
@@ -166,59 +196,30 @@ export class Agent {
|
|
|
166
196
|
}
|
|
167
197
|
}
|
|
168
198
|
/**
|
|
169
|
-
*
|
|
199
|
+
* Convert a ComponentConnection to the SDK's Stream interface.
|
|
170
200
|
*/
|
|
171
|
-
function
|
|
172
|
-
//
|
|
173
|
-
if (explicitPath) {
|
|
174
|
-
return explicitPath;
|
|
175
|
-
}
|
|
176
|
-
// 2. Check environment variable
|
|
177
|
-
const envPath = process.env.SACP_CONDUCTOR_PATH;
|
|
178
|
-
if (envPath) {
|
|
179
|
-
return envPath;
|
|
180
|
-
}
|
|
181
|
-
// 3. Assume it's in PATH
|
|
182
|
-
return "sacp-conductor";
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Convert Node.js streams to Web Streams for the ACP SDK
|
|
186
|
-
*/
|
|
187
|
-
function nodeToWebStreams(stdout, stdin) {
|
|
201
|
+
function componentConnectionToStream(connection) {
|
|
202
|
+
// Create a ReadableStream from the async iterable
|
|
188
203
|
const readable = new ReadableStream({
|
|
189
|
-
start(controller) {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
204
|
+
async start(controller) {
|
|
205
|
+
try {
|
|
206
|
+
for await (const message of connection.messages) {
|
|
207
|
+
controller.enqueue(message);
|
|
208
|
+
}
|
|
194
209
|
controller.close();
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
controller.error(
|
|
198
|
-
}
|
|
199
|
-
},
|
|
200
|
-
cancel() {
|
|
201
|
-
stdout.destroy();
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
controller.error(error);
|
|
213
|
+
}
|
|
202
214
|
},
|
|
203
215
|
});
|
|
216
|
+
// Create a WritableStream that sends to the connection
|
|
204
217
|
const writable = new WritableStream({
|
|
205
|
-
write(
|
|
206
|
-
|
|
207
|
-
stdin.write(Buffer.from(chunk), (err) => {
|
|
208
|
-
if (err)
|
|
209
|
-
reject(err);
|
|
210
|
-
else
|
|
211
|
-
resolve();
|
|
212
|
-
});
|
|
213
|
-
});
|
|
218
|
+
write(message) {
|
|
219
|
+
connection.send(message);
|
|
214
220
|
},
|
|
215
221
|
close() {
|
|
216
|
-
|
|
217
|
-
stdin.end(() => resolve());
|
|
218
|
-
});
|
|
219
|
-
},
|
|
220
|
-
abort(reason) {
|
|
221
|
-
stdin.destroy(reason instanceof Error ? reason : new Error(String(reason)));
|
|
222
|
+
connection.close();
|
|
222
223
|
},
|
|
223
224
|
});
|
|
224
225
|
return { readable, writable };
|
package/dist/agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,GAIlB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,iBAAiB,GAGlB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAoDvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,MAAM,OAAO,KAAK;IACC,KAAK,CAAkB;IAExC,YAAoB,IAAqB;QACvC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,K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AAI,EAAE,CAAC;YACjD,CAAC;YACD,MAAM;QACR,CAAC;QAED,KAAK,WAAW,CAAC,CAAC,CAAC;YACjB,OAAO;gBACL,IAAI,EAAE,UAAU;gBAChB,EAAE,EAAE,MAAM,CAAC,UAAU;gBACrB,IAAI,EAAE,MAAM,CAAC,KAAK;gBAClB,KAAK,EAAE,MAAM,CAAC,QAAQ,IAAI,EAAE;aAC7B,CAAC;QACJ,CAAC;QAED,KAAK,MAAM,CAAC;QACZ,KAAK,kBAAkB,CAAC;QACxB,KAAK,2BAA2B,CAAC;QACjC,KAAK,qBAAqB;YACxB,MAAM;IACV,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/schema.d.ts
CHANGED
package/dist/schema.js
CHANGED
package/dist/session.d.ts
CHANGED
|
@@ -61,12 +61,6 @@ export declare class Session {
|
|
|
61
61
|
* ```
|
|
62
62
|
*/
|
|
63
63
|
think<Output>(schema: SchemaProvider<Output>): ThinkBuilder<Output>;
|
|
64
|
-
/**
|
|
65
|
-
* Create a new think builder without a schema.
|
|
66
|
-
*
|
|
67
|
-
* @deprecated Use `think(schemaOf<T>(schema))` instead to provide a typed schema.
|
|
68
|
-
*/
|
|
69
|
-
think<Output>(): ThinkBuilder<Output>;
|
|
70
64
|
/**
|
|
71
65
|
* Close the session.
|
|
72
66
|
*
|
package/dist/session.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAkB;IACxC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6B;IACtD,OAAO,CAAC,OAAO,CAAkB;IAEjC;;OAEG;gBACS,IAAI,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc;IAM9E;;OAEG;IACH,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAkB;IACxC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6B;IACtD,OAAO,CAAC,OAAO,CAAkB;IAEjC;;OAEG;gBACS,IAAI,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc;IAM9E;;OAEG;IACH,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC;IAOnE;;;;;OAKG;IACH,KAAK,IAAI,IAAI;CAKd"}
|
package/dist/session.js
CHANGED
|
@@ -44,6 +44,26 @@ export class Session {
|
|
|
44
44
|
get sessionId() {
|
|
45
45
|
return this._sessionId;
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Create a new think builder for constructing a prompt with tools.
|
|
49
|
+
*
|
|
50
|
+
* Unlike `agent.think()`, prompts sent through a session maintain
|
|
51
|
+
* conversation context - the agent remembers previous interactions.
|
|
52
|
+
*
|
|
53
|
+
* @param schema - A SchemaProvider that defines the expected output structure
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* const result = await session
|
|
58
|
+
* .think(schemaOf<{ answer: string }>({
|
|
59
|
+
* type: "object",
|
|
60
|
+
* properties: { answer: { type: "string" } },
|
|
61
|
+
* required: ["answer"]
|
|
62
|
+
* }))
|
|
63
|
+
* .text("What was the first thing I asked you?")
|
|
64
|
+
* .run();
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
47
67
|
think(schema) {
|
|
48
68
|
if (this._closed) {
|
|
49
69
|
throw new Error("Session is closed");
|
package/dist/session.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAO,OAAO;IACD,KAAK,CAAkB;IACvB,UAAU,CAAS;IACnB,QAAQ,CAA6B;IAC9C,OAAO,GAAY,KAAK,CAAC;IAEjC;;OAEG;IACH,YAAY,IAAqB,EAAE,SAAiB,EAAE,OAAwB;QAC5E,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAO,OAAO;IACD,KAAK,CAAkB;IACvB,UAAU,CAAS;IACnB,QAAQ,CAA6B;IAC9C,OAAO,GAAY,KAAK,CAAC;IAEjC;;OAEG;IACH,YAAY,IAAqB,EAAE,SAAiB,EAAE,OAAwB;QAC5E,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,KAAK,CAAS,MAA8B;QAC1C,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACvC,CAAC;QACD,OAAO,IAAI,YAAY,CAAS,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACvE,CAAC;IAED;;;;;OAKG;IACH,KAAK;QACH,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,4DAA4D;QAC5D,oCAAoC;IACtC,CAAC;CACF"}
|
package/dist/think-builder.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type SchemaProvider } from "@thinkwell/acp";
|
|
2
2
|
import type { AgentConnection } from "./agent.js";
|
|
3
3
|
/**
|
|
4
4
|
* Fluent builder for composing prompts with tools.
|
|
@@ -33,12 +33,6 @@ export declare class ThinkBuilder<Output> {
|
|
|
33
33
|
* Quote some content as a Markdown-style code block.
|
|
34
34
|
*/
|
|
35
35
|
code(content: string, language?: string): this;
|
|
36
|
-
/**
|
|
37
|
-
* Interpolate a value using toString()
|
|
38
|
-
*
|
|
39
|
-
* @deprecated Use `text()` or `quote()` instead for clearer intent.
|
|
40
|
-
*/
|
|
41
|
-
display(value: unknown): this;
|
|
42
36
|
/**
|
|
43
37
|
* Register a tool and reference it in the prompt.
|
|
44
38
|
*
|
|
@@ -53,7 +47,7 @@ export declare class ThinkBuilder<Output> {
|
|
|
53
47
|
*
|
|
54
48
|
* @example
|
|
55
49
|
* ```typescript
|
|
56
|
-
* import { schemaOf } from "
|
|
50
|
+
* import { schemaOf } from "thinkwell";
|
|
57
51
|
*
|
|
58
52
|
* interface SearchInput {
|
|
59
53
|
* query: string;
|
|
@@ -120,15 +114,6 @@ export declare class ThinkBuilder<Output> {
|
|
|
120
114
|
* Register a tool without schemas (no prompt reference).
|
|
121
115
|
*/
|
|
122
116
|
defineTool(name: string, description: string, handler: (input: unknown) => Promise<unknown>): this;
|
|
123
|
-
/**
|
|
124
|
-
* Set the expected output schema.
|
|
125
|
-
*
|
|
126
|
-
* This generates a return_result tool that the LLM must call
|
|
127
|
-
* to provide the final output.
|
|
128
|
-
*
|
|
129
|
-
* @deprecated Use `agent.think(schemaOf<T>(schema))` instead to provide a typed schema at construction time.
|
|
130
|
-
*/
|
|
131
|
-
outputSchema(schema: JsonSchema): this;
|
|
132
117
|
/**
|
|
133
118
|
* Set the working directory for the session
|
|
134
119
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"think-builder.d.ts","sourceRoot":"","sources":["../src/think-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,
|
|
1
|
+
{"version":3,"file":"think-builder.d.ts","sourceRoot":"","sources":["../src/think-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,cAAc,EAEpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,eAAe,EAAkB,MAAM,YAAY,CAAC;AA2ElE;;;;;;;;GAQG;AACH,qBAAa,Y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AM,EACnB,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,GAC5C,IAAI;IAyCP;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,CAAC,EAAE,CAAC,EACb,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC,EAC9B,YAAY,EAAE,cAAc,CAAC,CAAC,CAAC,EAC/B,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,GAChC,IAAI;IAEP;;OAEG;IACH,UAAU,CAAC,CAAC,EACV,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC,EAC9B,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,GACtC,IAAI;IAEP;;OAEG;IACH,UAAU,CACR,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,GAC5C,IAAI;IAyCP;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKvB;;;;;;;;;;OAUG;IACG,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;YAMd,WAAW;CAyI1B"}
|
package/dist/think-builder.js
CHANGED
|
@@ -103,20 +103,6 @@ export class ThinkBuilder {
|
|
|
103
103
|
this._promptParts.push(`\`\`\`${language}\n${content}\n\`\`\`\n`);
|
|
104
104
|
return this;
|
|
105
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
106
|
tool(name, description, inputSchemaOrHandler, outputSchemaOrHandler, handler) {
|
|
121
107
|
let inputSchema;
|
|
122
108
|
let outputSchema;
|
|
@@ -181,19 +167,6 @@ export class ThinkBuilder {
|
|
|
181
167
|
});
|
|
182
168
|
return this;
|
|
183
169
|
}
|
|
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
170
|
/**
|
|
198
171
|
* Set the working directory for the session
|
|
199
172
|
*/
|
|
@@ -237,7 +210,7 @@ export class ThinkBuilder {
|
|
|
237
210
|
}
|
|
238
211
|
}
|
|
239
212
|
// Create the MCP server builder
|
|
240
|
-
const serverBuilder = mcpServer("
|
|
213
|
+
const serverBuilder = mcpServer("thinkwell");
|
|
241
214
|
// Track if we've received a result
|
|
242
215
|
let resultReceived = false;
|
|
243
216
|
let result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"think-builder.js","sourceRoot":"","sources":["../src/think-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,
|
|
1
|
+
{"version":3,"file":"think-builder.js","sourceRoot":"","sources":["../src/think-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,GAGV,MAAM,gBAAgB,CAAC;AAmBxB;;GAEG;AACH,M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AEnE,IAAI,CAAC;gBACH,kBAAkB;gBAClB,MAAM,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;gBAEjC,yDAAyD;gBACzD,OAAO,CAAC,cAAc,EAAE,CAAC;oBACvB,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;oBAE1C,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;wBAC3B,IAAI,CAAC,cAAc,EAAE,CAAC;4BACpB,MAAM,CAAC,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC,CAAC;wBACnE,CAAC;wBACD,MAAM;oBACR,CAAC;oBAED,2CAA2C;gBAC7C,CAAC;gBAED,IAAI,cAAc,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;oBAC3C,OAAO,CAAC,MAAM,CAAC,CAAC;gBAClB,CAAC;YACH,CAAC;oBAAS,CAAC;gBACT,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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "thinkwell",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "TypeScript library for blending deterministic code with LLM-powered reasoning",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -18,11 +18,6 @@
|
|
|
18
18
|
"files": [
|
|
19
19
|
"dist"
|
|
20
20
|
],
|
|
21
|
-
"scripts": {
|
|
22
|
-
"build": "tsc",
|
|
23
|
-
"clean": "rm -rf dist",
|
|
24
|
-
"test": "node --test --import tsx src/**/*.test.ts"
|
|
25
|
-
},
|
|
26
21
|
"keywords": [
|
|
27
22
|
"thinkwell",
|
|
28
23
|
"llm",
|
|
@@ -33,11 +28,17 @@
|
|
|
33
28
|
"license": "MIT",
|
|
34
29
|
"dependencies": {
|
|
35
30
|
"@agentclientprotocol/sdk": "^0.12.0",
|
|
36
|
-
"@thinkwell/acp": "
|
|
31
|
+
"@thinkwell/acp": "0.2.0",
|
|
32
|
+
"@thinkwell/conductor": "0.2.0"
|
|
37
33
|
},
|
|
38
34
|
"devDependencies": {
|
|
39
35
|
"@types/node": "^24.10.4",
|
|
40
36
|
"tsx": "^4.19.2",
|
|
41
37
|
"typescript": "^5.7.2"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc",
|
|
41
|
+
"clean": "rm -rf dist",
|
|
42
|
+
"test": "node --test --import tsx src/**/*.test.ts"
|
|
42
43
|
}
|
|
43
|
-
}
|
|
44
|
+
}
|
package/dist/patchwork.d.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { Agent } from "./agent.js";
|
|
2
|
-
import type { SchemaProvider } from "@thinkwell/acp";
|
|
3
|
-
import { ThinkBuilder } from "./think-builder.js";
|
|
4
|
-
/**
|
|
5
|
-
* Main entry point for creating patchwork instances.
|
|
6
|
-
*
|
|
7
|
-
* @deprecated Use Agent instead. This class will be removed in the next major version.
|
|
8
|
-
*
|
|
9
|
-
* Patchwork provides a fluent API for blending deterministic code
|
|
10
|
-
* with LLM-powered reasoning.
|
|
11
|
-
*/
|
|
12
|
-
export declare class Patchwork {
|
|
13
|
-
private readonly _agent;
|
|
14
|
-
/** @internal */
|
|
15
|
-
constructor(agent: Agent);
|
|
16
|
-
/**
|
|
17
|
-
* Create a new think builder for constructing a prompt with tools.
|
|
18
|
-
*
|
|
19
|
-
* @param schema - A SchemaProvider that defines the expected output structure
|
|
20
|
-
*
|
|
21
|
-
* @deprecated Use Agent.think() instead.
|
|
22
|
-
*/
|
|
23
|
-
think<Output>(schema: SchemaProvider<Output>): ThinkBuilder<Output>;
|
|
24
|
-
/**
|
|
25
|
-
* Create a new think builder without a schema.
|
|
26
|
-
*
|
|
27
|
-
* @deprecated Use `think(schemaOf<T>(schema))` instead to provide a typed schema.
|
|
28
|
-
*/
|
|
29
|
-
think<Output>(): ThinkBuilder<Output>;
|
|
30
|
-
/**
|
|
31
|
-
* Close the connection to the conductor
|
|
32
|
-
*
|
|
33
|
-
* @deprecated Use Agent.close() instead.
|
|
34
|
-
*/
|
|
35
|
-
close(): void;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Connect to an agent via the conductor.
|
|
39
|
-
*
|
|
40
|
-
* @deprecated Use Agent.connect() instead. This function will be removed in the next major version.
|
|
41
|
-
*
|
|
42
|
-
* @param conductorCommand - The command to spawn the conductor process
|
|
43
|
-
* @returns A Patchwork instance connected to the conductor
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* ```typescript
|
|
47
|
-
* // Old API (deprecated):
|
|
48
|
-
* const patchwork = await connect(["sacp-conductor", "agent", "npx ..."]);
|
|
49
|
-
*
|
|
50
|
-
* // New API:
|
|
51
|
-
* const agent = await Agent.connect("npx ...");
|
|
52
|
-
* ```
|
|
53
|
-
*/
|
|
54
|
-
export declare function connect(conductorCommand: string[]): Promise<Patchwork>;
|
|
55
|
-
//# sourceMappingURL=patchwork.d.ts.map
|
package/dist/patchwork.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"patchwork.d.ts","sourceRoot":"","sources":["../src/patchwork.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;;;;;GAOG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAE/B,gBAAgB;gBACJ,KAAK,EAAE,KAAK;IAIxB;;;;;;OAMG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC;IAEnE;;;;OAIG;IACH,KAAK,CAAC,MAAM,KAAK,YAAY,CAAC,MAAM,CAAC;IAMrC;;;;OAIG;IACH,KAAK,IAAI,IAAI;CAGd;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,OAAO,CAAC,gBAAgB,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,CAkB5E"}
|
package/dist/patchwork.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Agent } from "./agent.js";
|
|
2
|
-
/**
|
|
3
|
-
* Main entry point for creating patchwork instances.
|
|
4
|
-
*
|
|
5
|
-
* @deprecated Use Agent instead. This class will be removed in the next major version.
|
|
6
|
-
*
|
|
7
|
-
* Patchwork provides a fluent API for blending deterministic code
|
|
8
|
-
* with LLM-powered reasoning.
|
|
9
|
-
*/
|
|
10
|
-
export class Patchwork {
|
|
11
|
-
_agent;
|
|
12
|
-
/** @internal */
|
|
13
|
-
constructor(agent) {
|
|
14
|
-
this._agent = agent;
|
|
15
|
-
}
|
|
16
|
-
think(schema) {
|
|
17
|
-
return this._agent.think(schema);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Close the connection to the conductor
|
|
21
|
-
*
|
|
22
|
-
* @deprecated Use Agent.close() instead.
|
|
23
|
-
*/
|
|
24
|
-
close() {
|
|
25
|
-
this._agent.close();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Connect to an agent via the conductor.
|
|
30
|
-
*
|
|
31
|
-
* @deprecated Use Agent.connect() instead. This function will be removed in the next major version.
|
|
32
|
-
*
|
|
33
|
-
* @param conductorCommand - The command to spawn the conductor process
|
|
34
|
-
* @returns A Patchwork instance connected to the conductor
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```typescript
|
|
38
|
-
* // Old API (deprecated):
|
|
39
|
-
* const patchwork = await connect(["sacp-conductor", "agent", "npx ..."]);
|
|
40
|
-
*
|
|
41
|
-
* // New API:
|
|
42
|
-
* const agent = await Agent.connect("npx ...");
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
export async function connect(conductorCommand) {
|
|
46
|
-
// Extract the agent command from the conductor command
|
|
47
|
-
// Old format: ["sacp-conductor", "agent", "npx -y @zed-industries/claude-code-acp"]
|
|
48
|
-
// New format: just the agent command string
|
|
49
|
-
const agentIndex = conductorCommand.indexOf("agent");
|
|
50
|
-
let agentCommand;
|
|
51
|
-
if (agentIndex !== -1 && conductorCommand.length > agentIndex + 1) {
|
|
52
|
-
agentCommand = conductorCommand[agentIndex + 1];
|
|
53
|
-
}
|
|
54
|
-
else if (conductorCommand.length > 0) {
|
|
55
|
-
// Fallback: join remaining args as the command
|
|
56
|
-
agentCommand = conductorCommand.slice(1).join(" ");
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
throw new Error("Invalid conductor command format");
|
|
60
|
-
}
|
|
61
|
-
const agent = await Agent.connect(agentCommand);
|
|
62
|
-
return new Patchwork(agent);
|
|
63
|
-
}
|
|
64
|
-
//# sourceMappingURL=patchwork.js.map
|
package/dist/patchwork.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"patchwork.js","sourceRoot":"","sources":["../src/patchwork.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAInC;;;;;;;GAOG;AACH,MAAM,OAAO,SAAS;IACH,MAAM,CAAQ;IAE/B,gBAAgB;IAChB,YAAY,KAAY;QACtB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAkBD,KAAK,CAAS,MAA+B;QAC3C,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAO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