@oda-agent/openclaw-plugin 0.1.4 → 0.1.6

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.
@@ -0,0 +1,42 @@
1
+ /**
2
+ * OpenClaw native plugin entry.
3
+ *
4
+ * OpenClaw loads `dist/index.js` and expects a **default export** that is a
5
+ * plugin entry object with `register()` and `activate()` methods. This file
6
+ * provides that entrypoint by registering every tool that the Oda shopping
7
+ * assistant exposes, wired up to a lazily-authenticated OdaClient.
8
+ *
9
+ * The `definePluginEntry` helper is defined locally so that this package has
10
+ * no runtime dependency on the OpenClaw SDK. When the OpenClaw team publishes
11
+ * `openclaw/plugin-sdk`, this file can be updated to import from there instead.
12
+ */
13
+ /**
14
+ * Minimal OpenClaw plugin API surface passed to the `register()` callback.
15
+ * The complete interface is defined by the OpenClaw runtime; only the
16
+ * members used by this plugin are declared here.
17
+ */
18
+ export interface OpenClawApi {
19
+ /** Register a named tool with the plugin runtime. */
20
+ registerTool(name: string, description: string, handler: (params: unknown) => Promise<unknown>): void;
21
+ /** Return the plugin configuration provided by the user or environment. */
22
+ getConfig(): Record<string, unknown>;
23
+ }
24
+ /** Shape of an OpenClaw native plugin entry. */
25
+ export interface OpenClawPluginEntry {
26
+ /** Unique identifier for the plugin (must match `openclaw.plugin.json` id). */
27
+ id: string;
28
+ /** Human-readable plugin name. */
29
+ name: string;
30
+ /** Short description of the plugin. */
31
+ description: string;
32
+ /**
33
+ * Called once by the OpenClaw runtime during plugin installation.
34
+ * Use the provided `api` to register all tools this plugin exposes.
35
+ */
36
+ register(api: OpenClawApi): void;
37
+ /** Called once by the OpenClaw runtime when the plugin is activated. */
38
+ activate(): void;
39
+ }
40
+ declare const pluginEntry: OpenClawPluginEntry;
41
+ export default pluginEntry;
42
+ //# sourceMappingURL=entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAaH;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,qDAAqD;IACrD,YAAY,CACV,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,GAC7C,IAAI,CAAC;IACR,2EAA2E;IAC3E,SAAS,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED,gDAAgD;AAChD,MAAM,WAAW,mBAAmB;IAClC,+EAA+E;IAC/E,EAAE,EAAE,MAAM,CAAC;IACX,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAAC;IACjC,wEAAwE;IACxE,QAAQ,IAAI,IAAI,CAAC;CAClB;AAcD,QAAA,MAAM,WAAW,qBA0Jf,CAAC;AAEH,eAAe,WAAW,CAAC"}
package/dist/entry.js ADDED
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ /**
3
+ * OpenClaw native plugin entry.
4
+ *
5
+ * OpenClaw loads `dist/index.js` and expects a **default export** that is a
6
+ * plugin entry object with `register()` and `activate()` methods. This file
7
+ * provides that entrypoint by registering every tool that the Oda shopping
8
+ * assistant exposes, wired up to a lazily-authenticated OdaClient.
9
+ *
10
+ * The `definePluginEntry` helper is defined locally so that this package has
11
+ * no runtime dependency on the OpenClaw SDK. When the OpenClaw team publishes
12
+ * `openclaw/plugin-sdk`, this file can be updated to import from there instead.
13
+ */
14
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ var desc = Object.getOwnPropertyDescriptor(m, k);
17
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
18
+ desc = { enumerable: true, get: function() { return m[k]; } };
19
+ }
20
+ Object.defineProperty(o, k2, desc);
21
+ }) : (function(o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ o[k2] = m[k];
24
+ }));
25
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
26
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
27
+ }) : function(o, v) {
28
+ o["default"] = v;
29
+ });
30
+ var __importStar = (this && this.__importStar) || function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ const core_1 = require("@oda-agent/core");
39
+ const readOnlyTools = __importStar(require("./tools/readOnlyTools.js"));
40
+ const cartMutationTools = __importStar(require("./tools/cartMutationTools.js"));
41
+ const plugin_js_1 = require("./plugin.js");
42
+ /**
43
+ * Identity helper that mirrors `definePluginEntry` from the OpenClaw SDK.
44
+ * Defined locally so the package has no runtime dependency on the OpenClaw SDK.
45
+ */
46
+ function definePluginEntry(entry) {
47
+ return entry;
48
+ }
49
+ // ---------------------------------------------------------------------------
50
+ // Plugin entry
51
+ // ---------------------------------------------------------------------------
52
+ const pluginEntry = definePluginEntry({
53
+ id: '@oda-agent/openclaw-plugin',
54
+ name: 'oda-shopping-assistant',
55
+ description: 'Oda grocery shopping assistant — safe cart planning, order history analysis, and delivery slot discovery.',
56
+ register(api) {
57
+ const config = api.getConfig();
58
+ const email = config.email ?? process.env['ODA_EMAIL'] ?? '';
59
+ const password = config.password ?? process.env['ODA_PASSWORD'] ?? '';
60
+ if (!email || !password) {
61
+ throw new Error('Oda credentials are required. ' +
62
+ 'Set the email and password fields in the plugin config, ' +
63
+ 'or export the ODA_EMAIL and ODA_PASSWORD environment variables.');
64
+ }
65
+ const client = new core_1.OdaClient({ credentials: { email, password } });
66
+ const plugin = (0, plugin_js_1.createOpenClawPlugin)(client);
67
+ // Login is deferred and cached so it only happens on the first tool call.
68
+ let loginPromise = null;
69
+ function ensureLoggedIn() {
70
+ if (loginPromise === null) {
71
+ loginPromise = client.login();
72
+ }
73
+ return loginPromise;
74
+ }
75
+ // ── Read-only tools ─────────────────────────────────────────────────────
76
+ api.registerTool('searchProducts', 'Search for products in the Oda catalogue by keyword.', async (params) => {
77
+ await ensureLoggedIn();
78
+ return readOnlyTools.searchProducts(client, params);
79
+ });
80
+ api.registerTool('getCart', 'Retrieve the current shopping cart.', async () => {
81
+ await ensureLoggedIn();
82
+ return readOnlyTools.getCart(client);
83
+ });
84
+ api.registerTool('getOrders', 'Fetch paginated order history.', async (params) => {
85
+ await ensureLoggedIn();
86
+ return readOnlyTools.getOrders(client, params);
87
+ });
88
+ api.registerTool('getDeliverySlots', 'List available delivery time slots.', async () => {
89
+ await ensureLoggedIn();
90
+ return readOnlyTools.getDeliverySlots(client);
91
+ });
92
+ api.registerTool('getShoppingLists', "List the user's saved shopping lists.", async () => {
93
+ await ensureLoggedIn();
94
+ return readOnlyTools.getShoppingLists(client);
95
+ });
96
+ // ── Higher-level read-only helpers ──────────────────────────────────────
97
+ api.registerTool('analyseOrderHistory', 'Analyse past orders and return a summary of frequently ordered products.', async (params) => {
98
+ await ensureLoggedIn();
99
+ const p = params;
100
+ return plugin.analyseOrderHistory(p?.maxPages);
101
+ });
102
+ api.registerTool('buildShoppingList', 'Resolve plain-text queries into a structured shopping list without mutating the cart.', async (params) => {
103
+ await ensureLoggedIn();
104
+ const p = params;
105
+ return plugin.buildShoppingList(p.name, p.items);
106
+ });
107
+ api.registerTool('findCheapestDeliverySlot', 'Return the cheapest available delivery slot without booking it.', async () => {
108
+ await ensureLoggedIn();
109
+ return plugin.findCheapestDeliverySlot();
110
+ });
111
+ // ── Cart-mutation tools (disabled by default in manifest) ───────────────
112
+ api.registerTool('addToCart', 'Add a single product to the cart. Requires explicit user confirmation before use.', async (params) => {
113
+ await ensureLoggedIn();
114
+ const p = params;
115
+ return cartMutationTools.addToCart(client, p.productId, p.quantity);
116
+ });
117
+ api.registerTool('removeFromCart', 'Remove an item from the cart by product ID. Requires explicit user confirmation before use.', async (params) => {
118
+ await ensureLoggedIn();
119
+ const p = params;
120
+ return cartMutationTools.removeFromCart(client, p.productId);
121
+ });
122
+ api.registerTool('clearCart', 'Remove all items from the cart. Requires explicit user confirmation before use.', async () => {
123
+ await ensureLoggedIn();
124
+ return cartMutationTools.clearCart(client);
125
+ });
126
+ api.registerTool('prepareCart', 'Add all items from a shopping list to the cart. Requires explicit user confirmation before use.', async (params) => {
127
+ await ensureLoggedIn();
128
+ return cartMutationTools.prepareCart(client, params);
129
+ });
130
+ },
131
+ activate() {
132
+ // Lifecycle hook called when the plugin is activated by OpenClaw.
133
+ // No additional setup is required for the Oda shopping assistant.
134
+ },
135
+ });
136
+ exports.default = pluginEntry;
137
+ //# sourceMappingURL=entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry.js","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,0CAA4C;AAE5C,wEAA0D;AAC1D,gFAAkE;AAClE,2CAAmD;AAwCnD;;;GAGG;AACH,SAAS,iBAAiB,CAAC,KAA0B;IACnD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,8EAA8E;AAC9E,eAAe;AACf,8EAA8E;AAE9E,MAAM,WAAW,GAAG,iBAAiB,CAAC;IACpC,EAAE,EAAE,4BAA4B;IAChC,IAAI,EAAE,wBAAwB;IAC9B,WAAW,EACT,2GAA2G;IAE7G,QAAQ,CAAC,GAAgB;QACvB,MAAM,MAAM,GAAG,GAAG,CAAC,SAAS,EAA2C,CAAC;QACxE,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QAC7D,MAAM,QAAQ,GAAG,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C5D,OAAO,iBAAiB,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;QACtE,CAAC,CACF,CAAC;QAEF,GAAG,CAAC,YAAY,CACd,gBAAgB,EAChB,6FAA6F,EAC7F,KAAK,EAAE,MAAM,EAAE,EAAE;YACf,MAAM,cAAc,EAAE,CAAC;YACvB,MAAM,CAAC,GAAG,MAA+B,CAAC;YAC1C,OAAO,iBAAiB,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC;QAC/D,CAAC,CACF,CAAC;QAEF,GAAG,CAAC,YAAY,CACd,WAAW,EACX,iFAAiF,EACjF,KAAK,IAAI,EAAE;YACT,MAAM,cAAc,EAAE,CAAC;YACvB,OAAO,iBAAiB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC7C,CAAC,CACF,CAAC;QAEF,GAAG,CAAC,YAAY,CACd,aAAa,EACb,iGAAiG,EACjG,KAAK,EAAE,MAAM,EAAE,EAAE;YACf,MAAM,cAAc,EAAE,CAAC;YACvB,OAAO,iBAAiB,CAAC,WAAW,CAAC,MAAM,EAAE,MAAsB,CAAC,CAAC;QACvE,CAAC,CACF,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,kEAAkE;QAClE,kEAAkE;IACpE,CAAC;CACF,CAAC,CAAC;AAEH,kBAAe,WAAW,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export { default } from './entry.js';
2
+ export type { OpenClawApi, OpenClawPluginEntry } from './entry.js';
1
3
  export { createOpenClawPlugin } from './plugin.js';
