@taylorsatula/pi-timestamp 0.2.0 → 0.2.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/extensions/timestamp.ts +6 -2
- package/package.json +1 -1
package/extensions/timestamp.ts
CHANGED
|
@@ -30,7 +30,8 @@ function formatTimestamp(): string {
|
|
|
30
30
|
return `[${hours}:${String(minutes).padStart(2, "0")}${ampm} - ${month}/${day}/${year}]`;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
function injectable(msgs: Array<Record<string, unknown>>): boolean {
|
|
33
|
+
function injectable(msgs: Array<Record<string, unknown>> | undefined): boolean {
|
|
34
|
+
if (!Array.isArray(msgs) || msgs.length === 0) return false;
|
|
34
35
|
const last = msgs[msgs.length - 1];
|
|
35
36
|
if (!last) return false;
|
|
36
37
|
|
|
@@ -48,7 +49,10 @@ function injectable(msgs: Array<Record<string, unknown>>): boolean {
|
|
|
48
49
|
export default function (pi: ExtensionAPI) {
|
|
49
50
|
pi.on("before_provider_request", (event) => {
|
|
50
51
|
const payload = event.payload as Record<string, unknown>;
|
|
51
|
-
|
|
52
|
+
// OpenAI Responses API carries the conversation in `input` instead of `messages`.
|
|
53
|
+
const key = Array.isArray(payload.messages) ? "messages" : Array.isArray(payload.input) ? "input" : null;
|
|
54
|
+
if (!key) return;
|
|
55
|
+
const msgs = payload[key] as Array<Record<string, unknown>>;
|
|
52
56
|
if (!injectable(msgs)) return;
|
|
53
57
|
|
|
54
58
|
const ts = `\n${formatTimestamp()}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taylorsatula/pi-timestamp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Timestamp injection extension for Pi — appends the current wall-clock time to the tail of user messages and vocalizations just-in-time (cache-safe, no synthetic tool calls), so the model always knows what time it is.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|