@stage-labs/metro 0.1.0-beta.236 → 0.1.0-beta.237

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.
Files changed (26) hide show
  1. package/dist/claude.js +1 -1
  2. package/dist/cli.js +7 -0
  3. package/dist/voice.js +39 -0
  4. package/package.json +1 -1
  5. package/runtime/marketplace/plugin/.claude-plugin/plugin.json +1 -1
  6. package/runtime/node_modules/@metro-labs/daemon/package.json +2 -0
  7. package/runtime/node_modules/@metro-labs/daemon/src/boot/boot.ts +5 -0
  8. package/runtime/node_modules/@metro-labs/daemon/src/claude/session.ts +8 -4
  9. package/runtime/node_modules/@metro-labs/daemon/src/routes/session-apis.ts +2 -0
  10. package/runtime/node_modules/@metro-labs/daemon/src/voice/api.ts +14 -0
  11. package/runtime/node_modules/@metro-labs/daemon/src/voice/audio.ts +153 -0
  12. package/runtime/node_modules/@metro-labs/daemon/src/voice/brain.ts +95 -0
  13. package/runtime/node_modules/@metro-labs/daemon/src/voice/call.ts +154 -0
  14. package/runtime/node_modules/@metro-labs/daemon/src/voice/calls.ts +54 -0
  15. package/runtime/node_modules/@metro-labs/daemon/src/voice/peer.ts +84 -0
  16. package/runtime/node_modules/@metro-labs/daemon/src/voice/scribe.ts +102 -0
  17. package/runtime/node_modules/@metro-labs/daemon/src/voice/speakable.ts +54 -0
  18. package/runtime/node_modules/@metro-labs/daemon/src/voice/speech.ts +91 -0
  19. package/runtime/node_modules/@metro-labs/daemon/src/voice/store.ts +97 -0
  20. package/runtime/node_modules/@metro-labs/daemon/src/voice/talk.ts +234 -0
  21. package/runtime/node_modules/@metro-labs/xmtp/src/actions-conv.ts +2 -1
  22. package/runtime/node_modules/@metro-labs/xmtp/src/actions.ts +11 -1
  23. package/runtime/node_modules/@metro-labs/xmtp/src/codecs.ts +21 -3
  24. package/runtime/node_modules/@metro-labs/xmtp/src/emit-payloads.ts +2 -1
  25. package/runtime/runtime.json +1 -1
  26. package/runtime/stations.json +2 -0
