ofiere-openclaw-plugin 1.0.0 → 1.0.1
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 +1 -1
- package/src/config.ts +16 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ofiere-openclaw-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "OpenClaw plugin for Ofiere PM — manage tasks, agents, and projects from your agent",
|
|
6
6
|
"keywords": ["openclaw", "ofiere", "project-management", "agents", "plugin"],
|
package/src/config.ts
CHANGED
|
@@ -9,6 +9,9 @@ export const OfiereConfigSchema = z.object({
|
|
|
9
9
|
agentId: z.string().default(""),
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
+
// Cache the first successful config so per-agent re-registrations don't lose it
|
|
13
|
+
let _cachedConfig: OfiereConfig | null = null;
|
|
14
|
+
|
|
12
15
|
export function parseOfiereConfig(value: unknown): OfiereConfig {
|
|
13
16
|
const raw =
|
|
14
17
|
value && typeof value === "object" && !Array.isArray(value)
|
|
@@ -18,12 +21,13 @@ export function parseOfiereConfig(value: unknown): OfiereConfig {
|
|
|
18
21
|
const configObj = raw.config as Record<string, unknown> | undefined;
|
|
19
22
|
|
|
20
23
|
// Support both nested (config.supabaseUrl) and flat (supabaseUrl) access
|
|
21
|
-
// Also fall back to env vars
|
|
24
|
+
// Also fall back to env vars, then to cached config
|
|
22
25
|
const supabaseUrl =
|
|
23
26
|
(typeof configObj?.supabaseUrl === "string" && configObj.supabaseUrl.trim()) ||
|
|
24
27
|
(typeof raw.supabaseUrl === "string" && raw.supabaseUrl.trim()) ||
|
|
25
28
|
process.env.OFIERE_SUPABASE_URL ||
|
|
26
29
|
process.env.SUPABASE_URL ||
|
|
30
|
+
_cachedConfig?.supabaseUrl ||
|
|
27
31
|
"";
|
|
28
32
|
|
|
29
33
|
const serviceRoleKey =
|
|
@@ -31,25 +35,35 @@ export function parseOfiereConfig(value: unknown): OfiereConfig {
|
|
|
31
35
|
(typeof raw.serviceRoleKey === "string" && raw.serviceRoleKey.trim()) ||
|
|
32
36
|
process.env.OFIERE_SERVICE_ROLE_KEY ||
|
|
33
37
|
process.env.SUPABASE_SERVICE_ROLE_KEY ||
|
|
38
|
+
_cachedConfig?.serviceRoleKey ||
|
|
34
39
|
"";
|
|
35
40
|
|
|
36
41
|
const userId =
|
|
37
42
|
(typeof configObj?.userId === "string" && configObj.userId.trim()) ||
|
|
38
43
|
(typeof raw.userId === "string" && raw.userId.trim()) ||
|
|
39
44
|
process.env.OFIERE_USER_ID ||
|
|
45
|
+
_cachedConfig?.userId ||
|
|
40
46
|
"";
|
|
41
47
|
|
|
42
48
|
const agentId =
|
|
43
49
|
(typeof configObj?.agentId === "string" && configObj.agentId.trim()) ||
|
|
44
50
|
(typeof raw.agentId === "string" && raw.agentId.trim()) ||
|
|
45
51
|
process.env.OFIERE_AGENT_ID ||
|
|
52
|
+
_cachedConfig?.agentId ||
|
|
46
53
|
"";
|
|
47
54
|
|
|
48
|
-
|
|
55
|
+
const parsed = OfiereConfigSchema.parse({
|
|
49
56
|
...raw,
|
|
50
57
|
supabaseUrl,
|
|
51
58
|
serviceRoleKey,
|
|
52
59
|
userId,
|
|
53
60
|
agentId,
|
|
54
61
|
});
|
|
62
|
+
|
|
63
|
+
// Cache if this parse yielded a complete config
|
|
64
|
+
if (parsed.supabaseUrl && parsed.serviceRoleKey && parsed.userId) {
|
|
65
|
+
_cachedConfig = parsed;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return parsed;
|
|
55
69
|
}
|