@hasna/conversations 0.2.0 → 0.2.1
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/bin/index.js
CHANGED
|
@@ -4207,7 +4207,7 @@ var init_poll = __esm(() => {
|
|
|
4207
4207
|
var require_package = __commonJS((exports, module) => {
|
|
4208
4208
|
module.exports = {
|
|
4209
4209
|
name: "@hasna/conversations",
|
|
4210
|
-
version: "0.2.
|
|
4210
|
+
version: "0.2.1",
|
|
4211
4211
|
description: "Real-time CLI messaging for AI agents",
|
|
4212
4212
|
type: "module",
|
|
4213
4213
|
bin: {
|
|
@@ -31575,7 +31575,7 @@ var require_formats = __commonJS((exports) => {
|
|
|
31575
31575
|
}
|
|
31576
31576
|
var TIME = /^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;
|
|
31577
31577
|
function getTime(strictTimeZone) {
|
|
31578
|
-
return function
|
|
31578
|
+
return function time3(str) {
|
|
31579
31579
|
const matches = TIME.exec(str);
|
|
31580
31580
|
if (!matches)
|
|
31581
31581
|
return false;
|
|
@@ -31839,6 +31839,62 @@ class ExperimentalServerTasks {
|
|
|
31839
31839
|
requestStream(request, resultSchema, options) {
|
|
31840
31840
|
return this._server.requestStream(request, resultSchema, options);
|
|
31841
31841
|
}
|
|
31842
|
+
createMessageStream(params, options) {
|
|
31843
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
31844
|
+
if ((params.tools || params.toolChoice) && !clientCapabilities?.sampling?.tools) {
|
|
31845
|
+
throw new Error("Client does not support sampling tools capability.");
|
|
31846
|
+
}
|
|
31847
|
+
if (params.messages.length > 0) {
|
|
31848
|
+
const lastMessage = params.messages[params.messages.length - 1];
|
|
31849
|
+
const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [lastMessage.content];
|
|
31850
|
+
const hasToolResults = lastContent.some((c) => c.type === "tool_result");
|
|
31851
|
+
const previousMessage = params.messages.length > 1 ? params.messages[params.messages.length - 2] : undefined;
|
|
31852
|
+
const previousContent = previousMessage ? Array.isArray(previousMessage.content) ? previousMessage.content : [previousMessage.content] : [];
|
|
31853
|
+
const hasPreviousToolUse = previousContent.some((c) => c.type === "tool_use");
|
|
31854
|
+
if (hasToolResults) {
|
|
31855
|
+
if (lastContent.some((c) => c.type !== "tool_result")) {
|
|
31856
|
+
throw new Error("The last message must contain only tool_result content if any is present");
|
|
31857
|
+
}
|
|
31858
|
+
if (!hasPreviousToolUse) {
|
|
31859
|
+
throw new Error("tool_result blocks are not matching any tool_use from the previous message");
|
|
31860
|
+
}
|
|
31861
|
+
}
|
|
31862
|
+
if (hasPreviousToolUse) {
|
|
31863
|
+
const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
|
|
31864
|
+
const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
|
|
31865
|
+
if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id) => toolResultIds.has(id))) {
|
|
31866
|
+
throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match");
|
|
31867
|
+
}
|
|
31868
|
+
}
|
|
31869
|
+
}
|
|
31870
|
+
return this.requestStream({
|
|
31871
|
+
method: "sampling/createMessage",
|
|
31872
|
+
params
|
|
31873
|
+
}, CreateMessageResultSchema, options);
|
|
31874
|
+
}
|
|
31875
|
+
elicitInputStream(params, options) {
|
|
31876
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
31877
|
+
const mode = params.mode ?? "form";
|
|
31878
|
+
switch (mode) {
|
|
31879
|
+
case "url": {
|
|
31880
|
+
if (!clientCapabilities?.elicitation?.url) {
|
|
31881
|
+
throw new Error("Client does not support url elicitation.");
|
|
31882
|
+
}
|
|
31883
|
+
break;
|
|
31884
|
+
}
|
|
31885
|
+
case "form": {
|
|
31886
|
+
if (!clientCapabilities?.elicitation?.form) {
|
|
31887
|
+
throw new Error("Client does not support form elicitation.");
|
|
31888
|
+
}
|
|
31889
|
+
break;
|
|
31890
|
+
}
|
|
31891
|
+
}
|
|
31892
|
+
const normalizedParams = mode === "form" && params.mode === undefined ? { ...params, mode: "form" } : params;
|
|
31893
|
+
return this.requestStream({
|
|
31894
|
+
method: "elicitation/create",
|
|
31895
|
+
params: normalizedParams
|
|
31896
|
+
}, ElicitResultSchema, options);
|
|
31897
|
+
}
|
|
31842
31898
|
async getTask(taskId, options) {
|
|
31843
31899
|
return this._server.getTask({ taskId }, options);
|
|
31844
31900
|
}
|
|
@@ -31852,6 +31908,9 @@ class ExperimentalServerTasks {
|
|
|
31852
31908
|
return this._server.cancelTask({ taskId }, options);
|
|
31853
31909
|
}
|
|
31854
31910
|
}
|
|
31911
|
+
var init_server = __esm(() => {
|
|
31912
|
+
init_types2();
|
|
31913
|
+
});
|
|
31855
31914
|
|
|
31856
31915
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
|
|
31857
31916
|
function assertToolsCallTaskCapability(requests, method, entityName) {
|
|
@@ -31890,11 +31949,12 @@ function assertClientRequestTaskCapability(requests, method, entityName) {
|
|
|
31890
31949
|
|
|
31891
31950
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
|
|
31892
31951
|
var Server;
|
|
31893
|
-
var
|
|
31952
|
+
var init_server2 = __esm(() => {
|
|
31894
31953
|
init_protocol();
|
|
31895
31954
|
init_types2();
|
|
31896
31955
|
init_ajv_provider();
|
|
31897
31956
|
init_zod_compat();
|
|
31957
|
+
init_server();
|
|
31898
31958
|
Server = class Server extends Protocol {
|
|
31899
31959
|
constructor(_serverInfo, options) {
|
|
31900
31960
|
super(options);
|
|
@@ -33036,7 +33096,7 @@ function createCompletionResult(suggestions) {
|
|
|
33036
33096
|
}
|
|
33037
33097
|
var EMPTY_OBJECT_JSON_SCHEMA, EMPTY_COMPLETION_RESULT;
|
|
33038
33098
|
var init_mcp = __esm(() => {
|
|
33039
|
-
|
|
33099
|
+
init_server2();
|
|
33040
33100
|
init_zod_compat();
|
|
33041
33101
|
init_zod_json_schema_compat();
|
|
33042
33102
|
init_types2();
|
package/bin/mcp.js
CHANGED
|
@@ -6302,7 +6302,7 @@ var require_formats = __commonJS((exports) => {
|
|
|
6302
6302
|
}
|
|
6303
6303
|
var TIME = /^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;
|
|
6304
6304
|
function getTime(strictTimeZone) {
|
|
6305
|
-
return function
|
|
6305
|
+
return function time3(str) {
|
|
6306
6306
|
const matches = TIME.exec(str);
|
|
6307
6307
|
if (!matches)
|
|
6308
6308
|
return false;
|
|
@@ -27310,6 +27310,62 @@ class ExperimentalServerTasks {
|
|
|
27310
27310
|
requestStream(request, resultSchema, options) {
|
|
27311
27311
|
return this._server.requestStream(request, resultSchema, options);
|
|
27312
27312
|
}
|
|
27313
|
+
createMessageStream(params, options) {
|
|
27314
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
27315
|
+
if ((params.tools || params.toolChoice) && !clientCapabilities?.sampling?.tools) {
|
|
27316
|
+
throw new Error("Client does not support sampling tools capability.");
|
|
27317
|
+
}
|
|
27318
|
+
if (params.messages.length > 0) {
|
|
27319
|
+
const lastMessage = params.messages[params.messages.length - 1];
|
|
27320
|
+
const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [lastMessage.content];
|
|
27321
|
+
const hasToolResults = lastContent.some((c) => c.type === "tool_result");
|
|
27322
|
+
const previousMessage = params.messages.length > 1 ? params.messages[params.messages.length - 2] : undefined;
|
|
27323
|
+
const previousContent = previousMessage ? Array.isArray(previousMessage.content) ? previousMessage.content : [previousMessage.content] : [];
|
|
27324
|
+
const hasPreviousToolUse = previousContent.some((c) => c.type === "tool_use");
|
|
27325
|
+
if (hasToolResults) {
|
|
27326
|
+
if (lastContent.some((c) => c.type !== "tool_result")) {
|
|
27327
|
+
throw new Error("The last message must contain only tool_result content if any is present");
|
|
27328
|
+
}
|
|
27329
|
+
if (!hasPreviousToolUse) {
|
|
27330
|
+
throw new Error("tool_result blocks are not matching any tool_use from the previous message");
|
|
27331
|
+
}
|
|
27332
|
+
}
|
|
27333
|
+
if (hasPreviousToolUse) {
|
|
27334
|
+
const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
|
|
27335
|
+
const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
|
|
27336
|
+
if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id) => toolResultIds.has(id))) {
|
|
27337
|
+
throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match");
|
|
27338
|
+
}
|
|
27339
|
+
}
|
|
27340
|
+
}
|
|
27341
|
+
return this.requestStream({
|
|
27342
|
+
method: "sampling/createMessage",
|
|
27343
|
+
params
|
|
27344
|
+
}, CreateMessageResultSchema, options);
|
|
27345
|
+
}
|
|
27346
|
+
elicitInputStream(params, options) {
|
|
27347
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
27348
|
+
const mode = params.mode ?? "form";
|
|
27349
|
+
switch (mode) {
|
|
27350
|
+
case "url": {
|
|
27351
|
+
if (!clientCapabilities?.elicitation?.url) {
|
|
27352
|
+
throw new Error("Client does not support url elicitation.");
|
|
27353
|
+
}
|
|
27354
|
+
break;
|
|
27355
|
+
}
|
|
27356
|
+
case "form": {
|
|
27357
|
+
if (!clientCapabilities?.elicitation?.form) {
|
|
27358
|
+
throw new Error("Client does not support form elicitation.");
|
|
27359
|
+
}
|
|
27360
|
+
break;
|
|
27361
|
+
}
|
|
27362
|
+
}
|
|
27363
|
+
const normalizedParams = mode === "form" && params.mode === undefined ? { ...params, mode: "form" } : params;
|
|
27364
|
+
return this.requestStream({
|
|
27365
|
+
method: "elicitation/create",
|
|
27366
|
+
params: normalizedParams
|
|
27367
|
+
}, ElicitResultSchema, options);
|
|
27368
|
+
}
|
|
27313
27369
|
async getTask(taskId, options) {
|
|
27314
27370
|
return this._server.getTask({ taskId }, options);
|
|
27315
27371
|
}
|
|
@@ -30549,7 +30605,7 @@ function getGraphStats() {
|
|
|
30549
30605
|
// package.json
|
|
30550
30606
|
var package_default = {
|
|
30551
30607
|
name: "@hasna/conversations",
|
|
30552
|
-
version: "0.2.
|
|
30608
|
+
version: "0.2.1",
|
|
30553
30609
|
description: "Real-time CLI messaging for AI agents",
|
|
30554
30610
|
type: "module",
|
|
30555
30611
|
bin: {
|