@firfi/huly-mcp 0.1.57 → 0.1.58
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/index.cjs +184 -25
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -86799,7 +86799,7 @@ var require_utils13 = __commonJS({
|
|
|
86799
86799
|
var import_core44 = require_lib4();
|
|
86800
86800
|
var import_platform2 = require_lib21();
|
|
86801
86801
|
var import__ = __toESM2(require_lib28());
|
|
86802
|
-
var
|
|
86802
|
+
var import_types12 = require_types9();
|
|
86803
86803
|
var import_cache2 = __toESM2(require_cache4());
|
|
86804
86804
|
var currentEmployee;
|
|
86805
86805
|
var currentEmployeeSpace;
|
|
@@ -86828,20 +86828,20 @@ var require_utils13 = __commonJS({
|
|
|
86828
86828
|
}
|
|
86829
86829
|
__name(setCurrentEmployeeSpace, "setCurrentEmployeeSpace");
|
|
86830
86830
|
function getAvatarColorForId(id) {
|
|
86831
|
-
if (id == null) return
|
|
86831
|
+
if (id == null) return import_types12.AVATAR_COLORS[0].color;
|
|
86832
86832
|
let hash4 = 0;
|
|
86833
86833
|
for (let i = 0; i < id.length; i++) {
|
|
86834
86834
|
hash4 += id.charCodeAt(i);
|
|
86835
86835
|
}
|
|
86836
|
-
return
|
|
86836
|
+
return import_types12.AVATAR_COLORS[hash4 % import_types12.AVATAR_COLORS.length].color;
|
|
86837
86837
|
}
|
|
86838
86838
|
__name(getAvatarColorForId, "getAvatarColorForId");
|
|
86839
86839
|
function getAvatarColors() {
|
|
86840
|
-
return
|
|
86840
|
+
return import_types12.AVATAR_COLORS;
|
|
86841
86841
|
}
|
|
86842
86842
|
__name(getAvatarColors, "getAvatarColors");
|
|
86843
86843
|
function getAvatarColorName(color) {
|
|
86844
|
-
return
|
|
86844
|
+
return import_types12.AVATAR_COLORS.find((col) => col.color === color)?.name ?? import_types12.AVATAR_COLORS[0].name;
|
|
86845
86845
|
}
|
|
86846
86846
|
__name(getAvatarColorName, "getAvatarColorName");
|
|
86847
86847
|
function getAvatarProviderId(kind) {
|
|
@@ -156099,10 +156099,10 @@ var connectAccountClient = async (config3) => {
|
|
|
156099
156099
|
};
|
|
156100
156100
|
var connectAccountClientWithRetry = (config3) => connectWithRetry(() => connectAccountClient(config3), "Connection failed");
|
|
156101
156101
|
|
|
156102
|
-
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
156102
|
+
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/express.js
|
|
156103
156103
|
var import_express = __toESM(require_express2(), 1);
|
|
156104
156104
|
|
|
156105
|
-
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
156105
|
+
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/middleware/hostHeaderValidation.js
|
|
156106
156106
|
function hostHeaderValidation(allowedHostnames) {
|
|
156107
156107
|
return (req, res, next4) => {
|
|
156108
156108
|
const hostHeader = req.headers.host;
|
|
@@ -156149,7 +156149,7 @@ function localhostHostValidation() {
|
|
|
156149
156149
|
return hostHeaderValidation(["localhost", "127.0.0.1", "[::1]"]);
|
|
156150
156150
|
}
|
|
156151
156151
|
|
|
156152
|
-
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
156152
|
+
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/express.js
|
|
156153
156153
|
function createMcpExpressApp(options = {}) {
|
|
156154
156154
|
const { host = "127.0.0.1", allowedHosts } = options;
|
|
156155
156155
|
const app = (0, import_express.default)();
|
|
@@ -163498,7 +163498,7 @@ var z = {
|
|
|
163498
163498
|
// node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/external.js
|
|
163499
163499
|
config2(en_default());
|
|
163500
163500
|
|
|
163501
|
-
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
163501
|
+
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
|
|
163502
163502
|
var LATEST_PROTOCOL_VERSION = "2025-11-25";
|
|
163503
163503
|
var DEFAULT_NEGOTIATED_PROTOCOL_VERSION = "2025-03-26";
|
|
163504
163504
|
var SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-06-18", "2025-03-26", "2024-11-05", "2024-10-07"];
|
|
@@ -165006,7 +165006,7 @@ var UrlElicitationRequiredError = class extends McpError {
|
|
|
165006
165006
|
}
|
|
165007
165007
|
};
|
|
165008
165008
|
|
|
165009
|
-
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
165009
|
+
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js
|
|
165010
165010
|
var WebStandardStreamableHTTPServerTransport = class {
|
|
165011
165011
|
constructor(options = {}) {
|
|
165012
165012
|
this._started = false;
|
|
@@ -165139,6 +165139,7 @@ data:
|
|
|
165139
165139
|
async handleGetRequest(req) {
|
|
165140
165140
|
const acceptHeader = req.headers.get("accept");
|
|
165141
165141
|
if (!acceptHeader?.includes("text/event-stream")) {
|
|
165142
|
+
this.onerror?.(new Error("Not Acceptable: Client must accept text/event-stream"));
|
|
165142
165143
|
return this.createJsonErrorResponse(406, -32e3, "Not Acceptable: Client must accept text/event-stream");
|
|
165143
165144
|
}
|
|
165144
165145
|
const sessionError = this.validateSession(req);
|
|
@@ -165156,6 +165157,7 @@ data:
|
|
|
165156
165157
|
}
|
|
165157
165158
|
}
|
|
165158
165159
|
if (this._streamMapping.get(this._standaloneSseStreamId) !== void 0) {
|
|
165160
|
+
this.onerror?.(new Error("Conflict: Only one SSE stream is allowed per session"));
|
|
165159
165161
|
return this.createJsonErrorResponse(409, -32e3, "Conflict: Only one SSE stream is allowed per session");
|
|
165160
165162
|
}
|
|
165161
165163
|
const encoder2 = new TextEncoder();
|
|
@@ -165195,6 +165197,7 @@ data:
|
|
|
165195
165197
|
*/
|
|
165196
165198
|
async replayEvents(lastEventId) {
|
|
165197
165199
|
if (!this._eventStore) {
|
|
165200
|
+
this.onerror?.(new Error("Event store not configured"));
|
|
165198
165201
|
return this.createJsonErrorResponse(400, -32e3, "Event store not configured");
|
|
165199
165202
|
}
|
|
165200
165203
|
try {
|
|
@@ -165202,9 +165205,11 @@ data:
|
|
|
165202
165205
|
if (this._eventStore.getStreamIdForEventId) {
|
|
165203
165206
|
streamId = await this._eventStore.getStreamIdForEventId(lastEventId);
|
|
165204
165207
|
if (!streamId) {
|
|
165208
|
+
this.onerror?.(new Error("Invalid event ID format"));
|
|
165205
165209
|
return this.createJsonErrorResponse(400, -32e3, "Invalid event ID format");
|
|
165206
165210
|
}
|
|
165207
165211
|
if (this._streamMapping.get(streamId) !== void 0) {
|
|
165212
|
+
this.onerror?.(new Error("Conflict: Stream already has an active connection"));
|
|
165208
165213
|
return this.createJsonErrorResponse(409, -32e3, "Conflict: Stream already has an active connection");
|
|
165209
165214
|
}
|
|
165210
165215
|
}
|
|
@@ -165270,7 +165275,8 @@ data:
|
|
|
165270
165275
|
`;
|
|
165271
165276
|
controller.enqueue(encoder2.encode(eventData));
|
|
165272
165277
|
return true;
|
|
165273
|
-
} catch {
|
|
165278
|
+
} catch (error2) {
|
|
165279
|
+
this.onerror?.(error2);
|
|
165274
165280
|
return false;
|
|
165275
165281
|
}
|
|
165276
165282
|
}
|
|
@@ -165278,6 +165284,7 @@ data:
|
|
|
165278
165284
|
* Handles unsupported requests (PUT, PATCH, etc.)
|
|
165279
165285
|
*/
|
|
165280
165286
|
handleUnsupportedRequest() {
|
|
165287
|
+
this.onerror?.(new Error("Method not allowed."));
|
|
165281
165288
|
return new Response(JSON.stringify({
|
|
165282
165289
|
jsonrpc: "2.0",
|
|
165283
165290
|
error: {
|
|
@@ -165300,14 +165307,17 @@ data:
|
|
|
165300
165307
|
try {
|
|
165301
165308
|
const acceptHeader = req.headers.get("accept");
|
|
165302
165309
|
if (!acceptHeader?.includes("application/json") || !acceptHeader.includes("text/event-stream")) {
|
|
165310
|
+
this.onerror?.(new Error("Not Acceptable: Client must accept both application/json and text/event-stream"));
|
|
165303
165311
|
return this.createJsonErrorResponse(406, -32e3, "Not Acceptable: Client must accept both application/json and text/event-stream");
|
|
165304
165312
|
}
|
|
165305
165313
|
const ct = req.headers.get("content-type");
|
|
165306
165314
|
if (!ct || !ct.includes("application/json")) {
|
|
165315
|
+
this.onerror?.(new Error("Unsupported Media Type: Content-Type must be application/json"));
|
|
165307
165316
|
return this.createJsonErrorResponse(415, -32e3, "Unsupported Media Type: Content-Type must be application/json");
|
|
165308
165317
|
}
|
|
165309
165318
|
const requestInfo = {
|
|
165310
|
-
headers: Object.fromEntries(req.headers.entries())
|
|
165319
|
+
headers: Object.fromEntries(req.headers.entries()),
|
|
165320
|
+
url: new URL(req.url)
|
|
165311
165321
|
};
|
|
165312
165322
|
let rawMessage;
|
|
165313
165323
|
if (options?.parsedBody !== void 0) {
|
|
@@ -165316,6 +165326,7 @@ data:
|
|
|
165316
165326
|
try {
|
|
165317
165327
|
rawMessage = await req.json();
|
|
165318
165328
|
} catch {
|
|
165329
|
+
this.onerror?.(new Error("Parse error: Invalid JSON"));
|
|
165319
165330
|
return this.createJsonErrorResponse(400, -32700, "Parse error: Invalid JSON");
|
|
165320
165331
|
}
|
|
165321
165332
|
}
|
|
@@ -165327,14 +165338,17 @@ data:
|
|
|
165327
165338
|
messages2 = [JSONRPCMessageSchema.parse(rawMessage)];
|
|
165328
165339
|
}
|
|
165329
165340
|
} catch {
|
|
165341
|
+
this.onerror?.(new Error("Parse error: Invalid JSON-RPC message"));
|
|
165330
165342
|
return this.createJsonErrorResponse(400, -32700, "Parse error: Invalid JSON-RPC message");
|
|
165331
165343
|
}
|
|
165332
165344
|
const isInitializationRequest = messages2.some(isInitializeRequest);
|
|
165333
165345
|
if (isInitializationRequest) {
|
|
165334
165346
|
if (this._initialized && this.sessionId !== void 0) {
|
|
165347
|
+
this.onerror?.(new Error("Invalid Request: Server already initialized"));
|
|
165335
165348
|
return this.createJsonErrorResponse(400, -32600, "Invalid Request: Server already initialized");
|
|
165336
165349
|
}
|
|
165337
165350
|
if (messages2.length > 1) {
|
|
165351
|
+
this.onerror?.(new Error("Invalid Request: Only one initialization request is allowed"));
|
|
165338
165352
|
return this.createJsonErrorResponse(400, -32600, "Invalid Request: Only one initialization request is allowed");
|
|
165339
165353
|
}
|
|
165340
165354
|
this.sessionId = this.sessionIdGenerator?.();
|
|
@@ -165460,13 +165474,16 @@ data:
|
|
|
165460
165474
|
return void 0;
|
|
165461
165475
|
}
|
|
165462
165476
|
if (!this._initialized) {
|
|
165477
|
+
this.onerror?.(new Error("Bad Request: Server not initialized"));
|
|
165463
165478
|
return this.createJsonErrorResponse(400, -32e3, "Bad Request: Server not initialized");
|
|
165464
165479
|
}
|
|
165465
165480
|
const sessionId = req.headers.get("mcp-session-id");
|
|
165466
165481
|
if (!sessionId) {
|
|
165482
|
+
this.onerror?.(new Error("Bad Request: Mcp-Session-Id header is required"));
|
|
165467
165483
|
return this.createJsonErrorResponse(400, -32e3, "Bad Request: Mcp-Session-Id header is required");
|
|
165468
165484
|
}
|
|
165469
165485
|
if (sessionId !== this.sessionId) {
|
|
165486
|
+
this.onerror?.(new Error("Session not found"));
|
|
165470
165487
|
return this.createJsonErrorResponse(404, -32001, "Session not found");
|
|
165471
165488
|
}
|
|
165472
165489
|
return void 0;
|
|
@@ -165487,6 +165504,7 @@ data:
|
|
|
165487
165504
|
validateProtocolVersion(req) {
|
|
165488
165505
|
const protocolVersion = req.headers.get("mcp-protocol-version");
|
|
165489
165506
|
if (protocolVersion !== null && !SUPPORTED_PROTOCOL_VERSIONS.includes(protocolVersion)) {
|
|
165507
|
+
this.onerror?.(new Error(`Bad Request: Unsupported protocol version: ${protocolVersion} (supported versions: ${SUPPORTED_PROTOCOL_VERSIONS.join(", ")})`));
|
|
165490
165508
|
return this.createJsonErrorResponse(400, -32e3, `Bad Request: Unsupported protocol version: ${protocolVersion} (supported versions: ${SUPPORTED_PROTOCOL_VERSIONS.join(", ")})`);
|
|
165491
165509
|
}
|
|
165492
165510
|
return void 0;
|
|
@@ -165590,7 +165608,7 @@ data:
|
|
|
165590
165608
|
}
|
|
165591
165609
|
};
|
|
165592
165610
|
|
|
165593
|
-
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
165611
|
+
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/streamableHttp.js
|
|
165594
165612
|
var StreamableHTTPServerTransport = class {
|
|
165595
165613
|
constructor(options = {}) {
|
|
165596
165614
|
this._requestContext = /* @__PURE__ */ new WeakMap();
|
|
@@ -169710,7 +169728,7 @@ var nullableType = ZodNullable2.create;
|
|
|
169710
169728
|
var preprocessType = ZodEffects.createWithPreprocess;
|
|
169711
169729
|
var pipelineType = ZodPipeline.create;
|
|
169712
169730
|
|
|
169713
|
-
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
169731
|
+
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
|
|
169714
169732
|
function isZ4Schema(s) {
|
|
169715
169733
|
const schema = s;
|
|
169716
169734
|
return !!schema._zod;
|
|
@@ -169773,7 +169791,7 @@ function getLiteralValue(schema) {
|
|
|
169773
169791
|
return void 0;
|
|
169774
169792
|
}
|
|
169775
169793
|
|
|
169776
|
-
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
169794
|
+
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
|
|
169777
169795
|
function isTerminal(status) {
|
|
169778
169796
|
return status === "completed" || status === "failed" || status === "cancelled";
|
|
169779
169797
|
}
|
|
@@ -169781,7 +169799,7 @@ function isTerminal(status) {
|
|
|
169781
169799
|
// node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@4.3.6/node_modules/zod-to-json-schema/dist/esm/parsers/string.js
|
|
169782
169800
|
var ALPHA_NUMERIC = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
169783
169801
|
|
|
169784
|
-
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
169802
|
+
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
|
|
169785
169803
|
function getMethodLiteral(schema) {
|
|
169786
169804
|
const shape = getObjectShape(schema);
|
|
169787
169805
|
const methodSchema = shape?.method;
|
|
@@ -169802,7 +169820,7 @@ function parseWithCompat(schema, data) {
|
|
|
169802
169820
|
return result.data;
|
|
169803
169821
|
}
|
|
169804
169822
|
|
|
169805
|
-
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
169823
|
+
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
|
|
169806
169824
|
var DEFAULT_REQUEST_TIMEOUT_MSEC = 6e4;
|
|
169807
169825
|
var Protocol = class {
|
|
169808
169826
|
constructor(_options) {
|
|
@@ -170750,7 +170768,7 @@ function mergeCapabilities(base, additional) {
|
|
|
170750
170768
|
return result;
|
|
170751
170769
|
}
|
|
170752
170770
|
|
|
170753
|
-
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
170771
|
+
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
|
|
170754
170772
|
var import_ajv = __toESM(require_ajv(), 1);
|
|
170755
170773
|
var import_ajv_formats = __toESM(require_dist57(), 1);
|
|
170756
170774
|
function createDefaultAjvInstance() {
|
|
@@ -170818,7 +170836,7 @@ var AjvJsonSchemaValidator = class {
|
|
|
170818
170836
|
}
|
|
170819
170837
|
};
|
|
170820
170838
|
|
|
170821
|
-
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
170839
|
+
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
|
|
170822
170840
|
var ExperimentalServerTasks = class {
|
|
170823
170841
|
constructor(_server) {
|
|
170824
170842
|
this._server = _server;
|
|
@@ -170840,6 +170858,147 @@ var ExperimentalServerTasks = class {
|
|
|
170840
170858
|
requestStream(request2, resultSchema, options) {
|
|
170841
170859
|
return this._server.requestStream(request2, resultSchema, options);
|
|
170842
170860
|
}
|
|
170861
|
+
/**
|
|
170862
|
+
* Sends a sampling request and returns an AsyncGenerator that yields response messages.
|
|
170863
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
170864
|
+
*
|
|
170865
|
+
* For task-augmented requests, yields 'taskCreated' and 'taskStatus' messages
|
|
170866
|
+
* before the final result.
|
|
170867
|
+
*
|
|
170868
|
+
* @example
|
|
170869
|
+
* ```typescript
|
|
170870
|
+
* const stream = server.experimental.tasks.createMessageStream({
|
|
170871
|
+
* messages: [{ role: 'user', content: { type: 'text', text: 'Hello' } }],
|
|
170872
|
+
* maxTokens: 100
|
|
170873
|
+
* }, {
|
|
170874
|
+
* onprogress: (progress) => {
|
|
170875
|
+
* // Handle streaming tokens via progress notifications
|
|
170876
|
+
* console.log('Progress:', progress.message);
|
|
170877
|
+
* }
|
|
170878
|
+
* });
|
|
170879
|
+
*
|
|
170880
|
+
* for await (const message of stream) {
|
|
170881
|
+
* switch (message.type) {
|
|
170882
|
+
* case 'taskCreated':
|
|
170883
|
+
* console.log('Task created:', message.task.taskId);
|
|
170884
|
+
* break;
|
|
170885
|
+
* case 'taskStatus':
|
|
170886
|
+
* console.log('Task status:', message.task.status);
|
|
170887
|
+
* break;
|
|
170888
|
+
* case 'result':
|
|
170889
|
+
* console.log('Final result:', message.result);
|
|
170890
|
+
* break;
|
|
170891
|
+
* case 'error':
|
|
170892
|
+
* console.error('Error:', message.error);
|
|
170893
|
+
* break;
|
|
170894
|
+
* }
|
|
170895
|
+
* }
|
|
170896
|
+
* ```
|
|
170897
|
+
*
|
|
170898
|
+
* @param params - The sampling request parameters
|
|
170899
|
+
* @param options - Optional request options (timeout, signal, task creation params, onprogress, etc.)
|
|
170900
|
+
* @returns AsyncGenerator that yields ResponseMessage objects
|
|
170901
|
+
*
|
|
170902
|
+
* @experimental
|
|
170903
|
+
*/
|
|
170904
|
+
createMessageStream(params, options) {
|
|
170905
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
170906
|
+
if ((params.tools || params.toolChoice) && !clientCapabilities?.sampling?.tools) {
|
|
170907
|
+
throw new Error("Client does not support sampling tools capability.");
|
|
170908
|
+
}
|
|
170909
|
+
if (params.messages.length > 0) {
|
|
170910
|
+
const lastMessage = params.messages[params.messages.length - 1];
|
|
170911
|
+
const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [lastMessage.content];
|
|
170912
|
+
const hasToolResults = lastContent.some((c) => c.type === "tool_result");
|
|
170913
|
+
const previousMessage = params.messages.length > 1 ? params.messages[params.messages.length - 2] : void 0;
|
|
170914
|
+
const previousContent = previousMessage ? Array.isArray(previousMessage.content) ? previousMessage.content : [previousMessage.content] : [];
|
|
170915
|
+
const hasPreviousToolUse = previousContent.some((c) => c.type === "tool_use");
|
|
170916
|
+
if (hasToolResults) {
|
|
170917
|
+
if (lastContent.some((c) => c.type !== "tool_result")) {
|
|
170918
|
+
throw new Error("The last message must contain only tool_result content if any is present");
|
|
170919
|
+
}
|
|
170920
|
+
if (!hasPreviousToolUse) {
|
|
170921
|
+
throw new Error("tool_result blocks are not matching any tool_use from the previous message");
|
|
170922
|
+
}
|
|
170923
|
+
}
|
|
170924
|
+
if (hasPreviousToolUse) {
|
|
170925
|
+
const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
|
|
170926
|
+
const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
|
|
170927
|
+
if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id) => toolResultIds.has(id))) {
|
|
170928
|
+
throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match");
|
|
170929
|
+
}
|
|
170930
|
+
}
|
|
170931
|
+
}
|
|
170932
|
+
return this.requestStream({
|
|
170933
|
+
method: "sampling/createMessage",
|
|
170934
|
+
params
|
|
170935
|
+
}, CreateMessageResultSchema, options);
|
|
170936
|
+
}
|
|
170937
|
+
/**
|
|
170938
|
+
* Sends an elicitation request and returns an AsyncGenerator that yields response messages.
|
|
170939
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
170940
|
+
*
|
|
170941
|
+
* For task-augmented requests (especially URL-based elicitation), yields 'taskCreated'
|
|
170942
|
+
* and 'taskStatus' messages before the final result.
|
|
170943
|
+
*
|
|
170944
|
+
* @example
|
|
170945
|
+
* ```typescript
|
|
170946
|
+
* const stream = server.experimental.tasks.elicitInputStream({
|
|
170947
|
+
* mode: 'url',
|
|
170948
|
+
* message: 'Please authenticate',
|
|
170949
|
+
* elicitationId: 'auth-123',
|
|
170950
|
+
* url: 'https://example.com/auth'
|
|
170951
|
+
* }, {
|
|
170952
|
+
* task: { ttl: 300000 } // Task-augmented for long-running auth flow
|
|
170953
|
+
* });
|
|
170954
|
+
*
|
|
170955
|
+
* for await (const message of stream) {
|
|
170956
|
+
* switch (message.type) {
|
|
170957
|
+
* case 'taskCreated':
|
|
170958
|
+
* console.log('Task created:', message.task.taskId);
|
|
170959
|
+
* break;
|
|
170960
|
+
* case 'taskStatus':
|
|
170961
|
+
* console.log('Task status:', message.task.status);
|
|
170962
|
+
* break;
|
|
170963
|
+
* case 'result':
|
|
170964
|
+
* console.log('User action:', message.result.action);
|
|
170965
|
+
* break;
|
|
170966
|
+
* case 'error':
|
|
170967
|
+
* console.error('Error:', message.error);
|
|
170968
|
+
* break;
|
|
170969
|
+
* }
|
|
170970
|
+
* }
|
|
170971
|
+
* ```
|
|
170972
|
+
*
|
|
170973
|
+
* @param params - The elicitation request parameters
|
|
170974
|
+
* @param options - Optional request options (timeout, signal, task creation params, etc.)
|
|
170975
|
+
* @returns AsyncGenerator that yields ResponseMessage objects
|
|
170976
|
+
*
|
|
170977
|
+
* @experimental
|
|
170978
|
+
*/
|
|
170979
|
+
elicitInputStream(params, options) {
|
|
170980
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
170981
|
+
const mode = params.mode ?? "form";
|
|
170982
|
+
switch (mode) {
|
|
170983
|
+
case "url": {
|
|
170984
|
+
if (!clientCapabilities?.elicitation?.url) {
|
|
170985
|
+
throw new Error("Client does not support url elicitation.");
|
|
170986
|
+
}
|
|
170987
|
+
break;
|
|
170988
|
+
}
|
|
170989
|
+
case "form": {
|
|
170990
|
+
if (!clientCapabilities?.elicitation?.form) {
|
|
170991
|
+
throw new Error("Client does not support form elicitation.");
|
|
170992
|
+
}
|
|
170993
|
+
break;
|
|
170994
|
+
}
|
|
170995
|
+
}
|
|
170996
|
+
const normalizedParams = mode === "form" && params.mode === void 0 ? { ...params, mode: "form" } : params;
|
|
170997
|
+
return this.requestStream({
|
|
170998
|
+
method: "elicitation/create",
|
|
170999
|
+
params: normalizedParams
|
|
171000
|
+
}, ElicitResultSchema, options);
|
|
171001
|
+
}
|
|
170843
171002
|
/**
|
|
170844
171003
|
* Gets the current status of a task.
|
|
170845
171004
|
*
|
|
@@ -170890,7 +171049,7 @@ var ExperimentalServerTasks = class {
|
|
|
170890
171049
|
}
|
|
170891
171050
|
};
|
|
170892
171051
|
|
|
170893
|
-
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
171052
|
+
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
|
|
170894
171053
|
function assertToolsCallTaskCapability(requests, method, entityName) {
|
|
170895
171054
|
if (!requests) {
|
|
170896
171055
|
throw new Error(`${entityName} does not support task creation (required for ${method})`);
|
|
@@ -170925,7 +171084,7 @@ function assertClientRequestTaskCapability(requests, method, entityName) {
|
|
|
170925
171084
|
}
|
|
170926
171085
|
}
|
|
170927
171086
|
|
|
170928
|
-
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
171087
|
+
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
|
|
170929
171088
|
var Server = class extends Protocol {
|
|
170930
171089
|
/**
|
|
170931
171090
|
* Initializes this server with the given name and version information.
|
|
@@ -171305,10 +171464,10 @@ var Server = class extends Protocol {
|
|
|
171305
171464
|
}
|
|
171306
171465
|
};
|
|
171307
171466
|
|
|
171308
|
-
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
171467
|
+
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
|
|
171309
171468
|
var import_node_process = __toESM(require("node:process"), 1);
|
|
171310
171469
|
|
|
171311
|
-
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
171470
|
+
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
|
|
171312
171471
|
var ReadBuffer = class {
|
|
171313
171472
|
append(chunk4) {
|
|
171314
171473
|
this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk4]) : chunk4;
|
|
@@ -171336,7 +171495,7 @@ function serializeMessage(message) {
|
|
|
171336
171495
|
return JSON.stringify(message) + "\n";
|
|
171337
171496
|
}
|
|
171338
171497
|
|
|
171339
|
-
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
171498
|
+
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
|
|
171340
171499
|
var StdioServerTransport = class {
|
|
171341
171500
|
constructor(_stdin = import_node_process.default.stdin, _stdout = import_node_process.default.stdout) {
|
|
171342
171501
|
this._stdin = _stdin;
|
|
@@ -175195,7 +175354,7 @@ var PostHog = class extends PostHogBackendClient {
|
|
|
175195
175354
|
};
|
|
175196
175355
|
|
|
175197
175356
|
// src/version.ts
|
|
175198
|
-
var VERSION = true ? "0.1.
|
|
175357
|
+
var VERSION = true ? "0.1.57" : "0.0.0-dev";
|
|
175199
175358
|
|
|
175200
175359
|
// src/telemetry/posthog.ts
|
|
175201
175360
|
var POSTHOG_API_KEY = "phc_TGfFqCGdnF0p68wuFzd5WSw1IsBvOJW0YgoMJDyZPjm";
|