@openape/apes 0.26.0 → 0.27.0

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
@@ -2443,34 +2443,33 @@ async function chatFetch(bearer, path2, init) {
2443
2443
  }
2444
2444
  return await res.json();
2445
2445
  }
2446
- async function findRoomByName(bearer, name) {
2447
- const rooms = await chatFetch(bearer, "/api/rooms");
2448
- return rooms.find((r) => r.name === name) ?? null;
2446
+ async function listRooms(bearer) {
2447
+ return chatFetch(bearer, "/api/rooms");
2449
2448
  }
2450
- async function createRoom(bearer, name) {
2451
- return chatFetch(bearer, "/api/rooms", {
2452
- method: "POST",
2453
- body: { name, kind: "channel", members: [] }
2454
- });
2449
+ async function listMembers(bearer, roomId) {
2450
+ return chatFetch(bearer, `/api/rooms/${encodeURIComponent(roomId)}/members`);
2455
2451
  }
2456
- async function addMember(bearer, roomId, email, role = "member") {
2457
- await chatFetch(bearer, `/api/rooms/${encodeURIComponent(roomId)}/members`, {
2452
+ async function findExistingDm(bearer, callerEmail, peerEmail) {
2453
+ const rooms = await listRooms(bearer);
2454
+ for (const room of rooms) {
2455
+ if (room.kind !== "dm") continue;
2456
+ const members = await listMembers(bearer, room.id);
2457
+ if (members.length !== 2) continue;
2458
+ const emails = new Set(members.map((m) => m.userEmail.toLowerCase()));
2459
+ if (emails.has(callerEmail.toLowerCase()) && emails.has(peerEmail.toLowerCase())) {
2460
+ return room;
2461
+ }
2462
+ }
2463
+ return null;
2464
+ }
2465
+ async function ensureDmWith(opts) {
2466
+ const existing = await findExistingDm(opts.callerBearer, opts.callerEmail, opts.peerEmail);
2467
+ if (existing) return { roomId: existing.id, created: false };
2468
+ const room = await chatFetch(opts.callerBearer, "/api/rooms", {
2458
2469
  method: "POST",
2459
- body: { email, role }
2470
+ body: { name: opts.peerEmail, kind: "dm", members: [opts.peerEmail] }
2460
2471
  });
2461
- }
2462
- async function ensureRoomMembership(opts) {
2463
- const existing = await findRoomByName(opts.callerBearer, opts.roomName);
2464
- let room;
2465
- let created = false;
2466
- if (existing) {
2467
- room = existing;
2468
- } else {
2469
- room = await createRoom(opts.callerBearer, opts.roomName);
2470
- created = true;
2471
- }
2472
- await addMember(opts.callerBearer, room.id, opts.agentEmail);
2473
- return { roomId: room.id, created };
2472
+ return { roomId: room.id, created: true };
2474
2473
  }
2475
2474
 
2476
2475
  // src/lib/keygen.ts
@@ -2584,7 +2583,7 @@ function buildBridgeStartScript() {
2584
2583
  # Slim launcher \u2014 install stack lives in spawn, not here.
2585
2584
  set -euo pipefail
2586
2585
 
2587
- export PATH="$HOME/.bun/install/global/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
2586
+ export PATH="$HOME/.bun/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
2588
2587
 
2589
2588
  # Refresh IdP token. Agents auth via SSH-key signing \u2014 the cached IdP
2590
2589
  # token has no refresh_token and expires after ~1h. Re-running apes
@@ -2681,7 +2680,7 @@ function buildBridgePlist(agentName, homeDir) {
2681
2680
  <key>HOME</key>
2682
2681
  <string>${homeDir}</string>
2683
2682
  <key>PATH</key>
2684
- <string>${homeDir}/.bun/install/global/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin</string>
2683
+ <string>${homeDir}/.bun/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin</string>
2685
2684
  </dict>
2686
2685
  </dict>
2687
2686
  </plist>
@@ -2727,10 +2726,6 @@ var spawnAgentCommand = defineCommand23({
2727
2726
  "bridge-base-url": {
2728
2727
  type: "string",
2729
2728
  description: "Override LITELLM_BASE_URL for the bridge (default: read from ~/litellm/.env or http://127.0.0.1:4000/v1)."
2730
- },
2731
- "bridge-room": {
2732
- type: "string",
2733
- description: "After spawn, create (or find) a chat.openape.ai room with this name and add the new agent as a member. Uses the spawning user's IdP bearer."
2734
2729
  }
2735
2730
  },
2736
2731
  async run({ args }) {
@@ -2831,22 +2826,20 @@ and try again.`
2831
2826
  consola21.info("You will be asked to approve the as=root grant in your DDISA inbox; this command blocks until you do.");
2832
2827
  execFileSync4(apes, ["run", "--as", "root", "--wait", "--", "bash", scriptPath], { stdio: "inherit" });
2833
2828
  consola21.success(`Agent ${name} spawned.`);
2834
- const bridgeRoom = typeof args["bridge-room"] === "string" ? args["bridge-room"] : void 0;
2835
- if (args.bridge && bridgeRoom) {
2829
+ if (args.bridge) {
2836
2830
  try {
2837
- consola21.start(`Inviting agent into chat.openape.ai room "${bridgeRoom}"\u2026`);
2838
- const result = await ensureRoomMembership({
2831
+ consola21.start("Setting up direct chat with the agent\u2026");
2832
+ const result = await ensureDmWith({
2839
2833
  callerBearer: auth.access_token,
2840
- roomName: bridgeRoom,
2841
- agentEmail: registration.email
2834
+ callerEmail: auth.email,
2835
+ peerEmail: registration.email
2842
2836
  });
2843
2837
  consola21.success(
2844
- result.created ? `Created room ${result.roomId} and added ${registration.email}` : `Room ${result.roomId} already existed; added ${registration.email}`
2838
+ result.created ? `Created direct chat with ${registration.email}` : `Direct chat with ${registration.email} already existed`
2845
2839
  );
2846
2840
  } catch (err) {
2847
2841
  const msg = err instanceof Error ? err.message : String(err);
2848
- consola21.warn(`Could not auto-create / invite to chat room: ${msg}`);
2849
- consola21.info("Add the agent manually with: ape-chat members add <agent-email>");
2842
+ consola21.warn(`Could not auto-create direct chat: ${msg}`);
2850
2843
  }
2851
2844
  }
2852
2845
  console.log("");
@@ -4155,7 +4148,7 @@ var mcpCommand = defineCommand32({
4155
4148
  if (transport !== "stdio" && transport !== "sse") {
4156
4149
  throw new Error('Transport must be "stdio" or "sse"');
4157
4150
  }
4158
- const { startMcpServer } = await import("./server-M55Z6QYF.js");
4151
+ const { startMcpServer } = await import("./server-TNWUMXYI.js");
4159
4152
  await startMcpServer(transport, port);
4160
4153
  }
4161
4154
  });
@@ -4793,7 +4786,7 @@ async function bestEffortGrantCount(idp) {
4793
4786
  }
4794
4787
  }
4795
4788
  async function runHealth(args) {
4796
- const version = true ? "0.26.0" : "0.0.0";
4789
+ const version = true ? "0.27.0" : "0.0.0";
4797
4790
  const auth = loadAuth();
4798
4791
  if (!auth) {
4799
4792
  throw new CliError("Not logged in. Run `apes login` first.", 1);
@@ -5066,10 +5059,10 @@ if (shellRewrite) {
5066
5059
  if (shellRewrite.action === "rewrite") {
5067
5060
  process.argv = shellRewrite.argv;
5068
5061
  } else if (shellRewrite.action === "version") {
5069
- console.log(`ape-shell ${"0.26.0"} (OpenApe DDISA shell wrapper)`);
5062
+ console.log(`ape-shell ${"0.27.0"} (OpenApe DDISA shell wrapper)`);
5070
5063
  process.exit(0);
5071
5064
  } else if (shellRewrite.action === "help") {
5072
- console.log(`ape-shell ${"0.26.0"} \u2014 OpenApe DDISA shell wrapper`);
5065
+ console.log(`ape-shell ${"0.27.0"} \u2014 OpenApe DDISA shell wrapper`);
5073
5066
  console.log("");
5074
5067
  console.log("Usage:");
5075
5068
  console.log(" ape-shell Start interactive grant-mediated REPL");
@@ -5127,7 +5120,7 @@ var configCommand = defineCommand44({
5127
5120
  var main = defineCommand44({
5128
5121
  meta: {
5129
5122
  name: "apes",
5130
- version: "0.26.0",
5123
+ version: "0.27.0",
5131
5124
  description: "Unified CLI for OpenApe"
5132
5125
  },
5133
5126
  subCommands: {
@@ -5182,7 +5175,7 @@ async function maybeRefreshAuth() {
5182
5175
  }
5183
5176
  }
5184
5177
  await maybeRefreshAuth();
5185
- await maybeWarnStaleVersion("0.26.0").catch(() => {
5178
+ await maybeWarnStaleVersion("0.27.0").catch(() => {
5186
5179
  });
5187
5180
  runMain(main).catch((err) => {
5188
5181
  if (err instanceof CliExit) {