@pingagent/sdk 0.1.2 → 0.1.4
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 +25 -3
- package/dist/chunk-HMVPT5N4.js +1317 -0
- package/dist/chunk-YS54ADYV.js +1350 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +1 -1
- package/dist/web-server.js +2 -2
- package/package.json +3 -3
- package/src/auth.ts +1 -1
- package/src/history.ts +43 -1
- package/src/web-server.ts +1 -1
package/bin/pingagent.js
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
} from '../dist/index.js';
|
|
19
19
|
import { ERROR_HINTS, SCHEMA_TEXT } from '@pingagent/schemas';
|
|
20
20
|
|
|
21
|
-
const DEFAULT_SERVER = '
|
|
21
|
+
const DEFAULT_SERVER = 'https://pingagent.chat';
|
|
22
22
|
const UPGRADE_URL = 'https://pingagent.chat';
|
|
23
23
|
const DEFAULT_IDENTITY_PATH = path.join(os.homedir(), '.pingagent', 'identity.json');
|
|
24
24
|
|
|
@@ -309,7 +309,7 @@ program
|
|
|
309
309
|
.command('renew-token')
|
|
310
310
|
.description('Renew access token using existing identity (keeps DID and keypair). Tries /v1/auth/refresh first, falls back to re-register.')
|
|
311
311
|
.option('--profile <name>', 'Use profile from ~/.pingagent/<name> (e.g. agent1, receiver)')
|
|
312
|
-
.option('--server <url>', 'Server URL (defaults to identity server or
|
|
312
|
+
.option('--server <url>', 'Server URL (defaults to identity server or https://pingagent.chat)')
|
|
313
313
|
.option('--token <token>', 'Developer token for production mode (optional)')
|
|
314
314
|
.action(async (opts) => {
|
|
315
315
|
const identityPath = program.opts().identityDir
|
|
@@ -1077,6 +1077,10 @@ history
|
|
|
1077
1077
|
.description('List messages in a conversation (default: most recent conversation)')
|
|
1078
1078
|
.argument('[conversation_id]', 'Conversation ID (omit to use most recent from local history)')
|
|
1079
1079
|
.option('--limit <n>', 'Limit', '50')
|
|
1080
|
+
.option('--before-seq <n>', 'Page older messages: return the most recent <limit> messages with seq < n')
|
|
1081
|
+
.option('--after-seq <n>', 'Filter: seq > n (ascending order)')
|
|
1082
|
+
.option('--before-ts <ms>', 'Page older messages by timestamp (ms since epoch): ts_ms < ms')
|
|
1083
|
+
.option('--after-ts <ms>', 'Filter: ts_ms > ms (ascending order)')
|
|
1080
1084
|
.option('--json', 'Output as JSON')
|
|
1081
1085
|
.action((conversationId, opts) => {
|
|
1082
1086
|
const store = openStore();
|
|
@@ -1094,7 +1098,25 @@ history
|
|
|
1094
1098
|
console.log(`Using most recent conversation: ${cid}\n`);
|
|
1095
1099
|
}
|
|
1096
1100
|
}
|
|
1097
|
-
const
|
|
1101
|
+
const limit = parseInt(opts.limit);
|
|
1102
|
+
const beforeSeq = opts.beforeSeq != null ? parseInt(opts.beforeSeq) : undefined;
|
|
1103
|
+
const afterSeq = opts.afterSeq != null ? parseInt(opts.afterSeq) : undefined;
|
|
1104
|
+
const beforeTs = opts.beforeTs != null ? parseInt(opts.beforeTs) : undefined;
|
|
1105
|
+
const afterTs = opts.afterTs != null ? parseInt(opts.afterTs) : undefined;
|
|
1106
|
+
|
|
1107
|
+
let messages;
|
|
1108
|
+
if (beforeSeq != null && !Number.isNaN(beforeSeq)) {
|
|
1109
|
+
messages = mgr.listBeforeSeq(cid, beforeSeq, Number.isFinite(limit) ? limit : 50);
|
|
1110
|
+
} else if (beforeTs != null && !Number.isNaN(beforeTs)) {
|
|
1111
|
+
messages = mgr.listBeforeTs(cid, beforeTs, Number.isFinite(limit) ? limit : 50);
|
|
1112
|
+
} else {
|
|
1113
|
+
messages = mgr.list(cid, {
|
|
1114
|
+
limit: Number.isFinite(limit) ? limit : 50,
|
|
1115
|
+
afterSeq: afterSeq != null && !Number.isNaN(afterSeq) ? afterSeq : undefined,
|
|
1116
|
+
beforeTsMs: beforeTs != null && !Number.isNaN(beforeTs) ? beforeTs : undefined,
|
|
1117
|
+
afterTsMs: afterTs != null && !Number.isNaN(afterTs) ? afterTs : undefined,
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1098
1120
|
if (opts.json) {
|
|
1099
1121
|
console.log(JSON.stringify(messages, null, 2));
|
|
1100
1122
|
} else if (messages.length === 0) {
|