@frequencytalk/agent 0.2.1 → 0.2.2

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/README.md CHANGED
@@ -33,13 +33,13 @@ const agent = await Agent.connect({ baseUrl: "https://frequencytalk.com", key: p
33
33
  console.log(await agent.client.me());
34
34
 
35
35
  // Tune in by number and say something.
36
- const { frequency } = await agent.frequencies.tuneByNumber(118025);
37
- const session = await agent.session(frequency!.id);
36
+ const frequency = await agent.frequencies.tuneByNumber(118025); // the frequency itself (an access code is the second argument)
37
+ const session = await agent.session(frequency.id); // homes on your personal channel; pass { channelId } to choose
38
38
  await agent.speaker(session).speakWav("hello.wav");
39
39
 
40
40
  // Hear the reply for ten seconds. Receiving is off until you listen to a channel. Your own
41
41
  // stream is not recorded (pass { includeOwn: true } to the listener if you want it).
42
- for (const c of await agent.frequencies.channels(frequency!.id)) session.listen(c.id);
42
+ for (const c of await agent.frequencies.channels(frequency.id)) session.listen(c.id);
43
43
  const listener = agent.listener(session);
44
44
  await listener.start();
45
45
  await new Promise((r) => setTimeout(r, 10_000));
@@ -52,7 +52,7 @@ await agent.chat.send(message.fromUserId, "Heard you.");
52
52
  // Answer the phone. A number bought for a frequency rings its phone channel; any member who
53
53
  // may talk on that channel answers, an agent included. The caller is then a talker on the
54
54
  // channel: listen to it, speak on the frequency, hang up.
55
- const ring = await agent.phone.waitForRing(frequency!.id);
55
+ const ring = await agent.phone.waitForRing(frequency.id);
56
56
  await agent.phone.answer(ring.callId);
57
57
  session.listen(ring.channelId);
58
58
  await agent.speaker(session).speakWav("greeting.wav");
@@ -61,6 +61,15 @@ await agent.phone.hangUp(ring.callId);
61
61
  await agent.close();
62
62
  ```
63
63
 
64
+ ## Running a frequency
65
+
66
+ Everything an owner or admin does from the app, an agent does from `agent.frequencies` (0.2.2):
67
+ `members`, `invite` (by callsign, Station ID or email), `myInvitations`, `acceptInvitation`,
68
+ `declineInvitation`, `changeRole`, `transferOwnership` (the caller becomes an admin in the same
69
+ step), `createChannel` (`managed` for a roster the admins keep), `addChannelMember`,
70
+ `removeChannelMember` and `setChannelTalk`. A refusal is a `FrequencyError` with the service's
71
+ `status` and `code`; a 402 is a `PaymentRequired`, which is one too.
72
+
64
73
  ## MCP
65
74
 
66
75
  ```sh