@ouro.bot/cli 0.1.0-alpha.314 → 0.1.0-alpha.316

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.
@@ -1,7 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OUTLOOK_DEFAULT_PORT = exports.OUTLOOK_DEFAULT_INNER_VISIBILITY = exports.OUTLOOK_RELEASE_INTERACTION_MODEL = exports.OUTLOOK_PRODUCT_NAME = void 0;
4
+ exports.getOutlookTranscriptMessageText = getOutlookTranscriptMessageText;
5
+ exports.getOutlookTranscriptTimestamp = getOutlookTranscriptTimestamp;
4
6
  exports.OUTLOOK_PRODUCT_NAME = "Ouro Outlook";
5
7
  exports.OUTLOOK_RELEASE_INTERACTION_MODEL = "read-only";
6
8
  exports.OUTLOOK_DEFAULT_INNER_VISIBILITY = "summary";
7
9
  exports.OUTLOOK_DEFAULT_PORT = 6876;
10
+ function transcriptContentText(content) {
11
+ if (typeof content === "string")
12
+ return content;
13
+ if (!Array.isArray(content))
14
+ return "";
15
+ return content
16
+ .map((part) => (part.type === "text" && typeof part.text === "string"
17
+ ? part.text
18
+ : ""))
19
+ .filter((text) => text.length > 0)
20
+ .join("");
21
+ }
22
+ function getOutlookTranscriptMessageText(message) {
23
+ return transcriptContentText(message.content);
24
+ }
25
+ function getOutlookTranscriptTimestamp(message) {
26
+ return message.time.authoredAt ?? message.time.observedAt ?? message.time.recordedAt;
27
+ }
@@ -39,6 +39,7 @@ const fs = __importStar(require("fs"));
39
39
  const path = __importStar(require("path"));
40
40
  const runtime_1 = require("../nerves/runtime");
41
41
  const config_1 = require("./config");
42
+ const session_events_1 = require("./session-events");
42
43
  const DEFAULT_ACTIVE_THRESHOLD_MS = 24 * 60 * 60 * 1000;
43
44
  function activityPriority(source) {
44
45
  return source === "friend-facing" ? 0 : 1;
@@ -63,28 +64,42 @@ function parseFriendActivity(sessionPath) {
63
64
  catch {
64
65
  return null;
65
66
  }
66
- try {
67
- const raw = fs.readFileSync(sessionPath, "utf-8");
68
- const parsed = JSON.parse(raw);
69
- const explicit = parsed?.state?.lastFriendActivityAt;
70
- if (typeof explicit === "string") {
71
- const parsedMs = Date.parse(explicit);
72
- if (Number.isFinite(parsedMs)) {
73
- return {
74
- lastActivityMs: parsedMs,
75
- lastActivityAt: new Date(parsedMs).toISOString(),
76
- activitySource: "friend-facing",
77
- };
78
- }
67
+ const envelope = (0, session_events_1.loadSessionEnvelopeFile)(sessionPath);
68
+ const chronology = envelope ? (0, session_events_1.deriveSessionChronology)(envelope.events) : null;
69
+ const explicit = envelope?.state.lastFriendActivityAt;
70
+ if (typeof explicit === "string") {
71
+ const parsedMs = Date.parse(explicit);
72
+ if (Number.isFinite(parsedMs)) {
73
+ return {
74
+ lastActivityMs: parsedMs,
75
+ lastActivityAt: new Date(parsedMs).toISOString(),
76
+ activitySource: "friend-facing",
77
+ lastInboundAt: chronology?.lastInboundAt ?? null,
78
+ lastOutboundAt: chronology?.lastOutboundAt ?? null,
79
+ unansweredInboundCount: chronology?.unansweredInboundCount ?? 0,
80
+ };
79
81
  }
80
82
  }
81
- catch {
82
- // fall back to file mtime below
83
+ if (chronology?.lastInboundAt) {
84
+ const parsedMs = Date.parse(chronology.lastInboundAt);
85
+ if (Number.isFinite(parsedMs)) {
86
+ return {
87
+ lastActivityMs: parsedMs,
88
+ lastActivityAt: new Date(parsedMs).toISOString(),
89
+ activitySource: "friend-facing",
90
+ lastInboundAt: chronology.lastInboundAt,
91
+ lastOutboundAt: chronology.lastOutboundAt,
92
+ unansweredInboundCount: chronology.unansweredInboundCount,
93
+ };
94
+ }
83
95
  }
84
96
  return {
85
97
  lastActivityMs: mtimeMs,
86
98
  lastActivityAt: new Date(mtimeMs).toISOString(),
87
99
  activitySource: "mtime-fallback",
100
+ lastInboundAt: chronology?.lastInboundAt ?? null,
101
+ lastOutboundAt: chronology?.lastOutboundAt ?? null,
102
+ unansweredInboundCount: chronology?.unansweredInboundCount ?? 0,
88
103
  };
89
104
  }
90
105
  function listSessionActivity(query) {
@@ -151,6 +166,9 @@ function listSessionActivity(query) {
151
166
  lastActivityAt: activity.lastActivityAt,
152
167
  lastActivityMs: activity.lastActivityMs,
153
168
  activitySource: activity.activitySource,
169
+ lastInboundAt: activity.lastInboundAt,
170
+ lastOutboundAt: activity.lastOutboundAt,
171
+ unansweredInboundCount: activity.unansweredInboundCount,
154
172
  });
155
173
  }
156
174
  }