@kanvas/openclaw-plugin 0.1.10 → 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/README.md +15 -0
- package/dist/index.js +46 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -230,6 +230,21 @@ KANVAS_PASSWORD=yourpassword \
|
|
|
230
230
|
npx ts-node --esm scripts/smoke-test.ts
|
|
231
231
|
```
|
|
232
232
|
|
|
233
|
+
## Releasing
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
npm version patch # bumps 0.1.x → 0.1.x+1 and creates a git commit + tag
|
|
237
|
+
git push && git push --tags
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
GitHub Actions builds and publishes to npm automatically on any `v*` tag.
|
|
241
|
+
|
|
242
|
+
Then on the agent machine:
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
openclaw plugins update kanvas
|
|
246
|
+
```
|
|
247
|
+
|
|
233
248
|
## License
|
|
234
249
|
|
|
235
250
|
MIT
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,18 @@ import { registerOrdersTools } from "./tools/orders.js";
|
|
|
10
10
|
import { registerSocialTools } from "./tools/social.js";
|
|
11
11
|
import { toolResult } from "./tools/helpers.js";
|
|
12
12
|
const DEFAULT_API_URL = "https://graphapi.kanvas.dev/graphql";
|
|
13
|
+
// OpenClaw v2026.4.5+ calls register() per-agent-context (main, subagents,
|
|
14
|
+
// cron lanes). Heavy objects (client, services) are created once and shared;
|
|
15
|
+
// tools & hooks must be registered on every api object.
|
|
16
|
+
let sharedClient = null;
|
|
17
|
+
let sharedConfig = null;
|
|
18
|
+
let sharedEnsureAuth = null;
|
|
19
|
+
let sharedCrm = null;
|
|
20
|
+
let sharedInventory = null;
|
|
21
|
+
let sharedOrders = null;
|
|
22
|
+
let sharedSocial = null;
|
|
23
|
+
let startupBannerShown = false;
|
|
24
|
+
let skipBannerShown = false;
|
|
13
25
|
function resolveConfig(pluginConfig) {
|
|
14
26
|
const cfg = pluginConfig ?? {};
|
|
15
27
|
const apiUrl = cfg.apiUrl || process.env.KANVAS_API_URL || DEFAULT_API_URL;
|
|
@@ -67,17 +79,35 @@ export default {
|
|
|
67
79
|
description: "Connects agents to Kanvas — your company's nervous system for CRM, inventory, orders, and messaging.",
|
|
68
80
|
configSchema: { type: "object" },
|
|
69
81
|
register(api) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
82
|
+
// Resolve config — log once and bail silently on missing credentials.
|
|
83
|
+
let config;
|
|
84
|
+
try {
|
|
85
|
+
config = resolveConfig(api.pluginConfig);
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
if (!skipBannerShown) {
|
|
89
|
+
api.logger.info(`Kanvas plugin skipped: ${err.message}. Run "openclaw kanvas setup" to configure.`);
|
|
90
|
+
skipBannerShown = true;
|
|
91
|
+
}
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
// Create heavy objects once; reuse across agent contexts.
|
|
95
|
+
if (!sharedClient) {
|
|
96
|
+
sharedConfig = config;
|
|
97
|
+
sharedClient = new KanvasClient(config);
|
|
98
|
+
sharedEnsureAuth = createAuthGuard(sharedClient, config, api.logger);
|
|
99
|
+
sharedCrm = new CrmService(sharedClient);
|
|
100
|
+
sharedInventory = new InventoryService(sharedClient);
|
|
101
|
+
sharedOrders = new OrdersService(sharedClient);
|
|
102
|
+
sharedSocial = new SocialService(sharedClient);
|
|
103
|
+
}
|
|
104
|
+
// Tools and hooks must be registered on every api object — each one is
|
|
105
|
+
// a separate agent context (main, subagents, cron lanes).
|
|
106
|
+
const ensureAuth = sharedEnsureAuth;
|
|
107
|
+
registerCrmTools(api, sharedCrm, ensureAuth);
|
|
108
|
+
registerInventoryTools(api, sharedInventory, ensureAuth);
|
|
109
|
+
registerOrdersTools(api, sharedOrders, ensureAuth);
|
|
110
|
+
registerSocialTools(api, sharedSocial, ensureAuth);
|
|
81
111
|
api.registerTool({
|
|
82
112
|
name: "kanvas_test_connection",
|
|
83
113
|
label: "Test Connection",
|
|
@@ -85,15 +115,12 @@ export default {
|
|
|
85
115
|
parameters: Type.Object({}),
|
|
86
116
|
async execute() {
|
|
87
117
|
await ensureAuth();
|
|
88
|
-
return toolResult(await
|
|
118
|
+
return toolResult(await sharedClient.testConnection());
|
|
89
119
|
},
|
|
90
120
|
});
|
|
91
|
-
// Inject Kanvas context into the agent's system prompt so it knows
|
|
92
|
-
// what these tools are for and how to use them together.
|
|
93
121
|
api.on("before_prompt_build", () => ({
|
|
94
122
|
appendSystemContext: KANVAS_SYSTEM_CONTEXT,
|
|
95
123
|
}));
|
|
96
|
-
// Register `openclaw kanvas setup` CLI command for interactive configuration.
|
|
97
124
|
api.registerCli((ctx) => {
|
|
98
125
|
ctx.program
|
|
99
126
|
.command("setup")
|
|
@@ -103,7 +130,10 @@ export default {
|
|
|
103
130
|
await runSetup();
|
|
104
131
|
});
|
|
105
132
|
}, { commands: ["setup"] });
|
|
106
|
-
|
|
133
|
+
if (!startupBannerShown) {
|
|
134
|
+
startupBannerShown = true;
|
|
135
|
+
api.logger.info("Kanvas plugin registered — 53 tools loaded");
|
|
136
|
+
}
|
|
107
137
|
},
|
|
108
138
|
};
|
|
109
139
|
const KANVAS_SYSTEM_CONTEXT = `
|
package/package.json
CHANGED