@talajs/mcp 0.0.0-stage → 0.2.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EACL,UAAU,EAEV,IAAI,EAKJ,SAAS,EACT,QAAQ,EACR,KAAK,GACN,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvC,6BAA6B;AAC7B,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAG,SAAS,EAAE,GAAG,UAAU,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { z } from 'zod';
2
+ export declare const readTools: import("./types.js").TalaTool<z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>>[];
3
+ //# sourceMappingURL=read.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/tools/read.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AA4DvB,eAAO,MAAM,SAAS,oFAkVrB,CAAA"}
@@ -0,0 +1,366 @@
1
+ import { z } from 'zod';
2
+ import { localTime, money, today } from './format.js';
3
+ import { defineTool, READ, ToolError } from './types.js';
4
+ const Id = z.uuid();
5
+ const Search = z.string().trim().min(1).max(100);
6
+ const Cursor = z.uuid().describe('`nextCursor` from the previous result, for the next page');
7
+ const Limit = z.number().int().min(1).max(100).default(25);
8
+ const LocalDate = z.iso.date().describe("A date in the store's time zone, YYYY-MM-DD");
9
+ const STORE_HINT = 'Optional when the business has one store; otherwise pass a store id from get_business_overview.';
10
+ function storeOf(ctx, storeId) {
11
+ if (storeId) {
12
+ const store = ctx.stores.find((s) => s.id === storeId);
13
+ if (!store)
14
+ throw new ToolError('not_found', 'Unknown store, or not one you can access');
15
+ return store;
16
+ }
17
+ if (ctx.stores.length === 1)
18
+ return ctx.stores[0];
19
+ throw new ToolError('store_required', `Which store? ${ctx.stores.map((s) => `${s.name} (${s.id})`).join(', ') || 'There are none yet.'}`);
20
+ }
21
+ const page = (p, map) => ({
22
+ results: p.data.map(map),
23
+ nextCursor: p.nextCursor,
24
+ });
25
+ const variantOut = (v) => ({
26
+ id: v.id,
27
+ name: v.name,
28
+ price: money(v.priceMinor, v.currency),
29
+ sku: v.sku,
30
+ stockLevelId: v.stockLevelId,
31
+ });
32
+ const groupOut = (g) => ({
33
+ id: g.id,
34
+ name: g.name,
35
+ minSelect: g.minSelect,
36
+ maxSelect: g.maxSelect,
37
+ options: g.modifiers.map((m) => ({
38
+ id: m.id,
39
+ name: m.name,
40
+ priceDeltaMinor: m.priceDeltaMinor,
41
+ stockLevelId: m.stockLevelId,
42
+ })),
43
+ });
44
+ const STOCK_NOTE = 'Counts move with manual adjustments and with sales of variants or modifier options linked to this stock level, one unit per item sold. Tala has no recipes yet, so ingredients used in amounts (grams of beans, ml of milk) only change when counted by hand.';
45
+ export const readTools = [
46
+ defineTool({
47
+ name: 'get_business_overview',
48
+ title: 'Business overview',
49
+ description: 'The business, its stores (currency, time zone, whether prices include tax) and tax rates, and your role. Call this first to learn store ids and time zones.',
50
+ scope: READ,
51
+ role: 'STAFF',
52
+ readOnly: true,
53
+ input: z.object({}),
54
+ async run(ctx) {
55
+ const [tenant, stores, taxRates] = await Promise.all([
56
+ ctx.get(''),
57
+ ctx.get('/stores', { limit: 100 }),
58
+ ctx.get('/tax-rates', {
59
+ limit: 100,
60
+ }),
61
+ ]);
62
+ return {
63
+ business: { id: tenant.id, name: tenant.name, currency: tenant.defaultCurrency },
64
+ yourRole: ctx.role,
65
+ canWrite: ctx.scopes.includes('tala:write'),
66
+ stores: stores.data.map((s) => ({
67
+ id: s.id,
68
+ name: s.name,
69
+ currency: s.currency,
70
+ timezone: s.timezone,
71
+ pricesIncludeTax: s.pricesIncludeTax,
72
+ today: today(s.timezone),
73
+ })),
74
+ taxRates: taxRates.data.map((t) => ({ id: t.id, name: t.name, percent: t.rateBps / 100 })),
75
+ };
76
+ },
77
+ }),
78
+ defineTool({
79
+ name: 'list_categories',
80
+ title: 'List categories',
81
+ description: 'Menu categories, optionally filtered by name.',
82
+ scope: READ,
83
+ role: 'STAFF',
84
+ readOnly: true,
85
+ input: z.object({ q: Search.optional(), cursor: Cursor.optional(), limit: Limit }),
86
+ async run(ctx, input) {
87
+ const p = await ctx.get('/categories', input);
88
+ return page(p, (c) => ({ id: c.id, name: c.name, parentId: c.parentId }));
89
+ },
90
+ }),
91
+ defineTool({
92
+ name: 'list_items',
93
+ title: 'List menu items',
94
+ description: 'Menu items with their variants (sizes) and prices. Search by name with `q` (case-insensitive, partial), or filter by category.',
95
+ scope: READ,
96
+ role: 'STAFF',
97
+ readOnly: true,
98
+ input: z.object({
99
+ q: Search.optional(),
100
+ categoryId: Id.optional(),
101
+ cursor: Cursor.optional(),
102
+ limit: Limit,
103
+ }),
104
+ async run(ctx, input) {
105
+ const p = await ctx.get('/items', input);
106
+ return page(p, (i) => ({
107
+ id: i.id,
108
+ name: i.name,
109
+ variants: i.variants.map(variantOut),
110
+ modifierGroupIds: i.modifierGroupIds,
111
+ }));
112
+ },
113
+ }),
114
+ defineTool({
115
+ name: 'get_item',
116
+ title: 'Get a menu item',
117
+ description: 'One menu item with variants, prices, categories, and its modifier groups with every option and price change.',
118
+ scope: READ,
119
+ role: 'STAFF',
120
+ readOnly: true,
121
+ input: z.object({ id: Id }),
122
+ async run(ctx, { id }) {
123
+ const item = await ctx.get(`/items/${id}`);
124
+ const groups = await Promise.all(item.modifierGroupIds.map((g) => ctx.get(`/modifier-groups/${g}`)));
125
+ return {
126
+ id: item.id,
127
+ name: item.name,
128
+ description: item.description,
129
+ taxRateId: item.taxRateId,
130
+ categoryIds: item.categoryIds,
131
+ variants: item.variants.map(variantOut),
132
+ modifierGroups: groups.map(groupOut),
133
+ currency: ctx.currency,
134
+ };
135
+ },
136
+ }),
137
+ defineTool({
138
+ name: 'list_modifier_groups',
139
+ title: 'List modifier groups',
140
+ description: 'Modifier groups (e.g. milk choice, extra shots) with their options and price changes in minor units. Search by name with `q`.',
141
+ scope: READ,
142
+ role: 'STAFF',
143
+ readOnly: true,
144
+ input: z.object({ q: Search.optional(), cursor: Cursor.optional(), limit: Limit }),
145
+ async run(ctx, input) {
146
+ return page(await ctx.get('/modifier-groups', input), groupOut);
147
+ },
148
+ }),
149
+ defineTool({
150
+ name: 'get_modifier_group',
151
+ title: 'Get a modifier group',
152
+ description: 'One modifier group with its options, and the menu items it is attached to. Pair with modifier_usage to judge whether the options suit how customers order.',
153
+ scope: READ,
154
+ role: 'STAFF',
155
+ readOnly: true,
156
+ input: z.object({ id: Id }),
157
+ async run(ctx, { id }) {
158
+ const group = await ctx.get(`/modifier-groups/${id}`);
159
+ const items = [];
160
+ let cursor;
161
+ do {
162
+ const p = await ctx.get('/items', { limit: 200, cursor });
163
+ for (const i of p.data)
164
+ if (i.modifierGroupIds.includes(id))
165
+ items.push({ id: i.id, name: i.name });
166
+ cursor = p.nextCursor ?? undefined;
167
+ } while (cursor && items.length < 200);
168
+ return { ...groupOut(group), currency: ctx.currency, usedBy: items };
169
+ },
170
+ }),
171
+ defineTool({
172
+ name: 'list_stock_levels',
173
+ title: 'List stock levels',
174
+ description: `Inventory counts per store. Search by name with \`q\`: "espresso" finds "Espresso beans (Bourbon)". ${STOCK_NOTE}`,
175
+ scope: READ,
176
+ role: 'STAFF',
177
+ readOnly: true,
178
+ input: z.object({
179
+ q: Search.optional(),
180
+ storeId: Id.optional(),
181
+ cursor: Cursor.optional(),
182
+ limit: Limit,
183
+ }),
184
+ async run(ctx, input) {
185
+ const p = await ctx.get('/stock-levels', input);
186
+ return page(p, (s) => ({
187
+ id: s.id,
188
+ name: s.name,
189
+ storeId: s.storeId,
190
+ onHand: s.onHand,
191
+ unit: s.unit,
192
+ trackStrictly: s.trackStrictly,
193
+ }));
194
+ },
195
+ }),
196
+ defineTool({
197
+ name: 'get_stock_level',
198
+ title: 'Get a stock level',
199
+ description: `One stock level with its recent movements (sales, adjustments, recounts). ${STOCK_NOTE}`,
200
+ scope: READ,
201
+ role: 'STAFF',
202
+ readOnly: true,
203
+ input: z.object({ id: Id }),
204
+ async run(ctx, { id }) {
205
+ const level = await ctx.get(`/stock-levels/${id}`);
206
+ const movements = await ctx.get(`/stock-levels/${id}/movements`, {
207
+ limit: 20,
208
+ });
209
+ const tz = ctx.stores.find((s) => s.id === level.storeId)?.timezone ?? 'UTC';
210
+ return {
211
+ id: level.id,
212
+ name: level.name,
213
+ storeId: level.storeId,
214
+ onHand: level.onHand,
215
+ unit: level.unit,
216
+ trackStrictly: level.trackStrictly,
217
+ lastCounted: localTime(level.updatedAt, tz),
218
+ recentMovements: movements.data.map((m) => ({
219
+ delta: m.delta,
220
+ reason: m.reason,
221
+ note: m.note,
222
+ at: localTime(m.createdAt, tz),
223
+ })),
224
+ note: STOCK_NOTE,
225
+ };
226
+ },
227
+ }),
228
+ defineTool({
229
+ name: 'sales_summary',
230
+ title: 'Sales summary',
231
+ description: `Completed sales between two dates (inclusive, store time zone): totals plus rows by day, by item, or by payment method. At most 366 days. ${STORE_HINT}`,
232
+ scope: READ,
233
+ role: 'STAFF',
234
+ readOnly: true,
235
+ input: z.object({
236
+ storeId: Id.optional(),
237
+ from: LocalDate,
238
+ to: LocalDate,
239
+ groupBy: z.enum(['day', 'item', 'payment_method']).default('day'),
240
+ }),
241
+ async run(ctx, input) {
242
+ const store = storeOf(ctx, input.storeId);
243
+ const r = await ctx.get('/reports/sales', { ...input, storeId: store.id });
244
+ const m = (minor) => money(minor, r.currency);
245
+ return {
246
+ store: { id: store.id, name: store.name, timezone: r.timezone },
247
+ from: r.from,
248
+ to: r.to,
249
+ totals: {
250
+ orders: r.totals.orders,
251
+ subtotal: m(r.totals.subtotalMinor),
252
+ discounts: m(r.totals.discountMinor),
253
+ tax: m(r.totals.taxMinor),
254
+ total: m(r.totals.totalMinor),
255
+ tips: m(r.totals.tipMinor),
256
+ refunded: m(r.totals.refundedMinor),
257
+ },
258
+ groupBy: r.groupBy,
259
+ rows: r.rows.map(({ amountMinor, tipMinor, ...row }) => ({
260
+ ...row,
261
+ amount: m(amountMinor),
262
+ ...(tipMinor === undefined ? {} : { tips: m(tipMinor) }),
263
+ })),
264
+ };
265
+ },
266
+ }),
267
+ defineTool({
268
+ name: 'modifier_usage',
269
+ title: 'Modifier usage',
270
+ description: `How often each modifier option was chosen, per item, between two dates (store time zone), from real sales: units sold, count and share per option, and (with modifierGroupId) the group's options never chosen. Use it to judge whether a modifier group is set up well. ${STORE_HINT}`,
271
+ scope: READ,
272
+ role: 'STAFF',
273
+ readOnly: true,
274
+ input: z.object({
275
+ storeId: Id.optional(),
276
+ from: LocalDate,
277
+ to: LocalDate,
278
+ modifierGroupId: Id.optional(),
279
+ }),
280
+ async run(ctx, input) {
281
+ const store = storeOf(ctx, input.storeId);
282
+ const r = await ctx.get('/reports/modifier-usage', {
283
+ ...input,
284
+ storeId: store.id,
285
+ });
286
+ return { store: { id: store.id, name: store.name, timezone: store.timezone }, ...r };
287
+ },
288
+ }),
289
+ defineTool({
290
+ name: 'list_orders',
291
+ title: 'List orders',
292
+ description: 'Recent orders and open tabs, newest first, with totals and status. Filter by store, status (OPEN, COMPLETED, VOIDED) or tabs only.',
293
+ scope: READ,
294
+ role: 'STAFF',
295
+ readOnly: true,
296
+ input: z.object({
297
+ storeId: Id.optional(),
298
+ status: z.enum(['OPEN', 'COMPLETED', 'VOIDED']).optional(),
299
+ isTab: z.boolean().optional(),
300
+ cursor: Cursor.optional(),
301
+ limit: Limit,
302
+ }),
303
+ async run(ctx, input) {
304
+ const p = await ctx.get('/orders', input);
305
+ return page(p, (o) => {
306
+ const tz = ctx.stores.find((s) => s.id === o.storeId)?.timezone ?? 'UTC';
307
+ return {
308
+ id: o.id,
309
+ number: o.number,
310
+ storeId: o.storeId,
311
+ status: o.status,
312
+ tab: o.isTab ? o.tabName : null,
313
+ total: money(o.totalMinor, o.currency),
314
+ openedAt: localTime(o.openedAt, tz),
315
+ completedAt: localTime(o.completedAt, tz),
316
+ };
317
+ });
318
+ },
319
+ }),
320
+ defineTool({
321
+ name: 'get_order',
322
+ title: 'Get an order',
323
+ description: 'One order with its lines, modifiers, payments and refunds.',
324
+ scope: READ,
325
+ role: 'STAFF',
326
+ readOnly: true,
327
+ input: z.object({ id: Id }),
328
+ async run(ctx, { id }) {
329
+ const o = await ctx.get(`/orders/${id}`);
330
+ const tz = ctx.stores.find((s) => s.id === o.storeId)?.timezone ?? 'UTC';
331
+ const m = (minor) => money(minor, o.currency);
332
+ return {
333
+ id: o.id,
334
+ number: o.number,
335
+ storeId: o.storeId,
336
+ status: o.status,
337
+ tab: o.isTab ? o.tabName : null,
338
+ note: o.note,
339
+ openedAt: localTime(o.openedAt, tz),
340
+ completedAt: localTime(o.completedAt, tz),
341
+ totals: {
342
+ subtotal: m(o.subtotalMinor),
343
+ discount: m(o.discountMinor),
344
+ tax: m(o.taxMinor),
345
+ total: m(o.totalMinor),
346
+ tip: m(o.tipMinor),
347
+ },
348
+ lines: o.lines.map((l) => ({
349
+ item: l.variantName ? `${l.itemName} (${l.variantName})` : l.itemName,
350
+ quantity: l.quantity,
351
+ modifiers: l.modifiers.map((x) => x.name),
352
+ total: m(l.lineTotalMinor),
353
+ voided: l.voidedAt !== null,
354
+ })),
355
+ payments: o.payments.map((p) => ({
356
+ method: p.method,
357
+ status: p.status,
358
+ amount: m(p.amountMinor),
359
+ tip: m(p.tipMinor),
360
+ })),
361
+ refunds: o.refunds.map((r) => ({ amount: m(r.amountMinor), status: r.status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,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;oBACzB,IAAI,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ;oBACrE,QAAQ,EAAE,CAAC,CAAC,QAAQ;oBACpB,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;oBACzC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC;oBAC1B,MAAM,EAAE,CAAC,CAAC,QAAQ,KAAK,IAAI;iBAC5B,CAAC,CAAC;gBACH,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;oBAC/B,MAAM,EAAE,CAAC,CAAC,MAAM;oBAChB,MAAM,EAAE,CAAC,CAAC,MAAM;oBAChB,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;oBACxB,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;iBACnB,CAAC,CAAC;gBACH,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;aAChF,CAAA;QACH,CAAC;KACF,CAAC;CACH,CAAA"}
@@ -0,0 +1,62 @@
1
+ import type { MemberRole } from '@talajs/contracts';
2
+ import type { z } from 'zod';
3
+ export declare const READ = "tala:read";
4
+ export declare const WRITE = "tala:write";
5
+ export type Scope = typeof READ | typeof WRITE;
6
+ export interface Query {
7
+ [key: string]: string | number | boolean | undefined | null;
8
+ }
9
+ /** A failed API call, with the API's error code and message (never secrets). */
10
+ export declare class ToolError extends Error {
11
+ readonly code: string;
12
+ readonly status: number;
13
+ constructor(code: string, message: string, status?: number);
14
+ }
15
+ export interface StoreInfo {
16
+ id: string;
17
+ name: string;
18
+ currency: string;
19
+ timezone: string;
20
+ }
21
+ /**
22
+ * What a tool may use: the Tala REST API, called as the person (their role, their stores, their
23
+ * business), plus a little context. Tools never touch the database directly, so they can't reach
24
+ * anything the person couldn't reach in the admin.
25
+ */
26
+ export interface ToolContext {
27
+ tenantId: string;
28
+ tenantName: string;
29
+ currency: string;
30
+ role: MemberRole;
31
+ scopes: readonly string[];
32
+ /** Stores the person can work in. */
33
+ stores: StoreInfo[];
34
+ /** Tenant-relative API calls, e.g. `get('/items', { q: 'latte' })`. */
35
+ get<T>(path: string, query?: Query): Promise<T>;
36
+ post<T>(path: string, body?: unknown): Promise<T>;
37
+ patch<T>(path: string, body: unknown): Promise<T>;
38
+ del<T>(path: string): Promise<T>;
39
+ /** Where the person approves a proposal in the admin. */
40
+ proposalUrl(id: string): string;
41
+ }
42
+ /**
43
+ * A tool, independent of MCP: the admin's future chat panel can list and run the same tools.
44
+ * `role` and `scope` are checked before `run`; the API checks again on every call it makes.
45
+ */
46
+ export interface TalaTool<I extends z.ZodObject = z.ZodObject> {
47
+ name: string;
48
+ title: string;
49
+ /** For the model: what it does and when to use it. */
50
+ description: string;
51
+ scope: Scope;
52
+ role: MemberRole;
53
+ input: I;
54
+ readOnly: boolean;
55
+ /** Changes data (only `apply_proposal`); clients that honour hints ask the person first. */
56
+ destructive?: boolean;
57
+ run(ctx: ToolContext, input: z.output<I>): Promise<unknown>;
58
+ }
59
+ /** Tools this person may use with these scopes. */
60
+ export declare function toolsFor(tools: readonly TalaTool[], role: MemberRole, scopes: readonly string[]): TalaTool<z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>>[];
61
+ export declare const defineTool: <I extends z.ZodObject>(tool: TalaTool<I>) => TalaTool;
62
+ //# sourceMapp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,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IACjD,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IACjD,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IAChC,yDAAyD;IACzD,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;CAChC;AAED;;;GAGG;AACH,MAAM,WAAW,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS;IAC3D,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,sDAAsD;IACtD,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,KAAK,CAAA;IACZ,IAAI,EAAE,UAAU,CAAA;IAChB,KAAK,EAAE,CAAC,CAAA;IACR,QAAQ,EAAE,OAAO,CAAA;IACjB,4FAA4F;IAC5F,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,GAAG,CAAC,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CAC5D;AAID,mDAAmD;AACnD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,iEAI/F;AAED,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,CAAC,CAAC,SAAS,QAAQ,QAAQ,CAAC,CAAC,CAAC,KAAwB,QAAQ,CAAA"}
@@ -0,0 +1,21 @@
1
+ export const READ = 'tala:read';
2
+ export const WRITE = 'tala:write';
3
+ /** A failed API call, with the API's error code and message (never secrets). */
4
+ export class ToolError extends Error {
5
+ code;
6
+ status;
7
+ constructor(code, message, status = 400) {
8
+ super(message);
9
+ this.code = code;
10
+ this.status = status;
11
+ }
12
+ }
13
+ const RANK = { STAFF: 1, MANAGER: 2, OWNER: 3 };
14
+ /** Tools this person may use with these scopes. */
15
+ export function toolsFor(tools, role, scopes) {
16
+ const write = scopes.includes(WRITE);
17
+ const read = write || scopes.includes(READ);
18
+ return tools.filter((t) => RANK[role] >= RANK[t.role] && (t.scope === WRITE ? write : read));
19
+ }
20
+ export const defineTool = (tool) => tool;
21
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,IAAI,GAAG,WAAW,CAAA;AAC/B,MAAM,CAAC,MAAM,KAAK,GAAG,YAAY,CAAA;AAOjC,gFAAgF;AAChF,MAAM,OAAO,SAAU,SAAQ,KAAK;IAEvB,IAAI;IAEJ,MAAM;IAHjB,YACW,IAAY,EACrB,OAAe,EACN,MAAM,GAAG,GAAG;QAErB,KAAK,CAAC,OAAO,CAAC,CAAA;oBAJL,IAAI;sBAEJ,MAAM;IAGjB,CAAC;CACF;AAiDD,MAAM,IAAI,GAA+B,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAA;AAE3E,mDAAmD;AACnD,MAAM,UAAU,QAAQ,CAAC,KAA0B,EAAE,IAAgB,EAAE,MAAyB;IAC9F,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IACpC,MAAM,IAAI,GAAG,KAAK,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IAC3C,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;AAC9F,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,CAAwB,IAAiB,EAAE,EAAE,CAAC,IAA2B,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { z } from 'zod';
2
+ export declare const writeTools: import("./types.js").TalaTool<z.ZodObject<z.core.$ZodLooseShape, z.core.$strip>>[];
3
+ //# sourceMappingURL=write.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../src/tools/write.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAsDvB,eAAO,MAAM,UAAU,oFA6GtB,CAAA"}
@@ -0,0 +1,137 @@
1
+ import { ProposalChange } from '@talajs/contracts';
2
+ import { z } from 'zod';
3
+ import { localTime, money } from './format.js';
4
+ import { defineTool, ToolError, WRITE } from './types.js';
5
+ const Id = z.uuid();
6
+ const CONFIRM = 'This does not change anything yet. Show the person the summary and every line of the diff in plain words, then ask for an explicit yes. Only after they say yes, call apply_proposal with the proposal id. If they want something different, call discard_proposal and propose again.';
7
+ /** The ProposalChange variants whose operation starts with one of `prefixes`. */
8
+ function changesFor(...prefixes) {
9
+ const options = ProposalChange.options.filter((o) => prefixes.some((p) => o.shape.operation.value.startsWith(p)));
10
+ return z.discriminatedUnion('operation', options);
11
+ }
12
+ const MONEY_FIELDS = new Set(['priceMinor', 'priceDeltaMinor']);
13
+ function present(ctx, p) {
14
+ const store = ctx.stores[0];
15
+ return {
16
+ proposalId: p.id,
17
+ status: p.status,
18
+ summary: p.summary,
19
+ changes: p.diff.map((d) => MONEY_FIELDS.has(d.field) && typeof d.after === 'number'
20
+ ? {
21
+ field: d.field,
22
+ before: typeof d.before === 'number' ? money(d.before, ctx.currency) : d.before,
23
+ after: money(d.after, ctx.currency),
24
+ }
25
+ : d),
26
+ expiresAt: localTime(p.expiresAt, store?.timezone ?? 'UTC'),
27
+ ...(p.approvalRequired
28
+ ? {
29
+ approval: 'admin',
30
+ approveUrl: ctx.proposalUrl(p.id),
31
+ nextStep: `This business requires approval in Tala before changes apply. Ask the person to open ${ctx.proposalUrl(p.id)} and press Approve, then call apply_proposal.`,
32
+ }
33
+ : { approval: 'chat', nextStep: CONFIRM }),
34
+ ...(p.status === 'APPLIED' ? { result: p.result } : {}),
35
+ ...(p.error ? { error: p.error } : {}),
36
+ };
37
+ }
38
+ async function propose(ctx, change) {
39
+ return present(ctx, await ctx.post('/proposals', { change }));
40
+ }
41
+ export const writeTools = [
42
+ defineTool({
43
+ name: 'propose_stock_adjustment',
44
+ title: 'Propose a stock change',
45
+ description: `Prepare a stock change for one stock level: "receive" (a delivery, adds), "adjust" (adds or removes, e.g. waste or a correction; use a negative quantity to remove) or "recount" (sets the counted amount). A recount only applies if the count hasn't changed in the meantime. ${CONFIRM}`,
46
+ scope: WRITE,
47
+ role: 'STAFF',
48
+ readOnly: false,
49
+ input: z.object({
50
+ stockLevelId: Id,
51
+ kind: z.enum(['receive', 'adjust', 'recount']),
52
+ quantity: z
53
+ .number()
54
+ .int()
55
+ .describe('Units to add (receive), add or remove (adjust), or the new count (recount)'),
56
+ note: z.string().max(500).optional().describe('Why, e.g. "Weekly delivery" or "Spilled"'),
57
+ }),
58
+ run: (ctx, { stockLevelId, kind, quantity, note }) => {
59
+ const adjustment = kind === 'recount'
60
+ ? { reason: 'RECOUNT', count: quantity, note }
61
+ : { reason: kind === 'receive' ? 'RECEIVE' : 'ADJUST', delta: quantity, note };
62
+ return propose(ctx, { operation: 'stock.adjust', stockLevelId, adjustment });
63
+ },
64
+ }),
65
+ defineTool({
66
+ name: 'propose_item_change',
67
+ title: 'Propose a menu item change',
68
+ description: `Prepare one change to the menu: create, update or archive an item, or add, update or archive one of its variants (sizes). Prices are in minor units (cents). To attach or detach modifier groups, update the item's modifierGroupIds (the full list). One change per proposal; make several proposals for several changes. ${CONFIRM}`,
69
+ scope: WRITE,
70
+ role: 'MANAGER',
71
+ readOnly: false,
72
+ input: z.object({ change: changesFor('item.', 'variant.') }),
73
+ run: (ctx, { change }) => propose(ctx, change),
74
+ }),
75
+ defineTool({
76
+ name: 'propose_modifier_group_change',
77
+ title: 'Propose a modifier group change',
78
+ description: `Prepare one change to modifier groups: create, update (name, minSelect, maxSelect) or archive a group, or add, update (name, priceDeltaMinor in cents) or remove one option. Use modifier_usage first to base suggestions on what customers actually choose. One change per proposal. ${CONFIRM}`,
79
+ scope: WRITE,
80
+ role: 'MANAGER',
81
+ readOnly: false,
82
+ input: z.object({ change: changesFor('modifier_group.', 'modifier.') }),
83
+ run: (ctx, { change }) => propose(ctx, change),
84
+ }),
85
+ defineTool({
86
+ name: 'propose_category_change',
87
+ title: 'Propose a category change',
88
+ description: `Prepare one change to menu categories: create, update or archive. ${CONFIRM}`,
89
+ scope: WRITE,
90
+ role: 'MANAGER',
91
+ readOnly: false,
92
+ input: z.object({ change: changesFor('category.') }),
93
+ run: (ctx, { change }) => propose(ctx, change),
94
+ }),
95
+ defineTool({
96
+ name: 'get_proposal',
97
+ title: 'Get a proposal',
98
+ description: 'A proposal you made: its summary, diff and status (PENDING, APPROVED, APPLIED, DISCARDED, FAILED or EXPIRED).',
99
+ scope: WRITE,
100
+ role: 'STAFF',
101
+ readOnly: true,
102
+ input: z.object({ proposalId: Id }),
103
+ run: async (ctx, { proposalId }) => present(ctx, await ctx.get(`/proposals/${proposalId}`)),
104
+ }),
105
+ defineTool({
106
+ name: 'apply_proposal',
107
+ title: 'Apply a confirmed proposal',
108
+ description: 'Apply a proposal the person has explicitly confirmed. Never call it without their yes to this exact change. It fails if the proposal expired (15 minutes), if what it changes was changed since, if their role no longer allows it, or if the business requires approval in Tala first. Applying twice is harmless.',
109
+ scope: WRITE,
110
+ role: 'STAFF',
111
+ readOnly: false,
112
+ destructive: true,
113
+ input: z.object({ proposalId: Id }),
114
+ async run(ctx, { proposalId }) {
115
+ try {
116
+ return present(ctx, await ctx.post(`/proposals/${proposalId}/apply`));
117
+ }
118
+ catch (error) {
119
+ if (error instanceof ToolError && error.code === 'approval_required') {
120
+ throw new ToolError('approval_required', `Not applied: this business requires approval in Tala first. Ask the person to open ${ctx.proposalUrl(proposalId)}, press Approve, and then try again.`);
121
+ }
122
+ throw error;
123
+ }
124
+ },
125
+ }),
126
+ defineTool({
127
+ name: 'discard_proposal',
128
+ title: 'Discard a proposal',
129
+ description: 'Throw a proposal away, e.g. when the person says no or wants something different.',
130
+ scope: WRITE,
131
+ role: 'STAFF',
132
+ readOnly: false,
133
+ input: z.object({ proposalId: Id }),
134
+ run: async (ctx, { proposalId }) => present(ctx, await ctx.post(`/proposals/${proposalId}/discard`)),
135
+ }),
136
+ ];
137
+ //# sourceMappingURL=write.js.map