@zoralabs/cli 1.3.0 → 1.4.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.
|
@@ -96,6 +96,7 @@ var createMessagingClient = async (spec, options = {}) => {
|
|
|
96
96
|
sentAtMs: Number(message.sentAtNs / 1000000n)
|
|
97
97
|
});
|
|
98
98
|
const findDm = (peerAddress) => client.conversations.fetchDmByIdentifier(toIdentifier(peerAddress));
|
|
99
|
+
let streamAbort;
|
|
99
100
|
return {
|
|
100
101
|
address,
|
|
101
102
|
async sync(consent) {
|
|
@@ -156,7 +157,34 @@ var createMessagingClient = async (spec, options = {}) => {
|
|
|
156
157
|
}
|
|
157
158
|
await dm.updateConsentState(CONSENT_TO_SDK[consent]);
|
|
158
159
|
},
|
|
160
|
+
streamAllMessages() {
|
|
161
|
+
const ctrl = new AbortController();
|
|
162
|
+
streamAbort = ctrl;
|
|
163
|
+
const outerClient = client;
|
|
164
|
+
async function* generate() {
|
|
165
|
+
await outerClient.conversations.sync();
|
|
166
|
+
const stream = await outerClient.conversations.streamAllMessages();
|
|
167
|
+
for await (const message of stream) {
|
|
168
|
+
if (ctrl.signal.aborted) break;
|
|
169
|
+
let convo = outerClient.conversations.listDms().find((dm) => dm.id === message.conversationId);
|
|
170
|
+
if (!convo) {
|
|
171
|
+
await outerClient.conversations.sync();
|
|
172
|
+
convo = outerClient.conversations.listDms().find((dm) => dm.id === message.conversationId);
|
|
173
|
+
if (!convo) continue;
|
|
174
|
+
}
|
|
175
|
+
const addrByInbox = await addressMapForDm(convo);
|
|
176
|
+
const dmMessage = toMessage(message, addrByInbox);
|
|
177
|
+
const peerAddr = addrByInbox.get(convo.peerInboxId) ?? null;
|
|
178
|
+
yield { ...dmMessage, peerAddress: peerAddr };
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return generate();
|
|
182
|
+
},
|
|
159
183
|
async close() {
|
|
184
|
+
if (streamAbort) {
|
|
185
|
+
streamAbort.abort();
|
|
186
|
+
streamAbort = void 0;
|
|
187
|
+
}
|
|
160
188
|
}
|
|
161
189
|
};
|
|
162
190
|
};
|
package/dist/index.js
CHANGED
|
@@ -1469,7 +1469,7 @@ var getClient = () => {
|
|
|
1469
1469
|
return client;
|
|
1470
1470
|
};
|
|
1471
1471
|
var commonProperties = () => ({
|
|
1472
|
-
cli_version: true ? "1.
|
|
1472
|
+
cli_version: true ? "1.4.0" : "development",
|
|
1473
1473
|
os: process.platform,
|
|
1474
1474
|
arch: process.arch,
|
|
1475
1475
|
node_version: process.version
|
|
@@ -7139,7 +7139,7 @@ var resolveClient = async (json) => {
|
|
|
7139
7139
|
);
|
|
7140
7140
|
}
|
|
7141
7141
|
const token = await auth.getApiToken();
|
|
7142
|
-
const { createMessagingClient } = await import("./client-
|
|
7142
|
+
const { createMessagingClient } = await import("./client-M3K6L2ZM.js");
|
|
7143
7143
|
const client2 = await createMessagingClient(auth.signerSpec, {
|
|
7144
7144
|
// Register the CLI installation with the Zora backend so it shows up in the
|
|
7145
7145
|
// user's device list and counts against the install cap. Best-effort — see
|
|
@@ -7397,6 +7397,64 @@ dmCommand.command("send").description(
|
|
|
7397
7397
|
await client2.close();
|
|
7398
7398
|
}
|
|
7399
7399
|
});
|
|
7400
|
+
dmCommand.command("listen").description(
|
|
7401
|
+
"Stream incoming DMs in real time (no polling \u2014 uses XMTP's server-push stream to avoid rate limits)"
|
|
7402
|
+
).action(async function() {
|
|
7403
|
+
const json = getJson(this);
|
|
7404
|
+
const { client: client2 } = await resolveClient(json);
|
|
7405
|
+
if (!json) {
|
|
7406
|
+
console.log("Listening for new DMs\u2026 (Ctrl+C to stop)\n");
|
|
7407
|
+
}
|
|
7408
|
+
const shutdown = () => {
|
|
7409
|
+
client2.close().finally(() => process.exit(0));
|
|
7410
|
+
};
|
|
7411
|
+
process.on("SIGINT", shutdown);
|
|
7412
|
+
process.on("SIGTERM", shutdown);
|
|
7413
|
+
const labelCache = /* @__PURE__ */ new Map();
|
|
7414
|
+
const cachedPeerLabel = async (peer) => {
|
|
7415
|
+
const cached = labelCache.get(peer);
|
|
7416
|
+
if (cached) return cached;
|
|
7417
|
+
const label = await peerLabel(peer);
|
|
7418
|
+
labelCache.set(peer, label);
|
|
7419
|
+
return label;
|
|
7420
|
+
};
|
|
7421
|
+
let messageCount = 0;
|
|
7422
|
+
track("cli_dm_listen_start", {
|
|
7423
|
+
output_format: json ? "json" : "text"
|
|
7424
|
+
});
|
|
7425
|
+
try {
|
|
7426
|
+
for await (const msg of client2.streamAllMessages()) {
|
|
7427
|
+
if (msg.fromSelf) continue;
|
|
7428
|
+
messageCount++;
|
|
7429
|
+
const who = msg.peerAddress ? await cachedPeerLabel(msg.peerAddress) : "unknown";
|
|
7430
|
+
if (json) {
|
|
7431
|
+
console.log(
|
|
7432
|
+
JSON.stringify({
|
|
7433
|
+
from: who,
|
|
7434
|
+
address: msg.peerAddress,
|
|
7435
|
+
text: msg.text,
|
|
7436
|
+
contentType: msg.contentType,
|
|
7437
|
+
sentAt: new Date(msg.sentAtMs).toISOString()
|
|
7438
|
+
})
|
|
7439
|
+
);
|
|
7440
|
+
} else {
|
|
7441
|
+
const body = msg.text ? sanitizeMessageText(msg.text) : `[${msg.contentType}]`;
|
|
7442
|
+
const [first = "", ...rest] = body.split("\n");
|
|
7443
|
+
console.log(
|
|
7444
|
+
`\u2190 ${who} ${dim(formatAge(msg.sentAtMs))}
|
|
7445
|
+
${first}`
|
|
7446
|
+
);
|
|
7447
|
+
for (const line of rest) console.log(` ${line}`);
|
|
7448
|
+
}
|
|
7449
|
+
}
|
|
7450
|
+
} finally {
|
|
7451
|
+
track("cli_dm_listen_end", {
|
|
7452
|
+
output_format: json ? "json" : "text",
|
|
7453
|
+
message_count: messageCount
|
|
7454
|
+
});
|
|
7455
|
+
await client2.close();
|
|
7456
|
+
}
|
|
7457
|
+
});
|
|
7400
7458
|
var consentSubcommand = (name, consent, description) => {
|
|
7401
7459
|
dmCommand.command(name).description(description).argument("<address>", "Zora handle (@name) or 0x address").action(async function(address) {
|
|
7402
7460
|
const json = getJson(this);
|
|
@@ -11630,6 +11688,13 @@ import { resolve, join as join3 } from "path";
|
|
|
11630
11688
|
var DEFAULT_SKILLS_BASE_URL = "https://agents.zora.com/skill";
|
|
11631
11689
|
var getSkillsBaseUrl = () => process.env.ZORA_SKILLS_BASE_URL || DEFAULT_SKILLS_BASE_URL;
|
|
11632
11690
|
var SKILLS = [
|
|
11691
|
+
// Core
|
|
11692
|
+
{
|
|
11693
|
+
name: "cli",
|
|
11694
|
+
category: "Core",
|
|
11695
|
+
description: "The agent's full interface to Zora \u2014 set up an identity and trade, browse, look up coins, send tokens, and handle DMs from the CLI",
|
|
11696
|
+
integrity: "sha256-PyvDxJ7pbQ8PI5Lg/p4k7ryJNGHapqt9lRSjAV1KBDY="
|
|
11697
|
+
},
|
|
11633
11698
|
// Onboarding
|
|
11634
11699
|
{
|
|
11635
11700
|
name: "onboarding",
|
|
@@ -12481,7 +12546,7 @@ async function maybeNotifyNewDms() {
|
|
|
12481
12546
|
privateKey: normalizeKey(key)
|
|
12482
12547
|
});
|
|
12483
12548
|
const auth = createSmartWalletAuth(provider);
|
|
12484
|
-
const { createMessagingClient } = await import("./client-
|
|
12549
|
+
const { createMessagingClient } = await import("./client-M3K6L2ZM.js");
|
|
12485
12550
|
const client2 = await createMessagingClient(auth.signerSpec);
|
|
12486
12551
|
try {
|
|
12487
12552
|
await client2.sync(["unknown"]);
|
|
@@ -12522,7 +12587,7 @@ import { jsx as jsx24 } from "react/jsx-runtime";
|
|
|
12522
12587
|
if (process.env.ZORA_API_TARGET) {
|
|
12523
12588
|
setApiBaseUrl(process.env.ZORA_API_TARGET);
|
|
12524
12589
|
}
|
|
12525
|
-
var version = true ? "1.
|
|
12590
|
+
var version = true ? "1.4.0" : JSON.parse(
|
|
12526
12591
|
readFileSync5(new URL("../package.json", import.meta.url), "utf-8")
|
|
12527
12592
|
).version;
|
|
12528
12593
|
function styledHelpWriteOut(showHeader) {
|
|
@@ -12580,7 +12645,11 @@ var buildProgram = () => {
|
|
|
12580
12645
|
}
|
|
12581
12646
|
};
|
|
12582
12647
|
applyToSubcommands(program2);
|
|
12583
|
-
const argOptionalCommands = /* @__PURE__ */ new Set([
|
|
12648
|
+
const argOptionalCommands = /* @__PURE__ */ new Set([
|
|
12649
|
+
"profile",
|
|
12650
|
+
"agent budget set",
|
|
12651
|
+
"skills add"
|
|
12652
|
+
]);
|
|
12584
12653
|
const fullCommandPath = (cmd) => {
|
|
12585
12654
|
const parts = [];
|
|
12586
12655
|
let c = cmd;
|