@hasna/brains 0.0.4 → 0.0.5
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/cli/index.js +12 -12
- package/dist/index.js +12 -39
- package/dist/lib/index.d.ts +0 -1
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/mcp/index.d.ts +2 -74
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +297 -356
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +8 -46
- package/package.json +1 -1
- package/dist/lib/package-metadata.d.ts +0 -2
- package/dist/lib/package-metadata.d.ts.map +0 -1
package/dist/cli/index.js
CHANGED
|
@@ -9288,11 +9288,11 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
9288
9288
|
}
|
|
9289
9289
|
return this._addChatCompletion(__classPrivateFieldGet6(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_endRequest).call(this));
|
|
9290
9290
|
}
|
|
9291
|
-
[(_ChatCompletionStream_params = new WeakMap, _ChatCompletionStream_choiceEventStates = new WeakMap, _ChatCompletionStream_currentChatCompletionSnapshot = new WeakMap, _ChatCompletionStream_instances = new WeakSet, _ChatCompletionStream_beginRequest = function
|
|
9291
|
+
[(_ChatCompletionStream_params = new WeakMap, _ChatCompletionStream_choiceEventStates = new WeakMap, _ChatCompletionStream_currentChatCompletionSnapshot = new WeakMap, _ChatCompletionStream_instances = new WeakSet, _ChatCompletionStream_beginRequest = function _ChatCompletionStream_beginRequest2() {
|
|
9292
9292
|
if (this.ended)
|
|
9293
9293
|
return;
|
|
9294
9294
|
__classPrivateFieldSet5(this, _ChatCompletionStream_currentChatCompletionSnapshot, undefined, "f");
|
|
9295
|
-
}, _ChatCompletionStream_getChoiceEventState = function
|
|
9295
|
+
}, _ChatCompletionStream_getChoiceEventState = function _ChatCompletionStream_getChoiceEventState2(choice) {
|
|
9296
9296
|
let state = __classPrivateFieldGet6(this, _ChatCompletionStream_choiceEventStates, "f")[choice.index];
|
|
9297
9297
|
if (state) {
|
|
9298
9298
|
return state;
|
|
@@ -9307,7 +9307,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
9307
9307
|
};
|
|
9308
9308
|
__classPrivateFieldGet6(this, _ChatCompletionStream_choiceEventStates, "f")[choice.index] = state;
|
|
9309
9309
|
return state;
|
|
9310
|
-
}, _ChatCompletionStream_addChunk = function
|
|
9310
|
+
}, _ChatCompletionStream_addChunk = function _ChatCompletionStream_addChunk2(chunk) {
|
|
9311
9311
|
if (this.ended)
|
|
9312
9312
|
return;
|
|
9313
9313
|
const completion = __classPrivateFieldGet6(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_accumulateChatCompletion).call(this, chunk);
|
|
@@ -9374,7 +9374,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
9374
9374
|
}
|
|
9375
9375
|
}
|
|
9376
9376
|
}
|
|
9377
|
-
}, _ChatCompletionStream_emitToolCallDoneEvent = function
|
|
9377
|
+
}, _ChatCompletionStream_emitToolCallDoneEvent = function _ChatCompletionStream_emitToolCallDoneEvent2(choiceSnapshot, toolCallIndex) {
|
|
9378
9378
|
const state = __classPrivateFieldGet6(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);
|
|
9379
9379
|
if (state.done_tool_calls.has(toolCallIndex)) {
|
|
9380
9380
|
return;
|
|
@@ -9397,7 +9397,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
9397
9397
|
} else {
|
|
9398
9398
|
assertNever2(toolCallSnapshot.type);
|
|
9399
9399
|
}
|
|
9400
|
-
}, _ChatCompletionStream_emitContentDoneEvents = function
|
|
9400
|
+
}, _ChatCompletionStream_emitContentDoneEvents = function _ChatCompletionStream_emitContentDoneEvents2(choiceSnapshot) {
|
|
9401
9401
|
const state = __classPrivateFieldGet6(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);
|
|
9402
9402
|
if (choiceSnapshot.message.content && !state.content_done) {
|
|
9403
9403
|
state.content_done = true;
|
|
@@ -9419,7 +9419,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
9419
9419
|
state.logprobs_refusal_done = true;
|
|
9420
9420
|
this._emit("logprobs.refusal.done", { refusal: choiceSnapshot.logprobs.refusal });
|
|
9421
9421
|
}
|
|
9422
|
-
}, _ChatCompletionStream_endRequest = function
|
|
9422
|
+
}, _ChatCompletionStream_endRequest = function _ChatCompletionStream_endRequest2() {
|
|
9423
9423
|
if (this.ended) {
|
|
9424
9424
|
throw new OpenAIError(`stream has ended, this shouldn't happen`);
|
|
9425
9425
|
}
|
|
@@ -9430,13 +9430,13 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
9430
9430
|
__classPrivateFieldSet5(this, _ChatCompletionStream_currentChatCompletionSnapshot, undefined, "f");
|
|
9431
9431
|
__classPrivateFieldSet5(this, _ChatCompletionStream_choiceEventStates, [], "f");
|
|
9432
9432
|
return finalizeChatCompletion(snapshot, __classPrivateFieldGet6(this, _ChatCompletionStream_params, "f"));
|
|
9433
|
-
}, _ChatCompletionStream_getAutoParseableResponseFormat = function
|
|
9433
|
+
}, _ChatCompletionStream_getAutoParseableResponseFormat = function _ChatCompletionStream_getAutoParseableResponseFormat2() {
|
|
9434
9434
|
const responseFormat = __classPrivateFieldGet6(this, _ChatCompletionStream_params, "f")?.response_format;
|
|
9435
9435
|
if (isAutoParsableResponseFormat(responseFormat)) {
|
|
9436
9436
|
return responseFormat;
|
|
9437
9437
|
}
|
|
9438
9438
|
return null;
|
|
9439
|
-
}, _ChatCompletionStream_accumulateChatCompletion = function
|
|
9439
|
+
}, _ChatCompletionStream_accumulateChatCompletion = function _ChatCompletionStream_accumulateChatCompletion2(chunk) {
|
|
9440
9440
|
var _a, _b, _c, _d;
|
|
9441
9441
|
let snapshot = __classPrivateFieldGet6(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f");
|
|
9442
9442
|
const { choices, ...rest } = chunk;
|
|
@@ -10662,11 +10662,11 @@ class ResponseStream extends EventStream {
|
|
|
10662
10662
|
}
|
|
10663
10663
|
return __classPrivateFieldGet7(this, _ResponseStream_instances, "m", _ResponseStream_endRequest).call(this);
|
|
10664
10664
|
}
|
|
10665
|
-
[(_ResponseStream_params = new WeakMap, _ResponseStream_currentResponseSnapshot = new WeakMap, _ResponseStream_finalResponse = new WeakMap, _ResponseStream_instances = new WeakSet, _ResponseStream_beginRequest = function
|
|
10665
|
+
[(_ResponseStream_params = new WeakMap, _ResponseStream_currentResponseSnapshot = new WeakMap, _ResponseStream_finalResponse = new WeakMap, _ResponseStream_instances = new WeakSet, _ResponseStream_beginRequest = function _ResponseStream_beginRequest2() {
|
|
10666
10666
|
if (this.ended)
|
|
10667
10667
|
return;
|
|
10668
10668
|
__classPrivateFieldSet6(this, _ResponseStream_currentResponseSnapshot, undefined, "f");
|
|
10669
|
-
}, _ResponseStream_addEvent = function
|
|
10669
|
+
}, _ResponseStream_addEvent = function _ResponseStream_addEvent2(event, starting_after) {
|
|
10670
10670
|
if (this.ended)
|
|
10671
10671
|
return;
|
|
10672
10672
|
const maybeEmit = (name, event2) => {
|
|
@@ -10714,7 +10714,7 @@ class ResponseStream extends EventStream {
|
|
|
10714
10714
|
maybeEmit(event.type, event);
|
|
10715
10715
|
break;
|
|
10716
10716
|
}
|
|
10717
|
-
}, _ResponseStream_endRequest = function
|
|
10717
|
+
}, _ResponseStream_endRequest = function _ResponseStream_endRequest2() {
|
|
10718
10718
|
if (this.ended) {
|
|
10719
10719
|
throw new OpenAIError(`stream has ended, this shouldn't happen`);
|
|
10720
10720
|
}
|
|
@@ -10726,7 +10726,7 @@ class ResponseStream extends EventStream {
|
|
|
10726
10726
|
const parsedResponse = finalizeResponse(snapshot, __classPrivateFieldGet7(this, _ResponseStream_params, "f"));
|
|
10727
10727
|
__classPrivateFieldSet6(this, _ResponseStream_finalResponse, parsedResponse, "f");
|
|
10728
10728
|
return parsedResponse;
|
|
10729
|
-
}, _ResponseStream_accumulateResponse = function
|
|
10729
|
+
}, _ResponseStream_accumulateResponse = function _ResponseStream_accumulateResponse2(event) {
|
|
10730
10730
|
let snapshot = __classPrivateFieldGet7(this, _ResponseStream_currentResponseSnapshot, "f");
|
|
10731
10731
|
if (!snapshot) {
|
|
10732
10732
|
if (event.type !== "response.created") {
|
package/dist/index.js
CHANGED
|
@@ -7212,11 +7212,11 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
7212
7212
|
}
|
|
7213
7213
|
return this._addChatCompletion(__classPrivateFieldGet6(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_endRequest).call(this));
|
|
7214
7214
|
}
|
|
7215
|
-
[(_ChatCompletionStream_params = new WeakMap, _ChatCompletionStream_choiceEventStates = new WeakMap, _ChatCompletionStream_currentChatCompletionSnapshot = new WeakMap, _ChatCompletionStream_instances = new WeakSet, _ChatCompletionStream_beginRequest = function
|
|
7215
|
+
[(_ChatCompletionStream_params = new WeakMap, _ChatCompletionStream_choiceEventStates = new WeakMap, _ChatCompletionStream_currentChatCompletionSnapshot = new WeakMap, _ChatCompletionStream_instances = new WeakSet, _ChatCompletionStream_beginRequest = function _ChatCompletionStream_beginRequest2() {
|
|
7216
7216
|
if (this.ended)
|
|
7217
7217
|
return;
|
|
7218
7218
|
__classPrivateFieldSet5(this, _ChatCompletionStream_currentChatCompletionSnapshot, undefined, "f");
|
|
7219
|
-
}, _ChatCompletionStream_getChoiceEventState = function
|
|
7219
|
+
}, _ChatCompletionStream_getChoiceEventState = function _ChatCompletionStream_getChoiceEventState2(choice) {
|
|
7220
7220
|
let state = __classPrivateFieldGet6(this, _ChatCompletionStream_choiceEventStates, "f")[choice.index];
|
|
7221
7221
|
if (state) {
|
|
7222
7222
|
return state;
|
|
@@ -7231,7 +7231,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
7231
7231
|
};
|
|
7232
7232
|
__classPrivateFieldGet6(this, _ChatCompletionStream_choiceEventStates, "f")[choice.index] = state;
|
|
7233
7233
|
return state;
|
|
7234
|
-
}, _ChatCompletionStream_addChunk = function
|
|
7234
|
+
}, _ChatCompletionStream_addChunk = function _ChatCompletionStream_addChunk2(chunk) {
|
|
7235
7235
|
if (this.ended)
|
|
7236
7236
|
return;
|
|
7237
7237
|
const completion = __classPrivateFieldGet6(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_accumulateChatCompletion).call(this, chunk);
|
|
@@ -7298,7 +7298,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
7298
7298
|
}
|
|
7299
7299
|
}
|
|
7300
7300
|
}
|
|
7301
|
-
}, _ChatCompletionStream_emitToolCallDoneEvent = function
|
|
7301
|
+
}, _ChatCompletionStream_emitToolCallDoneEvent = function _ChatCompletionStream_emitToolCallDoneEvent2(choiceSnapshot, toolCallIndex) {
|
|
7302
7302
|
const state = __classPrivateFieldGet6(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);
|
|
7303
7303
|
if (state.done_tool_calls.has(toolCallIndex)) {
|
|
7304
7304
|
return;
|
|
@@ -7321,7 +7321,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
7321
7321
|
} else {
|
|
7322
7322
|
assertNever2(toolCallSnapshot.type);
|
|
7323
7323
|
}
|
|
7324
|
-
}, _ChatCompletionStream_emitContentDoneEvents = function
|
|
7324
|
+
}, _ChatCompletionStream_emitContentDoneEvents = function _ChatCompletionStream_emitContentDoneEvents2(choiceSnapshot) {
|
|
7325
7325
|
const state = __classPrivateFieldGet6(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);
|
|
7326
7326
|
if (choiceSnapshot.message.content && !state.content_done) {
|
|
7327
7327
|
state.content_done = true;
|
|
@@ -7343,7 +7343,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
7343
7343
|
state.logprobs_refusal_done = true;
|
|
7344
7344
|
this._emit("logprobs.refusal.done", { refusal: choiceSnapshot.logprobs.refusal });
|
|
7345
7345
|
}
|
|
7346
|
-
}, _ChatCompletionStream_endRequest = function
|
|
7346
|
+
}, _ChatCompletionStream_endRequest = function _ChatCompletionStream_endRequest2() {
|
|
7347
7347
|
if (this.ended) {
|
|
7348
7348
|
throw new OpenAIError(`stream has ended, this shouldn't happen`);
|
|
7349
7349
|
}
|
|
@@ -7354,13 +7354,13 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
7354
7354
|
__classPrivateFieldSet5(this, _ChatCompletionStream_currentChatCompletionSnapshot, undefined, "f");
|
|
7355
7355
|
__classPrivateFieldSet5(this, _ChatCompletionStream_choiceEventStates, [], "f");
|
|
7356
7356
|
return finalizeChatCompletion(snapshot, __classPrivateFieldGet6(this, _ChatCompletionStream_params, "f"));
|
|
7357
|
-
}, _ChatCompletionStream_getAutoParseableResponseFormat = function
|
|
7357
|
+
}, _ChatCompletionStream_getAutoParseableResponseFormat = function _ChatCompletionStream_getAutoParseableResponseFormat2() {
|
|
7358
7358
|
const responseFormat = __classPrivateFieldGet6(this, _ChatCompletionStream_params, "f")?.response_format;
|
|
7359
7359
|
if (isAutoParsableResponseFormat(responseFormat)) {
|
|
7360
7360
|
return responseFormat;
|
|
7361
7361
|
}
|
|
7362
7362
|
return null;
|
|
7363
|
-
}, _ChatCompletionStream_accumulateChatCompletion = function
|
|
7363
|
+
}, _ChatCompletionStream_accumulateChatCompletion = function _ChatCompletionStream_accumulateChatCompletion2(chunk) {
|
|
7364
7364
|
var _a, _b, _c, _d;
|
|
7365
7365
|
let snapshot = __classPrivateFieldGet6(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f");
|
|
7366
7366
|
const { choices, ...rest } = chunk;
|
|
@@ -8586,11 +8586,11 @@ class ResponseStream extends EventStream {
|
|
|
8586
8586
|
}
|
|
8587
8587
|
return __classPrivateFieldGet7(this, _ResponseStream_instances, "m", _ResponseStream_endRequest).call(this);
|
|
8588
8588
|
}
|
|
8589
|
-
[(_ResponseStream_params = new WeakMap, _ResponseStream_currentResponseSnapshot = new WeakMap, _ResponseStream_finalResponse = new WeakMap, _ResponseStream_instances = new WeakSet, _ResponseStream_beginRequest = function
|
|
8589
|
+
[(_ResponseStream_params = new WeakMap, _ResponseStream_currentResponseSnapshot = new WeakMap, _ResponseStream_finalResponse = new WeakMap, _ResponseStream_instances = new WeakSet, _ResponseStream_beginRequest = function _ResponseStream_beginRequest2() {
|
|
8590
8590
|
if (this.ended)
|
|
8591
8591
|
return;
|
|
8592
8592
|
__classPrivateFieldSet6(this, _ResponseStream_currentResponseSnapshot, undefined, "f");
|
|
8593
|
-
}, _ResponseStream_addEvent = function
|
|
8593
|
+
}, _ResponseStream_addEvent = function _ResponseStream_addEvent2(event, starting_after) {
|
|
8594
8594
|
if (this.ended)
|
|
8595
8595
|
return;
|
|
8596
8596
|
const maybeEmit = (name, event2) => {
|
|
@@ -8638,7 +8638,7 @@ class ResponseStream extends EventStream {
|
|
|
8638
8638
|
maybeEmit(event.type, event);
|
|
8639
8639
|
break;
|
|
8640
8640
|
}
|
|
8641
|
-
}, _ResponseStream_endRequest = function
|
|
8641
|
+
}, _ResponseStream_endRequest = function _ResponseStream_endRequest2() {
|
|
8642
8642
|
if (this.ended) {
|
|
8643
8643
|
throw new OpenAIError(`stream has ended, this shouldn't happen`);
|
|
8644
8644
|
}
|
|
@@ -8650,7 +8650,7 @@ class ResponseStream extends EventStream {
|
|
|
8650
8650
|
const parsedResponse = finalizeResponse(snapshot, __classPrivateFieldGet7(this, _ResponseStream_params, "f"));
|
|
8651
8651
|
__classPrivateFieldSet6(this, _ResponseStream_finalResponse, parsedResponse, "f");
|
|
8652
8652
|
return parsedResponse;
|
|
8653
|
-
}, _ResponseStream_accumulateResponse = function
|
|
8653
|
+
}, _ResponseStream_accumulateResponse = function _ResponseStream_accumulateResponse2(event) {
|
|
8654
8654
|
let snapshot = __classPrivateFieldGet7(this, _ResponseStream_currentResponseSnapshot, "f");
|
|
8655
8655
|
if (!snapshot) {
|
|
8656
8656
|
if (event.type !== "response.created") {
|
|
@@ -9403,32 +9403,6 @@ class ThinkerLabsProvider {
|
|
|
9403
9403
|
return cancelJob(jobId);
|
|
9404
9404
|
}
|
|
9405
9405
|
}
|
|
9406
|
-
// src/lib/package-metadata.ts
|
|
9407
|
-
import { existsSync, readFileSync as readFileSync2 } from "fs";
|
|
9408
|
-
import { dirname as dirname2, resolve } from "path";
|
|
9409
|
-
import { fileURLToPath } from "url";
|
|
9410
|
-
var DEFAULT_VERSION = "0.0.0";
|
|
9411
|
-
var cachedVersion;
|
|
9412
|
-
function getPackageJsonPath() {
|
|
9413
|
-
return resolve(dirname2(fileURLToPath(import.meta.url)), "../../package.json");
|
|
9414
|
-
}
|
|
9415
|
-
function getPackageVersion() {
|
|
9416
|
-
if (cachedVersion) {
|
|
9417
|
-
return cachedVersion;
|
|
9418
|
-
}
|
|
9419
|
-
const packageJsonPath = getPackageJsonPath();
|
|
9420
|
-
if (!existsSync(packageJsonPath)) {
|
|
9421
|
-
cachedVersion = DEFAULT_VERSION;
|
|
9422
|
-
return cachedVersion;
|
|
9423
|
-
}
|
|
9424
|
-
try {
|
|
9425
|
-
const packageJson = JSON.parse(readFileSync2(packageJsonPath, "utf-8"));
|
|
9426
|
-
cachedVersion = typeof packageJson.version === "string" ? packageJson.version : DEFAULT_VERSION;
|
|
9427
|
-
} catch {
|
|
9428
|
-
cachedVersion = DEFAULT_VERSION;
|
|
9429
|
-
}
|
|
9430
|
-
return cachedVersion;
|
|
9431
|
-
}
|
|
9432
9406
|
export {
|
|
9433
9407
|
uploadTrainingFile,
|
|
9434
9408
|
uploadTrainingData,
|
|
@@ -9438,7 +9412,6 @@ export {
|
|
|
9438
9412
|
listModels,
|
|
9439
9413
|
listFineTunedModels,
|
|
9440
9414
|
getStatus,
|
|
9441
|
-
getPackageVersion,
|
|
9442
9415
|
getFineTuneStatus,
|
|
9443
9416
|
getDb,
|
|
9444
9417
|
fineTunedModels,
|
package/dist/lib/index.d.ts
CHANGED
package/dist/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AACA,cAAc,sBAAsB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AACA,cAAc,sBAAsB,CAAC"}
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,75 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare const MCP_SERVER_INFO: {
|
|
4
|
-
readonly name: "brains";
|
|
5
|
-
readonly version: string;
|
|
6
|
-
};
|
|
7
|
-
export declare function createMcpServer(): Server<{
|
|
8
|
-
method: string;
|
|
9
|
-
params?: {
|
|
10
|
-
[x: string]: unknown;
|
|
11
|
-
_meta?: {
|
|
12
|
-
[x: string]: unknown;
|
|
13
|
-
progressToken?: string | number | undefined;
|
|
14
|
-
"io.modelcontextprotocol/related-task"?: {
|
|
15
|
-
taskId: string;
|
|
16
|
-
} | undefined;
|
|
17
|
-
} | undefined;
|
|
18
|
-
} | undefined;
|
|
19
|
-
}, {
|
|
20
|
-
method: string;
|
|
21
|
-
params?: {
|
|
22
|
-
[x: string]: unknown;
|
|
23
|
-
_meta?: {
|
|
24
|
-
[x: string]: unknown;
|
|
25
|
-
progressToken?: string | number | undefined;
|
|
26
|
-
"io.modelcontextprotocol/related-task"?: {
|
|
27
|
-
taskId: string;
|
|
28
|
-
} | undefined;
|
|
29
|
-
} | undefined;
|
|
30
|
-
} | undefined;
|
|
31
|
-
}, {
|
|
32
|
-
[x: string]: unknown;
|
|
33
|
-
_meta?: {
|
|
34
|
-
[x: string]: unknown;
|
|
35
|
-
progressToken?: string | number | undefined;
|
|
36
|
-
"io.modelcontextprotocol/related-task"?: {
|
|
37
|
-
taskId: string;
|
|
38
|
-
} | undefined;
|
|
39
|
-
} | undefined;
|
|
40
|
-
}>;
|
|
41
|
-
export declare function startMcpServer(transport?: StdioServerTransport): Promise<Server<{
|
|
42
|
-
method: string;
|
|
43
|
-
params?: {
|
|
44
|
-
[x: string]: unknown;
|
|
45
|
-
_meta?: {
|
|
46
|
-
[x: string]: unknown;
|
|
47
|
-
progressToken?: string | number | undefined;
|
|
48
|
-
"io.modelcontextprotocol/related-task"?: {
|
|
49
|
-
taskId: string;
|
|
50
|
-
} | undefined;
|
|
51
|
-
} | undefined;
|
|
52
|
-
} | undefined;
|
|
53
|
-
}, {
|
|
54
|
-
method: string;
|
|
55
|
-
params?: {
|
|
56
|
-
[x: string]: unknown;
|
|
57
|
-
_meta?: {
|
|
58
|
-
[x: string]: unknown;
|
|
59
|
-
progressToken?: string | number | undefined;
|
|
60
|
-
"io.modelcontextprotocol/related-task"?: {
|
|
61
|
-
taskId: string;
|
|
62
|
-
} | undefined;
|
|
63
|
-
} | undefined;
|
|
64
|
-
} | undefined;
|
|
65
|
-
}, {
|
|
66
|
-
[x: string]: unknown;
|
|
67
|
-
_meta?: {
|
|
68
|
-
[x: string]: unknown;
|
|
69
|
-
progressToken?: string | number | undefined;
|
|
70
|
-
"io.modelcontextprotocol/related-task"?: {
|
|
71
|
-
taskId: string;
|
|
72
|
-
} | undefined;
|
|
73
|
-
} | undefined;
|
|
74
|
-
}>>;
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
export {};
|
|
75
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/mcp/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":""}
|
package/dist/mcp/index.js
CHANGED
|
@@ -1,20 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
1
2
|
// @bun
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
-
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
-
for (let key of __getOwnPropNames(mod))
|
|
11
|
-
if (!__hasOwnProp.call(to, key))
|
|
12
|
-
__defProp(to, key, {
|
|
13
|
-
get: () => mod[key],
|
|
14
|
-
enumerable: true
|
|
15
|
-
});
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
4
|
var __export = (target, all) => {
|
|
19
5
|
for (var name in all)
|
|
20
6
|
__defProp(target, name, {
|
|
@@ -33,8 +19,8 @@ import {
|
|
|
33
19
|
CallToolRequestSchema,
|
|
34
20
|
ListToolsRequestSchema
|
|
35
21
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
36
|
-
import { readFileSync as
|
|
37
|
-
import { resolve
|
|
22
|
+
import { readFileSync as readFileSync2, existsSync } from "fs";
|
|
23
|
+
import { resolve } from "path";
|
|
38
24
|
import { homedir as homedir3 } from "os";
|
|
39
25
|
|
|
40
26
|
// node_modules/drizzle-orm/entity.js
|
|
@@ -7241,11 +7227,11 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
7241
7227
|
}
|
|
7242
7228
|
return this._addChatCompletion(__classPrivateFieldGet6(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_endRequest).call(this));
|
|
7243
7229
|
}
|
|
7244
|
-
[(_ChatCompletionStream_params = new WeakMap, _ChatCompletionStream_choiceEventStates = new WeakMap, _ChatCompletionStream_currentChatCompletionSnapshot = new WeakMap, _ChatCompletionStream_instances = new WeakSet, _ChatCompletionStream_beginRequest = function
|
|
7230
|
+
[(_ChatCompletionStream_params = new WeakMap, _ChatCompletionStream_choiceEventStates = new WeakMap, _ChatCompletionStream_currentChatCompletionSnapshot = new WeakMap, _ChatCompletionStream_instances = new WeakSet, _ChatCompletionStream_beginRequest = function _ChatCompletionStream_beginRequest2() {
|
|
7245
7231
|
if (this.ended)
|
|
7246
7232
|
return;
|
|
7247
7233
|
__classPrivateFieldSet5(this, _ChatCompletionStream_currentChatCompletionSnapshot, undefined, "f");
|
|
7248
|
-
}, _ChatCompletionStream_getChoiceEventState = function
|
|
7234
|
+
}, _ChatCompletionStream_getChoiceEventState = function _ChatCompletionStream_getChoiceEventState2(choice) {
|
|
7249
7235
|
let state = __classPrivateFieldGet6(this, _ChatCompletionStream_choiceEventStates, "f")[choice.index];
|
|
7250
7236
|
if (state) {
|
|
7251
7237
|
return state;
|
|
@@ -7260,7 +7246,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
7260
7246
|
};
|
|
7261
7247
|
__classPrivateFieldGet6(this, _ChatCompletionStream_choiceEventStates, "f")[choice.index] = state;
|
|
7262
7248
|
return state;
|
|
7263
|
-
}, _ChatCompletionStream_addChunk = function
|
|
7249
|
+
}, _ChatCompletionStream_addChunk = function _ChatCompletionStream_addChunk2(chunk) {
|
|
7264
7250
|
if (this.ended)
|
|
7265
7251
|
return;
|
|
7266
7252
|
const completion = __classPrivateFieldGet6(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_accumulateChatCompletion).call(this, chunk);
|
|
@@ -7327,7 +7313,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
7327
7313
|
}
|
|
7328
7314
|
}
|
|
7329
7315
|
}
|
|
7330
|
-
}, _ChatCompletionStream_emitToolCallDoneEvent = function
|
|
7316
|
+
}, _ChatCompletionStream_emitToolCallDoneEvent = function _ChatCompletionStream_emitToolCallDoneEvent2(choiceSnapshot, toolCallIndex) {
|
|
7331
7317
|
const state = __classPrivateFieldGet6(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);
|
|
7332
7318
|
if (state.done_tool_calls.has(toolCallIndex)) {
|
|
7333
7319
|
return;
|
|
@@ -7350,7 +7336,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
7350
7336
|
} else {
|
|
7351
7337
|
assertNever2(toolCallSnapshot.type);
|
|
7352
7338
|
}
|
|
7353
|
-
}, _ChatCompletionStream_emitContentDoneEvents = function
|
|
7339
|
+
}, _ChatCompletionStream_emitContentDoneEvents = function _ChatCompletionStream_emitContentDoneEvents2(choiceSnapshot) {
|
|
7354
7340
|
const state = __classPrivateFieldGet6(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);
|
|
7355
7341
|
if (choiceSnapshot.message.content && !state.content_done) {
|
|
7356
7342
|
state.content_done = true;
|
|
@@ -7372,7 +7358,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
7372
7358
|
state.logprobs_refusal_done = true;
|
|
7373
7359
|
this._emit("logprobs.refusal.done", { refusal: choiceSnapshot.logprobs.refusal });
|
|
7374
7360
|
}
|
|
7375
|
-
}, _ChatCompletionStream_endRequest = function
|
|
7361
|
+
}, _ChatCompletionStream_endRequest = function _ChatCompletionStream_endRequest2() {
|
|
7376
7362
|
if (this.ended) {
|
|
7377
7363
|
throw new OpenAIError(`stream has ended, this shouldn't happen`);
|
|
7378
7364
|
}
|
|
@@ -7383,13 +7369,13 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
7383
7369
|
__classPrivateFieldSet5(this, _ChatCompletionStream_currentChatCompletionSnapshot, undefined, "f");
|
|
7384
7370
|
__classPrivateFieldSet5(this, _ChatCompletionStream_choiceEventStates, [], "f");
|
|
7385
7371
|
return finalizeChatCompletion(snapshot, __classPrivateFieldGet6(this, _ChatCompletionStream_params, "f"));
|
|
7386
|
-
}, _ChatCompletionStream_getAutoParseableResponseFormat = function
|
|
7372
|
+
}, _ChatCompletionStream_getAutoParseableResponseFormat = function _ChatCompletionStream_getAutoParseableResponseFormat2() {
|
|
7387
7373
|
const responseFormat = __classPrivateFieldGet6(this, _ChatCompletionStream_params, "f")?.response_format;
|
|
7388
7374
|
if (isAutoParsableResponseFormat(responseFormat)) {
|
|
7389
7375
|
return responseFormat;
|
|
7390
7376
|
}
|
|
7391
7377
|
return null;
|
|
7392
|
-
}, _ChatCompletionStream_accumulateChatCompletion = function
|
|
7378
|
+
}, _ChatCompletionStream_accumulateChatCompletion = function _ChatCompletionStream_accumulateChatCompletion2(chunk) {
|
|
7393
7379
|
var _a, _b, _c, _d;
|
|
7394
7380
|
let snapshot = __classPrivateFieldGet6(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f");
|
|
7395
7381
|
const { choices, ...rest } = chunk;
|
|
@@ -8615,11 +8601,11 @@ class ResponseStream extends EventStream {
|
|
|
8615
8601
|
}
|
|
8616
8602
|
return __classPrivateFieldGet7(this, _ResponseStream_instances, "m", _ResponseStream_endRequest).call(this);
|
|
8617
8603
|
}
|
|
8618
|
-
[(_ResponseStream_params = new WeakMap, _ResponseStream_currentResponseSnapshot = new WeakMap, _ResponseStream_finalResponse = new WeakMap, _ResponseStream_instances = new WeakSet, _ResponseStream_beginRequest = function
|
|
8604
|
+
[(_ResponseStream_params = new WeakMap, _ResponseStream_currentResponseSnapshot = new WeakMap, _ResponseStream_finalResponse = new WeakMap, _ResponseStream_instances = new WeakSet, _ResponseStream_beginRequest = function _ResponseStream_beginRequest2() {
|
|
8619
8605
|
if (this.ended)
|
|
8620
8606
|
return;
|
|
8621
8607
|
__classPrivateFieldSet6(this, _ResponseStream_currentResponseSnapshot, undefined, "f");
|
|
8622
|
-
}, _ResponseStream_addEvent = function
|
|
8608
|
+
}, _ResponseStream_addEvent = function _ResponseStream_addEvent2(event, starting_after) {
|
|
8623
8609
|
if (this.ended)
|
|
8624
8610
|
return;
|
|
8625
8611
|
const maybeEmit = (name, event2) => {
|
|
@@ -8667,7 +8653,7 @@ class ResponseStream extends EventStream {
|
|
|
8667
8653
|
maybeEmit(event.type, event);
|
|
8668
8654
|
break;
|
|
8669
8655
|
}
|
|
8670
|
-
}, _ResponseStream_endRequest = function
|
|
8656
|
+
}, _ResponseStream_endRequest = function _ResponseStream_endRequest2() {
|
|
8671
8657
|
if (this.ended) {
|
|
8672
8658
|
throw new OpenAIError(`stream has ended, this shouldn't happen`);
|
|
8673
8659
|
}
|
|
@@ -8679,7 +8665,7 @@ class ResponseStream extends EventStream {
|
|
|
8679
8665
|
const parsedResponse = finalizeResponse(snapshot, __classPrivateFieldGet7(this, _ResponseStream_params, "f"));
|
|
8680
8666
|
__classPrivateFieldSet6(this, _ResponseStream_finalResponse, parsedResponse, "f");
|
|
8681
8667
|
return parsedResponse;
|
|
8682
|
-
}, _ResponseStream_accumulateResponse = function
|
|
8668
|
+
}, _ResponseStream_accumulateResponse = function _ResponseStream_accumulateResponse2(event) {
|
|
8683
8669
|
let snapshot = __classPrivateFieldGet7(this, _ResponseStream_currentResponseSnapshot, "f");
|
|
8684
8670
|
if (!snapshot) {
|
|
8685
8671
|
if (event.type !== "response.created") {
|
|
@@ -9525,33 +9511,6 @@ async function gatherFromTodos(options = {}) {
|
|
|
9525
9511
|
}
|
|
9526
9512
|
}
|
|
9527
9513
|
|
|
9528
|
-
// src/lib/package-metadata.ts
|
|
9529
|
-
import { existsSync, readFileSync as readFileSync2 } from "fs";
|
|
9530
|
-
import { dirname as dirname2, resolve } from "path";
|
|
9531
|
-
import { fileURLToPath } from "url";
|
|
9532
|
-
var DEFAULT_VERSION = "0.0.0";
|
|
9533
|
-
var cachedVersion;
|
|
9534
|
-
function getPackageJsonPath() {
|
|
9535
|
-
return resolve(dirname2(fileURLToPath(import.meta.url)), "../../package.json");
|
|
9536
|
-
}
|
|
9537
|
-
function getPackageVersion() {
|
|
9538
|
-
if (cachedVersion) {
|
|
9539
|
-
return cachedVersion;
|
|
9540
|
-
}
|
|
9541
|
-
const packageJsonPath = getPackageJsonPath();
|
|
9542
|
-
if (!existsSync(packageJsonPath)) {
|
|
9543
|
-
cachedVersion = DEFAULT_VERSION;
|
|
9544
|
-
return cachedVersion;
|
|
9545
|
-
}
|
|
9546
|
-
try {
|
|
9547
|
-
const packageJson = JSON.parse(readFileSync2(packageJsonPath, "utf-8"));
|
|
9548
|
-
cachedVersion = typeof packageJson.version === "string" ? packageJson.version : DEFAULT_VERSION;
|
|
9549
|
-
} catch {
|
|
9550
|
-
cachedVersion = DEFAULT_VERSION;
|
|
9551
|
-
}
|
|
9552
|
-
return cachedVersion;
|
|
9553
|
-
}
|
|
9554
|
-
|
|
9555
9514
|
// src/mcp/index.ts
|
|
9556
9515
|
function getProvider(provider) {
|
|
9557
9516
|
if (provider === "openai")
|
|
@@ -9561,330 +9520,312 @@ function getProvider(provider) {
|
|
|
9561
9520
|
throw new Error(`Unknown provider: ${provider}`);
|
|
9562
9521
|
}
|
|
9563
9522
|
function defaultOutputDir() {
|
|
9564
|
-
return
|
|
9565
|
-
}
|
|
9566
|
-
var
|
|
9567
|
-
|
|
9568
|
-
|
|
9569
|
-
|
|
9570
|
-
|
|
9571
|
-
|
|
9572
|
-
|
|
9573
|
-
|
|
9574
|
-
|
|
9575
|
-
|
|
9576
|
-
|
|
9577
|
-
|
|
9578
|
-
|
|
9579
|
-
|
|
9580
|
-
|
|
9581
|
-
|
|
9582
|
-
|
|
9583
|
-
|
|
9584
|
-
|
|
9585
|
-
|
|
9586
|
-
|
|
9587
|
-
|
|
9588
|
-
|
|
9589
|
-
|
|
9523
|
+
return resolve(homedir3(), ".brains", "datasets");
|
|
9524
|
+
}
|
|
9525
|
+
var server = new Server({ name: "brains", version: "0.0.1" }, { capabilities: { tools: {} } });
|
|
9526
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
9527
|
+
tools: [
|
|
9528
|
+
{
|
|
9529
|
+
name: "list_models",
|
|
9530
|
+
description: "List all fine-tuned models tracked in the local DB",
|
|
9531
|
+
inputSchema: {
|
|
9532
|
+
type: "object",
|
|
9533
|
+
properties: {},
|
|
9534
|
+
required: []
|
|
9535
|
+
}
|
|
9536
|
+
},
|
|
9537
|
+
{
|
|
9538
|
+
name: "get_model",
|
|
9539
|
+
description: "Get details for a specific fine-tuned model",
|
|
9540
|
+
inputSchema: {
|
|
9541
|
+
type: "object",
|
|
9542
|
+
properties: {
|
|
9543
|
+
model_id: { type: "string", description: "Model ID" }
|
|
9544
|
+
},
|
|
9545
|
+
required: ["model_id"]
|
|
9546
|
+
}
|
|
9547
|
+
},
|
|
9548
|
+
{
|
|
9549
|
+
name: "start_finetune",
|
|
9550
|
+
description: "Upload a training file and start a fine-tuning job",
|
|
9551
|
+
inputSchema: {
|
|
9552
|
+
type: "object",
|
|
9553
|
+
properties: {
|
|
9554
|
+
provider: {
|
|
9555
|
+
type: "string",
|
|
9556
|
+
enum: ["openai", "thinker-labs"],
|
|
9557
|
+
description: "Provider to use for fine-tuning"
|
|
9590
9558
|
},
|
|
9591
|
-
|
|
9592
|
-
|
|
9593
|
-
|
|
9594
|
-
{
|
|
9595
|
-
name: "start_finetune",
|
|
9596
|
-
description: "Upload a training file and start a fine-tuning job",
|
|
9597
|
-
inputSchema: {
|
|
9598
|
-
type: "object",
|
|
9599
|
-
properties: {
|
|
9600
|
-
provider: {
|
|
9601
|
-
type: "string",
|
|
9602
|
-
enum: ["openai", "thinker-labs"],
|
|
9603
|
-
description: "Provider to use for fine-tuning"
|
|
9604
|
-
},
|
|
9605
|
-
base_model: {
|
|
9606
|
-
type: "string",
|
|
9607
|
-
description: "Base model identifier (e.g. gpt-4o-mini-2024-07-18)"
|
|
9608
|
-
},
|
|
9609
|
-
dataset_path: {
|
|
9610
|
-
type: "string",
|
|
9611
|
-
description: "Absolute path to the JSONL training file"
|
|
9612
|
-
},
|
|
9613
|
-
name: {
|
|
9614
|
-
type: "string",
|
|
9615
|
-
description: "Optional friendly name for this model"
|
|
9616
|
-
}
|
|
9559
|
+
base_model: {
|
|
9560
|
+
type: "string",
|
|
9561
|
+
description: "Base model identifier (e.g. gpt-4o-mini-2024-07-18)"
|
|
9617
9562
|
},
|
|
9618
|
-
|
|
9619
|
-
|
|
9620
|
-
|
|
9621
|
-
{
|
|
9622
|
-
name: "get_finetune_status",
|
|
9623
|
-
description: "Check the status of a fine-tuning job",
|
|
9624
|
-
inputSchema: {
|
|
9625
|
-
type: "object",
|
|
9626
|
-
properties: {
|
|
9627
|
-
job_id: { type: "string", description: "Fine-tune job ID" },
|
|
9628
|
-
provider: {
|
|
9629
|
-
type: "string",
|
|
9630
|
-
enum: ["openai", "thinker-labs"],
|
|
9631
|
-
description: "Provider that owns the job"
|
|
9632
|
-
}
|
|
9563
|
+
dataset_path: {
|
|
9564
|
+
type: "string",
|
|
9565
|
+
description: "Absolute path to the JSONL training file"
|
|
9633
9566
|
},
|
|
9634
|
-
|
|
9635
|
-
|
|
9636
|
-
|
|
9637
|
-
|
|
9638
|
-
|
|
9639
|
-
|
|
9640
|
-
|
|
9641
|
-
|
|
9642
|
-
|
|
9643
|
-
|
|
9644
|
-
|
|
9645
|
-
|
|
9646
|
-
|
|
9647
|
-
|
|
9648
|
-
|
|
9649
|
-
|
|
9650
|
-
|
|
9651
|
-
|
|
9652
|
-
|
|
9653
|
-
|
|
9654
|
-
|
|
9655
|
-
|
|
9567
|
+
name: {
|
|
9568
|
+
type: "string",
|
|
9569
|
+
description: "Optional friendly name for this model"
|
|
9570
|
+
}
|
|
9571
|
+
},
|
|
9572
|
+
required: ["provider", "base_model", "dataset_path"]
|
|
9573
|
+
}
|
|
9574
|
+
},
|
|
9575
|
+
{
|
|
9576
|
+
name: "get_finetune_status",
|
|
9577
|
+
description: "Check the status of a fine-tuning job",
|
|
9578
|
+
inputSchema: {
|
|
9579
|
+
type: "object",
|
|
9580
|
+
properties: {
|
|
9581
|
+
job_id: { type: "string", description: "Fine-tune job ID" },
|
|
9582
|
+
provider: {
|
|
9583
|
+
type: "string",
|
|
9584
|
+
enum: ["openai", "thinker-labs"],
|
|
9585
|
+
description: "Provider that owns the job"
|
|
9586
|
+
}
|
|
9587
|
+
},
|
|
9588
|
+
required: ["job_id", "provider"]
|
|
9589
|
+
}
|
|
9590
|
+
},
|
|
9591
|
+
{
|
|
9592
|
+
name: "gather_training_data",
|
|
9593
|
+
description: "Gather training data from ecosystem sources (todos, mementos, conversations, sessions)",
|
|
9594
|
+
inputSchema: {
|
|
9595
|
+
type: "object",
|
|
9596
|
+
properties: {
|
|
9597
|
+
sources: {
|
|
9598
|
+
type: "array",
|
|
9599
|
+
items: { type: "string" },
|
|
9600
|
+
description: "Sources to gather from: todos, mementos, conversations, sessions"
|
|
9656
9601
|
},
|
|
9657
|
-
|
|
9658
|
-
|
|
9659
|
-
|
|
9660
|
-
{
|
|
9661
|
-
name: "preview_training_data",
|
|
9662
|
-
description: "Preview examples from a JSONL training file",
|
|
9663
|
-
inputSchema: {
|
|
9664
|
-
type: "object",
|
|
9665
|
-
properties: {
|
|
9666
|
-
file_path: {
|
|
9667
|
-
type: "string",
|
|
9668
|
-
description: "Absolute path to the JSONL file to preview"
|
|
9669
|
-
},
|
|
9670
|
-
limit: {
|
|
9671
|
-
type: "number",
|
|
9672
|
-
description: "Max number of examples to return (default: 5)"
|
|
9673
|
-
}
|
|
9602
|
+
limit: {
|
|
9603
|
+
type: "number",
|
|
9604
|
+
description: "Max examples per source (default: unlimited)"
|
|
9674
9605
|
},
|
|
9675
|
-
|
|
9676
|
-
|
|
9606
|
+
output_dir: {
|
|
9607
|
+
type: "string",
|
|
9608
|
+
description: "Directory to write JSONL files (default: ~/.brains/datasets/)"
|
|
9609
|
+
}
|
|
9610
|
+
},
|
|
9611
|
+
required: ["sources"]
|
|
9677
9612
|
}
|
|
9678
|
-
|
|
9679
|
-
|
|
9680
|
-
|
|
9681
|
-
|
|
9682
|
-
|
|
9683
|
-
|
|
9684
|
-
|
|
9685
|
-
|
|
9686
|
-
|
|
9687
|
-
|
|
9688
|
-
|
|
9689
|
-
|
|
9690
|
-
|
|
9691
|
-
|
|
9692
|
-
created_at: fineTunedModels.createdAt
|
|
9693
|
-
}).from(fineTunedModels).orderBy(fineTunedModels.createdAt);
|
|
9694
|
-
return {
|
|
9695
|
-
content: [
|
|
9696
|
-
{
|
|
9697
|
-
type: "text",
|
|
9698
|
-
text: JSON.stringify(models, null, 2)
|
|
9699
|
-
}
|
|
9700
|
-
]
|
|
9701
|
-
};
|
|
9702
|
-
}
|
|
9703
|
-
case "get_model": {
|
|
9704
|
-
const { model_id } = args;
|
|
9705
|
-
const db = getDb();
|
|
9706
|
-
const results = await db.select().from(fineTunedModels).where(eq(fineTunedModels.id, model_id));
|
|
9707
|
-
if (results.length === 0) {
|
|
9708
|
-
return {
|
|
9709
|
-
content: [{ type: "text", text: `Model not found: ${model_id}` }],
|
|
9710
|
-
isError: true
|
|
9711
|
-
};
|
|
9613
|
+
},
|
|
9614
|
+
{
|
|
9615
|
+
name: "preview_training_data",
|
|
9616
|
+
description: "Preview examples from a JSONL training file",
|
|
9617
|
+
inputSchema: {
|
|
9618
|
+
type: "object",
|
|
9619
|
+
properties: {
|
|
9620
|
+
file_path: {
|
|
9621
|
+
type: "string",
|
|
9622
|
+
description: "Absolute path to the JSONL file to preview"
|
|
9623
|
+
},
|
|
9624
|
+
limit: {
|
|
9625
|
+
type: "number",
|
|
9626
|
+
description: "Max number of examples to return (default: 5)"
|
|
9712
9627
|
}
|
|
9628
|
+
},
|
|
9629
|
+
required: ["file_path"]
|
|
9630
|
+
}
|
|
9631
|
+
}
|
|
9632
|
+
]
|
|
9633
|
+
}));
|
|
9634
|
+
server.setRequestHandler(CallToolRequestSchema, async (request2) => {
|
|
9635
|
+
const { name, arguments: args } = request2.params;
|
|
9636
|
+
try {
|
|
9637
|
+
switch (name) {
|
|
9638
|
+
case "list_models": {
|
|
9639
|
+
const db = getDb();
|
|
9640
|
+
const models = await db.select({
|
|
9641
|
+
id: fineTunedModels.id,
|
|
9642
|
+
name: fineTunedModels.name,
|
|
9643
|
+
provider: fineTunedModels.provider,
|
|
9644
|
+
status: fineTunedModels.status,
|
|
9645
|
+
base_model: fineTunedModels.baseModel,
|
|
9646
|
+
created_at: fineTunedModels.createdAt
|
|
9647
|
+
}).from(fineTunedModels).orderBy(fineTunedModels.createdAt);
|
|
9648
|
+
return {
|
|
9649
|
+
content: [
|
|
9650
|
+
{
|
|
9651
|
+
type: "text",
|
|
9652
|
+
text: JSON.stringify(models, null, 2)
|
|
9653
|
+
}
|
|
9654
|
+
]
|
|
9655
|
+
};
|
|
9656
|
+
}
|
|
9657
|
+
case "get_model": {
|
|
9658
|
+
const { model_id } = args;
|
|
9659
|
+
const db = getDb();
|
|
9660
|
+
const results = await db.select().from(fineTunedModels).where(eq(fineTunedModels.id, model_id));
|
|
9661
|
+
if (results.length === 0) {
|
|
9713
9662
|
return {
|
|
9714
|
-
content: [
|
|
9715
|
-
|
|
9716
|
-
]
|
|
9663
|
+
content: [{ type: "text", text: `Model not found: ${model_id}` }],
|
|
9664
|
+
isError: true
|
|
9717
9665
|
};
|
|
9718
9666
|
}
|
|
9719
|
-
|
|
9720
|
-
|
|
9721
|
-
|
|
9722
|
-
|
|
9723
|
-
|
|
9724
|
-
|
|
9725
|
-
|
|
9726
|
-
|
|
9727
|
-
|
|
9728
|
-
|
|
9729
|
-
|
|
9730
|
-
|
|
9731
|
-
|
|
9732
|
-
|
|
9733
|
-
|
|
9734
|
-
],
|
|
9735
|
-
isError: true
|
|
9736
|
-
};
|
|
9737
|
-
}
|
|
9738
|
-
const p = getProvider(provider);
|
|
9739
|
-
const { fileId } = await p.uploadTrainingFile(resolvedPath);
|
|
9740
|
-
const { jobId, status } = await p.createFineTuneJob(fileId, base_model, modelName);
|
|
9741
|
-
const db = getDb();
|
|
9742
|
-
const now = Date.now();
|
|
9743
|
-
const id = `${provider}-${jobId}`;
|
|
9744
|
-
await db.insert(fineTunedModels).values({
|
|
9745
|
-
id,
|
|
9746
|
-
name: modelName ?? `${base_model}-finetune-${now}`,
|
|
9747
|
-
provider,
|
|
9748
|
-
baseModel: base_model,
|
|
9749
|
-
status: "pending",
|
|
9750
|
-
fineTuneJobId: jobId,
|
|
9751
|
-
createdAt: now,
|
|
9752
|
-
updatedAt: now
|
|
9753
|
-
});
|
|
9667
|
+
return {
|
|
9668
|
+
content: [
|
|
9669
|
+
{ type: "text", text: JSON.stringify(results[0], null, 2) }
|
|
9670
|
+
]
|
|
9671
|
+
};
|
|
9672
|
+
}
|
|
9673
|
+
case "start_finetune": {
|
|
9674
|
+
const {
|
|
9675
|
+
provider,
|
|
9676
|
+
base_model,
|
|
9677
|
+
dataset_path,
|
|
9678
|
+
name: modelName
|
|
9679
|
+
} = args;
|
|
9680
|
+
const resolvedPath = resolve(dataset_path);
|
|
9681
|
+
if (!existsSync(resolvedPath)) {
|
|
9754
9682
|
return {
|
|
9755
9683
|
content: [
|
|
9756
9684
|
{
|
|
9757
9685
|
type: "text",
|
|
9758
|
-
text:
|
|
9686
|
+
text: `Dataset file not found: ${resolvedPath}`
|
|
9759
9687
|
}
|
|
9760
|
-
]
|
|
9688
|
+
],
|
|
9689
|
+
isError: true
|
|
9761
9690
|
};
|
|
9762
9691
|
}
|
|
9763
|
-
|
|
9764
|
-
|
|
9765
|
-
|
|
9766
|
-
|
|
9767
|
-
|
|
9768
|
-
|
|
9769
|
-
|
|
9770
|
-
|
|
9771
|
-
|
|
9772
|
-
|
|
9773
|
-
|
|
9774
|
-
|
|
9775
|
-
|
|
9776
|
-
|
|
9777
|
-
|
|
9778
|
-
|
|
9779
|
-
|
|
9780
|
-
|
|
9781
|
-
|
|
9782
|
-
|
|
9783
|
-
status:
|
|
9784
|
-
|
|
9785
|
-
|
|
9786
|
-
|
|
9787
|
-
|
|
9788
|
-
|
|
9789
|
-
|
|
9790
|
-
|
|
9791
|
-
|
|
9792
|
-
|
|
9793
|
-
|
|
9794
|
-
|
|
9795
|
-
|
|
9796
|
-
|
|
9797
|
-
|
|
9798
|
-
|
|
9799
|
-
|
|
9692
|
+
const p = getProvider(provider);
|
|
9693
|
+
const { fileId } = await p.uploadTrainingFile(resolvedPath);
|
|
9694
|
+
const { jobId, status } = await p.createFineTuneJob(fileId, base_model, modelName);
|
|
9695
|
+
const db = getDb();
|
|
9696
|
+
const now = Date.now();
|
|
9697
|
+
const id = `${provider}-${jobId}`;
|
|
9698
|
+
await db.insert(fineTunedModels).values({
|
|
9699
|
+
id,
|
|
9700
|
+
name: modelName ?? `${base_model}-finetune-${now}`,
|
|
9701
|
+
provider,
|
|
9702
|
+
baseModel: base_model,
|
|
9703
|
+
status: "pending",
|
|
9704
|
+
fineTuneJobId: jobId,
|
|
9705
|
+
createdAt: now,
|
|
9706
|
+
updatedAt: now
|
|
9707
|
+
});
|
|
9708
|
+
return {
|
|
9709
|
+
content: [
|
|
9710
|
+
{
|
|
9711
|
+
type: "text",
|
|
9712
|
+
text: JSON.stringify({ job_id: jobId, status, model_db_id: id }, null, 2)
|
|
9713
|
+
}
|
|
9714
|
+
]
|
|
9715
|
+
};
|
|
9716
|
+
}
|
|
9717
|
+
case "get_finetune_status": {
|
|
9718
|
+
const { job_id, provider } = args;
|
|
9719
|
+
const p = getProvider(provider);
|
|
9720
|
+
const result = await p.getFineTuneStatus(job_id);
|
|
9721
|
+
const db = getDb();
|
|
9722
|
+
const dbId = `${provider}-${job_id}`;
|
|
9723
|
+
const existing = await db.select().from(fineTunedModels).where(eq(fineTunedModels.id, dbId));
|
|
9724
|
+
if (existing.length > 0) {
|
|
9725
|
+
const mappedStatus = (() => {
|
|
9726
|
+
if (result.status === "succeeded")
|
|
9727
|
+
return "succeeded";
|
|
9728
|
+
if (result.status === "failed")
|
|
9729
|
+
return "failed";
|
|
9730
|
+
if (result.status === "cancelled")
|
|
9731
|
+
return "cancelled";
|
|
9732
|
+
if (result.status === "running")
|
|
9733
|
+
return "running";
|
|
9734
|
+
return "pending";
|
|
9735
|
+
})();
|
|
9736
|
+
await db.update(fineTunedModels).set({
|
|
9737
|
+
status: mappedStatus,
|
|
9738
|
+
updatedAt: Date.now()
|
|
9739
|
+
}).where(eq(fineTunedModels.id, dbId));
|
|
9800
9740
|
}
|
|
9801
|
-
|
|
9802
|
-
|
|
9803
|
-
|
|
9804
|
-
|
|
9805
|
-
|
|
9806
|
-
|
|
9807
|
-
|
|
9808
|
-
|
|
9809
|
-
|
|
9810
|
-
|
|
9811
|
-
const datasets = [];
|
|
9812
|
-
let totalExamples = 0;
|
|
9813
|
-
for (const source of sources) {
|
|
9814
|
-
let examples = [];
|
|
9815
|
-
if (source === "todos") {
|
|
9816
|
-
const result = await gatherFromTodos({ limit: limit2 });
|
|
9817
|
-
examples = result.examples;
|
|
9818
|
-
} else {
|
|
9819
|
-
examples = [];
|
|
9741
|
+
return {
|
|
9742
|
+
content: [
|
|
9743
|
+
{
|
|
9744
|
+
type: "text",
|
|
9745
|
+
text: JSON.stringify({
|
|
9746
|
+
job_id: result.jobId,
|
|
9747
|
+
status: result.status,
|
|
9748
|
+
model_id: result.fineTunedModel,
|
|
9749
|
+
error: result.error
|
|
9750
|
+
}, null, 2)
|
|
9820
9751
|
}
|
|
9821
|
-
|
|
9822
|
-
|
|
9823
|
-
|
|
9824
|
-
|
|
9825
|
-
|
|
9826
|
-
|
|
9752
|
+
]
|
|
9753
|
+
};
|
|
9754
|
+
}
|
|
9755
|
+
case "gather_training_data": {
|
|
9756
|
+
const {
|
|
9757
|
+
sources,
|
|
9758
|
+
limit: limit2,
|
|
9759
|
+
output_dir
|
|
9760
|
+
} = args;
|
|
9761
|
+
const { mkdirSync: mkdirSync2, writeFileSync } = await import("fs");
|
|
9762
|
+
const { join: join3 } = await import("path");
|
|
9763
|
+
const outDir = output_dir ?? defaultOutputDir();
|
|
9764
|
+
mkdirSync2(outDir, { recursive: true });
|
|
9765
|
+
const datasets = [];
|
|
9766
|
+
let totalExamples = 0;
|
|
9767
|
+
for (const source of sources) {
|
|
9768
|
+
let examples = [];
|
|
9769
|
+
if (source === "todos") {
|
|
9770
|
+
const result = await gatherFromTodos({ limit: limit2 });
|
|
9771
|
+
examples = result.examples;
|
|
9772
|
+
} else {
|
|
9773
|
+
examples = [];
|
|
9827
9774
|
}
|
|
9828
|
-
|
|
9829
|
-
|
|
9830
|
-
|
|
9831
|
-
|
|
9832
|
-
|
|
9833
|
-
|
|
9834
|
-
]
|
|
9835
|
-
};
|
|
9775
|
+
const filePath = join3(outDir, `${source}-${Date.now()}.jsonl`);
|
|
9776
|
+
const jsonl = examples.map((ex) => JSON.stringify(ex)).join(`
|
|
9777
|
+
`);
|
|
9778
|
+
writeFileSync(filePath, jsonl, "utf-8");
|
|
9779
|
+
datasets.push({ source, count: examples.length, file_path: filePath });
|
|
9780
|
+
totalExamples += examples.length;
|
|
9836
9781
|
}
|
|
9837
|
-
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
|
|
9841
|
-
|
|
9842
|
-
|
|
9843
|
-
|
|
9844
|
-
|
|
9845
|
-
|
|
9846
|
-
|
|
9847
|
-
|
|
9848
|
-
|
|
9849
|
-
|
|
9850
|
-
`).map((l) => l.trim()).filter(Boolean);
|
|
9851
|
-
const total = lines.length;
|
|
9852
|
-
const examples = lines.slice(0, limit2).map((line) => JSON.parse(line));
|
|
9782
|
+
return {
|
|
9783
|
+
content: [
|
|
9784
|
+
{
|
|
9785
|
+
type: "text",
|
|
9786
|
+
text: JSON.stringify({ datasets, total_examples: totalExamples }, null, 2)
|
|
9787
|
+
}
|
|
9788
|
+
]
|
|
9789
|
+
};
|
|
9790
|
+
}
|
|
9791
|
+
case "preview_training_data": {
|
|
9792
|
+
const { file_path, limit: limit2 = 5 } = args;
|
|
9793
|
+
const resolvedPath = resolve(file_path);
|
|
9794
|
+
if (!existsSync(resolvedPath)) {
|
|
9853
9795
|
return {
|
|
9854
9796
|
content: [
|
|
9855
|
-
{
|
|
9856
|
-
|
|
9857
|
-
text: JSON.stringify({ examples, total }, null, 2)
|
|
9858
|
-
}
|
|
9859
|
-
]
|
|
9860
|
-
};
|
|
9861
|
-
}
|
|
9862
|
-
default:
|
|
9863
|
-
return {
|
|
9864
|
-
content: [{ type: "text", text: `Unknown tool: ${name}` }],
|
|
9797
|
+
{ type: "text", text: `File not found: ${resolvedPath}` }
|
|
9798
|
+
],
|
|
9865
9799
|
isError: true
|
|
9866
9800
|
};
|
|
9801
|
+
}
|
|
9802
|
+
const content = readFileSync2(resolvedPath, "utf-8");
|
|
9803
|
+
const lines = content.split(`
|
|
9804
|
+
`).map((l) => l.trim()).filter(Boolean);
|
|
9805
|
+
const total = lines.length;
|
|
9806
|
+
const examples = lines.slice(0, limit2).map((line) => JSON.parse(line));
|
|
9807
|
+
return {
|
|
9808
|
+
content: [
|
|
9809
|
+
{
|
|
9810
|
+
type: "text",
|
|
9811
|
+
text: JSON.stringify({ examples, total }, null, 2)
|
|
9812
|
+
}
|
|
9813
|
+
]
|
|
9814
|
+
};
|
|
9867
9815
|
}
|
|
9868
|
-
|
|
9869
|
-
|
|
9870
|
-
|
|
9871
|
-
|
|
9872
|
-
|
|
9873
|
-
};
|
|
9816
|
+
default:
|
|
9817
|
+
return {
|
|
9818
|
+
content: [{ type: "text", text: `Unknown tool: ${name}` }],
|
|
9819
|
+
isError: true
|
|
9820
|
+
};
|
|
9874
9821
|
}
|
|
9875
|
-
})
|
|
9876
|
-
|
|
9877
|
-
|
|
9878
|
-
|
|
9879
|
-
|
|
9880
|
-
|
|
9881
|
-
|
|
9882
|
-
}
|
|
9883
|
-
|
|
9884
|
-
|
|
9885
|
-
}
|
|
9886
|
-
export {
|
|
9887
|
-
startMcpServer,
|
|
9888
|
-
createMcpServer,
|
|
9889
|
-
MCP_SERVER_INFO
|
|
9890
|
-
};
|
|
9822
|
+
} catch (err) {
|
|
9823
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
9824
|
+
return {
|
|
9825
|
+
content: [{ type: "text", text: `Error: ${message}` }],
|
|
9826
|
+
isError: true
|
|
9827
|
+
};
|
|
9828
|
+
}
|
|
9829
|
+
});
|
|
9830
|
+
var transport = new StdioServerTransport;
|
|
9831
|
+
await server.connect(transport);
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
declare const port: number;
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":";AAIA,QAAA,MAAM,IAAI,QAAsC,CAAC"}
|
package/dist/server/index.js
CHANGED
|
@@ -1,54 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
1
2
|
// @bun
|
|
2
|
-
// src/lib/package-metadata.ts
|
|
3
|
-
import { existsSync, readFileSync } from "fs";
|
|
4
|
-
import { dirname, resolve } from "path";
|
|
5
|
-
import { fileURLToPath } from "url";
|
|
6
|
-
var DEFAULT_VERSION = "0.0.0";
|
|
7
|
-
var cachedVersion;
|
|
8
|
-
function getPackageJsonPath() {
|
|
9
|
-
return resolve(dirname(fileURLToPath(import.meta.url)), "../../package.json");
|
|
10
|
-
}
|
|
11
|
-
function getPackageVersion() {
|
|
12
|
-
if (cachedVersion) {
|
|
13
|
-
return cachedVersion;
|
|
14
|
-
}
|
|
15
|
-
const packageJsonPath = getPackageJsonPath();
|
|
16
|
-
if (!existsSync(packageJsonPath)) {
|
|
17
|
-
cachedVersion = DEFAULT_VERSION;
|
|
18
|
-
return cachedVersion;
|
|
19
|
-
}
|
|
20
|
-
try {
|
|
21
|
-
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
22
|
-
cachedVersion = typeof packageJson.version === "string" ? packageJson.version : DEFAULT_VERSION;
|
|
23
|
-
} catch {
|
|
24
|
-
cachedVersion = DEFAULT_VERSION;
|
|
25
|
-
}
|
|
26
|
-
return cachedVersion;
|
|
27
|
-
}
|
|
28
3
|
|
|
29
4
|
// src/server/index.ts
|
|
30
5
|
var port = Number(process.env["PORT"] ?? 7020);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
6
|
+
console.log(`brains server starting on port ${port}`);
|
|
7
|
+
Bun.serve({
|
|
8
|
+
port,
|
|
9
|
+
fetch(req) {
|
|
34
10
|
const url = new URL(req.url);
|
|
35
11
|
if (url.pathname === "/health") {
|
|
36
|
-
return Response.json({ status: "ok", service, version });
|
|
12
|
+
return Response.json({ status: "ok", service: "brains", version: "0.0.1" });
|
|
37
13
|
}
|
|
38
14
|
return Response.json({ error: "not found" }, { status: 404 });
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
function startServer(serverPort = port) {
|
|
42
|
-
console.log(`${service} server starting on port ${serverPort}`);
|
|
43
|
-
return Bun.serve({
|
|
44
|
-
port: serverPort,
|
|
45
|
-
fetch: createServerFetchHandler()
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
if (import.meta.main) {
|
|
49
|
-
startServer();
|
|
50
|
-
}
|
|
51
|
-
export {
|
|
52
|
-
startServer,
|
|
53
|
-
createServerFetchHandler
|
|
54
|
-
};
|
|
15
|
+
}
|
|
16
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hasna/brains",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Fine-tuned model tracker and trainer — wraps OpenAI + Thinker Labs, gathers training data from todos/mementos/conversations/sessions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package-metadata.d.ts","sourceRoot":"","sources":["../../src/lib/package-metadata.ts"],"names":[],"mappings":"AAYA,wBAAgB,iBAAiB,IAAI,MAAM,CAmB1C"}
|