ofiere-openclaw-plugin 1.0.0 → 1.0.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/index.ts +12 -15
- package/package.json +1 -1
- package/src/config.ts +16 -2
- package/src/tools.ts +0 -3
package/index.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// index.ts — Ofiere PM Plugin for OpenClaw
|
|
2
|
-
//
|
|
3
|
-
// Pattern: https://docs.openclaw.ai/plugins/building-plugins#quick-start-tool-plugin
|
|
2
|
+
// Matches Composio plugin pattern: plain object export + api.on()
|
|
4
3
|
|
|
5
|
-
import {
|
|
4
|
+
import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
|
|
6
5
|
import { parseOfiereConfig } from "./src/config.js";
|
|
7
6
|
import { getSupabase } from "./src/supabase.js";
|
|
8
7
|
import { registerTools } from "./src/tools.js";
|
|
@@ -10,21 +9,21 @@ import { getSystemPrompt } from "./src/prompt.js";
|
|
|
10
9
|
import { registerCli } from "./src/cli.js";
|
|
11
10
|
import { seedAgentCache } from "./src/agent-resolver.js";
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
const ofierePlugin = {
|
|
14
13
|
id: "ofiere",
|
|
15
14
|
name: "Ofiere PM",
|
|
16
15
|
description:
|
|
17
16
|
"Manage Ofiere PM tasks, agents, and projects directly from the agent. " +
|
|
18
17
|
"Create tasks, update progress, assign agents — all synced to the dashboard in real time.",
|
|
19
18
|
|
|
20
|
-
register(api) {
|
|
19
|
+
register(api: OpenClawPluginApi) {
|
|
21
20
|
const config = parseOfiereConfig(api.pluginConfig);
|
|
22
21
|
|
|
23
22
|
// Always register CLI (even if disabled — so user can run `openclaw ofiere setup`)
|
|
24
23
|
registerCli(api);
|
|
25
24
|
|
|
26
25
|
if (!config.enabled) {
|
|
27
|
-
api.logger.debug("[ofiere] Plugin disabled via config");
|
|
26
|
+
api.logger.debug?.("[ofiere] Plugin disabled via config");
|
|
28
27
|
return;
|
|
29
28
|
}
|
|
30
29
|
|
|
@@ -44,7 +43,6 @@ export default definePluginEntry({
|
|
|
44
43
|
|
|
45
44
|
// ── Pre-seed agent cache if OFIERE_AGENT_ID is set (legacy mode) ──────
|
|
46
45
|
if (config.agentId) {
|
|
47
|
-
// Try to extract the calling agent's name from OpenClaw context
|
|
48
46
|
const callerName =
|
|
49
47
|
(api as any)?.agentContext?.accountId ||
|
|
50
48
|
(api as any)?.agentContext?.name ||
|
|
@@ -64,13 +62,10 @@ export default definePluginEntry({
|
|
|
64
62
|
};
|
|
65
63
|
|
|
66
64
|
// ── Hook: inject Ofiere context into every agent prompt ────────────────
|
|
67
|
-
//
|
|
68
|
-
api.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
prependSystemContext: getSystemPrompt(promptState),
|
|
72
|
-
}),
|
|
73
|
-
);
|
|
65
|
+
// Using api.on() — same pattern as Composio
|
|
66
|
+
api.on("before_prompt_build", () => ({
|
|
67
|
+
prependSystemContext: getSystemPrompt(promptState),
|
|
68
|
+
}));
|
|
74
69
|
|
|
75
70
|
// ── Connect to Supabase and register tools ────────────────────────────
|
|
76
71
|
try {
|
|
@@ -89,4 +84,6 @@ export default definePluginEntry({
|
|
|
89
84
|
api.logger.error(`[ofiere] Failed to initialize: ${msg}`);
|
|
90
85
|
}
|
|
91
86
|
},
|
|
92
|
-
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export default ofierePlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ofiere-openclaw-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
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
|
}
|
package/src/tools.ts
CHANGED
|
@@ -232,7 +232,6 @@ export function registerTools(
|
|
|
232
232
|
}
|
|
233
233
|
},
|
|
234
234
|
},
|
|
235
|
-
{ optional: true },
|
|
236
235
|
);
|
|
237
236
|
|
|
238
237
|
// ── OFIERE_UPDATE_TASK — Optional (has side effects) ─────────────────
|
|
@@ -297,7 +296,6 @@ export function registerTools(
|
|
|
297
296
|
}
|
|
298
297
|
},
|
|
299
298
|
},
|
|
300
|
-
{ optional: true },
|
|
301
299
|
);
|
|
302
300
|
|
|
303
301
|
// ── OFIERE_DELETE_TASK — Optional (destructive side effect) ──────────
|
|
@@ -352,7 +350,6 @@ export function registerTools(
|
|
|
352
350
|
}
|
|
353
351
|
},
|
|
354
352
|
},
|
|
355
|
-
{ optional: true },
|
|
356
353
|
);
|
|
357
354
|
|
|
358
355
|
// ── OFIERE_LIST_AGENTS — Required (read-only, no side effects) ───────
|