2
4
  export type { ShoppingList, OrderHistorySummary, OpenClawPlugin } from './plugin.js';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createOpenClawPlugin = void 0;
6
+ exports.createOpenClawPlugin = exports.default = void 0;
7
+ var entry_js_1 = require("./entry.js");
8
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(entry_js_1).default; } });
4
9
  var plugin_js_1 = require("./plugin.js");
5
10
  Object.defineProperty(exports, "createOpenClawPlugin", { enumerable: true, get: function () { return plugin_js_1.createOpenClawPlugin; } });
6
11
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAAmD;AAA1C,iHAAA,oBAAoB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,uCAAqC;AAA5B,oHAAA,OAAO,OAAA;AAEhB,yCAAmD;AAA1C,iHAAA,oBAAoB,OAAA"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "@oda-agent/openclaw-plugin",
3
3
  "name": "oda-shopping-assistant",
4
- "version": "0.1.4",
4
+ "version": "0.1.6",
5
5
  "description": "Oda grocery shopping assistant — safe cart planning, order history analysis, and delivery slot discovery.",
6
6
  "author": "oda-agent-kit",
7
7
  "license": "MIT",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oda-agent/openclaw-plugin",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "OpenClaw plugin for safe grocery planning and Oda automation",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -32,7 +32,6 @@
32
32
  "openclaw": {
33
33
  "extensions": [
34
34
  "./dist/index.js"
35
- ],
36
- "hooks": []
35
+ ]
37
36
  }
38
37
  }