@pingagent/sdk 0.1.3 → 0.1.5
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/bin/pingagent.js +34 -4
- package/dist/chunk-V4IHFEJC.js +1447 -0
- package/dist/chunk-Y67SYMD4.js +1456 -0
- package/dist/chunk-YS54ADYV.js +1350 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +1 -1
- package/dist/web-server.js +1 -1
- package/package.json +1 -1
- package/src/history.ts +43 -1
- package/src/ws-subscription.ts +152 -0
package/bin/pingagent.js
CHANGED
|
@@ -491,7 +491,7 @@ program
|
|
|
491
491
|
}
|
|
492
492
|
|
|
493
493
|
if (opts.json) {
|
|
494
|
-
console.log(JSON.stringify(sendRes, null, 2));
|
|
494
|
+
console.log(JSON.stringify({ conversation_id: openRes.data.conversation_id, ...sendRes }, null, 2));
|
|
495
495
|
} else {
|
|
496
496
|
console.log(`Sent: ${sendRes.data?.message_id} (seq: ${sendRes.data?.seq})`);
|
|
497
497
|
}
|
|
@@ -563,7 +563,7 @@ program
|
|
|
563
563
|
if (!openRes.data.trusted) {
|
|
564
564
|
await client.sendContactRequest(openRes.data.conversation_id, opts.message);
|
|
565
565
|
if (opts.json) {
|
|
566
|
-
console.log(JSON.stringify({ sent: 'contact_request', conversation_id: openRes.data.conversation_id }));
|
|
566
|
+
console.log(JSON.stringify({ sent: 'contact_request', conversation_id: openRes.data.conversation_id }, null, 2));
|
|
567
567
|
} else {
|
|
568
568
|
console.log('Contact request sent with your message. They need to approve before further messages are delivered.');
|
|
569
569
|
}
|
|
@@ -577,9 +577,17 @@ program
|
|
|
577
577
|
process.exit(1);
|
|
578
578
|
}
|
|
579
579
|
if (opts.json) {
|
|
580
|
-
console.log(JSON.stringify({
|
|
580
|
+
console.log(JSON.stringify({
|
|
581
|
+
conversation_id: openRes.data.conversation_id,
|
|
582
|
+
message_id: sendRes.data?.message_id,
|
|
583
|
+
seq: sendRes.data?.seq ?? null,
|
|
584
|
+
receipt: sendRes.data?.receipt ?? null,
|
|
585
|
+
}, null, 2));
|
|
581
586
|
} else {
|
|
582
587
|
console.log(`Sent: ${sendRes.data?.message_id} (seq: ${sendRes.data?.seq})`);
|
|
588
|
+
if (sendRes.data?.seq == null) {
|
|
589
|
+
console.log(`Note: seq is server-assigned and may be omitted by some relays. Fetch inbox to confirm ordering: pingagent inbox --conversation ${openRes.data.conversation_id} --since-seq 0 --limit 1 --box all`);
|
|
590
|
+
}
|
|
583
591
|
}
|
|
584
592
|
});
|
|
585
593
|
|
|
@@ -1077,6 +1085,10 @@ history
|
|
|
1077
1085
|
.description('List messages in a conversation (default: most recent conversation)')
|
|
1078
1086
|
.argument('[conversation_id]', 'Conversation ID (omit to use most recent from local history)')
|
|
1079
1087
|
.option('--limit <n>', 'Limit', '50')
|
|
1088
|
+
.option('--before-seq <n>', 'Page older messages: return the most recent <limit> messages with seq < n')
|
|
1089
|
+
.option('--after-seq <n>', 'Filter: seq > n (ascending order)')
|
|
1090
|
+
.option('--before-ts <ms>', 'Page older messages by timestamp (ms since epoch): ts_ms < ms')
|
|
1091
|
+
.option('--after-ts <ms>', 'Filter: ts_ms > ms (ascending order)')
|
|
1080
1092
|
.option('--json', 'Output as JSON')
|
|
1081
1093
|
.action((conversationId, opts) => {
|
|
1082
1094
|
const store = openStore();
|
|
@@ -1094,7 +1106,25 @@ history
|
|
|
1094
1106
|
console.log(`Using most recent conversation: ${cid}\n`);
|
|
1095
1107
|
}
|
|
1096
1108
|
}
|
|
1097
|
-
const
|
|
1109
|
+
const limit = parseInt(opts.limit);
|
|
1110
|
+
const beforeSeq = opts.beforeSeq != null ? parseInt(opts.beforeSeq) : undefined;
|
|
1111
|
+
const afterSeq = opts.afterSeq != null ? parseInt(opts.afterSeq) : undefined;
|
|
1112
|
+
const beforeTs = opts.beforeTs != null ? parseInt(opts.beforeTs) : undefined;
|
|
1113
|
+
const afterTs = opts.afterTs != null ? parseInt(opts.afterTs) : undefined;
|
|
1114
|
+
|
|
1115
|
+
let messages;
|
|
1116
|
+
if (beforeSeq != null && !Number.isNaN(beforeSeq)) {
|
|
1117
|
+
messages = mgr.listBeforeSeq(cid, beforeSeq, Number.isFinite(limit) ? limit : 50);
|
|
1118
|
+
} else if (beforeTs != null && !Number.isNaN(beforeTs)) {
|
|
1119
|
+
messages = mgr.listBeforeTs(cid, beforeTs, Number.isFinite(limit) ? limit : 50);
|
|
1120
|
+
} else {
|
|
1121
|
+
messages = mgr.list(cid, {
|
|
1122
|
+
limit: Number.isFinite(limit) ? limit : 50,
|
|
1123
|
+
afterSeq: afterSeq != null && !Number.isNaN(afterSeq) ? afterSeq : undefined,
|
|
1124
|
+
beforeTsMs: beforeTs != null && !Number.isNaN(beforeTs) ? beforeTs : undefined,
|
|
1125
|
+
afterTsMs: afterTs != null && !Number.isNaN(afterTs) ? afterTs : undefined,
|
|
1126
|
+
});
|
|
1127
|
+
}
|
|
1098
1128
|
if (opts.json) {
|
|
1099
1129
|
console.log(JSON.stringify(messages, null, 2));
|
|
1100
1130
|
} else if (messages.length === 0) {
|