@advertising-chat/mcp 0.11.0 → 0.17.4

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.
Files changed (54) hide show
  1. package/README.md +21 -5
  2. package/bin/cli.js +1 -1
  3. package/bin/client.d.ts +1 -0
  4. package/bin/client.js +3 -0
  5. package/bin/client.js.map +1 -1
  6. package/bin/index.d.ts +1 -1
  7. package/bin/index.js +3 -1
  8. package/bin/index.js.map +1 -1
  9. package/bin/routeInventory.d.ts +8 -1
  10. package/bin/routeInventory.js +50 -4
  11. package/bin/routeInventory.js.map +1 -1
  12. package/bin/server.d.ts +1 -1
  13. package/bin/server.js +5 -5
  14. package/bin/tool.d.ts +22 -0
  15. package/bin/tool.js +24 -1
  16. package/bin/tool.js.map +1 -1
  17. package/bin/tools/account.js +1 -1
  18. package/bin/tools/account.js.map +1 -1
  19. package/bin/tools/attributes.js +49 -2
  20. package/bin/tools/attributes.js.map +1 -1
  21. package/bin/tools/campaigns.d.ts +12 -0
  22. package/bin/tools/campaigns.js +230 -0
  23. package/bin/tools/campaigns.js.map +1 -0
  24. package/bin/tools/decisions.js +52 -34
  25. package/bin/tools/decisions.js.map +1 -1
  26. package/bin/tools/docs.js +2 -2
  27. package/bin/tools/docs.js.map +1 -1
  28. package/bin/tools/index.d.ts +4 -0
  29. package/bin/tools/index.js +12 -0
  30. package/bin/tools/index.js.map +1 -1
  31. package/bin/tools/moments.js +27 -5
  32. package/bin/tools/moments.js.map +1 -1
  33. package/bin/tools/network.d.ts +5 -0
  34. package/bin/tools/network.js +99 -0
  35. package/bin/tools/network.js.map +1 -0
  36. package/bin/tools/offers.d.ts +1 -1
  37. package/bin/tools/offers.js +73 -26
  38. package/bin/tools/offers.js.map +1 -1
  39. package/bin/tools/results.d.ts +18 -0
  40. package/bin/tools/results.js +116 -0
  41. package/bin/tools/results.js.map +1 -0
  42. package/bin/tools/rules.js +137 -0
  43. package/bin/tools/rules.js.map +1 -1
  44. package/bin/tools/settings.d.ts +3 -0
  45. package/bin/tools/settings.js +54 -0
  46. package/bin/tools/settings.js.map +1 -0
  47. package/bin/tools/shared.d.ts +12 -1
  48. package/bin/tools/shared.js +67 -2
  49. package/bin/tools/shared.js.map +1 -1
  50. package/bin/tools/translation.js +4 -1
  51. package/bin/tools/translation.js.map +1 -1
  52. package/bin/version.d.ts +1 -1
  53. package/bin/version.js +1 -1
  54. package/package.json +33 -5
@@ -18,10 +18,17 @@ const code = zod_1.z
18
18
  const description = zod_1.z
19
19
  .string()
20
20
  .max(1000)
21
- .describe('What the moment means in the conversation, in a sentence. Rules and the copilot rely on it.');
21
+ .describe('What the moment means in the conversation, in a sentence. Rules and the Assistant rely on it.');
22
22
  const source = zod_1.z
23
23
  .enum(offer_rules_1.MOMENT_SOURCES)
24
24
  .describe('Who reports the moment: `agent` (the default) or `context_layer`.');
25
+ /** The words for a moment's fields, for approval sentences. */
26
+ const MOMENT_WORDS = {
27
+ name: 'name',
28
+ code: 'code',
29
+ description: 'description',
30
+ source: 'source',
31
+ };
25
32
  /** A moment as the list shows it. */
