@frequencytalk/agent 0.1.0 → 0.1.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 +3 -1
- package/dist/cli.js +13 -5
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +24 -6
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.js +7 -4
- package/dist/mcp/server.js.map +1 -1
- package/package.json +1 -1
- package/server.json +15 -15
package/README.md
CHANGED
|
@@ -37,7 +37,9 @@ const { frequency } = await agent.frequencies.tuneByNumber(118025);
|
|
|
37
37
|
const session = await agent.session(frequency!.id);
|
|
38
38
|
await agent.speaker(session).speakWav("hello.wav");
|
|
39
39
|
|
|
40
|
-
// Hear the reply for ten seconds.
|
|
40
|
+
// Hear the reply for ten seconds. Receiving is off until you listen to a channel. Your own
|
|
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);
|
|
41
43
|
const listener = agent.listener(session);
|
|
42
44
|
await listener.start();
|
|
43
45
|
await new Promise((r) => setTimeout(r, 10_000));
|
package/dist/cli.js
CHANGED
|
@@ -5115,18 +5115,21 @@ var Speaker = class {
|
|
|
5115
5115
|
|
|
5116
5116
|
// src/listener.ts
|
|
5117
5117
|
var Listener = class {
|
|
5118
|
-
constructor(session) {
|
|
5118
|
+
constructor(session, options = {}) {
|
|
5119
5119
|
this.session = session;
|
|
5120
|
+
this.options = options;
|
|
5120
5121
|
}
|
|
5121
5122
|
session;
|
|
5123
|
+
options;
|
|
5122
5124
|
codec = null;
|
|
5123
5125
|
streams = /* @__PURE__ */ new Map();
|
|
5124
5126
|
detach = null;
|
|
5125
|
-
/** Start recording everything the session hears. */
|
|
5127
|
+
/** Start recording everything the session hears (its own stream excepted, see `ListenerOptions`). */
|
|
5126
5128
|
async start() {
|
|
5127
5129
|
this.codec ??= await createOpus();
|
|
5128
5130
|
const codec = this.codec;
|
|
5129
5131
|
const handler = (frame) => {
|
|
5132
|
+
if (!this.options.includeOwn && frame.connectionId === this.session.connectionId) return;
|
|
5130
5133
|
let s = this.streams.get(frame.streamId);
|
|
5131
5134
|
if (!s) {
|
|
5132
5135
|
s = { connectionId: frame.connectionId, chunks: [], lastTimestamp: null, first: frame.timestamp };
|
|
@@ -5221,8 +5224,8 @@ var Agent = class _Agent {
|
|
|
5221
5224
|
speaker(session) {
|
|
5222
5225
|
return new Speaker(session);
|
|
5223
5226
|
}
|
|
5224
|
-
listener(session) {
|
|
5225
|
-
return new Listener(session);
|
|
5227
|
+
listener(session, options) {
|
|
5228
|
+
return new Listener(session, options);
|
|
5226
5229
|
}
|
|
5227
5230
|
async close() {
|
|
5228
5231
|
for (const id of [...this.sessions.keys()]) await this.closeSession(id);
|
|
@@ -5417,6 +5420,10 @@ async function startMcpServer(options = {}) {
|
|
|
5417
5420
|
async function main() {
|
|
5418
5421
|
const argv = process.argv.slice(2);
|
|
5419
5422
|
const cmd = argv[0];
|
|
5423
|
+
if (argv.includes("--help") || argv.includes("-h") || cmd === "help") {
|
|
5424
|
+
console.log(USAGE);
|
|
5425
|
+
return;
|
|
5426
|
+
}
|
|
5420
5427
|
const at = argv.indexOf("--base-url");
|
|
5421
5428
|
const baseUrl = at === -1 ? void 0 : argv[at + 1];
|
|
5422
5429
|
if (cmd === "mcp") {
|
|
@@ -5433,9 +5440,10 @@ async function main() {
|
|
|
5433
5440
|
}
|
|
5434
5441
|
return;
|
|
5435
5442
|
}
|
|
5436
|
-
console.error(
|
|
5443
|
+
console.error(USAGE);
|
|
5437
5444
|
process.exit(2);
|
|
5438
5445
|
}
|
|
5446
|
+
var USAGE = "usage: frequencytalk-agent <mcp|whoami> [--base-url URL] [--help]\n mcp run the MCP server on stdio (the key from FREQUENCY_AGENT_KEY or ~/.config/frequencytalk/agent.json, never argv)\n whoami sign in with the key and print the account and its credit";
|
|
5439
5447
|
main().catch((err) => {
|
|
5440
5448
|
console.error(err instanceof Error ? err.message : String(err));
|
|
5441
5449
|
process.exit(1);
|