@hasna/conversations 0.1.23 → 0.1.24
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 +74 -3
- package/bin/mcp.js +68 -1
- package/dist/lib/identity.d.ts +4 -0
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -3282,6 +3282,14 @@ function resolveIdentity(explicit) {
|
|
|
3282
3282
|
return envValue;
|
|
3283
3283
|
return getAutoName();
|
|
3284
3284
|
}
|
|
3285
|
+
function updateCachedAutoName(newName) {
|
|
3286
|
+
cachedAutoName = newName;
|
|
3287
|
+
try {
|
|
3288
|
+
mkdirSync3(dirname2(AGENT_ID_FILE), { recursive: true });
|
|
3289
|
+
writeFileSync(AGENT_ID_FILE, newName + `
|
|
3290
|
+
`, "utf-8");
|
|
3291
|
+
} catch {}
|
|
3292
|
+
}
|
|
3285
3293
|
var AGENT_ID_FILE, cachedAutoName = null;
|
|
3286
3294
|
var init_identity = __esm(() => {
|
|
3287
3295
|
init_names();
|
|
@@ -3509,7 +3517,7 @@ var init_poll = __esm(() => {
|
|
|
3509
3517
|
var require_package = __commonJS((exports, module) => {
|
|
3510
3518
|
module.exports = {
|
|
3511
3519
|
name: "@hasna/conversations",
|
|
3512
|
-
version: "0.1.
|
|
3520
|
+
version: "0.1.24",
|
|
3513
3521
|
description: "Real-time CLI messaging for AI agents",
|
|
3514
3522
|
type: "module",
|
|
3515
3523
|
bin: {
|
|
@@ -31141,6 +31149,62 @@ class ExperimentalServerTasks {
|
|
|
31141
31149
|
requestStream(request, resultSchema, options) {
|
|
31142
31150
|
return this._server.requestStream(request, resultSchema, options);
|
|
31143
31151
|
}
|
|
31152
|
+
createMessageStream(params, options) {
|
|
31153
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
31154
|
+
if ((params.tools || params.toolChoice) && !clientCapabilities?.sampling?.tools) {
|
|
31155
|
+
throw new Error("Client does not support sampling tools capability.");
|
|
31156
|
+
}
|
|
31157
|
+
if (params.messages.length > 0) {
|
|
31158
|
+
const lastMessage = params.messages[params.messages.length - 1];
|
|
31159
|
+
const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [lastMessage.content];
|
|
31160
|
+
const hasToolResults = lastContent.some((c) => c.type === "tool_result");
|
|
31161
|
+
const previousMessage = params.messages.length > 1 ? params.messages[params.messages.length - 2] : undefined;
|
|
31162
|
+
const previousContent = previousMessage ? Array.isArray(previousMessage.content) ? previousMessage.content : [previousMessage.content] : [];
|
|
31163
|
+
const hasPreviousToolUse = previousContent.some((c) => c.type === "tool_use");
|
|
31164
|
+
if (hasToolResults) {
|
|
31165
|
+
if (lastContent.some((c) => c.type !== "tool_result")) {
|
|
31166
|
+
throw new Error("The last message must contain only tool_result content if any is present");
|
|
31167
|
+
}
|
|
31168
|
+
if (!hasPreviousToolUse) {
|
|
31169
|
+
throw new Error("tool_result blocks are not matching any tool_use from the previous message");
|
|
31170
|
+
}
|
|
31171
|
+
}
|
|
31172
|
+
if (hasPreviousToolUse) {
|
|
31173
|
+
const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
|
|
31174
|
+
const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
|
|
31175
|
+
if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id) => toolResultIds.has(id))) {
|
|
31176
|
+
throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match");
|
|
31177
|
+
}
|
|
31178
|
+
}
|
|
31179
|
+
}
|
|
31180
|
+
return this.requestStream({
|
|
31181
|
+
method: "sampling/createMessage",
|
|
31182
|
+
params
|
|
31183
|
+
}, CreateMessageResultSchema, options);
|
|
31184
|
+
}
|
|
31185
|
+
elicitInputStream(params, options) {
|
|
31186
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
31187
|
+
const mode = params.mode ?? "form";
|
|
31188
|
+
switch (mode) {
|
|
31189
|
+
case "url": {
|
|
31190
|
+
if (!clientCapabilities?.elicitation?.url) {
|
|
31191
|
+
throw new Error("Client does not support url elicitation.");
|
|
31192
|
+
}
|
|
31193
|
+
break;
|
|
31194
|
+
}
|
|
31195
|
+
case "form": {
|
|
31196
|
+
if (!clientCapabilities?.elicitation?.form) {
|
|
31197
|
+
throw new Error("Client does not support form elicitation.");
|
|
31198
|
+
}
|
|
31199
|
+
break;
|
|
31200
|
+
}
|
|
31201
|
+
}
|
|
31202
|
+
const normalizedParams = mode === "form" && params.mode === undefined ? { ...params, mode: "form" } : params;
|
|
31203
|
+
return this.requestStream({
|
|
31204
|
+
method: "elicitation/create",
|
|
31205
|
+
params: normalizedParams
|
|
31206
|
+
}, ElicitResultSchema, options);
|
|
31207
|
+
}
|
|
31144
31208
|
async getTask(taskId, options) {
|
|
31145
31209
|
return this._server.getTask({ taskId }, options);
|
|
31146
31210
|
}
|
|
@@ -31154,6 +31218,9 @@ class ExperimentalServerTasks {
|
|
|
31154
31218
|
return this._server.cancelTask({ taskId }, options);
|
|
31155
31219
|
}
|
|
31156
31220
|
}
|
|
31221
|
+
var init_server = __esm(() => {
|
|
31222
|
+
init_types2();
|
|
31223
|
+
});
|
|
31157
31224
|
|
|
31158
31225
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
|
|
31159
31226
|
function assertToolsCallTaskCapability(requests, method, entityName) {
|
|
@@ -31192,11 +31259,12 @@ function assertClientRequestTaskCapability(requests, method, entityName) {
|
|
|
31192
31259
|
|
|
31193
31260
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
|
|
31194
31261
|
var Server;
|
|
31195
|
-
var
|
|
31262
|
+
var init_server2 = __esm(() => {
|
|
31196
31263
|
init_protocol();
|
|
31197
31264
|
init_types2();
|
|
31198
31265
|
init_ajv_provider();
|
|
31199
31266
|
init_zod_compat();
|
|
31267
|
+
init_server();
|
|
31200
31268
|
Server = class Server extends Protocol {
|
|
31201
31269
|
constructor(_serverInfo, options) {
|
|
31202
31270
|
super(options);
|
|
@@ -32338,7 +32406,7 @@ function createCompletionResult(suggestions) {
|
|
|
32338
32406
|
}
|
|
32339
32407
|
var EMPTY_OBJECT_JSON_SCHEMA, EMPTY_COMPLETION_RESULT;
|
|
32340
32408
|
var init_mcp = __esm(() => {
|
|
32341
|
-
|
|
32409
|
+
init_server2();
|
|
32342
32410
|
init_zod_compat();
|
|
32343
32411
|
init_zod_json_schema_compat();
|
|
32344
32412
|
init_types2();
|
|
@@ -33190,6 +33258,9 @@ var init_mcp2 = __esm(() => {
|
|
|
33190
33258
|
isError: true
|
|
33191
33259
|
};
|
|
33192
33260
|
}
|
|
33261
|
+
if (!fromParam) {
|
|
33262
|
+
updateCachedAutoName(newName);
|
|
33263
|
+
}
|
|
33193
33264
|
return {
|
|
33194
33265
|
content: [{ type: "text", text: JSON.stringify({ old_name: oldName, new_name: newName, renamed: true }) }]
|
|
33195
33266
|
};
|
package/bin/mcp.js
CHANGED
|
@@ -27263,6 +27263,62 @@ class ExperimentalServerTasks {
|
|
|
27263
27263
|
requestStream(request, resultSchema, options) {
|
|
27264
27264
|
return this._server.requestStream(request, resultSchema, options);
|
|
27265
27265
|
}
|
|
27266
|
+
createMessageStream(params, options) {
|
|
27267
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
27268
|
+
if ((params.tools || params.toolChoice) && !clientCapabilities?.sampling?.tools) {
|
|
27269
|
+
throw new Error("Client does not support sampling tools capability.");
|
|
27270
|
+
}
|
|
27271
|
+
if (params.messages.length > 0) {
|
|
27272
|
+
const lastMessage = params.messages[params.messages.length - 1];
|
|
27273
|
+
const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [lastMessage.content];
|
|
27274
|
+
const hasToolResults = lastContent.some((c) => c.type === "tool_result");
|
|
27275
|
+
const previousMessage = params.messages.length > 1 ? params.messages[params.messages.length - 2] : undefined;
|
|
27276
|
+
const previousContent = previousMessage ? Array.isArray(previousMessage.content) ? previousMessage.content : [previousMessage.content] : [];
|
|
27277
|
+
const hasPreviousToolUse = previousContent.some((c) => c.type === "tool_use");
|
|
27278
|
+
if (hasToolResults) {
|
|
27279
|
+
if (lastContent.some((c) => c.type !== "tool_result")) {
|
|
27280
|
+
throw new Error("The last message must contain only tool_result content if any is present");
|
|
27281
|
+
}
|
|
27282
|
+
if (!hasPreviousToolUse) {
|
|
27283
|
+
throw new Error("tool_result blocks are not matching any tool_use from the previous message");
|
|
27284
|
+
}
|
|
27285
|
+
}
|
|
27286
|
+
if (hasPreviousToolUse) {
|
|
27287
|
+
const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
|
|
27288
|
+
const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
|
|
27289
|
+
if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id) => toolResultIds.has(id))) {
|
|
27290
|
+
throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match");
|
|
27291
|
+
}
|
|
27292
|
+
}
|
|
27293
|
+
}
|
|
27294
|
+
return this.requestStream({
|
|
27295
|
+
method: "sampling/createMessage",
|
|
27296
|
+
params
|
|
27297
|
+
}, CreateMessageResultSchema, options);
|
|
27298
|
+
}
|
|
27299
|
+
elicitInputStream(params, options) {
|
|
27300
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
27301
|
+
const mode = params.mode ?? "form";
|
|
27302
|
+
switch (mode) {
|
|
27303
|
+
case "url": {
|
|
27304
|
+
if (!clientCapabilities?.elicitation?.url) {
|
|
27305
|
+
throw new Error("Client does not support url elicitation.");
|
|
27306
|
+
}
|
|
27307
|
+
break;
|
|
27308
|
+
}
|
|
27309
|
+
case "form": {
|
|
27310
|
+
if (!clientCapabilities?.elicitation?.form) {
|
|
27311
|
+
throw new Error("Client does not support form elicitation.");
|
|
27312
|
+
}
|
|
27313
|
+
break;
|
|
27314
|
+
}
|
|
27315
|
+
}
|
|
27316
|
+
const normalizedParams = mode === "form" && params.mode === undefined ? { ...params, mode: "form" } : params;
|
|
27317
|
+
return this.requestStream({
|
|
27318
|
+
method: "elicitation/create",
|
|
27319
|
+
params: normalizedParams
|
|
27320
|
+
}, ElicitResultSchema, options);
|
|
27321
|
+
}
|
|
27266
27322
|
async getTask(taskId, options) {
|
|
27267
27323
|
return this._server.getTask({ taskId }, options);
|
|
27268
27324
|
}
|
|
@@ -29710,6 +29766,14 @@ function resolveIdentity(explicit) {
|
|
|
29710
29766
|
return envValue;
|
|
29711
29767
|
return getAutoName();
|
|
29712
29768
|
}
|
|
29769
|
+
function updateCachedAutoName(newName) {
|
|
29770
|
+
cachedAutoName = newName;
|
|
29771
|
+
try {
|
|
29772
|
+
mkdirSync3(dirname2(AGENT_ID_FILE), { recursive: true });
|
|
29773
|
+
writeFileSync(AGENT_ID_FILE, newName + `
|
|
29774
|
+
`, "utf-8");
|
|
29775
|
+
} catch {}
|
|
29776
|
+
}
|
|
29713
29777
|
|
|
29714
29778
|
// src/lib/presence.ts
|
|
29715
29779
|
init_db();
|
|
@@ -29782,7 +29846,7 @@ function renameAgent(oldName, newName) {
|
|
|
29782
29846
|
// package.json
|
|
29783
29847
|
var package_default = {
|
|
29784
29848
|
name: "@hasna/conversations",
|
|
29785
|
-
version: "0.1.
|
|
29849
|
+
version: "0.1.24",
|
|
29786
29850
|
description: "Real-time CLI messaging for AI agents",
|
|
29787
29851
|
type: "module",
|
|
29788
29852
|
bin: {
|
|
@@ -30575,6 +30639,9 @@ server.registerTool("rename_agent", {
|
|
|
30575
30639
|
isError: true
|
|
30576
30640
|
};
|
|
30577
30641
|
}
|
|
30642
|
+
if (!fromParam) {
|
|
30643
|
+
updateCachedAutoName(newName);
|
|
30644
|
+
}
|
|
30578
30645
|
return {
|
|
30579
30646
|
content: [{ type: "text", text: JSON.stringify({ old_name: oldName, new_name: newName, renamed: true }) }]
|
|
30580
30647
|
};
|
package/dist/lib/identity.d.ts
CHANGED
|
@@ -14,6 +14,10 @@ export declare function resolveIdentity(explicit?: string): string;
|
|
|
14
14
|
* Throws if no identity is set via flag or env.
|
|
15
15
|
*/
|
|
16
16
|
export declare function requireIdentity(explicit?: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Update the cached auto name after a successful rename.
|
|
19
|
+
*/
|
|
20
|
+
export declare function updateCachedAutoName(newName: string): void;
|
|
17
21
|
/**
|
|
18
22
|
* Reset the cached auto name (for testing).
|
|
19
23
|
*/
|