26
33
  function momentRow(m) {
27
34
  return {
@@ -51,7 +58,7 @@ exports.listMoments = (0, tool_1.defineTool)({
51
58
  exports.getMoment = (0, tool_1.defineTool)({
52
59
  name: 'get_moment',
53
60
  title: 'Get a moment',
54
- description: 'One moment with every field, including its frequency cap. Maps to GET /system/offer-manager/adunit/{id}.',
61
+ description: 'One moment with every field. Maps to GET /system/offer-manager/adunit/{id}.',
55
62
  kind: 'read',
56
63
  roleFloor: 'viewer',
57
64
  input: { id: (0, shared_1.id)('moment') },
@@ -62,7 +69,7 @@ exports.getMoment = (0, tool_1.defineTool)({
62
69
  exports.createMoment = (0, tool_1.defineTool)({
63
70
  name: 'create_moment',
64
71
  title: 'Create a moment',
65
- description: 'Create a moment for one agent. The agent must then send its `code` on requests at that point in the conversation; until it does, no offer appears there. A moment serves nothing until a rule includes it. `application` is fixed once created. Maps to POST /system/offer-manager/adunit.',
72
+ description: 'Create a moment for one agent. The agent must then send its `code` on requests at that point in the conversation; until it does, no offer appears there. A moment serves nothing until a rule or the agent’s network switch includes it. `application` is fixed once created. Maps to POST /system/offer-manager/adunit.',
66
73
  kind: 'write',
67
74
  roleFloor: 'editor',
68
75
  input: {
@@ -72,8 +79,8 @@ exports.createMoment = (0, tool_1.defineTool)({
72
79
  description: description.optional(),
73
80
  source: source.optional(),
74
81
  enabled: zod_1.z.boolean().optional().describe('Default true.'),
75
- frequency: shared_1.frequency.optional(),
76
82
  },
83
+ approval: args => `Add the moment ${(0, shared_1.quoted)(args.name, '')} to this agent. The agent reports it by sending the code “${args.code}”; offers or ads from the network appear there only once an offer’s audience or the agent’s Ads from the network includes it.`,
77
84
  async run({ client }, args) {
78
85
  return client.post(`${shared_1.OM}/adunit`, (0, shared_1.defined)(args));
79
86
  },
@@ -93,7 +100,21 @@ exports.updateMoment = (0, tool_1.defineTool)({
93
100
  description: description.optional(),
94
101
  source: source.optional(),
95
102
  enabled: zod_1.z.boolean().optional(),
96
- frequency: shared_1.frequency.optional(),
103
+ },
104
+ approval: (args, before) => {
105
+ const name = (0, shared_1.named)('moment', before?.name ?? args.name);
106
+ const rest = { ...args, enabled: undefined };
107
+ const what = (0, shared_1.changedWords)(rest, MOMENT_WORDS);
108
+ const parts = [];
109
+ if (args.enabled === false)
110
+ parts.push(`Turn off ${name}: no offer or network ad appears there until it is turned back on.`);
111
+ if (args.enabled === true)
112
+ parts.push(`Turn on ${name}.`);
113
+ if (what.length)
114
+ parts.push(`Change the ${(0, shared_1.listWords)(what)} of ${name}.${args.code !== undefined && args.code !== before?.code
115
+ ? ' The agent must send the new code, or no offer appears there.'
116
+ : ''}`);
117
+ return parts.join(' ') || `Change ${name}.`;
97
118
  },
98
119
  async run({ client }, args) {
99
120
  return client.patch(`${shared_1.OM}/adunit/${(0, shared_1.enc)(args.id)}`, (0, shared_1.patchBody)(args, ['application']));
@@ -107,6 +128,7 @@ exports.deleteMoment = (0, tool_1.defineTool)({
107
128
  roleFloor: 'editor',
108
129
  reader: 'get_moment',
109
130
  input: { id: (0, shared_1.id)('moment') },
131
+ approval: (_args, before) => `Delete ${(0, shared_1.named)('moment', before?.name)} for good. Requests the agent still sends for it get no offer.`,
110
132
  async run({ client }, { id: momentId }) {
111
133
  return client.delete(`${shared_1.OM}/adunit/${(0, shared_1.enc)(momentId)}`);
112
134
  },
@@ -1 +1 @@
1
- {"version":3,"file":"moments.js","sourceRoot":"","sources":["../../src/tools/moments.ts"],"names":[],"mappings":";;;AA6CA,8BASC;AAtDD;;;GAGG;AACH,+DAA+D;AAC/D,6BAAwB;AACxB,kCAAqC;AACrC,qCAckB;AAElB,MAAM,IAAI,GAAG,OAAC;KACX,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,GAAG,CAAC;KACR,QAAQ,CACP,6GAA6G,CAC9G,CAAC;AAEJ,MAAM,WAAW,GAAG,OAAC;KAClB,MAAM,EAAE;KACR,GAAG,CAAC,IAAI,CAAC;KACT,QAAQ,CACP,6FAA6F,CAC9F,CAAC;AAEJ,MAAM,MAAM,GAAG,OAAC;KACb,IAAI,CAAC,4BAAc,CAAC;KACpB,QAAQ,CACP,mEAAmE,CACpE,CAAC;AAEJ,qCAAqC;AACrC,SAAgB,SAAS,CAAC,CAAM;IAC9B,OAAO;QACL,EAAE,EAAE,IAAA,YAAG,EAAC,CAAC,CAAC,GAAG,CAAC,IAAI,IAAA,YAAG,EAAC,CAAC,CAAC,EAAE,CAAC;QAC3B,IAAI,EAAE,IAAA,YAAG,EAAC,CAAC,CAAC,IAAI,CAAC;QACjB,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,WAAW,EAAE,IAAA,YAAG,EAAC,CAAC,CAAC,WAAW,CAAC;QAC/B,OAAO,EAAE,CAAC,CAAC,OAAO;QAClB,WAAW,EAAE,IAAA,cAAK,EAAC,CAAC,CAAC,WAAW,CAAC;KAClC,CAAC;AACJ,CAAC;AAEY,QAAA,WAAW,G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;IACxD,CAAC;CACF,CAAC,CAAC;AAEU,QAAA,WAAW,GAAG;IACzB,mBAAW;IACX,iBAAS;IACT,oBAAY;IACZ,oBAAY;IACZ,oBAAY;CACb,CAAC"}
@@ -0,0 +1,5 @@
1
+ /** What the agent's network enrollment means. */
2
+ export declare const NETWORK_STATUS_MEANINGS: Record<string, string>;
3
+ export declare const getNetworkStatus: import("../tool").AnyTool;
4
+ export declare const setNetworkAds: import("../tool").AnyTool;
5
+ export declare const networkTools: import("../tool").AnyTool[];
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.networkTools = exports.setNetworkAds = exports.getNetworkStatus = exports.NETWORK_STATUS_MEANINGS = void 0;
4
+ /**
5
+ * Ads from the network, per agent: one switch that turns the network's
6
+ * ads on or off at chosen moments of the agent
7
+ * (`/system/offer-manager/application/:id/network`). Any workspace may use
8
+ * it; the server owns the agent's network rule and enrollment.
9
+ */
10
+ const zod_1 = require("zod");
11
+ const tool_1 = require("../tool");
12
+ const shared_1 = require("./shared");
13
+ /** What the agent's network enrollment means. */
14
+ exports.NETWORK_STATUS_MEANINGS = {
15
+ none: 'Not enrolled: ads from the network are off for this agent.',
16
+ pending: 'Enrolled and waiting for approval; no network ads appear yet.',
17
+ approved: 'Approved: network ads can appear at the chosen moments.',
18
+ rejected: 'The network declined this agent; no network ads appear. Our team can say why.',
19
+ };
20
+ const momentRef = (m) => ({
21
+ id: (0, shared_1.str)(m._id) ?? (0, shared_1.str)(m.id),
22
+ name: m.name,
23
+ code: (0, shared_1.str)(m.code),
24
+ });
25
+ exports.getNetworkStatus = (0, tool_1.defineTool)({
26
+ name: 'get_network_status',
27
+ title: 'Ads from the network for an agent',
28
+ description: 'Whether ads from the network are on for one agent: `on`, the enrollment `status` (none, pending, approved, rejected) with its meaning, the `moments` where network ads may appear, and the agent’s `otherMoments`. Any workspace can show network ads. Change it with set_network_ads. Results: get_results with section network. Maps to GET /system/offer-manager/application/{id}/network.',
29
+ kind: 'read',
30
+ roleFloor: 'viewer',
31
+ input: { application: shared_1.application },
32
+ async run({ client }, { application: agent }) {
33
+ const [setting, app, moments] = await Promise.all([
34
+ client.get(`${shared_1.OM}/application/${(0, shared_1.enc)(agent)}/network`),
35
+ client.get(`${shared_1.OM}/application/${(0, shared_1.enc)(agent)}`),
36
+ client.get(`${shared_1.OM}/adunit`, { application: agent }),
37
+ ]);
38
+ const on = new Set(Array.isArray(setting?.moments) ? setting.moments : []);
39
+ const all = (0, shared_1.rows)(moments).map(momentRef);
40
+ const status = (0, shared_1.str)(setting?.networkStatus) ?? 'none';
41
+ return {
42
+ agent: { id: agent, name: app?.name },
43
+ on: !!setting?.enabled,
44
+ status,
45
+ meaning: exports.NETWORK_STATUS_MEANINGS[status],
46
+ moments: all.filter(m => m.id && on.has(m.id)),
47
+ otherMoments: all.filter(m => !m.id || !on.has(m.id)),
48
+ };
49
+ },
50
+ });
51
+ /** Moment names for ids, from the reader's result. */
52
+ function momentNames(ids, before) {
53
+ const known = [
54
+ ...(Array.isArray(before?.moments) ? before.moments : []),
55
+ ...(Array.isArray(before?.otherMoments) ? before.otherMoments : []),
56
+ ];
57
+ return ids.map(id => {
58
+ const m = known.find(k => k.id === id);
59
+ return m?.name ? (0, shared_1.quoted)(m.name, '') : 'a moment';
60
+ });
61
+ }
62
+ exports.setNetworkAds = (0, tool_1.defineTool)({
63
+ name: 'set_network_ads',
64
+ title: 'Turn ads from the network on or off',
65
+ description: 'Turn ads from the network on or off for one agent. On needs at least one of the agent’s moments: network ads may appear there when no offer of the brand’s own is chosen. `moments` replaces the list. Off removes them from every moment. Read the current state with get_network_status first. Refused (409) for an agent the network declined. Maps to PUT /system/offer-manager/application/{id}/network.',
66
+ kind: 'write',
67
+ roleFloor: 'editor',
68
+ reader: 'get_network_status',
69
+ input: {
70
+ application: shared_1.application,
71
+ enabled: zod_1.z.boolean().describe('On or off.'),
72
+ moments: zod_1.z
73
+ .array(zod_1.z.string().regex(/^[0-9a-fA-F]{24}$/))
74
+ .optional()
75
+ .describe('Moment ids of this agent where network ads may appear; required, at least one, when turning on.'),
76
+ },
77
+ approval: (args, before) => {
78
+ const agent = (0, shared_1.named)('agent', before?.agent?.name);
79
+ if (!args.enabled)
80
+ return `Turn off ads from the network for ${agent}. They stop appearing at once.`;
81
+ const ids = args.moments ?? [];
82
+ const names = momentNames(ids, before);
83
+ const at = names.length && names.every(n => n !== 'a moment')
84
+ ? `at ${(0, shared_1.listWords)(names)}`
85
+ : `at ${ids.length === 1 ? 'one moment' : `${ids.length} moments`}`;
86
+ const approved = before?.status === 'pending'
87
+ ? ' They appear once the agent is approved for the network.'
88
+ : '';
89
+ return `${before?.on ? 'Show' : 'Turn on'} ads from the network for ${agent} ${at}.${approved}`;
90
+ },
91
+ async run({ client }, args) {
92
+ return client.put(`${shared_1.OM}/application/${(0, shared_1.enc)(args.application)}/network`, {
93
+ enabled: args.enabled,
94
+ moments: args.moments ?? [],
95
+ });
96
+ },
97
+ });
98
+ exports.networkTools = [exports.getNetworkStatus, exports.setNetworkAds];
99
+ //# sourceMappingURL=network.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network.js","sourceRoot":"","sources":["../../src/tools/network.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,6BAAwB;AACxB,kCAAqC;AACrC,qCAUkB;AAElB,iDAAiD;AACpC,QAAA,uBAAuB,GAA2B;IAC7D,IAAI,EAAE,4DAA4D;IAClE,OAAO,EAAE,+DAA+D;IACxE,QAAQ,EAAE,yDAAyD;IACnE,QAAQ,EACN,+EAA+E;CAClF,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC;IAC7B,EAAE,EAAE,IAAA,YAAG,EAAC,CAAC,CAAC,GAAG,CAAC,IAAI,IAAA,YAAG,EAAC,CAAC,CAAC,EAAE,CAAC;IAC3B,IAAI,EAAE,CAAC,CAAC,IAAI;IACZ,IAAI,EAAE,IAAA,YAAG,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AQ,EAAE,CAAC;IAClG,CAAC;IACD,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE,IAAI;QACxB,OAAO,MAAM,CAAC,GAAG,CAAC,GAAG,WAAE,gBAAgB,IAAA,YAAG,EAAC,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE;YACtE,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE;SAC5B,CAAC,CAAC;IACL,CAAC;CACF,CAAC,CAAC;AAEU,QAAA,YAAY,GAAG,CAAC,wBAAgB,EAAE,qBAAa,CAAC,CAAC"}
@@ -5,7 +5,7 @@ export declare const listOffers: import("../tool").AnyTool;
5
5
  export declare const getOffer: import("../tool").AnyTool;
6
6
  export declare const createOffer: import("../tool").AnyTool;
7
7
  export declare const updateOffer: import("../tool").AnyTool;
8
+ export declare const publishOffer: import("../tool").AnyTool;
8
9
  export declare const pauseOffer: import("../tool").AnyTool;
9
- export declare const resumeOffer: import("../tool").AnyTool;
10
10
  export declare const deleteOffer: import("../tool").AnyTool;
11
11
  export declare const offerTools: import("../tool").AnyTool[];
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.offerTools = exports.deleteOffer = exports.resumeOffer = exports.pauseOffer = exports.updateOffer = exports.createOffer = exports.getOffer = exports.listOffers = void 0;
3
+ exports.offerTools = exports.deleteOffer = exports.pauseOffer = exports.publishOffer = exports.updateOffer = exports.createOffer = exports.getOffer = exports.listOffers = void 0;
4
4
  exports.offerRow = offerRow;
5
5
  /**
6
6
  * Offers (the API's creatives): what a customer sees. Offers are an
7
- * org-wide library that any agent's rules can use.
7
+ * org-wide library that any agent's rules can use. Reads and publishing go
8
+ * through `/offers` (each offer with its status, rules, and last 7 days);
9
+ * the content is written on `/creative`.
8
10
  */
9
11
  const offer_rules_1 = require("@advertising-chat/offer-rules");
10
12
  const zod_1 = require("zod");
@@ -73,39 +75,60 @@ function offerRow(c) {
73
75
  id: (0, shared_1.str)(c._id) ?? (0, shared_1.str)(c.id),
74
76
  name: c.name,
75
77
  format: c.format,
76
- status: c.status ?? c._status,
78
+ status: c.status,
77
79
  title: (0, shared_1.str)(c.payload?.universal?.title),
80
+ rules: Array.isArray(c.rules) ? c.rules.length : undefined,
81
+ last7Days: c.last7Days,
78
82
  };
79
83
  }
84
+ const STATUS = 'status is draft (never published: no rule uses it yet, or none has been turned on), live (an enabled rule that uses it is within its dates), paused (published before, now off), or ended (every rule’s dates are over)';
85
+ /** The words for an offer's fields, for approval sentences. */
86
+ const OFFER_WORDS = {
87
+ name: 'name',
88
+ format: 'format',
89
+ description: 'description',
90
+ payload: 'content',
91
+ actions: 'replies and buttons',
92
+ properties: 'custom properties',
93
+ };
94
+ /** What a live offer's change means, for approval sentences. */
95
+ function liveNote(before) {
96
+ return before?.status === 'live'
97
+ ? ' Customers see the change from the next request.'
98
+ : '';
99
+ }
80
100
  exports.listOffers = (0, tool_1.defineTool)({
81
101
  name: 'list_offers',
82
102
  title: 'List offers',
83
- description: 'The org’s offers (the API calls them creatives): id, name, format, status (active, paused, or under review), and the title or text. Any agent’s rules can use any offer. Read one in full with get_offer. Maps to GET /system/offer-manager/creative.',
103
+ description: `The workspace’s offers, each with id, name, format, ${STATUS}, the title, how many rules use it, and last7Days (shown and accepted over the last 7 days in the workspace’s time zone). Any agent’s rules can use any offer. Read one in full with get_offer. Maps to GET /system/offer-manager/offers.`,
84
104
  kind: 'read',
85
105
  roleFloor: 'viewer',
86
- input: { ...shared_1.listShape },
87
- async run({ client }, args) {
88
- const body = await client.get(`${shared_1.OM}/creative`, (0, shared_1.defined)(args));
106
+ capability: 'offer-manager',
107
+ input: {},
108
+ async run({ client }) {
109
+ const body = await client.get(`${shared_1.OM}/offers`);
89
110
  return (0, shared_1.rows)(body).map(offerRow);
90
111
  },
91
112
  });
92
113
  exports.getOffer = (0, tool_1.defineTool)({
93
114
  name: 'get_offer',
94
115
  title: 'Get an offer',
95
- description: 'One offer with every field: content, replies and their roles, properties, frequency cap, and status. Maps to GET /system/offer-manager/creative/{id}.',
116
+ description: `One offer with every field: content, replies and their roles, properties, its ${STATUS}, the rules that use it (name, agent, moments, enabled, schedule), and last7Days (shown and accepted). Maps to GET /system/offer-manager/offers/{id}.`,
96
117
  kind: 'read',
97
118
  roleFloor: 'viewer',
119
+ capability: 'offer-manager',
98
120
  input: { id: (0, shared_1.id)('offer') },
99
121
  async run({ client }, { id: offerId }) {
100
- return client.get(`${shared_1.OM}/creative/${(0, shared_1.enc)(offerId)}`);
122
+ return client.get(`${shared_1.OM}/offers/${(0, shared_1.enc)(offerId)}`);
101
123
  },
102
124
  });
103
125
  exports.createOffer = (0, tool_1.defineTool)({
104
126
  name: 'create_offer',
105
127
  title: 'Create an offer',
106
- description: 'Create an offer. It appears only through a rule that includes it, so creating it changes nothing a customer sees until a rule uses it. Maps to POST /system/offer-manager/creative.',
128
+ description: 'Create an offer as a draft. It appears only through a rule that uses it, so creating it changes nothing a customer sees until a rule uses it and is published. Maps to POST /system/offer-manager/creative.',
107
129
  kind: 'write',
108
130
  roleFloor: 'editor',
131
+ capability: 'offer-manager',
109
132
  input: {
110
133
  name: zod_1.z.string().min(1).max(200).describe('Display name.'),
111
134
  format,
@@ -113,8 +136,8 @@ exports.createOffer = (0, tool_1.defineTool)({
113
136
  payload: payload.optional(),
114
137
  actions: actions.optional(),
115
138
  properties: properties.optional(),
116
- frequency: shared_1.frequency.optional(),
117
139
  },
140
+ approval: args => `Create the offer ${(0, shared_1.quoted)(args.name, '')} as a draft. Customers see it only once you choose who sees it and publish it.`,
118
141
  async run({ client }, args) {
119
142
  const body = (0, shared_1.defined)(args);
120
143
  checkOfferBody(body, false);
@@ -124,10 +147,11 @@ exports.createOffer = (0, tool_1.defineTool)({
124
147
  exports.updateOffer = (0, tool_1.defineTool)({
125
148
  name: 'update_offer',
126
149
  title: 'Update an offer',
127
- description: 'Change an offer. Only the fields given change; `actions` and `properties` replace the whole list. Customers see the change on the next request through any rule that uses it. Maps to PATCH /system/offer-manager/creative/{id}.',
150
+ description: 'Change an offer’s content. Only the fields given change; `actions` and `properties` replace the whole list. Customers see the change on the next request through any rule that uses it. Maps to PATCH /system/offer-manager/creative/{id}.',
128
151
  kind: 'write',
129
152
  roleFloor: 'editor',
130
153
  reader: 'get_offer',
154
+ capability: 'offer-manager',
131
155
  input: {
132
156
  id: (0, shared_1.id)('offer'),
133
157
  name: zod_1.z.string().min(1).max(200).optional(),
@@ -136,7 +160,17 @@ exports.updateOffer = (0, tool_1.defineTool)({
136
160
  payload: payload.optional(),
137
161
  actions: actions.optional(),
138
162
  properties: properties.optional(),
139
- frequency: shared_1.frequency.optional(),
163
+ },
164
+ approval: (args, before) => {
165
+ const what = (0, shared_1.changedWords)(args, OFFER_WORDS);
166
+ const renamed = args.name && before?.name && args.name !== before.name
167
+ ? ` It will be called ${(0, shared_1.quoted)(args.name, '')}.`
168
+ : '';
169
+ const offer = (0, shared_1.named)('offer', before?.name ?? args.name);
170
+ const change = what.length
171
+ ? `Change the ${(0, shared_1.listWords)(what)} of ${offer}.`
172
+ : `Change ${offer}.`;
173
+ return `${change}${renamed}${liveNote(before)}`;
140
174
  },
141
175
  async run({ client }, args) {
142
176
  const body = (0, shared_1.patchBody)(args);
@@ -144,40 +178,53 @@ exports.updateOffer = (0, tool_1.defineTool)({
144
178
  return client.patch(`${shared_1.OM}/creative/${(0, shared_1.enc)(args.id)}`, body);
145
179
  },
146
180
  });
147
- exports.pauseOffer = (0, tool_1.defineTool)({
148
- name: 'pause_offer',
149
- title: 'Pause an offer',
150
- description: 'Stop an active offer from appearing, through every rule, at once. Undo with resume_offer. Refused (422) when the offer is not active. Maps to POST /system/offer-manager/creative/{id}/pause.',
181
+ /** `its 2 audiences`, from the offer as it stands (an audience is a rule). */
182
+ function audiences(before) {
183
+ const n = Array.isArray(before?.rules) ? before.rules.length : undefined;
184
+ if (n === 1)
185
+ return 'its audience';
186
+ return n === undefined ? 'its audiences' : `its ${n} audiences`;
187
+ }
188
+ exports.publishOffer = (0, tool_1.defineTool)({
189
+ name: 'publish_offer',
190
+ title: 'Publish an offer',
191
+ description: 'Publish an offer: turn on every rule that uses it, so it can appear wherever those rules apply, within their dates. Refused (409) when no rule uses the offer: create one first (create_rule). Returns the offer with its new status. Maps to POST /system/offer-manager/offers/{id}/publish.',
151
192
  kind: 'write',
152
193
  roleFloor: 'editor',
153
194
  reader: 'get_offer',
195
+ capability: 'offer-manager',
154
196
  input: { id: (0, shared_1.id)('offer') },
197
+ approval: (_args, before) => `Publish ${(0, shared_1.named)('offer', before?.name)}: it starts showing to ${audiences(before)} from the next request.`,
155
198
  async run({ client }, { id: offerId }) {
156
- return client.post(`${shared_1.OM}/creative/${(0, shared_1.enc)(offerId)}/pause`);
199
+ return client.post(`${shared_1.OM}/offers/${(0, shared_1.enc)(offerId)}/publish`);
157
200
  },
158
201
  });
159
- exports.resumeOffer = (0, tool_1.defineTool)({
160
- name: 'resume_offer',
161
- title: 'Resume an offer',
162
- description: 'Let a paused offer appear again through its rules. Refused (422) when the offer is not paused. Maps to POST /system/offer-manager/creative/{id}/resume.',
202
+ exports.pauseOffer = (0, tool_1.defineTool)({
203
+ name: 'pause_offer',
204
+ title: 'Pause an offer',
205
+ description: 'Pause an offer: turn off every rule that uses it, so it stops appearing at once. Undo with publish_offer. Returns the offer with its new status. Maps to POST /system/offer-manager/offers/{id}/pause.',
163
206
  kind: 'write',
164
207
  roleFloor: 'editor',
165
208
  reader: 'get_offer',
209
+ capability: 'offer-manager',
166
210
  input: { id: (0, shared_1.id)('offer') },
211
+ approval: (_args, before) => `Pause ${(0, shared_1.named)('offer', before?.name)}: it stops showing to ${audiences(before)} at once.`,
167
212
  async run({ client }, { id: offerId }) {
168
- return client.post(`${shared_1.OM}/creative/${(0, shared_1.enc)(offerId)}/resume`);
213
+ return client.post(`${shared_1.OM}/offers/${(0, shared_1.enc)(offerId)}/pause`);
169
214
  },
170
215
  });
171
216
  exports.deleteOffer = (0, tool_1.defineTool)({
172
217
  name: 'delete_offer',
173
218
  title: 'Delete an offer',
174
- description: 'Permanently delete an offer. Refused (409) while a rule still uses it; the error names those rules. To stop it for now, use pause_offer. Maps to DELETE /system/offer-manager/creative/{id}.',
219
+ description: 'Permanently delete an offer in one step: the rules that show only this offer are deleted with it, and it is taken out of rules that rotate it with other offers. Returns what was removed (`rulesDeleted`, `rulesChanged`, and `message`, a sentence to relay). To stop it for now, use pause_offer. Maps to DELETE /system/offer-manager/offers/{id}.',
175
220
  kind: 'destructive',
176
221
  roleFloor: 'editor',
177
222
  reader: 'get_offer',
223
+ capability: 'offer-manager',
178
224
  input: { id: (0, shared_1.id)('offer') },
225
+ approval: (_args, before) => `Delete ${(0, shared_1.named)('offer', before?.name)} for good, with the rules that show only it, and take it out of any rotation. This cannot be undone.`,
179
226
  async run({ client }, { id: offerId }) {
180
- return client.delete(`${shared_1.OM}/creative/${(0, shared_1.enc)(offerId)}`);
227
+ return client.delete(`${shared_1.OM}/offers/${(0, shared_1.enc)(offerId)}`);
181
228
  },
182
229
  });
183
230
  exports.offerTools = [
@@ -185,8 +232,8 @@ exports.offerTools = [
185
232
  exports.getOffer,
186
233
  exports.createOffer,
187
234
  exports.updateOffer,
235
+ exports.publishOffer,
188
236
  exports.pauseOffer,
189
- exports.resumeOffer,
190
237
  exports.deleteOffer,
191
238
  ];
192
239
  //# sourceMappingURL=offers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"offers.js","sourceRoot":"","sources":["../../src/tools/offers.ts"],"names":[],"mappings":";;;AAsGA,4BAQC;AA9GD;;;GAGG;AACH,+DAA4D;AAC5D,6BAAwB;AACxB,yDAA4D;AAC5D,6CAA8C;AAC9C,kCAAqC;AACrC,qCAYkB;AAElB,MAAM,OAAO,GAAG,CAAC,WAAW,EAAE,MAAM,CAAU,CAAC;AAE/C,MAAM,MAAM,GAAG,OAAC;KACb,IAAI,CAAC,OAAO,CAAC;KACb,QAAQ,CACP,qQAAq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M,CAAC,MAAM,CAAC,GAAG,WAAE,WAAW,IAAA,YAAG,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACvD,CAAC;CACF,CAAC,CAAC;AAEU,QAAA,UAAU,GAAG;IACxB,kBAAU;IACV,gBAAQ;IACR,mBAAW;IACX,mBAAW;IACX,oBAAY;IACZ,kBAAU;IACV,mBAAW;CACZ,CAAC"}
@@ -0,0 +1,18 @@
1
+ /** The `groupBy` values each section accepts. */
2
+ export declare const RESULTS_GROUP_BY: {
3
+ readonly offers: readonly ["day", "offer", "moment", "channel", "agent"];
4
+ readonly network: readonly ["day", "moment", "channel", "agent"];
5
+ readonly campaigns: readonly ["day", "campaign"];
6
+ };
7
+ type Section = keyof typeof RESULTS_GROUP_BY;
8
+ /**
9
+ * The (section, groupBy) pairs a call asks for: every section with every
10
+ * split it accepts. A section none of the splits fits is refused.
11
+ */
12
+ export declare function resultsViews(section: Section | Section[], groupBy?: string | string[]): Array<{
13
+ section: Section;
14
+ groupBy?: string;
15
+ }>;
16
+ export declare const getResults: import("../tool").AnyTool;
17
+ export declare const resultsTools: import("../tool").AnyTool[];
18
+ export {};
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resultsTools = exports.getResults = exports.RESULTS_GROUP_BY = void 0;
4
+ exports.resultsViews = resultsViews;
5
+ /**
6
+ * Results: daily counts for the workspace's offers, its ads from the
7
+ * network, and its campaigns (`GET /system/results`). Every workspace can
8
+ * read them; a section the workspace does not use comes back as zeros.
9
+ */
10
+ const zod_1 = require("zod");
11
+ const tool_1 = require("../tool");
12
+ const shared_1 = require("./shared");
13
+ /** The `groupBy` values each section accepts. */
14
+ exports.RESULTS_GROUP_BY = {
15
+ offers: ['day', 'offer', 'moment', 'channel', 'agent'],
16
+ network: ['day', 'moment', 'channel', 'agent'],
17
+ campaigns: ['day', 'campaign'],
18
+ };
19
+ const SECTIONS = Object.keys(exports.RESULTS_GROUP_BY);
20
+ const GROUP_BYS = [
21
+ 'day',
22
+ 'offer',
23
+ 'moment',
24
+ 'channel',
25
+ 'agent',
26
+ 'campaign',
27
+ ];
28
+ const oneOrMore = (t) => zod_1.z.union([t, zod_1.z.array(t).min(1).max(GROUP_BYS.length)]);
29
+ const list = (v) => v === undefined ? undefined : Array.isArray(v) ? v : [v];
30
+ /**
31
+ * The (section, groupBy) pairs a call asks for: every section with every
32
+ * split it accepts. A section none of the splits fits is refused.
33
+ */
34
+ function resultsViews(section, groupBy) {
35
+ const sections = [...new Set(list(section))];
36
+ const splits = list(groupBy);
37
+ const views = [];
38
+ for (const s of sections) {
39
+ if (!splits) {
40
+ views.push({ section: s });
41
+ continue;
42
+ }
43
+ const fits = [...new Set(splits)].filter(g => exports.RESULTS_GROUP_BY[s].includes(g));
44
+ if (!fits.length)
45
+ throw new shared_1.ToolInputError(`${s} cannot be split by ${(0, shared_1.listWords)(splits)}; it takes ${(0, shared_1.listWords)([...exports.RESULTS_GROUP_BY[s]])}. Nothing was sent.`);
46
+ for (const g of fits)
47
+ views.push({ section: s, groupBy: g });
48
+ }
49
+ return views;
50
+ }
51
+ const day = (what) => zod_1.z
52
+ .string()
53
+ .regex(/^\d{4}-\d{2}-\d{2}$/, 'a date like 2026-10-01')
54
+ .describe(`${what}, yyyy-mm-dd in the workspace’s time zone, inclusive. The range is at most 400 days.`);
55
+ exports.getResults = (0, tool_1.defineTool)({
56
+ name: 'get_results',
57
+ title: 'Get results',
58
+ description: 'Daily counts for the workspace, over a range of days in its time zone, with totals and rows. Sections and their metrics: `offers` (the brand’s own offers: requests, shown, accepted, declined, clicked, converted), `network` (ads from the network: requests offered to the network, shown, clicked), `campaigns` (the workspace’s campaigns wherever they serve: shown, clicks, conversions; conversationsStarted and cost are null until they are computed). `groupBy` splits the rows: by `day` (every day of the range, oldest first, the default), or by offer, moment, channel, or agent (offers); moment, channel, or agent (network); campaign (campaigns). Grouped rows are sorted highest first and carry a display name (`label`). A null value is not computed; offers `requests` is null by offer because requests are counted before an offer is chosen. `application` limits it to one agent; `offer` limits the offers section to one offer, and `campaign` the campaigns section to one campaign. To answer a question that needs several views (say offers by offer and by agent, and the network), ask for them in one call: `section` and `groupBy` each take a list, and you get `{ results: [...] }`, one entry (section, groupBy, totals, rows) per section with each split it accepts; one section and one split return that view alone. Metric definitions: read_doc offer-manager/results-metrics. Maps to GET /system/results.',
59
+ kind: 'read',
60
+ roleFloor: 'viewer',
61
+ input: {
62
+ section: oneOrMore(zod_1.z.enum(SECTIONS)).describe('Which results: one section, or a list of them.'),
63
+ from: day('First day'),
64
+ to: day('Last day'),
65
+ groupBy: oneOrMore(zod_1.z.enum(GROUP_BYS))
66
+ .optional()
67
+ .describe('How to split the rows, one or a list; the values each section accepts are listed above, and each section gets the splits it accepts. Default day.'),
68
+ application: shared_1.application
69
+ .optional()
70
+ .describe('Only this agent’s requests (list_applications).'),
71
+ offer: zod_1.z
72
+ .string()
73
+ .min(1)
74
+ .optional()
75
+ .describe('Only this offer (an id from list_offers); applies to the offers section, not with application.'),
76
+ campaign: zod_1.z
77
+ .string()
78
+ .min(1)
79
+ .optional()
80
+ .describe('Only this campaign (an id from list_campaigns); applies to the campaigns section, not with application.'),
81
+ },
82
+ async run({ client }, args) {
83
+ const views = resultsViews(args.section, args.groupBy);
84
+ const filters = [
85
+ ['offer', 'offers'],
86
+ ['campaign', 'campaigns'],
87
+ ];
88
+ for (const [key, section] of filters) {
89
+ if (args[key] === undefined)
90
+ continue;
91
+ if (args.application !== undefined)
92
+ throw new shared_1.ToolInputError(`${key} cannot be combined with application; pass one of them.`);
93
+ if (!views.some(v => v.section === section))
94
+ throw new shared_1.ToolInputError(`${key} applies only to the ${section} section; add it to section.`);
95
+ }
96
+ // Each filter goes only to its own section's views.
97
+ const query = (v) => client.get('/results', (0, shared_1.defined)({
98
+ ...args,
99
+ offer: v.section === 'offers' ? args.offer : undefined,
100
+ campaign: v.section === 'campaigns' ? args.campaign : undefined,
101
+ ...v,
102
+ }));
103
+ if (views.length === 1)
104
+ return query(views[0]);
105
+ const bodies = await Promise.all(views.map(query));
106
+ return {
107
+ results: bodies.map((b, i) => ({
108
+ ...b,
109
+ section: views[i].section,
110
+ groupBy: views[i].groupBy ?? 'day',
111
+ })),
112
+ };
113
+ },
114
+ });
115
+ exports.resultsTools = [exports.getResults];
116
+ //# sourceMappingURL=results.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"results.js","sourceRoot":"","sources":["../../src/tools/results.ts"],"names":[],"mappings":";;;AAqCA,oCAsBC;AA3DD;;;;GAIG;AACH,6BAAwB;AACxB,kCAAqC;AACrC,qCAAgF;AAEhF,iDAAiD;AACpC,QAAA,gBAAgB,GAAG;IAC9B,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC;IACtD,OAAO,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC;IAC9C,SAAS,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC;CACtB,CAAC;AAGX,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,wBAAgB,CAAc,CAAC;AAC5D,MAAM,SAAS,GAAG;IAChB,KAAK;IACL,OAAO;IACP,QAAQ;IACR,SAAS;IACT,OAAO;IACP,UAAU;CACF,CAAC;AAEX,MAAM,SAAS,GAAG,CAAyB,CAAI,EAAE,EAAE,CACjD,OAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,OAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAExD,MAAM,IAAI,GAAG,CAAI,CAAsB,EAAmB,EAAE,CAC1D,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC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