@cello-protocol/cli 0.0.308 → 0.0.310

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.js CHANGED
@@ -40,7 +40,7 @@ function usageLine(op) {
40
40
  return p.required ? text : `[${text}]`;
41
41
  });
42
42
  const signal = op.command === "send" ? [SIGNAL_FLAGS] : [];
43
- const scoped = [...(op.scoped ? ["[--agent <name-or-id>]"] : []), ...(op.acts ? ["[--force]"] : []), ...(op.plain ? ["[--json]"] : [])];
43
+ const scoped = [...(op.scoped ? ["[--agent <name-or-id>]"] : []), ...(op.acts ? ["[--force]"] : []), ...(op.plain ? ["[--json]"] : []), ...(op.command === "agents" ? ["[--labels]"] : [])];
44
44
  return `cello ${[op.command, ...positional, ...signal, ...flags, ...scoped].join(" ")}`;
45
45
  }
46
46
  function commandHelp(op) {
@@ -79,7 +79,7 @@ Usage: cello <command> [args]
79
79
  ${sections.join("\n\n")}
80
80
 
81
81
  Run 'cello <command> --help' for details on any command.
82
- Commands print JSON on one line, and --pretty indents it.
82
+ Commands print indented JSON.
83
83
  A failure prints {"error","message"} on standard error and exits ${EXIT_REFUSED}.
84
84
  A usage mistake exits ${EXIT_USAGE}, and wait exits ${EXIT_TIMEOUT} when its time runs out.
85
85
  Any agent that can run a shell command can use all of this with no MCP.
@@ -123,10 +123,13 @@ function readValue(param, raw) {
123
123
  usageError(`${flag(param.name)} must be one of ${param.allowed.join(", ")}, got ${raw}`);
124
124
  return raw;
125
125
  }
126
- // One line by default, because the usual reader is a program or an agent paying for every character.
127
- let pretty = false;
126
+ // Indented always: the few extra characters cost an agent next to nothing, and a person can read it.
128
127
  let asJson = false;
129
- const render = (value) => `${pretty ? JSON.stringify(value, null, 2) : JSON.stringify(value)}\n`;
128
+ // cello agents --labels: one line per agent, name then agent_id, for pasting into the account site.
129
+ // The person carries it there; the daemon never sends names anywhere.
130
+ let labels = false;
131
+ const render = (value) => `${JSON.stringify(value, null, 2)}\n`;
132
+ const labelLines = (value) => (value.agents ?? []).map((a) => `${a.name} ${a.agent_id}\n`).join("");
130
133
  // Fails on anything it doesn't recognise, so a mistyped flag can't quietly change what a command does.
131
134
  function parse(op, args) {
132
135
  const params = {};
@@ -143,8 +146,8 @@ function parse(op, args) {
143
146
  flagsEnded = true;
144
147
  continue;
145
148
  }
146
- if (arg === "--pretty") {
147
- pretty = true;
149
+ if (op.command === "agents" && arg === "--labels") {
150
+ labels = true;
148
151
  continue;
149
152
  }
150
153
  if (op.plain && arg === "--json") {
@@ -583,7 +586,7 @@ async function main() {
583
586
  }
584
587
  const result = answer;
585
588
  client.close();
586
- process.stdout.write(op.plain && !asJson ? op.plain(result) : render(result));
589
+ process.stdout.write(labels ? labelLines(result) : op.plain && !asJson ? op.plain(result) : render(result));
587
590
  // The id, never the name: a name is a label, and it could later mean a different agent.
588
591
  if (op.method === "use_agent")
589
592
  writeFileSync(currentAgentFile(), `${result.agent_id}\n`, { mode: 0o600 });
@@ -121,6 +121,27 @@ function stopListening(socket) {
121
121
  }
122
122
  }
123
123
  }
124
+ // A Claude session (caller mcp:<uuid>) talks over one long-lived connection, so when its last one closes the session is
125
+ // gone, and every hold it took goes with it, however it was taken. Identity still comes from each call; only the hold ends.
126
+ // The command line and named callers like hermes may connect per call, so their holds last until they let go.
127
+ const sessionSockets = new Map();
128
+ function noteSessionSocket(socket, caller) {
129
+ if (typeof caller !== "string" || !caller.startsWith("mcp:"))
130
+ return;
131
+ const set = sessionSockets.get(caller) ?? new Set();
132
+ set.add(socket);
133
+ sessionSockets.set(caller, set);
134
+ }
135
+ function releaseSessionHolds(socket) {
136
+ for (const [caller, set] of sessionSockets) {
137
+ if (!set.delete(socket) || set.size > 0)
138
+ continue;
139
+ sessionSockets.delete(caller);
140
+ for (const [agent, holder] of holders)
141
+ if (holder.caller === caller)
142
+ holders.delete(agent);
143
+ }
144
+ }
124
145
  let shuttingDown = false;
125
146
  function shutdown() {
126
147
  if (shuttingDown)
@@ -483,6 +504,7 @@ const ipc = createServer((socket) => {
483
504
  socket.destroy();
484
505
  return;
485
506
  }
507
+ noteSessionSocket(socket, request.params?.["caller"]);
486
508
  handle(socket, request.method, request.params ?? {}).then((result) => {
487
509
  if (result instanceof AfterWrite)
488
510
  respond({ id: request.id, ok: true, result: result.result }, result.commit);
@@ -501,6 +523,7 @@ const ipc = createServer((socket) => {
501
523
  socket.on("close", () => {
502
524
  stopListening(socket);
503
525
  sockets.delete(socket);
526
+ releaseSessionHolds(socket);
504
527
  });
505
528
  socket.on("error", () => undefined);
506
529
  });
@@ -240,7 +240,7 @@ The code stops agents that are simply trying commands, and pipes and scripts wit
240
240
  summary: "List your agents, and whether each one is online.",
241
241
  scoped: false,
242
242
  acts: false,
243
- description: "List the agents on this machine, whether each one is online, and how much is unread for each.",
243
+ description: "List the agents on this machine, whether each one is online, and how much is unread for each. With --labels, print one line per agent, its name then its agent_id, to paste into the account site so it can show your agents' names. Nothing is sent: you carry it there.",
244
244
  params: [],
245
245
  },
246
246
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cello-protocol/cli",
3
- "version": "0.0.308",
3
+ "version": "0.0.310",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=24.7"