thinkwell 0.5.6 → 0.5.7
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/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +32 -6
- package/dist/agent.js.map +1 -1
- package/dist/cli/schema.d.ts.map +1 -1
- package/dist/cli/schema.js +4 -2
- package/dist/cli/schema.js.map +1 -1
- package/dist/generated/features.d.ts +2 -1
- package/dist/generated/features.d.ts.map +1 -1
- package/dist/generated/features.js +2 -1
- package/dist/generated/features.js.map +1 -1
- package/dist/think-builder.d.ts.map +1 -1
- package/dist/think-builder.js +25 -5
- package/dist/think-builder.js.map +1 -1
- package/dist-pkg/acp.cjs +2 -1
- package/dist-pkg/cli-build.cjs +110 -94
- package/dist-pkg/cli-bundle.cjs +196 -180
- package/dist-pkg/cli-check.cjs +128 -112
- package/dist-pkg/cli-loader.cjs +3 -2
- package/dist-pkg/thinkwell.cjs +58 -11
- package/package.json +6 -5
package/dist-pkg/cli-loader.cjs
CHANGED
|
@@ -238798,8 +238798,9 @@ function transformJsonSchemas(path, source, projectDir) {
|
|
|
238798
238798
|
return source;
|
|
238799
238799
|
const schemas = generateSchemas2(path, markedTypes, source, projectDir), insertions = generateInsertions(markedTypes, schemas);
|
|
238800
238800
|
let modifiedSource = applyInsertions(source, insertions);
|
|
238801
|
-
|
|
238802
|
-
|
|
238801
|
+
const [shebang, rest] = extractShebang(modifiedSource);
|
|
238802
|
+
return modifiedSource = shebang + generateSchemaImport() + `
|
|
238803
|
+
` + rest, modifiedSource;
|
|
238803
238804
|
}
|
|
238804
238805
|
__name(transformJsonSchemas, "transformJsonSchemas");
|
|
238805
238806
|
|
package/dist-pkg/thinkwell.cjs
CHANGED
|
@@ -19060,8 +19060,9 @@ __name(createSkillServer, "createSkillServer");
|
|
|
19060
19060
|
|
|
19061
19061
|
// dist/generated/features.js
|
|
19062
19062
|
var features2 = {
|
|
19063
|
+
FAULT_INJECTION: false,
|
|
19063
19064
|
LOG_PERMISSIONS: false,
|
|
19064
|
-
STRIP_CLAUDECODE_ENV:
|
|
19065
|
+
STRIP_CLAUDECODE_ENV: true
|
|
19065
19066
|
};
|
|
19066
19067
|
|
|
19067
19068
|
// dist/think-builder.js
|
|
@@ -19326,12 +19327,31 @@ Available tools:
|
|
|
19326
19327
|
`;
|
|
19327
19328
|
}
|
|
19328
19329
|
const serverBuilder = mcpServer("thinkwell");
|
|
19329
|
-
let resultReceived = false, result, resolveResultReady;
|
|
19330
|
+
let resultReceived = false, result, resultError, resolveResultReady;
|
|
19330
19331
|
const resultReady = new Promise((r) => {
|
|
19331
19332
|
resolveResultReady = r;
|
|
19332
|
-
}), acceptResult = /* @__PURE__ */ __name((input) => {
|
|
19333
|
-
|
|
19334
|
-
|
|
19333
|
+
}), rawSchema = this._schemaProvider?.toJsonSchema() ?? { type: "object" }, needsWrap = rawSchema.type !== "object", outputSchema = needsWrap ? { type: "object", properties: { result: rawSchema }, required: ["result"] } : rawSchema, acceptResult = /* @__PURE__ */ __name((input) => {
|
|
19334
|
+
if (resultReceived)
|
|
19335
|
+
return;
|
|
19336
|
+
const value = needsWrap ? input.result : input, schemaRequired = rawSchema.required;
|
|
19337
|
+
let required2 = Array.isArray(schemaRequired) ? schemaRequired : void 0;
|
|
19338
|
+
if (features2.FAULT_INJECTION) {
|
|
19339
|
+
const injectedField = process.env.THINKWELL_INJECT_REQUIRED_FIELD;
|
|
19340
|
+
injectedField && (required2 = required2 ? [...required2, injectedField] : [injectedField]);
|
|
19341
|
+
}
|
|
19342
|
+
if (Array.isArray(required2)) {
|
|
19343
|
+
if (value == null || typeof value != "object") {
|
|
19344
|
+
resultError = new TypeError(`Agent result must be an object when schema has required fields, got ${value === null ? "null" : typeof value}`), resultReceived = true, resolveResultReady();
|
|
19345
|
+
return;
|
|
19346
|
+
}
|
|
19347
|
+
const obj = value, missing = required2.filter((key) => !Object.hasOwn(obj, key));
|
|
19348
|
+
if (missing.length > 0) {
|
|
19349
|
+
resultError = new TypeError(`Agent result is missing required field(s): ${missing.join(", ")}`), resultReceived = true, resolveResultReady();
|
|
19350
|
+
return;
|
|
19351
|
+
}
|
|
19352
|
+
}
|
|
19353
|
+
result = value, resultReceived = true, resolveResultReady();
|
|
19354
|
+
}, "acceptResult");
|
|
19335
19355
|
prompt += "\n\nWhen you have your answer, call the `return_result` MCP tool with the result.", serverBuilder.tool("return_result", "Return the final result", outputSchema, { type: "object", properties: { success: { type: "boolean" } } }, async (input) => (acceptResult(input), { success: true }));
|
|
19336
19356
|
for (const tool of this._tools.values())
|
|
19337
19357
|
serverBuilder.tool(tool.name, tool.description, tool.inputSchema.toJsonSchema(), tool.outputSchema.toJsonSchema(), async (input, _context) => tool.handler(input));
|
|
@@ -19404,7 +19424,7 @@ ${msg}`);
|
|
|
19404
19424
|
`) + "\n\nWhen you have your answer, call the `return_result` MCP tool with the result.";
|
|
19405
19425
|
await sendTurn(followUp);
|
|
19406
19426
|
}
|
|
19407
|
-
resultReceived && result !== void 0 ? stream.resolveResult(result) : stream.rejectResult(new Error("
|
|
19427
|
+
resultError ? stream.rejectResult(resultError) : resultReceived && result !== void 0 ? stream.resolveResult(result) : resultReceived ? stream.rejectResult(new TypeError("Agent returned an undefined value")) : stream.rejectResult(new Error("Agent session ended without returning a result"));
|
|
19408
19428
|
} finally {
|
|
19409
19429
|
stream.close(), session.close(), this._conn.sessionHandlers.delete(sessionId);
|
|
19410
19430
|
}
|
|
@@ -19487,7 +19507,7 @@ var Session = class {
|
|
|
19487
19507
|
var import_node_fs3 = require("node:fs");
|
|
19488
19508
|
var import_node_path4 = require("node:path");
|
|
19489
19509
|
var AGENT_COMMANDS = {
|
|
19490
|
-
claude: "npx -y @
|
|
19510
|
+
claude: "npx -y @agentclientprotocol/claude-agent-acp",
|
|
19491
19511
|
codex: "npx -y @zed-industries/codex-acp",
|
|
19492
19512
|
gemini: "npx -y @google/gemini-cli --experimental-acp",
|
|
19493
19513
|
kiro: "kiro-cli acp",
|
|
@@ -19531,12 +19551,39 @@ var AgentImpl = class {
|
|
|
19531
19551
|
}), this._conn.initialized = true);
|
|
19532
19552
|
}
|
|
19533
19553
|
};
|
|
19534
|
-
function
|
|
19554
|
+
function createTracer() {
|
|
19555
|
+
const traceDir = process.env.THINKWELL_TRACE;
|
|
19556
|
+
if (!traceDir)
|
|
19557
|
+
return null;
|
|
19558
|
+
try {
|
|
19559
|
+
(0, import_node_fs3.mkdirSync)(traceDir, { recursive: true });
|
|
19560
|
+
} catch {
|
|
19561
|
+
return null;
|
|
19562
|
+
}
|
|
19563
|
+
const tracePath = (0, import_node_path4.join)(traceDir, `trace-${process.pid}-${Date.now()}.ndjson`);
|
|
19564
|
+
let seq = 0;
|
|
19565
|
+
const t0 = performance.now();
|
|
19566
|
+
return (dir, msg) => {
|
|
19567
|
+
const record2 = {
|
|
19568
|
+
seq: seq++,
|
|
19569
|
+
ms: Math.round((performance.now() - t0) * 1e3) / 1e3,
|
|
19570
|
+
dir,
|
|
19571
|
+
msg
|
|
19572
|
+
};
|
|
19573
|
+
try {
|
|
19574
|
+
(0, import_node_fs3.appendFileSync)(tracePath, JSON.stringify(record2) + `
|
|
19575
|
+
`);
|
|
19576
|
+
} catch {
|
|
19577
|
+
}
|
|
19578
|
+
};
|
|
19579
|
+
}
|
|
19580
|
+
__name(createTracer, "createTracer");
|
|
19581
|
+
function componentConnectionToStream(connection, trace) {
|
|
19535
19582
|
const readable = new ReadableStream({
|
|
19536
19583
|
async start(controller) {
|
|
19537
19584
|
try {
|
|
19538
19585
|
for await (const message of connection.messages)
|
|
19539
|
-
controller.enqueue(message);
|
|
19586
|
+
trace?.("recv", message), controller.enqueue(message);
|
|
19540
19587
|
controller.close();
|
|
19541
19588
|
} catch (error40) {
|
|
19542
19589
|
controller.error(error40);
|
|
@@ -19544,7 +19591,7 @@ function componentConnectionToStream(connection) {
|
|
|
19544
19591
|
}
|
|
19545
19592
|
}), writable = new WritableStream({
|
|
19546
19593
|
write(message) {
|
|
19547
|
-
connection.send(message);
|
|
19594
|
+
trace?.("send", message), connection.send(message);
|
|
19548
19595
|
},
|
|
19549
19596
|
close() {
|
|
19550
19597
|
connection.close();
|
|
@@ -19700,7 +19747,7 @@ async function open(nameOrOptions, maybeOptions) {
|
|
|
19700
19747
|
...options?.env
|
|
19701
19748
|
}, commandSpec = parseCommandWithEnv(command, agentEnv), conductor = new Conductor({
|
|
19702
19749
|
instantiator: fromCommands([commandSpec])
|
|
19703
|
-
}), pair = createChannelPair(), stream = componentConnectionToStream(pair.left), mcpHandler = new McpOverAcpHandler(), conn = {
|
|
19750
|
+
}), pair = createChannelPair(), trace = createTracer(), stream = componentConnectionToStream(pair.left, trace), mcpHandler = new McpOverAcpHandler(), conn = {
|
|
19704
19751
|
conductor,
|
|
19705
19752
|
connection: null,
|
|
19706
19753
|
// Set below after creating the client
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "thinkwell",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.7",
|
|
4
4
|
"description": "TypeScript library for blending deterministic code with LLM-powered reasoning",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"@agentclientprotocol/sdk": "^0.16.1",
|
|
41
41
|
"ts-json-schema-generator": "^2.4.0",
|
|
42
42
|
"typescript": "^5.7.2",
|
|
43
|
-
"@thinkwell/acp": "0.5.
|
|
44
|
-
"@thinkwell/conductor": "0.5.
|
|
45
|
-
"@thinkwell/protocol": "0.5.
|
|
43
|
+
"@thinkwell/acp": "0.5.7",
|
|
44
|
+
"@thinkwell/conductor": "0.5.7",
|
|
45
|
+
"@thinkwell/protocol": "0.5.7"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/node": "^24.10.4",
|
|
@@ -82,6 +82,7 @@
|
|
|
82
82
|
"build:binary:linux-arm64": "tsx scripts/bundle.ts && tsx scripts/build-binary.ts linux-arm64",
|
|
83
83
|
"bundle": "tsx scripts/bundle.ts",
|
|
84
84
|
"clean": "rm -rf dist dist-bin dist-pkg",
|
|
85
|
-
"test": "node --test --import tsx src/**/*.test.ts"
|
|
85
|
+
"test": "node --test --import tsx src/**/*.test.ts",
|
|
86
|
+
"test:smoke": "node --test --test-force-exit --test-timeout=180000 --import tsx src/integration.test.ts"
|
|
86
87
|
}
|
|
87
88
|
}
|