@oda-agent/openclaw-plugin 0.1.9 → 0.3.0
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/entry.d.ts +13 -2
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +159 -50
- package/dist/entry.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/plugin.d.ts +98 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +168 -50
- package/dist/plugin.js.map +1 -1
- package/dist/tools/cartMutationTools.d.ts +19 -0
- package/dist/tools/cartMutationTools.d.ts.map +1 -1
- package/dist/tools/cartMutationTools.js +58 -1
- package/dist/tools/cartMutationTools.js.map +1 -1
- package/dist/tools/readOnlyTools.d.ts +30 -2
- package/dist/tools/readOnlyTools.d.ts.map +1 -1
- package/dist/tools/readOnlyTools.js +26 -2
- package/dist/tools/readOnlyTools.js.map +1 -1
- package/openclaw.plugin.json +12 -44
- package/package.json +1 -1
- package/skills/oda-shopping-assistant/SKILL.md +6 -14
package/dist/entry.d.ts
CHANGED
|
@@ -16,11 +16,22 @@
|
|
|
16
16
|
* members used by this plugin are declared here.
|
|
17
17
|
*/
|
|
18
18
|
export interface OpenClawApi {
|
|
19
|
-
/** Register a
|
|
20
|
-
registerTool(
|
|
19
|
+
/** Register a tool with the plugin runtime. */
|
|
20
|
+
registerTool(tool: OpenClawToolDefinition): void;
|
|
21
21
|
/** Return the plugin configuration provided by the user or environment. */
|
|
22
22
|
getConfig(): Record<string, unknown>;
|
|
23
23
|
}
|
|
24
|
+
export interface OpenClawToolDefinition {
|
|
25
|
+
name: string;
|
|
26
|
+
label?: string;
|
|
27
|
+
description: string;
|
|
28
|
+
parameters: {
|
|
29
|
+
type: 'object';
|
|
30
|
+
properties: Record<string, unknown>;
|
|
31
|
+
required?: string[];
|
|
32
|
+
};
|
|
33
|
+
execute(toolCallId: string, params: unknown): Promise<unknown>;
|
|
34
|
+
}
|
|
24
35
|
/** Shape of an OpenClaw native plugin entry. */
|
|
25
36
|
export interface OpenClawPluginEntry {
|
|
26
37
|
/** Unique identifier for the plugin (must match `openclaw.plugin.json` id). */
|
package/dist/entry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAcH;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAcH;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,+CAA+C;IAC/C,YAAY,CAAC,IAAI,EAAE,sBAAsB,GAAG,IAAI,CAAC;IACjD,2EAA2E;IAC3E,SAAS,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACpC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;IACF,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAChE;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;AAkCD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAkO/C;AAED,wBAAgB,QAAQ,IAAI,IAAI,CAG/B;AAMD,QAAA,MAAM,WAAW,qBAOf,CAAC;AAEH,eAAe,WAAW,CAAC"}
|
package/dist/entry.js
CHANGED
|
@@ -48,6 +48,17 @@ const plugin_js_1 = require("./plugin.js");
|
|
|
48
48
|
function definePluginEntry(entry) {
|
|
49
49
|
return entry;
|
|
50
50
|
}
|
|
51
|
+
function registerTool(api, name, label, description, parameters, handler) {
|
|
52
|
+
api.registerTool({
|
|
53
|
+
name,
|
|
54
|
+
label,
|
|
55
|
+
description,
|
|
56
|
+
parameters,
|
|
57
|
+
async execute(_toolCallId, params) {
|
|
58
|
+
return handler(params);
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
}
|
|
51
62
|
function register(api) {
|
|
52
63
|
let runtimePromise = null;
|
|
53
64
|
let authenticatedRuntimePromise = null;
|
|
@@ -83,60 +94,158 @@ function register(api) {
|
|
|
83
94
|
}
|
|
84
95
|
return authenticatedRuntimePromise;
|
|
85
96
|
}
|
|
86
|
-
// ──
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return readOnlyTools.getDeliverySlots(client);
|
|
102
|
-
});
|
|
103
|
-
api.registerTool('getShoppingLists', "List the user's saved shopping lists.", async () => {
|
|
97
|
+
// ── Workflow-oriented tools ─────────────────────────────────────────────
|
|
98
|
+
registerTool(api, 'browse_oda_catalog', 'Browse Catalog', 'Search the Oda catalog with a short, easy-to-scan result list.', {
|
|
99
|
+
type: 'object',
|
|
100
|
+
properties: {
|
|
101
|
+
query: {
|
|
102
|
+
type: 'string',
|
|
103
|
+
description: 'Search query for the Oda catalog.',
|
|
104
|
+
},
|
|
105
|
+
limit: {
|
|
106
|
+
type: 'number',
|
|
107
|
+
description: 'Maximum number of products to return. Defaults to 5.',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
required: ['query'],
|
|
111
|
+
}, async (params) => {
|
|
104
112
|
const { client } = await ensureLoggedIn();
|
|
105
|
-
return readOnlyTools.
|
|
106
|
-
});
|
|
107
|
-
// ── Higher-level read-only helpers ──────────────────────────────────────
|
|
108
|
-
api.registerTool('analyseOrderHistory', 'Analyse past orders and return a summary of frequently ordered products.', async (params) => {
|
|
109
|
-
const { plugin } = await ensureLoggedIn();
|
|
110
|
-
const p = params;
|
|
111
|
-
return plugin.analyseOrderHistory(p?.maxPages);
|
|
113
|
+
return readOnlyTools.browseCatalog(client, params);
|
|
112
114
|
});
|
|
113
|
-
|
|
115
|
+
registerTool(api, 'review_shopping_overview', 'Review Shopping Overview', 'See the cart, saved lists, repeat buys, and delivery options together.', {
|
|
116
|
+
type: 'object',
|
|
117
|
+
properties: {
|
|
118
|
+
includeCart: {
|
|
119
|
+
type: 'boolean',
|
|
120
|
+
description: 'Include a cart summary. Defaults to true.',
|
|
121
|
+
},
|
|
122
|
+
includeSavedLists: {
|
|
123
|
+
type: 'boolean',
|
|
124
|
+
description: 'Include saved shopping lists. Defaults to true.',
|
|
125
|
+
},
|
|
126
|
+
includeOrderHistory: {
|
|
127
|
+
type: 'boolean',
|
|
128
|
+
description: 'Include frequent purchase analysis. Defaults to true.',
|
|
129
|
+
},
|
|
130
|
+
includeDelivery: {
|
|
131
|
+
type: 'boolean',
|
|
132
|
+
description: 'Include delivery slot overview. Defaults to true.',
|
|
133
|
+
},
|
|
134
|
+
maxHistoryPages: {
|
|
135
|
+
type: 'number',
|
|
136
|
+
description: 'Maximum number of order-history pages to inspect.',
|
|
137
|
+
},
|
|
138
|
+
maxSavedLists: {
|
|
139
|
+
type: 'number',
|
|
140
|
+
description: 'Maximum number of saved lists to include.',
|
|
141
|
+
},
|
|
142
|
+
maxDeliverySlots: {
|
|
143
|
+
type: 'number',
|
|
144
|
+
description: 'Maximum number of delivery slots to include.',
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
}, async (params) => {
|
|
114
148
|
const { plugin } = await ensureLoggedIn();
|
|
115
|
-
|
|
116
|
-
return plugin.buildShoppingList(p.name, p.items);
|
|
149
|
+
return plugin.reviewAccount((params ?? {}));
|
|
117
150
|
});
|
|
118
|
-
|
|
151
|
+
registerTool(api, 'plan_grocery_list', 'Plan Grocery List', 'Turn grocery requests into a matched plan without changing the cart.', {
|
|
152
|
+
type: 'object',
|
|
153
|
+
properties: {
|
|
154
|
+
name: {
|
|
155
|
+
type: 'string',
|
|
156
|
+
description: 'Plan name shown back to the user.',
|
|
157
|
+
},
|
|
158
|
+
requests: {
|
|
159
|
+
type: 'array',
|
|
160
|
+
description: 'Requested groceries to resolve into Oda products.',
|
|
161
|
+
items: {
|
|
162
|
+
type: 'object',
|
|
163
|
+
properties: {
|
|
164
|
+
query: {
|
|
165
|
+
type: 'string',
|
|
166
|
+
description: 'Free-text grocery request.',
|
|
167
|
+
},
|
|
168
|
+
quantity: {
|
|
169
|
+
type: 'number',
|
|
170
|
+
description: 'Requested quantity. Defaults to 1.',
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
required: ['query'],
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
required: ['name', 'requests'],
|
|
178
|
+
}, async (params) => {
|
|
119
179
|
const { plugin } = await ensureLoggedIn();
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
// ── Cart-mutation tools (disabled by default in manifest) ───────────────
|
|
123
|
-
api.registerTool('addToCart', 'Add a single product to the cart. Requires explicit user confirmation before use.', async (params) => {
|
|
124
|
-
const { client } = await ensureLoggedIn();
|
|
125
|
-
const p = params;
|
|
126
|
-
return cartMutationTools.addToCart(client, p.productId, p.quantity);
|
|
127
|
-
});
|
|
128
|
-
api.registerTool('removeFromCart', 'Remove an item from the cart by product ID. Requires explicit user confirmation before use.', async (params) => {
|
|
129
|
-
const { client } = await ensureLoggedIn();
|
|
130
|
-
const p = params;
|
|
131
|
-
return cartMutationTools.removeFromCart(client, p.productId);
|
|
132
|
-
});
|
|
133
|
-
api.registerTool('clearCart', 'Remove all items from the cart. Requires explicit user confirmation before use.', async () => {
|
|
134
|
-
const { client } = await ensureLoggedIn();
|
|
135
|
-
return cartMutationTools.clearCart(client);
|
|
180
|
+
const plan = params;
|
|
181
|
+
return plugin.planGroceries(plan.name, plan.requests);
|
|
136
182
|
});
|
|
137
|
-
|
|
183
|
+
registerTool(api, 'apply_cart_changes', 'Apply Cart Changes', 'Apply one confirmed cart change.', {
|
|
184
|
+
type: 'object',
|
|
185
|
+
properties: {
|
|
186
|
+
mode: {
|
|
187
|
+
type: 'string',
|
|
188
|
+
description: 'Cart update mode.',
|
|
189
|
+
enum: ['apply-plan', 'add-products', 'remove-products', 'clear-cart'],
|
|
190
|
+
},
|
|
191
|
+
plan: {
|
|
192
|
+
type: 'object',
|
|
193
|
+
description: 'Shopping plan to apply when mode is "apply-plan".',
|
|
194
|
+
properties: {
|
|
195
|
+
name: {
|
|
196
|
+
type: 'string',
|
|
197
|
+
description: 'Shopping-plan name.',
|
|
198
|
+
},
|
|
199
|
+
items: {
|
|
200
|
+
type: 'array',
|
|
201
|
+
items: {
|
|
202
|
+
type: 'object',
|
|
203
|
+
properties: {
|
|
204
|
+
productId: {
|
|
205
|
+
type: 'number',
|
|
206
|
+
description: 'Oda product ID.',
|
|
207
|
+
},
|
|
208
|
+
quantity: {
|
|
209
|
+
type: 'number',
|
|
210
|
+
description: 'Quantity to add.',
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
required: ['productId', 'quantity'],
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
required: ['name', 'items'],
|
|
218
|
+
},
|
|
219
|
+
items: {
|
|
220
|
+
type: 'array',
|
|
221
|
+
description: 'Products to add when mode is "add-products".',
|
|
222
|
+
items: {
|
|
223
|
+
type: 'object',
|
|
224
|
+
properties: {
|
|
225
|
+
productId: {
|
|
226
|
+
type: 'number',
|
|
227
|
+
description: 'Oda product ID.',
|
|
228
|
+
},
|
|
229
|
+
quantity: {
|
|
230
|
+
type: 'number',
|
|
231
|
+
description: 'Quantity to add.',
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
required: ['productId', 'quantity'],
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
productIds: {
|
|
238
|
+
type: 'array',
|
|
239
|
+
description: 'Products to remove when mode is "remove-products".',
|
|
240
|
+
items: {
|
|
241
|
+
type: 'number',
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
required: ['mode'],
|
|
246
|
+
}, async (params) => {
|
|
138
247
|
const { client } = await ensureLoggedIn();
|
|
139
|
-
return cartMutationTools.
|
|
248
|
+
return cartMutationTools.updateCart(client, params);
|
|
140
249
|
});
|
|
141
250
|
}
|
|
142
251
|
exports.register = register;
|
|
@@ -149,9 +258,9 @@ exports.activate = activate;
|
|
|
149
258
|
// Plugin entry
|
|
150
259
|
// ---------------------------------------------------------------------------
|
|
151
260
|
const pluginEntry = definePluginEntry({
|
|
152
|
-
id: '
|
|
153
|
-
name: '
|
|
154
|
-
description: '
|
|
261
|
+
id: 'oda-groceries',
|
|
262
|
+
name: 'Oda Groceries',
|
|
263
|
+
description: 'Browse groceries, review your shopping context, and apply confirmed cart changes.',
|
|
155
264
|
register,
|
|
156
265
|
activate,
|
|
157
266
|
});
|
package/dist/entry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.js","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,0CAA4C;AAE5C,wEAA0D;AAC1D,gFAAkE;AAClE,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4BACR,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,kBAAkB;yBAChC;qBACF;oBACD,QAAQ,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC;iBACpC;aACF;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,oDAAoD;gBACjE,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;iBACf;aACF;SACF;QACD,QAAQ,EAAE,CAAC,MAAM,CAAC;KACnB,EACD,KAAK,EAAE,MAAM,EAAE,EAAE;QACf,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,cAAc,EAAE,CAAC;QAC1C,OAAO,iBAAiB,CAAC,UAAU,CAAC,MAAM,EAAE,MAA4C,CAAC,CAAC;IAC5F,CAAC,CACF,CAAC;AACJ,CAAC;AAlOD,4BAkOC;AAED,SAAgB,QAAQ;IACtB,kEAAkE;IAClE,kEAAkE;AACpE,CAAC;AAHD,4BAGC;AAED,8EAA8E;AAC9E,eAAe;AACf,8EAA8E;AAE9E,MAAM,WAAW,GAAG,iBAAiB,CAAC;IACpC,EAAE,EAAE,eAAe;IACnB,IAAI,EAAE,eAAe;IACrB,WAAW,EACT,mFAAmF;IACrF,QAAQ;IACR,QAAQ;CACT,CAAC,CAAC;AAEH,kBAAe,WAAW,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { default, register, activate } from './entry.js';
|
|
2
2
|
export type { OpenClawApi, OpenClawPluginEntry } from './entry.js';
|
|
3
3
|
export { createOpenClawPlugin } from './plugin.js';
|
|
4
|
-
export type {
|
|
4
|
+
export type { AccountReview, CartOverview, DeliverySlotOverview, GroceryPlan, GroceryRequest, OpenClawPlugin, OrderHistorySummary, PlannedGroceryItem, ReviewAccountOptions, SavedListOverview, ShoppingList, UnmatchedGroceryRequest, } from './plugin.js';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACzD,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACzD,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EACV,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,WAAW,EACX,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,EACZ,uBAAuB,GACxB,MAAM,aAAa,CAAC"}
|
package/dist/plugin.d.ts
CHANGED
|
@@ -7,6 +7,96 @@ export interface ShoppingList {
|
|
|
7
7
|
quantity: number;
|
|
8
8
|
}>;
|
|
9
9
|
}
|
|
10
|
+
/** A user-friendly summary of a cart item. */
|
|
11
|
+
export interface CartOverviewItem {
|
|
12
|
+
productId: number;
|
|
13
|
+
name: string;
|
|
14
|
+
quantity: number;
|
|
15
|
+
linePrice: string;
|
|
16
|
+
available: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** A compact cart summary for UI-facing tools. */
|
|
19
|
+
export interface CartOverview {
|
|
20
|
+
itemCount: number;
|
|
21
|
+
totalPrice: string;
|
|
22
|
+
currency: string;
|
|
23
|
+
items: CartOverviewItem[];
|
|
24
|
+
}
|
|
25
|
+
/** A compact saved-list summary for UI-facing tools. */
|
|
26
|
+
export interface SavedListOverview {
|
|
27
|
+
id: number;
|
|
28
|
+
name: string;
|
|
29
|
+
itemCount: number;
|
|
30
|
+
}
|
|
31
|
+
/** A compact product frequency summary. */
|
|
32
|
+
export interface FrequentProductOverview {
|
|
33
|
+
productId: number;
|
|
34
|
+
name: string;
|
|
35
|
+
brand: string | null;
|
|
36
|
+
timesOrdered: number;
|
|
37
|
+
}
|
|
38
|
+
/** A compact delivery-slot summary. */
|
|
39
|
+
export interface DeliverySlotOverview {
|
|
40
|
+
id: number;
|
|
41
|
+
start: string;
|
|
42
|
+
end: string;
|
|
43
|
+
price: string;
|
|
44
|
+
currency: string;
|
|
45
|
+
}
|
|
46
|
+
/** Options for the reviewAccount helper. */
|
|
47
|
+
export interface ReviewAccountOptions {
|
|
48
|
+
includeCart?: boolean;
|
|
49
|
+
includeSavedLists?: boolean;
|
|
50
|
+
includeOrderHistory?: boolean;
|
|
51
|
+
includeDelivery?: boolean;
|
|
52
|
+
maxHistoryPages?: number;
|
|
53
|
+
maxSavedLists?: number;
|
|
54
|
+
maxDeliverySlots?: number;
|
|
55
|
+
}
|
|
56
|
+
/** User-facing account review returned by the OpenClaw tool. */
|
|
57
|
+
export interface AccountReview {
|
|
58
|
+
cart?: CartOverview;
|
|
59
|
+
savedLists?: SavedListOverview[];
|
|
60
|
+
orderHistory?: {
|
|
61
|
+
totalOrders: number;
|
|
62
|
+
totalSpend: string;
|
|
63
|
+
currency: string;
|
|
64
|
+
mostOrderedProducts: FrequentProductOverview[];
|
|
65
|
+
};
|
|
66
|
+
delivery?: {
|
|
67
|
+
availableSlotCount: number;
|
|
68
|
+
cheapestSlot?: DeliverySlotOverview;
|
|
69
|
+
upcomingSlots: DeliverySlotOverview[];
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** A single request supplied to the grocery planner. */
|
|
73
|
+
export interface GroceryRequest {
|
|
74
|
+
query: string;
|
|
75
|
+
quantity?: number;
|
|
76
|
+
}
|
|
77
|
+
/** A matched request in the grocery planner output. */
|
|
78
|
+
export interface PlannedGroceryItem {
|
|
79
|
+
query: string;
|
|
80
|
+
quantity: number;
|
|
81
|
+
productId: number;
|
|
82
|
+
productName: string;
|
|
83
|
+
brand: string | null;
|
|
84
|
+
price: string;
|
|
85
|
+
currency: string;
|
|
86
|
+
}
|
|
87
|
+
/** A request that could not be matched to a product. */
|
|
88
|
+
export interface UnmatchedGroceryRequest {
|
|
89
|
+
query: string;
|
|
90
|
+
quantity: number;
|
|
91
|
+
}
|
|
92
|
+
/** User-facing grocery plan returned by the OpenClaw tool. */
|
|
93
|
+
export interface GroceryPlan {
|
|
94
|
+
name: string;
|
|
95
|
+
shoppingList: ShoppingList;
|
|
96
|
+
matchedItems: PlannedGroceryItem[];
|
|
97
|
+
unmatchedItems: UnmatchedGroceryRequest[];
|
|
98
|
+
summary: string;
|
|
99
|
+
}
|
|
10
100
|
/** Summary of a user's order history. */
|
|
11
101
|
export interface OrderHistorySummary {
|
|
12
102
|
totalOrders: number;
|
|
@@ -19,6 +109,14 @@ export interface OrderHistorySummary {
|
|
|
19
109
|
}
|
|
20
110
|
/** The OpenClaw plugin object returned by the factory. */
|
|
21
111
|
export interface OpenClawPlugin {
|
|
112
|
+
/**
|
|
113
|
+
* Search the current account state in one call for day-to-day planning.
|
|
114
|
+
*/
|
|
115
|
+
reviewAccount(options?: ReviewAccountOptions): Promise<AccountReview>;
|
|
116
|
+
/**
|
|
117
|
+
* Build a user-facing grocery plan from free-text requests.
|
|
118
|
+
*/
|
|
119
|
+
planGroceries(name: string, requests: GroceryRequest[]): Promise<GroceryPlan>;
|
|
22
120
|
/**
|
|
23
121
|
* Search for products and build a shopping list from a plain-text description.
|
|
24
122
|
* Returns a list of matched products ready to add to cart.
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version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,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CACxF,CAAC;CACH;AAsHD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,cAAc,CAiItE"}
|
package/dist/plugin.js
CHANGED
|
@@ -1,6 +1,87 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createOpenClawPlugin = void 0;
|
|
4
|
+
function summarizeCart(cart) {
|
|
5
|
+
return {
|
|
6
|
+
itemCount: cart.item_count,
|
|
7
|
+
totalPrice: cart.total_price,
|
|
8
|
+
currency: cart.currency,
|
|
9
|
+
items: cart.items.map((item) => ({
|
|
10
|
+
productId: item.product.id,
|
|
11
|
+
name: item.product.full_name,
|
|
12
|
+
quantity: item.quantity,
|
|
13
|
+
linePrice: item.line_price,
|
|
14
|
+
available: item.product.is_available,
|
|
15
|
+
})),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function summarizeSavedLists(lists, maxSavedLists) {
|
|
19
|
+
return lists.slice(0, maxSavedLists).map((list) => ({
|
|
20
|
+
id: list.id,
|
|
21
|
+
name: list.name,
|
|
22
|
+
itemCount: list.items.length,
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
async function loadShoppingLists(client) {
|
|
26
|
+
const clientWithLists = client;
|
|
27
|
+
if (typeof clientWithLists.getShoppingLists !== 'function') {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
return clientWithLists.getShoppingLists();
|
|
31
|
+
}
|
|
32
|
+
function summarizeDeliverySlots(slots, maxDeliverySlots) {
|
|
33
|
+
const available = slots
|
|
34
|
+
.filter((slot) => slot.is_available)
|
|
35
|
+
.sort((left, right) => parseFloat(left.price) - parseFloat(right.price));
|
|
36
|
+
return {
|
|
37
|
+
availableSlotCount: available.length,
|
|
38
|
+
cheapestSlot: available[0]
|
|
39
|
+
? {
|
|
40
|
+
id: available[0].id,
|
|
41
|
+
start: available[0].start,
|
|
42
|
+
end: available[0].end,
|
|
43
|
+
price: available[0].price,
|
|
44
|
+
currency: available[0].currency,
|
|
45
|
+
}
|
|
46
|
+
: undefined,
|
|
47
|
+
upcomingSlots: available.slice(0, maxDeliverySlots).map((slot) => ({
|
|
48
|
+
id: slot.id,
|
|
49
|
+
start: slot.start,
|
|
50
|
+
end: slot.end,
|
|
51
|
+
price: slot.price,
|
|
52
|
+
currency: slot.currency,
|
|
53
|
+
})),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
async function resolveShoppingRequests(client, requests) {
|
|
57
|
+
const items = [];
|
|
58
|
+
const matchedItems = [];
|
|
59
|
+
const unmatchedItems = [];
|
|
60
|
+
for (const request of requests) {
|
|
61
|
+
const quantity = request.quantity ?? 1;
|
|
62
|
+
const results = await client.searchProducts(request.query);
|
|
63
|
+
const first = results.results[0];
|
|
64
|
+
if (!first) {
|
|
65
|
+
unmatchedItems.push({ query: request.query, quantity });
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
items.push({ productId: first.id, quantity });
|
|
69
|
+
matchedItems.push({
|
|
70
|
+
query: request.query,
|
|
71
|
+
quantity,
|
|
72
|
+
productId: first.id,
|
|
73
|
+
productName: first.full_name,
|
|
74
|
+
brand: first.brand,
|
|
75
|
+
price: first.gross_price,
|
|
76
|
+
currency: first.currency,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
items,
|
|
81
|
+
matchedItems,
|
|
82
|
+
unmatchedItems,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
4
85
|
// ---------------------------------------------------------------------------
|
|
5
86
|
// Factory
|
|
6
87
|
// ---------------------------------------------------------------------------
|
|
@@ -20,67 +101,104 @@ exports.createOpenClawPlugin = void 0;
|
|
|
20
101
|
* ```
|
|
21
102
|
*/
|
|
22
103
|
function createOpenClawPlugin(client) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
break;
|
|
44
|
-
totalOrders += orderPage.results.length;
|
|
45
|
-
for (const order of orderPage.results) {
|
|
46
|
-
currency = order.currency;
|
|
47
|
-
totalSpendCents += Math.round(parseFloat(order.total_price) * 100);
|
|
48
|
-
for (const item of order.items) {
|
|
49
|
-
const existing = productCounts.get(item.product.id);
|
|
50
|
-
if (existing) {
|
|
51
|
-
existing.count += item.quantity;
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
productCounts.set(item.product.id, { product: item.product, count: item.quantity });
|
|
55
|
-
}
|
|
104
|
+
async function analyseOrderHistory(maxPages = 5) {
|
|
105
|
+
const productCounts = new Map();
|
|
106
|
+
let totalOrders = 0;
|
|
107
|
+
let totalSpendCents = 0;
|
|
108
|
+
let currency = 'NOK';
|
|
109
|
+
for (let page = 1; page <= maxPages; page++) {
|
|
110
|
+
const orderPage = await client.getOrders(page);
|
|
111
|
+
if (orderPage.results.length === 0)
|
|
112
|
+
break;
|
|
113
|
+
totalOrders += orderPage.results.length;
|
|
114
|
+
for (const order of orderPage.results) {
|
|
115
|
+
currency = order.currency;
|
|
116
|
+
totalSpendCents += Math.round(parseFloat(order.total_price) * 100);
|
|
117
|
+
for (const item of order.items) {
|
|
118
|
+
const existing = productCounts.get(item.product.id);
|
|
119
|
+
if (existing) {
|
|
120
|
+
existing.count += item.quantity;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
productCounts.set(item.product.id, { product: item.product, count: item.quantity });
|
|
56
124
|
}
|
|
57
125
|
}
|
|
58
|
-
if (!orderPage.next)
|
|
59
|
-
break;
|
|
60
126
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
127
|
+
if (!orderPage.next)
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
const sorted = [...productCounts.values()]
|
|
131
|
+
.sort((a, b) => b.count - a.count)
|
|
132
|
+
.slice(0, 10)
|
|
133
|
+
.map(({ product, count }) => ({ product, timesOrdered: count }));
|
|
134
|
+
return {
|
|
135
|
+
totalOrders,
|
|
136
|
+
totalSpend: (totalSpendCents / 100).toFixed(2),
|
|
137
|
+
currency,
|
|
138
|
+
mostOrderedProducts: sorted,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
async function buildShoppingList(name, items) {
|
|
142
|
+
const resolved = await resolveShoppingRequests(client, items);
|
|
143
|
+
return { name, items: resolved.items };
|
|
144
|
+
}
|
|
145
|
+
async function findCheapestDeliverySlot() {
|
|
146
|
+
const slots = await client.getDeliverySlots();
|
|
147
|
+
const available = slots.filter((slot) => slot.is_available);
|
|
148
|
+
if (available.length === 0)
|
|
149
|
+
return undefined;
|
|
150
|
+
return available.sort((left, right) => parseFloat(left.price) - parseFloat(right.price))[0];
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
async reviewAccount(options = {}) {
|
|
154
|
+
const { includeCart = true, includeSavedLists = true, includeOrderHistory = true, includeDelivery = true, maxHistoryPages = 5, maxSavedLists = 5, maxDeliverySlots = 3, } = options;
|
|
155
|
+
const review = {};
|
|
156
|
+
if (includeCart) {
|
|
157
|
+
review.cart = summarizeCart(await client.getCart());
|
|
158
|
+
}
|
|
159
|
+
if (includeSavedLists) {
|
|
160
|
+
review.savedLists = summarizeSavedLists(await loadShoppingLists(client), maxSavedLists);
|
|
161
|
+
}
|
|
162
|
+
if (includeOrderHistory) {
|
|
163
|
+
const summary = await analyseOrderHistory(maxHistoryPages);
|
|
164
|
+
review.orderHistory = {
|
|
165
|
+
totalOrders: summary.totalOrders,
|
|
166
|
+
totalSpend: summary.totalSpend,
|
|
167
|
+
currency: summary.currency,
|
|
168
|
+
mostOrderedProducts: summary.mostOrderedProducts.map(({ product, timesOrdered }) => ({
|
|
169
|
+
productId: product.id,
|
|
170
|
+
name: product.full_name,
|
|
171
|
+
brand: product.brand,
|
|
172
|
+
timesOrdered,
|
|
173
|
+
})),
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
if (includeDelivery) {
|
|
177
|
+
review.delivery = summarizeDeliverySlots(await client.getDeliverySlots(), maxDeliverySlots);
|
|
178
|
+
}
|
|
179
|
+
return review;
|
|
180
|
+
},
|
|
181
|
+
async planGroceries(name, requests) {
|
|
182
|
+
const resolved = await resolveShoppingRequests(client, requests);
|
|
65
183
|
return {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
184
|
+
name,
|
|
185
|
+
shoppingList: {
|
|
186
|
+
name,
|
|
187
|
+
items: resolved.items,
|
|
188
|
+
},
|
|
189
|
+
matchedItems: resolved.matchedItems,
|
|
190
|
+
unmatchedItems: resolved.unmatchedItems,
|
|
191
|
+
summary: `Matched ${resolved.matchedItems.length} request(s) and left ${resolved.unmatchedItems.length} unmatched.`,
|
|
70
192
|
};
|
|
71
193
|
},
|
|
194
|
+
buildShoppingList,
|
|
195
|
+
analyseOrderHistory,
|
|
72
196
|
async prepareCart(list) {
|
|
73
197
|
for (const item of list.items) {
|
|
74
198
|
await client.addToCart(item.productId, item.quantity);
|
|
75
199
|
}
|
|
76
200
|
},
|
|
77
|
-
|
|
78
|
-
const slots = await client.getDeliverySlots();
|
|
79
|
-
const available = slots.filter((s) => s.is_available);
|
|
80
|
-
if (available.length === 0)
|
|
81
|
-
return undefined;
|
|
82
|
-
return available.sort((a, b) => parseFloat(a.price) - parseFloat(b.price))[0];
|
|
83
|
-
},
|
|
201
|
+
findCheapestDeliverySlot,
|
|
84
202
|
};
|
|
85
203
|
}
|
|
86
204
|
exports.createOpenClawPlugin = createOpenClawPlugin;
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot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nC,cAAc,EAAE,QAAQ,CAAC,cAAc;gBACvC,OAAO,EAAE,WAAW,QAAQ,CAAC,YAAY,CAAC,MAAM,wBAAwB,QAAQ,CAAC,cAAc,CAAC,MAAM,aAAa;aACpH,CAAC;QACJ,CAAC;QAED,iBAAiB;QAEjB,mBAAmB;QAEnB,KAAK,CAAC,WAAW,CAAC,IAAI;YACpB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBAC9B,MAAM,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;QAED,wBAAwB;KACzB,CAAC;AACJ,CAAC;AAjID,oDAiIC"}
|
|
@@ -22,6 +22,21 @@ export interface CartMutationResult {
|
|
|
22
22
|
/** Human-readable description of what changed. */
|
|
23
23
|
summary: string;
|
|
24
24
|
}
|
|
25
|
+
/** Parameters for the higher-level updateCart tool. */
|
|
26
|
+
export interface UpdateCartParams {
|
|
27
|
+
mode: 'apply-plan' | 'add-products' | 'remove-products' | 'clear-cart';
|
|
28
|
+
plan?: ShoppingList;
|
|
29
|
+
items?: Array<{
|
|
30
|
+
productId: number;
|
|
31
|
+
quantity: number;
|
|
32
|
+
}>;
|
|
33
|
+
productIds?: number[];
|
|
34
|
+
}
|
|
35
|
+
/** Result of the higher-level updateCart tool. */
|
|
36
|
+
export interface CartUpdateResult extends CartMutationResult {
|
|
37
|
+
mode: UpdateCartParams['mode'];
|
|
38
|
+
steps: string[];
|
|
39
|
+
}
|
|
25
40
|
/**
|
|
26
41
|
* Add `quantity` units of `productId` to the cart.
|
|
27
42
|
*
|
|
@@ -50,4 +65,8 @@ export declare function clearCart(client: OdaClient): Promise<CartMutationResult
|
|
|
50
65
|
* the full shopping list to the user and wait for approval.
|
|
51
66
|
*/
|
|
52
67
|
export declare function prepareCart(client: OdaClient, list: ShoppingList): Promise<CartMutationResult>;
|
|
68
|
+
/**
|
|
69
|
+
* Apply one cart update intent by composing the lower-level mutation helpers.
|
|
70
|
+
*/
|
|
71
|
+
export declare function updateCart(client: OdaClient, params: UpdateCartParams): Promise<CartUpdateResult>;
|
|
53
72
|
//# sourceMappingURL=cartMutationTools.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cartMutationTools.d.ts","sourceRoot":"","sources":["../../src/tools/cartMutationTools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAMjD,2CAA2C;AAC3C,MAAM,WAAW,kBAAkB;IACjC,kDAAkD;IAClD,OAAO,EAAE,MAAM,CAAC;CACjB;AAMD;;;;GAIG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,kBAAkB,CAAC,CAG7B;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,kBAAkB,CAAC,CAG7B;AAED;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAG9E;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,YAAY,GACjB,OAAO,CAAC,kBAAkB,CAAC,CAO7B"}
|
|
1
|
+
{"version":3,"file":"cartMutationTools.d.ts","sourceRoot":"","sources":["../../src/tools/cartMutationTools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC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ical workflow.
|
|
18
18
|
*/
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.prepareCart = exports.clearCart = exports.removeFromCart = exports.addToCart = void 0;
|
|
20
|
+
exports.updateCart = exports.prepareCart = exports.clearCart = exports.removeFromCart = exports.addToCart = void 0;
|
|
21
21
|
// ---------------------------------------------------------------------------
|
|
22
22
|
// Tool implementations
|
|
23
23
|
// ---------------------------------------------------------------------------
|
|
@@ -69,4 +69,61 @@ async function prepareCart(client, list) {
|
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
exports.prepareCart = prepareCart;
|
|
72
|
+
/**
|
|
73
|
+
* Apply one cart update intent by composing the lower-level mutation helpers.
|
|
74
|
+
*/
|
|
75
|
+
async function updateCart(client, params) {
|
|
76
|
+
switch (params.mode) {
|
|
77
|
+
case 'apply-plan': {
|
|
78
|
+
if (!params.plan) {
|
|
79
|
+
throw new Error('updateCart with mode "apply-plan" requires a shopping plan.');
|
|
80
|
+
}
|
|
81
|
+
const result = await prepareCart(client, params.plan);
|
|
82
|
+
return {
|
|
83
|
+
mode: params.mode,
|
|
84
|
+
summary: result.summary,
|
|
85
|
+
steps: params.plan.items.map((item) => `Add ${item.quantity}× product #${item.productId}.`),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
case 'add-products': {
|
|
89
|
+
if (!params.items || params.items.length === 0) {
|
|
90
|
+
throw new Error('updateCart with mode "add-products" requires at least one item.');
|
|
91
|
+
}
|
|
92
|
+
const steps = [];
|
|
93
|
+
for (const item of params.items) {
|
|
94
|
+
const result = await addToCart(client, item.productId, item.quantity);
|
|
95
|
+
steps.push(result.summary);
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
mode: params.mode,
|
|
99
|
+
summary: `Added ${params.items.length} product(s) to cart.`,
|
|
100
|
+
steps,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
case 'remove-products': {
|
|
104
|
+
if (!params.productIds || params.productIds.length === 0) {
|
|
105
|
+
throw new Error('updateCart with mode "remove-products" requires at least one product ID.');
|
|
106
|
+
}
|
|
107
|
+
const steps = [];
|
|
108
|
+
for (const productId of params.productIds) {
|
|
109
|
+
const result = await removeFromCart(client, productId);
|
|
110
|
+
steps.push(result.summary);
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
mode: params.mode,
|
|
114
|
+
summary: `Removed ${params.productIds.length} product(s) from cart.`,
|
|
115
|
+
steps,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
case 'clear-cart': {
|
|
119
|
+
const result = await clearCart(client);
|
|
120
|
+
return {
|
|
121
|
+
mode: params.mode,
|
|
122
|
+
summary: result.summary,
|
|
123
|
+
steps: [result.summary],
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
exports.updateCart = updateCart;
|
|
72
129
|
//# sourceMappingURL=cartMutationTools.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cartMutationTools.js","sourceRoot":"","sources":["../../src/tools/cartMutationTools.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;
|
|
1
|
+
{"version":3,"file":"cartMutationTools.js","sourceRoot":"","sources":["../../src/tools/cartMutationTools.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AA6BH,8EAA8E;AAC9E,uBAAuB;AACvB,8EAA8E;AAE9E;;;;GAIG;AACI,KAAK,UAAU,SAAS,CAC7B,MAAiB,EACjB,SAAiB,EACjB,QAAgB;IAEhB,MAAM,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC5C,OAAO,EAAE,OAAO,EAAE,SAAS,QAAQ,cAAc,SAAS,WAAW,EAAE,CAAC;AAC1E,CAAC;AAPD,8BAOC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,cAAc,CAClC,MAAiB,EACjB,SAAiB;IAEjB,MAAM,MAAM,CAAC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,CAAC;QAED,KAAK,YAAY,CAAC,CAAC,CAAC;YAClB,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,CAAC;YACvC,OAAO;gBACL,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,KAAK,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC;aACxB,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC;AAjED,gCAiEC"}
|
|
@@ -15,21 +15,48 @@
|
|
|
15
15
|
* findCheapestDeliverySlot) are implemented in plugin.ts and compose
|
|
16
16
|
* these primitives without performing any writes.
|
|
17
17
|
*/
|
|
18
|
-
import type { OdaClient, OdaSearchResponse, OdaCart, OdaPage, OdaOrder, OdaDeliverySlot
|
|
18
|
+
import type { OdaClient, OdaSearchResponse, OdaCart, OdaPage, OdaOrder, OdaDeliverySlot } from '@oda-agent/core';
|
|
19
19
|
/** Parameters for the searchProducts tool. */
|
|
20
20
|
export interface SearchProductsParams {
|
|
21
21
|
query: string;
|
|
22
22
|
}
|
|
23
|
+
/** Parameters for the browseCatalog tool. */
|
|
24
|
+
export interface BrowseCatalogParams {
|
|
25
|
+
query: string;
|
|
26
|
+
limit?: number;
|
|
27
|
+
}
|
|
28
|
+
/** A compact search result for UI-facing catalog browsing. */
|
|
29
|
+
export interface CatalogBrowseResult {
|
|
30
|
+
query: string;
|
|
31
|
+
totalMatches: number;
|
|
32
|
+
products: Array<{
|
|
33
|
+
productId: number;
|
|
34
|
+
name: string;
|
|
35
|
+
brand: string | null;
|
|
36
|
+
price: string;
|
|
37
|
+
currency: string;
|
|
38
|
+
available: boolean;
|
|
39
|
+
}>;
|
|
40
|
+
}
|
|
23
41
|
/** Parameters for the getOrders tool. */
|
|
24
42
|
export interface GetOrdersParams {
|
|
25
43
|
/** Page number, 1-based. Defaults to 1. */
|
|
26
44
|
page?: number;
|
|
27
45
|
}
|
|
46
|
+
interface SavedListLike {
|
|
47
|
+
id: number;
|
|
48
|
+
name: string;
|
|
49
|
+
items: unknown[];
|
|
50
|
+
}
|
|
28
51
|
/**
|
|
29
52
|
* Search the Oda catalogue for products matching `query`.
|
|
30
53
|
* Returns the raw search response including matched products and result count.
|
|
31
54
|
*/
|
|
32
55
|
export declare function searchProducts(client: OdaClient, params: SearchProductsParams): Promise<OdaSearchResponse>;
|
|
56
|
+
/**
|
|
57
|
+
* Search the Oda catalogue and return a compact, UI-friendly result list.
|
|
58
|
+
*/
|
|
59
|
+
export declare function browseCatalog(client: OdaClient, params: BrowseCatalogParams): Promise<CatalogBrowseResult>;
|
|
33
60
|
/**
|
|
34
61
|
* Retrieve the authenticated user's current shopping cart.
|
|
35
62
|
*/
|
|
@@ -45,5 +72,6 @@ export declare function getDeliverySlots(client: OdaClient): Promise<OdaDelivery
|
|
|
45
72
|
/**
|
|
46
73
|
* List the authenticated user's saved shopping lists.
|
|
47
74
|
*/
|
|
48
|
-
export declare function getShoppingLists(client: OdaClient): Promise<
|
|
75
|
+
export declare function getShoppingLists(client: OdaClient): Promise<SavedListLike[]>;
|
|
76
|
+
export {};
|
|
49
77
|
//# sourceMappingURL=readOnlyTools.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readOnlyTools.d.ts","sourceRoot":"","sources":["../../src/tools/readOnlyTools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"readOnlyTools.d.ts","sourceRoot":"","sources":["../../src/tools/readOnlyTools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAMjH,8CAA8C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BAAsB,gBAAgB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAEpF;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAQlF"}
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* these primitives without performing any writes.
|
|
18
18
|
*/
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.getShoppingLists = exports.getDeliverySlots = exports.getOrders = exports.getCart = exports.searchProducts = void 0;
|
|
20
|
+
exports.getShoppingLists = exports.getDeliverySlots = exports.getOrders = exports.getCart = exports.browseCatalog = exports.searchProducts = void 0;
|
|
21
21
|
// ---------------------------------------------------------------------------
|
|
22
22
|
// Tool implementations
|
|
23
23
|
// ---------------------------------------------------------------------------
|
|
@@ -29,6 +29,26 @@ async function searchProducts(client, params) {
|
|
|
29
29
|
return client.searchProducts(params.query);
|
|
30
30
|
}
|
|
31
31
|
exports.searchProducts = searchProducts;
|
|
32
|
+
/**
|
|
33
|
+
* Search the Oda catalogue and return a compact, UI-friendly result list.
|
|
34
|
+
*/
|
|
35
|
+
async function browseCatalog(client, params) {
|
|
36
|
+
const response = await client.searchProducts(params.query);
|
|
37
|
+
const limit = params.limit ?? 5;
|
|
38
|
+
return {
|
|
39
|
+
query: response.query,
|
|
40
|
+
totalMatches: response.count,
|
|
41
|
+
products: response.results.slice(0, limit).map((product) => ({
|
|
42
|
+
productId: product.id,
|
|
43
|
+
name: product.full_name,
|
|
44
|
+
brand: product.brand,
|
|
45
|
+
price: product.gross_price,
|
|
46
|
+
currency: product.currency,
|
|
47
|
+
available: product.is_available,
|
|
48
|
+
})),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
exports.browseCatalog = browseCatalog;
|
|
32
52
|
/**
|
|
33
53
|
* Retrieve the authenticated user's current shopping cart.
|
|
34
54
|
*/
|
|
@@ -54,7 +74,11 @@ exports.getDeliverySlots = getDeliverySlots;
|
|
|
54
74
|
* List the authenticated user's saved shopping lists.
|
|
55
75
|
*/
|
|
56
76
|
async function getShoppingLists(client) {
|
|
57
|
-
|
|
77
|
+
const clientWithLists = client;
|
|
78
|
+
if (typeof clientWithLists.getShoppingLists !== 'function') {
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
return clientWithLists.getShoppingLists();
|
|
58
82
|
}
|
|
59
83
|
exports.getShoppingLists = getShoppingLists;
|
|
60
84
|
//# sourceMappingURL=readOnlyTools.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readOnlyTools.js","sourceRoot":"","sources":["../../src/tools/readOnlyTools.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;
|
|
1
|
+
{"version":3,"file":"readOnlyTools.js","sourceRoot":"","sources":["../../src/tools/readOnlyTools.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAiDH,8EAA8E;AAC9E,uBAAuB;AACvB,8EAA8E;AAE9E;;;GAGG;AACI,KAAK,UAAU,cAAc,CAClC,MAAiB,EACjB,MAA4B;IAE5B,OAAO,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC7C,CAAC;AALD,wCAKC;AAED;;GAEG;AACI,KAAK,UAAU,aAAa,CACjC,MAAiB,EACjB,MAA2B;IAE3B,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3D,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC;IAEhC,OAAO;QACL,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,YAAY,EAAE,QAAQ,CAAC,KAAK;QAC5B,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YAC3D,SAAS,EAAE,OAAO,CAAC,EAAE;YACrB,IAAI,EAAE,OAAO,CAAC,SAAS;YACvB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,KAAK,EAAE,OAAO,CAAC,WAAW;YAC1B,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,SAAS,EAAE,OAAO,CAAC,YAAY;SAChC,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC;AAnBD,sCAmBC;AAED;;GAEG;AACI,KAAK,UAAU,OAAO,CAAC,MAAiB;IAC7C,OAAO,MAAM,CAAC,OAAO,EAAE,CAAC;AAC1B,CAAC;AAFD,0BAEC;AAED;;GAEG;AACI,KAAK,UAAU,SAAS,CAC7B,MAAiB,EACjB,SAA0B,EAAE;IAE5B,OAAO,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;AAC5C,CAAC;AALD,8BAKC;AAED;;GAEG;AACI,KAAK,UAAU,gBAAgB,CAAC,MAAiB;IACtD,OAAO,MAAM,CAAC,gBAAgB,EAAE,CAAC;AACnC,CAAC;AAFD,4CAEC;AAED;;GAEG;AACI,KAAK,UAAU,gBAAgB,CAAC,MAAiB;IACtD,MAAM,eAAe,GAAG,MAAoC,CAAC;IAE7D,IAAI,OAAO,eAAe,CAAC,gBAAgB,KAAK,UAAU,EAAE,CAAC;QAC3D,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,eAAe,CAAC,gBAAgB,EAAE,CAAC;AAC5C,CAAC;AARD,4CAQC"}
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"id": "
|
|
3
|
-
"name": "
|
|
2
|
+
"id": "oda-groceries",
|
|
3
|
+
"name": "Oda Groceries",
|
|
4
4
|
"version": "0.1.8",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "Browse groceries, review your shopping context, and apply confirmed cart changes.",
|
|
6
6
|
"author": "oda-agent-kit",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"configSchema": {
|
|
@@ -14,40 +14,20 @@
|
|
|
14
14
|
"toolGroups": [
|
|
15
15
|
{
|
|
16
16
|
"name": "read-only",
|
|
17
|
-
"description": "Safe
|
|
17
|
+
"description": "Safe tools for browsing groceries and reviewing shopping context.",
|
|
18
18
|
"enabled": true,
|
|
19
19
|
"tools": [
|
|
20
20
|
{
|
|
21
|
-
"name": "
|
|
22
|
-
"description": "Search
|
|
21
|
+
"name": "browse_oda_catalog",
|
|
22
|
+
"description": "Search the Oda catalog with a short, easy-to-scan result list."
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
|
-
"name": "
|
|
26
|
-
"description": "
|
|
25
|
+
"name": "review_shopping_overview",
|
|
26
|
+
"description": "See the cart, saved lists, repeat buys, and delivery options together."
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
|
-
"name": "
|
|
30
|
-
"description": "
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"name": "getDeliverySlots",
|
|
34
|
-
"description": "List available delivery time slots."
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"name": "getShoppingLists",
|
|
38
|
-
"description": "List the user's saved shopping lists."
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
"name": "analyseOrderHistory",
|
|
42
|
-
"description": "Analyse past orders and return a summary of frequently ordered products."
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"name": "buildShoppingList",
|
|
46
|
-
"description": "Resolve plain-text queries into a structured shopping list without mutating the cart."
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
"name": "findCheapestDeliverySlot",
|
|
50
|
-
"description": "Return the cheapest available delivery slot without booking it."
|
|
29
|
+
"name": "plan_grocery_list",
|
|
30
|
+
"description": "Turn grocery requests into a matched plan without changing the cart."
|
|
51
31
|
}
|
|
52
32
|
]
|
|
53
33
|
},
|
|
@@ -57,20 +37,8 @@
|
|
|
57
37
|
"enabled": false,
|
|
58
38
|
"tools": [
|
|
59
39
|
{
|
|
60
|
-
"name": "
|
|
61
|
-
"description": "
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
"name": "addToCart",
|
|
65
|
-
"description": "Add a single product to the cart. Requires explicit user confirmation before use."
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
"name": "removeFromCart",
|
|
69
|
-
"description": "Remove an item from the cart by cart-item ID from getCart (`cart.items[].id`). Requires explicit user confirmation before use."
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
"name": "clearCart",
|
|
73
|
-
"description": "Remove all items from the cart. Requires explicit user confirmation before use."
|
|
40
|
+
"name": "apply_cart_changes",
|
|
41
|
+
"description": "Apply one confirmed cart change."
|
|
74
42
|
}
|
|
75
43
|
]
|
|
76
44
|
},
|
package/package.json
CHANGED
|
@@ -27,14 +27,9 @@ These tools are safe to invoke without user confirmation. They observe but do no
|
|
|
27
27
|
|
|
28
28
|
| Tool | Description |
|
|
29
29
|
|------|-------------|
|
|
30
|
-
| `
|
|
31
|
-
| `
|
|
32
|
-
| `
|
|
33
|
-
| `getDeliverySlots` | List available delivery time slots |
|
|
34
|
-
| `getShoppingLists` | List the user's saved shopping lists |
|
|
35
|
-
| `buildShoppingList` | Resolve plain-text queries into a structured shopping list |
|
|
36
|
-
| `analyseOrderHistory` | Summarise past orders and frequently bought products |
|
|
37
|
-
| `findCheapestDeliverySlot` | Find the cheapest available delivery slot (read-only) |
|
|
30
|
+
| `browse_oda_catalog` | Search the Oda catalogue with a short result list |
|
|
31
|
+
| `review_shopping_overview` | Review the cart, saved lists, repeat purchases, and delivery options in one call |
|
|
32
|
+
| `plan_grocery_list` | Turn grocery requests into a matched shopping plan without mutating the cart |
|
|
38
33
|
|
|
39
34
|
### Cart-mutation tools (disabled by default)
|
|
40
35
|
|
|
@@ -42,10 +37,7 @@ These tools modify the shopping cart. They must be **explicitly enabled** by the
|
|
|
42
37
|
|
|
43
38
|
| Tool | Description |
|
|
44
39
|
|------|-------------|
|
|
45
|
-
| `
|
|
46
|
-
| `addToCart` | Add a single product to the cart |
|
|
47
|
-
| `removeFromCart` | Remove a cart item by cart-item ID (`cart.items[].id`) |
|
|
48
|
-
| `clearCart` | Remove all items from the cart |
|
|
40
|
+
| `apply_cart_changes` | Apply one confirmed cart change, including adding products, removing products, clearing the cart, or applying a shopping plan |
|
|
49
41
|
|
|
50
42
|
### High-risk tools (not implemented in v0)
|
|
51
43
|
|
|
@@ -68,7 +60,7 @@ Order placement and payment are **out of scope** for v0. The `placeOrder` tool i
|
|
|
68
60
|
```
|
|
69
61
|
User: Can you suggest a weekly shop based on what I usually buy?
|
|
70
62
|
|
|
71
|
-
Agent:
|
|
63
|
+
Agent: I reviewed your account and built a proposed list based on your recent orders:
|
|
72
64
|
|
|
73
65
|
1. Oat Milk 1L × 2 — ordered 4 times in the last 3 months
|
|
74
66
|
2. Sourdough Bread × 1 — ordered every week
|
|
@@ -78,7 +70,7 @@ Agent: Sure! Here's a proposed list based on your last 5 orders:
|
|
|
78
70
|
|
|
79
71
|
User: Yes, add them.
|
|
80
72
|
|
|
81
|
-
Agent:
|
|
73
|
+
Agent: Applying the confirmed cart update…
|
|
82
74
|
✓ Oat Milk 1L × 2
|
|
83
75
|
✓ Sourdough Bread × 1
|
|
84
76
|
✓ Greek Yoghurt 500g × 2
|