@syengup/friday-channel-next 0.1.11 → 0.1.12
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/dist/src/channel.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import crypto from "node:crypto";
|
|
7
7
|
import fs from "node:fs";
|
|
8
|
+
import os from "node:os";
|
|
8
9
|
import path from "node:path";
|
|
9
10
|
import { createChatChannelPlugin } from "openclaw/plugin-sdk/core";
|
|
10
11
|
import { createFridayNextLogger } from "./logging.js";
|
|
@@ -27,7 +28,7 @@ function pickFirstString(source, keys) {
|
|
|
27
28
|
function resolveLocalMediaPath(mediaUrl, localRoots) {
|
|
28
29
|
if (path.isAbsolute(mediaUrl))
|
|
29
30
|
return mediaUrl;
|
|
30
|
-
const roots = localRoots ?? [process.cwd(),
|
|
31
|
+
const roots = localRoots ?? [process.cwd(), os.tmpdir()];
|
|
31
32
|
for (const root of roots) {
|
|
32
33
|
const candidate = path.join(root, mediaUrl);
|
|
33
34
|
if (fs.existsSync(candidate))
|
|
@@ -5,7 +5,7 @@ const FRIDAY_AGENT_ID = "main";
|
|
|
5
5
|
const SESSION_ID_RE = /^[a-z0-9][a-z0-9._-]{0,127}$/i;
|
|
6
6
|
function deriveOpenClawBaseDir(historyDir) {
|
|
7
7
|
if (historyDir) {
|
|
8
|
-
const match = historyDir.replace(
|
|
8
|
+
const match = historyDir.replace(/[\\/]+$/, "").match(/(.*[\\/]\.openclaw)[\\/]/);
|
|
9
9
|
if (match?.[1])
|
|
10
10
|
return match[1];
|
|
11
11
|
}
|
|
@@ -48,7 +48,7 @@ export class FridaySseOfflineQueue {
|
|
|
48
48
|
return 0;
|
|
49
49
|
let max = 0;
|
|
50
50
|
const content = fs.readFileSync(file, "utf8");
|
|
51
|
-
for (const line of content.split(
|
|
51
|
+
for (const line of content.split(/\r?\n/)) {
|
|
52
52
|
if (!line.trim())
|
|
53
53
|
continue;
|
|
54
54
|
try {
|
|
@@ -82,7 +82,7 @@ export class FridaySseOfflineQueue {
|
|
|
82
82
|
return [];
|
|
83
83
|
const out = [];
|
|
84
84
|
const content = fs.readFileSync(file, "utf8");
|
|
85
|
-
for (const line of content.split(
|
|
85
|
+
for (const line of content.split(/\r?\n/)) {
|
|
86
86
|
if (!line.trim())
|
|
87
87
|
continue;
|
|
88
88
|
try {
|
|
@@ -111,7 +111,7 @@ export class FridaySseOfflineQueue {
|
|
|
111
111
|
return;
|
|
112
112
|
const all = [];
|
|
113
113
|
const content = fs.readFileSync(file, "utf8");
|
|
114
|
-
for (const line of content.split(
|
|
114
|
+
for (const line of content.split(/\r?\n/)) {
|
|
115
115
|
if (!line.trim())
|
|
116
116
|
continue;
|
|
117
117
|
try {
|
package/package.json
CHANGED
package/src/channel.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import crypto from "node:crypto";
|
|
8
8
|
import fs from "node:fs";
|
|
9
|
+
import os from "node:os";
|
|
9
10
|
import path from "node:path";
|
|
10
11
|
import { createChatChannelPlugin } from "openclaw/plugin-sdk/core";
|
|
11
12
|
import { createFridayNextLogger } from "./logging.js";
|
|
@@ -33,7 +34,7 @@ function pickFirstString(source: Record<string, unknown>, keys: string[]): strin
|
|
|
33
34
|
|
|
34
35
|
function resolveLocalMediaPath(mediaUrl: string, localRoots?: string[]): string {
|
|
35
36
|
if (path.isAbsolute(mediaUrl)) return mediaUrl;
|
|
36
|
-
const roots = localRoots ?? [process.cwd(),
|
|
37
|
+
const roots = localRoots ?? [process.cwd(), os.tmpdir()];
|
|
37
38
|
for (const root of roots) {
|
|
38
39
|
const candidate = path.join(root, mediaUrl);
|
|
39
40
|
if (fs.existsSync(candidate)) return candidate;
|
|
@@ -7,7 +7,7 @@ const SESSION_ID_RE = /^[a-z0-9][a-z0-9._-]{0,127}$/i;
|
|
|
7
7
|
|
|
8
8
|
function deriveOpenClawBaseDir(historyDir?: string): string {
|
|
9
9
|
if (historyDir) {
|
|
10
|
-
const match = historyDir.replace(
|
|
10
|
+
const match = historyDir.replace(/[\\/]+$/, "").match(/(.*[\\/]\.openclaw)[\\/]/);
|
|
11
11
|
if (match?.[1]) return match[1];
|
|
12
12
|
}
|
|
13
13
|
return join(os.homedir(), ".openclaw");
|
package/src/sse/offline-queue.ts
CHANGED
|
@@ -55,7 +55,7 @@ export class FridaySseOfflineQueue {
|
|
|
55
55
|
if (!fs.existsSync(file)) return 0;
|
|
56
56
|
let max = 0;
|
|
57
57
|
const content = fs.readFileSync(file, "utf8");
|
|
58
|
-
for (const line of content.split(
|
|
58
|
+
for (const line of content.split(/\r?\n/)) {
|
|
59
59
|
if (!line.trim()) continue;
|
|
60
60
|
try {
|
|
61
61
|
const o = JSON.parse(line) as { id?: number };
|
|
@@ -87,7 +87,7 @@ export class FridaySseOfflineQueue {
|
|
|
87
87
|
if (!fs.existsSync(file)) return [];
|
|
88
88
|
const out: PersistedSseEntry[] = [];
|
|
89
89
|
const content = fs.readFileSync(file, "utf8");
|
|
90
|
-
for (const line of content.split(
|
|
90
|
+
for (const line of content.split(/\r?\n/)) {
|
|
91
91
|
if (!line.trim()) continue;
|
|
92
92
|
try {
|
|
93
93
|
const o = JSON.parse(line) as PersistedSseEntry;
|
|
@@ -115,7 +115,7 @@ export class FridaySseOfflineQueue {
|
|
|
115
115
|
if (!fs.existsSync(file)) return;
|
|
116
116
|
const all: PersistedSseEntry[] = [];
|
|
117
117
|
const content = fs.readFileSync(file, "utf8");
|
|
118
|
-
for (const line of content.split(
|
|
118
|
+
for (const line of content.split(/\r?\n/)) {
|
|
119
119
|
if (!line.trim()) continue;
|
|
120
120
|
try {
|
|
121
121
|
const o = JSON.parse(line) as PersistedSseEntry;
|