@@ -12,7 +12,7 @@ import {
12
12
  import { convOf, type Account } from './accounts.js';
13
13
  import { resolveMsgId } from './wire.js';
14
14
  import { emitOutbound } from './emit.js';
15
- import { FrameCodec, PollCodec, buildPollContent, encodeDeleteMessage } from './codecs.js';
15
+ import { CallSignalCodec, FrameCodec, PollCodec, buildPollContent, encodeDeleteMessage } from './codecs.js';
16
16
  import { buildFrameContent } from './frames.js';
17
17
  import { convHandlers } from './actions-conv.js';
18
18
  import { messagingAliases } from '@metro-labs/core/stations/messaging-normalize';
@@ -142,6 +142,15 @@ async function remove(id: string, args: Args): Promise<void> {
142
142
  respond(id, { result: { messageId: sentId } });
143
143
  }
144
144
 
145
+ async function callSignal(id: string, args: Args): Promise<void> {
146
+ const { line, signal } = args as { line: string; signal?: unknown };
147
+ if (typeof signal !== 'object' || signal === null) throw badArgs('callSignal requires a signal object');
148
+ const { conv } = await convOf(line);
149
+ if (!conv) throw noConv(line);
150
+ const messageId = await conv.send(new CallSignalCodec().encode(signal as Record<string, unknown>), { shouldPush: false });
151
+ respond(id, { result: { messageId } });
152
+ }
153
+
145
154
  async function sendAttachment(id: string, args: Args): Promise<void> {
146
155
  const { line, name, mime, dataB64 } = args as {
147
156
  line: string;
@@ -223,6 +232,7 @@ const handlers: Record<string, (id: string, args: Args) => Promise<void>> = {
223
232
  react,
224
233
  reply,
225
234
  delete: remove,
235
+ callSignal,
226
236
  sendAttachment,
227
237
  sendImage,
228
238
  ...convHandlers,
@@ -11,17 +11,19 @@ const dec = (e: EncodedContent): unknown =>
11
11
 
12
12
  const makeJsonCodec = <T>(
13
13
  contentType: ContentTypeId,
14
- fallbackFn: (c: T) => string,
14
+ fallbackFn: (c: T) => string | undefined,
15
+ push = true,
15
16
  ) =>
16
17
  class {
17
18
  get contentType() {
18
19
  return contentType;
19
20
  }
20
21
  encode(c: T): EncodedContent {
22
+ const fallback = fallbackFn(c);
21
23
  return {
22
24
  type: contentType,
23
25
  parameters: {},
24
- fallback: fallbackFn(c),
26
+ ...(fallback === undefined ? {} : { fallback }),
25
27
  content: enc(c),
26
28
  };
27
29
  }
@@ -32,7 +34,7 @@ const makeJsonCodec = <T>(
32
34
  return fallbackFn(c);
33
35
  }
34
36
  shouldPush() {
35
- return true;
37
+ return push;
36
38
  }
37
39
  };
38
40
 
@@ -235,6 +237,20 @@ export function encodeDeleteMessage(messageId: string): EncodedContent {
235
237
  };
236
238
  }
237
239
 
240
+ export const CALL_TYPES = new Set(['callInvite', 'callSignal']);
241
+ const callContentType = (typeId: string): ContentTypeId => ({
242
+ authorityId: 'stage.box',
243
+ typeId,
244
+ versionMajor: 1,
245
+ versionMinor: 0,
246
+ });
247
+ const CallInviteCodec = makeJsonCodec<{ video?: unknown }>(callContentType('callInvite'), (c) =>
248
+ c.video === true ? '📞 Video call' : '📞 Voice call',
249
+ );
250
+ export const isCallSignal = (m: { contentType?: ContentTypeId }): boolean =>
251
+ m.contentType?.authorityId === 'stage.box' && m.contentType.typeId === 'callSignal';
252
+ export const CallSignalCodec = makeJsonCodec<Record<string, unknown>>(callContentType('callSignal'), () => undefined, false);
253
+
238
254
  export const CODECS = (): ContentCodec[] => [
239
255
  new PollCodec(),
240
256
  new SignatureRequestCodec(),
@@ -242,4 +258,6 @@ export const CODECS = (): ContentCodec[] => [
242
258
  new FrameCodec(),
243
259
  new FrameActionCodec(),
244
260
  new DeleteRequestCodec(),
261
+ new CallInviteCodec(),
262
+ new CallSignalCodec(),
245
263
  ];
@@ -9,7 +9,7 @@ import {
9
9
  } from './attachments.js';
10
10
  import { reportAttachment } from '@metro-labs/core/stations/train-events';
11
11
  import { sentByMe } from './wire.js';
12
- import { frameActionText, frameFallback, type FrameContent } from './codecs.js';
12
+ import { CALL_TYPES, frameActionText, frameFallback, type FrameContent } from './codecs.js';
13
13
  import { asFrameAction } from './frames.js';
14
14
 
15
15
  export interface EnvelopeCtx {
@@ -336,6 +336,7 @@ export function typedEnvelope(
336
336
  if (typeId === 'reaction') return reactionPayload(base, c as Reaction);
337
337
  if (typeId === 'reply') return replyPayload(base, typeId, c as Reply);
338
338
  if (typeId === 'poll') return pollPayload(base, typeId, c);
339
+ if (typeId !== undefined && CALL_TYPES.has(typeId)) return { ...base, payload: { contentType: typeId, call: c } };
339
340
  return (
340
341
  attachmentEnvelope(base, typeId ?? '', c, ctx) ??
341
342
  refEnvelope(base, typeId, c) ??
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "0.1.0-beta.236"
2
+ "version": "0.1.0-beta.237"
3
3
  }
@@ -1,8 +1,10 @@
1
1
  {
2
2
  "core": {
3
3
  "@modelcontextprotocol/sdk": "^1.12.0",
4
+ "opusscript": "^0.1.1",
4
5
  "pino": "^9.5.0",
5
6
  "pino-pretty": "^13.1.3",
7
+ "werift": "^0.24.4",
6
8
  "ws": "^8.18.0",
7
9
  "zod": "^3.23.8"
8
10
  },