@hasna/conversations 0.1.3 → 0.1.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/bin/mcp.js CHANGED
@@ -29033,6 +29033,381 @@ function deleteProject(id) {
29033
29033
  }
29034
29034
 
29035
29035
  // src/lib/identity.ts
29036
+ import { readFileSync, writeFileSync, mkdirSync as mkdirSync2 } from "fs";
29037
+ import { join as join2, dirname as dirname2 } from "path";
29038
+ import { homedir as homedir2 } from "os";
29039
+
29040
+ // src/lib/names.ts
29041
+ var AGENT_NAMES = [
29042
+ "amber-fox",
29043
+ "arctic-wolf",
29044
+ "ashen-crow",
29045
+ "azure-hawk",
29046
+ "astral-lynx",
29047
+ "autumn-bear",
29048
+ "agile-puma",
29049
+ "alpine-ibex",
29050
+ "ancient-owl",
29051
+ "aqua-otter",
29052
+ "arid-viper",
29053
+ "atom-finch",
29054
+ "auburn-deer",
29055
+ "aurora-seal",
29056
+ "avid-mink",
29057
+ "blaze-tiger",
29058
+ "bright-heron",
29059
+ "bronze-eagle",
29060
+ "brisk-hare",
29061
+ "burnt-moth",
29062
+ "bold-raven",
29063
+ "blue-whale",
29064
+ "boreal-fox",
29065
+ "brass-cobra",
29066
+ "brave-ram",
29067
+ "brick-crane",
29068
+ "brief-newt",
29069
+ "briny-crab",
29070
+ "broad-elk",
29071
+ "brook-dove",
29072
+ "calm-panda",
29073
+ "cedar-jay",
29074
+ "chief-lion",
29075
+ "chrome-bat",
29076
+ "civic-wren",
29077
+ "clear-swan",
29078
+ "cliff-goat",
29079
+ "coal-shark",
29080
+ "cold-crane",
29081
+ "copper-jay",
29082
+ "coral-fish",
29083
+ "crisp-lark",
29084
+ "cross-mole",
29085
+ "cubic-wasp",
29086
+ "cyan-toad",
29087
+ "dark-stag",
29088
+ "dawn-robin",
29089
+ "deep-squid",
29090
+ "delta-fox",
29091
+ "dense-boar",
29092
+ "dew-spider",
29093
+ "dim-gecko",
29094
+ "draft-bear",
29095
+ "drift-gull",
29096
+ "dry-newt",
29097
+ "dual-crane",
29098
+ "dune-mouse",
29099
+ "dusk-moth",
29100
+ "dusty-mule",
29101
+ "dwarf-carp",
29102
+ "east-falcon",
29103
+ "echo-parrot",
29104
+ "edge-shark",
29105
+ "elm-beetle",
29106
+ "ember-lynx",
29107
+ "epoch-crane",
29108
+ "even-pike",
29109
+ "extra-ant",
29110
+ "elder-stork",
29111
+ "ebon-crow",
29112
+ "ever-finch",
29113
+ "exact-moth",
29114
+ "exile-wren",
29115
+ "equal-dove",
29116
+ "etch-hare",
29117
+ "faint-orca",
29118
+ "far-condor",
29119
+ "fern-mouse",
29120
+ "fierce-yak",
29121
+ "first-kite",
29122
+ "fjord-seal",
29123
+ "flint-wolf",
29124
+ "fog-parrot",
29125
+ "forge-bull",
29126
+ "fossil-ray",
29127
+ "frank-mink",
29128
+ "free-eagle",
29129
+ "fresh-colt",
29130
+ "frost-bear",
29131
+ "fuse-wasp",
29132
+ "gale-hawk",
29133
+ "gem-turtle",
29134
+ "ghost-lynx",
29135
+ "gilt-robin",
29136
+ "glad-moose",
29137
+ "glass-eel",
29138
+ "gleam-puma",
29139
+ "glyph-owl",
29140
+ "gold-crane",
29141
+ "gorge-lion",
29142
+ "grain-duck",
29143
+ "grand-wolf",
29144
+ "gray-fox",
29145
+ "green-hare",
29146
+ "grit-shark",
29147
+ "half-stork",
29148
+ "haze-panther",
29149
+ "heart-dove",
29150
+ "helm-eagle",
29151
+ "herb-toad",
29152
+ "hex-spider",
29153
+ "high-falcon",
29154
+ "hive-hornet",
29155
+ "holo-swan",
29156
+ "hood-cobra",
29157
+ "horn-bison",
29158
+ "huge-squid",
29159
+ "hull-crab",
29160
+ "hunt-marten",
29161
+ "husk-moth",
29162
+ "ice-leopard",
29163
+ "idle-crane",
29164
+ "inch-beetle",
29165
+ "indigo-jay",
29166
+ "inner-fox",
29167
+ "ion-parrot",
29168
+ "iron-bull",
29169
+ "isle-pelican",
29170
+ "ivory-hawk",
29171
+ "ivy-snake",
29172
+ "iota-wren",
29173
+ "ink-raven",
29174
+ "ignite-ram",
29175
+ "inert-slug",
29176
+ "infra-mole",
29177
+ "jade-tiger",
29178
+ "jest-magpie",
29179
+ "jewel-crane",
29180
+ "joint-boar",
29181
+ "jovial-elk",
29182
+ "jump-frog",
29183
+ "jungle-cat",
29184
+ "jury-dove",
29185
+ "just-heron",
29186
+ "jolt-wasp",
29187
+ "keen-osprey",
29188
+ "kelp-seal",
29189
+ "key-falcon",
29190
+ "kind-panda",
29191
+ "knot-viper",
29192
+ "kraft-bear",
29193
+ "kite-mouse",
29194
+ "knoll-deer",
29195
+ "know-crane",
29196
+ "karma-wolf",
29197
+ "lake-otter",
29198
+ "lapis-jay",
29199
+ "last-condor",
29200
+ "leaf-gecko",
29201
+ "lean-coyote",
29202
+ "light-lynx",
29203
+ "lime-parrot",
29204
+ "live-eagle",
29205
+ "long-crane",
29206
+ "lost-fox",
29207
+ "loud-finch",
29208
+ "low-shark",
29209
+ "luck-rabbit",
29210
+ "lunar-owl",
29211
+ "lush-ibis",
29212
+ "malt-badger",
29213
+ "maple-wren",
29214
+ "mars-falcon",
29215
+ "matte-crow",
29216
+ "mesa-hawk",
29217
+ "mild-orca",
29218
+ "mint-dove",
29219
+ "mist-puma",
29220
+ "mock-robin",
29221
+ "mono-wolf",
29222
+ "moon-bear",
29223
+ "moss-turtle",
29224
+ "mud-heron",
29225
+ "mute-swan",
29226
+ "myth-lynx",
29227
+ "navy-eagle",
29228
+ "near-mink",
29229
+ "neon-parrot",
29230
+ "nest-crane",
29231
+ "next-fox",
29232
+ "nimble-ram",
29233
+ "node-spider",
29234
+ "noon-hawk",
29235
+ "north-seal",
29236
+ "nova-owl",
29237
+ "null-moth",
29238
+ "numb-carp",
29239
+ "nutmeg-jay",
29240
+ "neat-cobra",
29241
+ "nomad-elk",
29242
+ "oak-badger",
29243
+ "oat-finch",
29244
+ "odd-pelican",
29245
+ "olive-bear",
29246
+ "onyx-raven",
29247
+ "opal-crane",
29248
+ "open-wolf",
29249
+ "orbit-lynx",
29250
+ "ore-shark",
29251
+ "outer-dove",
29252
+ "pale-tiger",
29253
+ "park-heron",
29254
+ "peak-eagle",
29255
+ "pine-fox",
29256
+ "pixel-owl",
29257
+ "plain-goat",
29258
+ "plum-crane",
29259
+ "polar-ray",
29260
+ "port-falcon",
29261
+ "prime-wolf",
29262
+ "prism-jay",
29263
+ "proud-lion",
29264
+ "pulse-bat",
29265
+ "pure-swan",
29266
+ "pyro-hawk",
29267
+ "quake-bear",
29268
+ "quartz-jay",
29269
+ "quest-falcon",
29270
+ "quick-otter",
29271
+ "quiet-crane",
29272
+ "rain-leopard",
29273
+ "rapid-hare",
29274
+ "raw-condor",
29275
+ "reef-dolphin",
29276
+ "regal-stag",
29277
+ "ridge-fox",
29278
+ "rift-cobra",
29279
+ "rigid-crane",
29280
+ "river-otter",
29281
+ "rock-eagle",
29282
+ "root-mole",
29283
+ "rose-finch",
29284
+ "rough-boar",
29285
+ "ruby-hawk",
29286
+ "rust-wolf",
29287
+ "sage-owl",
29288
+ "salt-crane",
29289
+ "sand-viper",
29290
+ "satin-dove",
29291
+ "scale-dragon",
29292
+ "scarlet-ibis",
29293
+ "sea-falcon",
29294
+ "shade-lynx",
29295
+ "sharp-eagle",
29296
+ "shell-crab",
29297
+ "short-fox",
29298
+ "sigma-jay",
29299
+ "silk-moth",
29300
+ "silver-wolf",
29301
+ "slate-bear",
29302
+ "slim-heron",
29303
+ "smoke-puma",
29304
+ "snap-turtle",
29305
+ "snow-leopard",
29306
+ "solar-crane",
29307
+ "solid-ram",
29308
+ "sonic-bat",
29309
+ "south-seal",
29310
+ "spark-robin",
29311
+ "spice-wren",
29312
+ "split-mink",
29313
+ "spring-elk",
29314
+ "squid-ink",
29315
+ "stark-crow",
29316
+ "steel-hawk",
29317
+ "stern-bull",
29318
+ "still-swan",
29319
+ "stone-fox",
29320
+ "storm-eagle",
29321
+ "stout-boar",
29322
+ "stray-cat",
29323
+ "strong-lion",
29324
+ "sun-parrot",
29325
+ "surf-dolphin",
29326
+ "swift-deer",
29327
+ "teal-crane",
29328
+ "terra-wolf",
29329
+ "thick-bear",
29330
+ "thin-spider",
29331
+ "third-owl",
29332
+ "thorn-fox",
29333
+ "tide-seal",
29334
+ "timber-jay",
29335
+ "tiny-wren",
29336
+ "toast-mole",
29337
+ "topaz-hawk",
29338
+ "torch-lynx",
29339
+ "trace-falcon",
29340
+ "true-eagle",
29341
+ "tusk-walrus",
29342
+ "ultra-crane",
29343
+ "umbra-wolf",
29344
+ "unit-fox",
29345
+ "upper-hawk",
29346
+ "urban-jay",
29347
+ "vale-deer",
29348
+ "vast-eagle",
29349
+ "vault-bear",
29350
+ "velvet-owl",
29351
+ "vent-crane",
29352
+ "verse-fox",
29353
+ "vigor-lynx",
29354
+ "vine-parrot",
29355
+ "vivid-swan",
29356
+ "void-raven",
29357
+ "volt-hawk",
29358
+ "vow-falcon",
29359
+ "vintage-jay",
29360
+ "vista-wolf",
29361
+ "vital-hare",
29362
+ "warm-otter",
29363
+ "wave-dolphin",
29364
+ "wax-crane",
29365
+ "west-falcon",
29366
+ "wheat-mouse",
29367
+ "white-tiger",
29368
+ "wide-eagle",
29369
+ "wild-fox",
29370
+ "wind-hawk",
29371
+ "wire-spider",
29372
+ "wise-owl",
29373
+ "wood-thrush",
29374
+ "wool-ram",
29375
+ "wren-song",
29376
+ "wry-crow",
29377
+ "xeno-crane",
29378
+ "xerus-fox",
29379
+ "yarn-robin",
29380
+ "yew-falcon",
29381
+ "young-wolf",
29382
+ "zeal-hawk",
29383
+ "zen-panda",
29384
+ "zero-crane",
29385
+ "zinc-eagle",
29386
+ "zone-fox"
29387
+ ];
29388
+
29389
+ // src/lib/identity.ts
29390
+ var AGENT_ID_FILE = join2(homedir2(), ".conversations", "agent-id");
29391
+ var cachedAutoName = null;
29392
+ function getAutoName() {
29393
+ if (cachedAutoName)
29394
+ return cachedAutoName;
29395
+ try {
29396
+ const name2 = readFileSync(AGENT_ID_FILE, "utf-8").trim();
29397
+ if (name2) {
29398
+ cachedAutoName = name2;
29399
+ return name2;
29400
+ }
29401
+ } catch {}
29402
+ const name = AGENT_NAMES[Math.floor(Math.random() * AGENT_NAMES.length)];
29403
+ cachedAutoName = name;
29404
+ try {
29405
+ mkdirSync2(dirname2(AGENT_ID_FILE), { recursive: true });
29406
+ writeFileSync(AGENT_ID_FILE, name + `
29407
+ `, "utf-8");
29408
+ } catch {}
29409
+ return name;
29410
+ }
29036
29411
  function resolveIdentity(explicit) {
29037
29412
  const explicitValue = explicit?.trim();
29038
29413
  if (explicitValue)
@@ -29040,7 +29415,7 @@ function resolveIdentity(explicit) {
29040
29415
  const envValue = process.env.CONVERSATIONS_AGENT_ID?.trim();
29041
29416
  if (envValue)
29042
29417
  return envValue;
29043
- return "user";
29418
+ return getAutoName();
29044
29419
  }
29045
29420
 
29046
29421
  // src/lib/presence.ts
@@ -29090,10 +29465,26 @@ function listAgents(opts) {
29090
29465
  const rows = db2.prepare(query).all(...params);
29091
29466
  return rows.map(parsePresence);
29092
29467
  }
29468
+ function removePresence(agent) {
29469
+ const db2 = getDb();
29470
+ const result = db2.prepare("DELETE FROM agent_presence WHERE agent = ?").run(agent);
29471
+ return result.changes > 0;
29472
+ }
29473
+ function renameAgent(oldName, newName) {
29474
+ const db2 = getDb();
29475
+ const existing = db2.prepare("SELECT agent FROM agent_presence WHERE agent = ?").get(oldName);
29476
+ if (!existing)
29477
+ return false;
29478
+ const conflict = db2.prepare("SELECT agent FROM agent_presence WHERE agent = ?").get(newName);
29479
+ if (conflict)
29480
+ throw new Error(`Agent "${newName}" already exists`);
29481
+ db2.prepare("UPDATE agent_presence SET agent = ? WHERE agent = ?").run(newName, oldName);
29482
+ return true;
29483
+ }
29093
29484
  // package.json
29094
29485
  var package_default = {
29095
29486
  name: "@hasna/conversations",
29096
- version: "0.1.3",
29487
+ version: "0.1.5",
29097
29488
  description: "Real-time CLI messaging for AI agents",
29098
29489
  type: "module",
29099
29490
  bin: {
@@ -29849,6 +30240,61 @@ server.registerTool("list_agents", {
29849
30240
  content: [{ type: "text", text: JSON.stringify(agents, null, 2) }]
29850
30241
  };
29851
30242
  });
30243
+ server.registerTool("remove_agent", {
30244
+ title: "Remove Agent",
30245
+ description: "Remove an agent from the presence list. Only the agent itself should remove its own presence.",
30246
+ inputSchema: {
30247
+ from: exports_external.string().optional().describe("Your agent ID. Falls back to CONVERSATIONS_AGENT_ID env var."),
30248
+ agent: exports_external.string().optional().describe("Agent to remove (defaults to yourself)")
30249
+ }
30250
+ }, async ({ from: fromParam, agent: targetAgent }) => {
30251
+ const self = resolveIdentity(fromParam);
30252
+ const agent = targetAgent?.trim() || self;
30253
+ const removed = removePresence(agent);
30254
+ if (!removed) {
30255
+ return {
30256
+ content: [{ type: "text", text: `Agent "${agent}" not found` }],
30257
+ isError: true
30258
+ };
30259
+ }
30260
+ return {
30261
+ content: [{ type: "text", text: JSON.stringify({ agent, removed: true }, null, 2) }]
30262
+ };
30263
+ });
30264
+ server.registerTool("rename_agent", {
30265
+ title: "Rename Agent",
30266
+ description: "Rename an agent in the presence list. By default renames yourself.",
30267
+ inputSchema: {
30268
+ from: exports_external.string().optional().describe("Your current agent ID. Falls back to CONVERSATIONS_AGENT_ID env var."),
30269
+ new_name: exports_external.string().describe("The new name for the agent")
30270
+ }
30271
+ }, async ({ from: fromParam, new_name }) => {
30272
+ const oldName = resolveIdentity(fromParam);
30273
+ const newName = new_name.trim();
30274
+ if (!newName) {
30275
+ return {
30276
+ content: [{ type: "text", text: "New name cannot be empty" }],
30277
+ isError: true
30278
+ };
30279
+ }
30280
+ try {
30281
+ const renamed = renameAgent(oldName, newName);
30282
+ if (!renamed) {
30283
+ return {
30284
+ content: [{ type: "text", text: `Agent "${oldName}" not found in presence list` }],
30285
+ isError: true
30286
+ };
30287
+ }
30288
+ return {
30289
+ content: [{ type: "text", text: JSON.stringify({ old_name: oldName, new_name: newName, renamed: true }, null, 2) }]
30290
+ };
30291
+ } catch (e) {
30292
+ return {
30293
+ content: [{ type: "text", text: e.message }],
30294
+ isError: true
30295
+ };
30296
+ }
30297
+ });
29852
30298
  async function startMcpServer() {
29853
30299
  const transport = new StdioServerTransport;
29854
30300
  await server.connect(transport);