@stage-labs/metro 0.1.0-beta.275 → 0.1.0-beta.276

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stage-labs/metro",
3
- "version": "0.1.0-beta.275",
3
+ "version": "0.1.0-beta.276",
4
4
  "description": "The metro command line: run your agent on this machine, relaying its chat channels and connectors to Claude Code.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metro",
3
- "version": "0.1.0-beta.275",
3
+ "version": "0.1.0-beta.276",
4
4
  "description": "Metro for Claude Code, installed by the metro daemon on this machine: every connector the agent holds as its own MCP server relayed through the daemon, the orchestrator-only guard on the main thread, and the standing rules loaded at each session start. No vendor credential ever sits in a config file.",
5
5
  "author": {
6
6
  "name": "Bonustrack",
@@ -106,9 +106,16 @@ export const saveBufferToCache = async (
106
106
  meta: { mime?: string; name?: string },
107
107
  ): Promise<SavedAttachment> => {
108
108
  assertAttachmentSize(data.length);
109
- const { writeFile } = await import('node:fs/promises');
109
+ const { writeFile, rename, rm } = await import('node:fs/promises');
110
+ const { randomUUID } = await import('node:crypto');
110
111
  const path = await cachePathFor(messageId, index, meta);
111
- await writeFile(path, data);
112
+ const part = `${await cachePathFor(randomUUID(), index, meta)}.part`;
113
+ try {
114
+ await writeFile(part, data);
115
+ await rename(part, path);
116
+ } finally {
117
+ await rm(part, { force: true });
118
+ }
112
119
  return { path, mime: meta.mime, name: meta.name, bytes: data.length };
113
120
  };
114
121
 
@@ -2,7 +2,7 @@ import { IdentifierKind, type DecodedMessage } from '@xmtp/node-sdk';
2
2
  import { accountForCall, convOf, lineOf, type Account } from './accounts.js';
3
3
  import { respond } from '@metro-labs/core/stations/station-runtime';
4
4
  import { resolveMsgId } from './wire.js';
5
- import { TrainError } from '@metro-labs/core/train-error';
5
+ import { serializeTrainError, TrainError } from '@metro-labs/core/train-error';
6
6
  import {
7
7
  buildGroupInfo,
8
8
  buildMemberList,
@@ -80,8 +80,12 @@ async function read(id: string, args: Args): Promise<void> {
80
80
  if (message?.conversationId !== conv.id || isDeleteRequest(message) || isCallSignal(message))
81
81
  throw new TrainError('NOT_FOUND', `message ${messageId} is not in this conversation`);
82
82
  const deleted = deletedByRequests([...all, message], superAdminCheck(conv));
83
- const attachments = deleted.has(message.id) ? [] : await readAttachments(message);
84
- respond(id, { result: { line, account: acct.cfg.id, message: { ...messageOf(acct, message, deleted), attachments } } });
83
+ try {
84
+ const attachments = deleted.has(message.id) ? [] : await readAttachments(message);
85
+ respond(id, { result: { line, account: acct.cfg.id, message: { ...messageOf(acct, message, deleted), attachments } } });
86
+ } catch (error) {
87
+ respond(id, serializeTrainError(error));
88
+ }
85
89
  return;
86
90
  }
87
91
  const lim = Math.min(Math.max(1, limit ?? 20), 200);
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "0.1.0-beta.275"
2
+ "version": "0.1.0-beta.276"
3
3
  }
@@ -106,9 +106,16 @@ export const saveBufferToCache = async (
106
106
  meta: { mime?: string; name?: string },
107
107
  ): Promise<SavedAttachment> => {
108
108
  assertAttachmentSize(data.length);
109
- const { writeFile } = await import('node:fs/promises');
109
+ const { writeFile, rename, rm } = await import('node:fs/promises');
110
+ const { randomUUID } = await import('node:crypto');
110
111
  const path = await cachePathFor(messageId, index, meta);
111
- await writeFile(path, data);
112
+ const part = `${await cachePathFor(randomUUID(), index, meta)}.part`;
113
+ try {
114
+ await writeFile(part, data);
115
+ await rename(part, path);
116
+ } finally {
117
+ await rm(part, { force: true });
118
+ }
112
119
  return { path, mime: meta.mime, name: meta.name, bytes: data.length };
113
120
  };
114
121
 
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.0-beta.275",
2
+ "version": "0.1.0-beta.276",
3
3
  "dependencies": {
4
4
  "@anthropic-ai/claude-agent-sdk": "0.3.287",
5
5
  "@modelcontextprotocol/sdk": "^1.29.0",