poe-code 3.0.296 → 3.0.297

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-code",
3
- "version": "3.0.296",
3
+ "version": "3.0.297",
4
4
  "description": "CLI tool to configure Poe API for developer workflows.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -30,9 +30,19 @@ function removeContextTags(text) {
30
30
  return result;
31
31
  }
32
32
  function recordKey(record) {
33
- return [record.source, record.traceId, record.text].join("\u0000");
33
+ return [record.source, record.traceId, record.timestamp ?? "", record.text].join("\u0000");
34
+ }
35
+ function isValidDate(date) {
36
+ return Number.isFinite(date.getTime());
34
37
  }
35
38
  export async function collectHumanPromptsFromReaders(readers, options = {}) {
39
+ if (options.since !== undefined && !isValidDate(options.since)) {
40
+ throw new Error("since must be a valid Date.");
41
+ }
42
+ if (options.limit !== undefined &&
43
+ (!Number.isInteger(options.limit) || options.limit < 0 || !Number.isFinite(options.limit))) {
44
+ throw new Error("limit must be a non-negative integer.");
45
+ }
36
46
  const sources = options.sources ?? DEFAULT_SOURCES;
37
47
  const readerById = new Map(readers.map((reader) => [reader.id, reader]));
38
48
  const fs = options.fs ?? nodeFs;
@@ -71,12 +81,13 @@ export async function collectHumanPromptsFromReaders(readers, options = {}) {
71
81
  if (isInjectedContext(text)) {
72
82
  continue;
73
83
  }
84
+ const timestamp = turn.timestamp && isValidDate(turn.timestamp) ? turn.timestamp.toISOString() : undefined;
74
85
  const record = {
75
86
  traceId: trace.id,
76
87
  source: trace.source,
77
88
  ...(trace.cwd ? { cwd: trace.cwd } : {}),
78
89
  ...(trace.title ? { title: trace.title } : {}),
79
- ...(turn.timestamp ? { timestamp: turn.timestamp.toISOString() } : {}),
90
+ ...(timestamp ? { timestamp } : {}),
80
91
  text
81
92
  };
82
93
  const key = recordKey(record);
@@ -23,7 +23,8 @@ export function asRecord(value) {
23
23
  export function parseDate(value) {
24
24
  if (typeof value === "number" && Number.isFinite(value)) {
25
25
  const milliseconds = value > 10_000_000_000 ? value : value * 1_000;
26
- return new Date(milliseconds);
26
+ const date = new Date(milliseconds);
27
+ return Number.isNaN(date.getTime()) ? undefined : date;
27
28
  }
28
29
  if (typeof value !== "string" || value.trim().length === 0) {
29
30
  return undefined;
@@ -3,7 +3,7 @@ import { asRecord, newestDate, parseDate, parseJsonLines } from "../line-json.js
3
3
  function isMissingFile(error) {
4
4
  return (typeof error === "object" &&
5
5
  error !== null &&
6
- "code" in error &&
6
+ Object.prototype.hasOwnProperty.call(error, "code") &&
7
7
  error.code === "ENOENT");
8
8
  }
9
9
  function encodeClaudeProjectPath(cwd) {
@@ -3,7 +3,7 @@ import { asRecord, newestDate, parseDate, parseJsonLines } from "../line-json.js
3
3
  function isMissingFile(error) {
4
4
  return (typeof error === "object" &&
5
5
  error !== null &&
6
- "code" in error &&
6
+ Object.prototype.hasOwnProperty.call(error, "code") &&
7
7
  error.code === "ENOENT");
8
8
  }
9
9
  async function importNodeSqlite() {
@@ -36,7 +36,7 @@ async function defaultSqliteFactory(databasePath) {
36
36
  }
37
37
  function dateFromRow(seconds, milliseconds) {
38
38
  if (typeof milliseconds === "number" && Number.isFinite(milliseconds)) {
39
- return new Date(milliseconds);
39
+ return parseDate(milliseconds);
40
40
  }
41
41
  return parseDate(seconds);
42
42
  }