@pingagent/sdk 0.1.3 → 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 +23 -1
- 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 +1 -1
- package/package.json +3 -3
- package/src/history.ts +43 -1
package/dist/index.d.ts
CHANGED
|
@@ -67,7 +67,18 @@ declare class HistoryManager {
|
|
|
67
67
|
limit?: number;
|
|
68
68
|
beforeSeq?: number;
|
|
69
69
|
afterSeq?: number;
|
|
70
|
+
beforeTsMs?: number;
|
|
71
|
+
afterTsMs?: number;
|
|
70
72
|
}): StoredMessage[];
|
|
73
|
+
/**
|
|
74
|
+
* List the most recent N messages *before* a seq (paging older history).
|
|
75
|
+
* Only compares rows where seq is not null.
|
|
76
|
+
*/
|
|
77
|
+
listBeforeSeq(conversationId: string, beforeSeq: number, limit: number): StoredMessage[];
|
|
78
|
+
/**
|
|
79
|
+
* List the most recent N messages *before* a timestamp (paging older history).
|
|
80
|
+
*/
|
|
81
|
+
listBeforeTs(conversationId: string, beforeTsMs: number, limit: number): StoredMessage[];
|
|
71
82
|
/** Returns the N most recent messages (chronological order, oldest to newest of those N). */
|
|
72
83
|
listRecent(conversationId: string, limit: number): StoredMessage[];
|
|
73
84
|
search(query: string, opts?: {
|
package/dist/index.js
CHANGED
package/dist/web-server.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pingagent/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"commander": "^13.0.0",
|
|
27
27
|
"uuid": "^11.0.0",
|
|
28
28
|
"ws": "^8.0.0",
|
|
29
|
-
"@pingagent/protocol": "0.1.1",
|
|
30
29
|
"@pingagent/schemas": "0.1.1",
|
|
31
|
-
"@pingagent/a2a": "0.1.1"
|
|
30
|
+
"@pingagent/a2a": "0.1.1",
|
|
31
|
+
"@pingagent/protocol": "0.1.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/better-sqlite3": "^7.6.0",
|
package/src/history.ts
CHANGED
|
@@ -82,7 +82,10 @@ export class HistoryManager {
|
|
|
82
82
|
return count;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
list(
|
|
85
|
+
list(
|
|
86
|
+
conversationId: string,
|
|
87
|
+
opts?: { limit?: number; beforeSeq?: number; afterSeq?: number; beforeTsMs?: number; afterTsMs?: number },
|
|
88
|
+
): StoredMessage[] {
|
|
86
89
|
const conditions = ['conversation_id = ?'];
|
|
87
90
|
const params: any[] = [conversationId];
|
|
88
91
|
|
|
@@ -94,6 +97,14 @@ export class HistoryManager {
|
|
|
94
97
|
conditions.push('seq > ?');
|
|
95
98
|
params.push(opts.afterSeq);
|
|
96
99
|
}
|
|
100
|
+
if (opts?.beforeTsMs !== undefined) {
|
|
101
|
+
conditions.push('ts_ms < ?');
|
|
102
|
+
params.push(opts.beforeTsMs);
|
|
103
|
+
}
|
|
104
|
+
if (opts?.afterTsMs !== undefined) {
|
|
105
|
+
conditions.push('ts_ms > ?');
|
|
106
|
+
params.push(opts.afterTsMs);
|
|
107
|
+
}
|
|
97
108
|
|
|
98
109
|
const limit = opts?.limit ?? 100;
|
|
99
110
|
const rows = this.store.getDb()
|
|
@@ -102,6 +113,37 @@ export class HistoryManager {
|
|
|
102
113
|
return rows.map(rowToMessage);
|
|
103
114
|
}
|
|
104
115
|
|
|
116
|
+
/**
|
|
117
|
+
* List the most recent N messages *before* a seq (paging older history).
|
|
118
|
+
* Only compares rows where seq is not null.
|
|
119
|
+
*/
|
|
120
|
+
listBeforeSeq(conversationId: string, beforeSeq: number, limit: number): StoredMessage[] {
|
|
121
|
+
const rows = this.store.getDb()
|
|
122
|
+
.prepare(
|
|
123
|
+
`SELECT * FROM messages
|
|
124
|
+
WHERE conversation_id = ? AND seq IS NOT NULL AND seq < ?
|
|
125
|
+
ORDER BY seq DESC
|
|
126
|
+
LIMIT ?`,
|
|
127
|
+
)
|
|
128
|
+
.all(conversationId, beforeSeq, limit) as MessageRow[];
|
|
129
|
+
return rows.map(rowToMessage).reverse();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* List the most recent N messages *before* a timestamp (paging older history).
|
|
134
|
+
*/
|
|
135
|
+
listBeforeTs(conversationId: string, beforeTsMs: number, limit: number): StoredMessage[] {
|
|
136
|
+
const rows = this.store.getDb()
|
|
137
|
+
.prepare(
|
|
138
|
+
`SELECT * FROM messages
|
|
139
|
+
WHERE conversation_id = ? AND ts_ms < ?
|
|
140
|
+
ORDER BY ts_ms DESC
|
|
141
|
+
LIMIT ?`,
|
|
142
|
+
)
|
|
143
|
+
.all(conversationId, beforeTsMs, limit) as MessageRow[];
|
|
144
|
+
return rows.map(rowToMessage).reverse();
|
|
145
|
+
}
|
|
146
|
+
|
|
105
147
|
/** Returns the N most recent messages (chronological order, oldest to newest of those N). */
|
|
106
148
|
listRecent(conversationId: string, limit: number): StoredMessage[] {
|
|
107
149
|
const rows = this.store.getDb()
|