@advertising-chat/mcp 0.2.1 → 0.17.3

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 (85) hide show
  1. package/README.md +123 -18
  2. package/bin/auth.d.ts +46 -0
  3. package/bin/auth.js +186 -0
  4. package/bin/auth.js.map +1 -0
  5. package/bin/cli.js +79 -11
  6. package/bin/cli.js.map +1 -1
  7. package/bin/client.d.ts +70 -0
  8. package/bin/client.js +121 -0
  9. package/bin/client.js.map +1 -0
  10. package/bin/docs.d.ts +66 -0
  11. package/bin/docs.js +247 -0
  12. package/bin/docs.js.map +1 -0
  13. package/bin/flow/flowSchema.d.ts +298 -0
  14. package/bin/flow/flowSchema.js +234 -0
  15. package/bin/flow/flowSchema.js.map +1 -0
  16. package/bin/flow/flowValidator.d.ts +15 -0
  17. package/bin/flow/flowValidator.js +179 -0
  18. package/bin/flow/flowValidator.js.map +1 -0
  19. package/bin/flow/flowZod.d.ts +117 -0
  20. package/bin/flow/flowZod.js +130 -0
  21. package/bin/flow/flowZod.js.map +1 -0
  22. package/bin/format.d.ts +14 -0
  23. package/bin/format.js +50 -0
  24. package/bin/format.js.map +1 -0
  25. package/bin/index.d.ts +23 -1
  26. package/bin/index.js +65 -4
  27. package/bin/index.js.map +1 -1
  28. package/bin/routeInventory.d.ts +69 -0
  29. package/bin/routeInventory.js +201 -0
  30. package/bin/routeInventory.js.map +1 -0
  31. package/bin/serve.d.ts +24 -0
  32. package/bin/serve.js +196 -0
  33. package/bin/serve.js.map +1 -0
  34. package/bin/server.d.ts +24 -36
  35. package/bin/server.js +54 -182
  36. package/bin/server.js.map +1 -1
  37. package/bin/tool.d.ts +84 -0
  38. package/bin/tool.js +39 -0
  39. package/bin/tool.js.map +1 -0
  40. package/bin/tools/account.d.ts +2 -0
  41. package/bin/tools/account.js +47 -0
  42. package/bin/tools/account.js.map +1 -0
  43. package/bin/tools/attributes.d.ts +10 -0
  44. package/bin/tools/attributes.js +200 -0
  45. package/bin/tools/attributes.js.map +1 -0
  46. package/bin/tools/campaigns.d.ts +12 -0
  47. package/bin/tools/campaigns.js +230 -0
  48. package/bin/tools/campaigns.js.map +1 -0
  49. package/bin/tools/decisions.d.ts +14 -0
  50. package/bin/tools/decisions.js +309 -0
  51. package/bin/tools/decisions.js.map +1 -0
  52. package/bin/tools/docs.d.ts +3 -0
  53. package/bin/tools/docs.js +55 -0
  54. package/bin/tools/docs.js.map +1 -0
  55. package/bin/tools/index.d.ts +21 -0
  56. package/bin/tools/index.js +60 -0
  57. package/bin/tools/index.js.map +1 -0
  58. package/bin/tools/moments.d.ts +9 -0
  59. package/bin/tools/moments.js +143 -0
  60. package/bin/tools/moments.js.map +1 -0
  61. package/bin/tools/network.d.ts +5 -0
  62. package/bin/tools/network.js +99 -0
  63. package/bin/tools/network.js.map +1 -0
  64. package/bin/tools/offers.d.ts +11 -0
  65. package/bin/tools/offers.js +239 -0
  66. package/bin/tools/offers.js.map +1 -0
  67. package/bin/tools/results.d.ts +18 -0
  68. package/bin/tools/results.js +116 -0
  69. package/bin/tools/results.js.map +1 -0
  70. package/bin/tools/rules.d.ts +9 -0
  71. package/bin/tools/rules.js +318 -0
  72. package/bin/tools/rules.js.map +1 -0
  73. package/bin/tools/settings.d.ts +3 -0
  74. package/bin/tools/settings.js +54 -0
  75. package/bin/tools/settings.js.map +1 -0
  76. package/bin/tools/shared.d.ts +50 -0
  77. package/bin/tools/shared.js +171 -0
  78. package/bin/tools/shared.js.map +1 -0
  79. package/bin/tools/translation.d.ts +6 -0
  80. package/bin/tools/translation.js +139 -0
  81. package/bin/tools/translation.js.map +1 -0
  82. package/bin/version.d.ts +2 -0
  83. package/bin/version.js +6 -0
  84. package/bin/version.js.map +1 -0
  85. package/package.json +10 -7
@@ -0,0 +1,200 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.attributeTools = exports.deleteAttribute = exports.updateAttribute = exports.documentAttribute = exports.addAttribute = exports.getAttribute = exports.listAttributes = void 0;
4
+ exports.attributeRow = attributeRow;
5
+ /**
6
+ * The attribute catalog: the vocabulary rules are written in. Each agent
7
+ * has its own catalog; a rule can use only attributes in its agent's
8
+ * catalog. The agent platform registers types; marketers document what an
9
+ * attribute means (`document_attribute`). Input schemas come from
10
+ * `@advertising-chat/offer-rules`, the package the server validates with.
11
+ */
12
+ const offer_rules_1 = require("@advertising-chat/offer-rules");
13
+ const zod_1 = require("zod");
14
+ const tool_1 = require("../tool");
15
+ const shared_1 = require("./shared");
16
+ const A = offer_rules_1.AttributeCreate.shape;
17
+ const U = offer_rules_1.AttributeUpdate.shape;
18
+ const CATALOG = 'https://docs.advertising.chat/reference/catalog/';
19
+ const fields = {
20
+ key: A.key.describe('The attribute key exactly as the agent sends it on fetch requests, e.g. `data_limit_streak_months`. Unique within the agent.'),
21
+ type: A.type.describe('string, number, boolean, date, enum, or list. It decides how values are read and which operators a condition can use; enum needs `values`.'),
22
+ label: A.label.describe('What marketers call it, e.g. "Months at data limit in a row".'),
23
+ description: A.description.describe('What it means and how it is computed, for people and for the Assistant.'),
24
+ values: A.values.describe('For enum only: the allowed values, as { value, label? }.'),
25
+ examples: A.examples.describe('Up to 10 sample values.'),
26
+ source: A.source.describe('Who supplies it: agent (default), context_layer, or data_feed.'),
27
+ };
28
+ /** `the customer detail “Plan” (plan)`, from an entry or an input. */
29
+ function attrName(e) {
30
+ const label = typeof e.label === 'string' && e.label ? e.label : undefined;
31
+ const key = typeof e.key === 'string' && e.key ? e.key : undefined;
32
+ if (label)
33
+ return `the customer detail ${(0, shared_1.quoted)(label, '')}`;
34
+ if (key)
35
+ return `the customer detail “${key}”`;
36
+ return 'this customer detail';
37
+ }
38
+ /** A catalog entry as the list shows it. */
39
+ function attributeRow(e) {
40
+ return {
41
+ id: (0, shared_1.str)(e._id) ?? (0, shared_1.str)(e.id),
42
+ key: e.key,
43
+ type: e.type,
44
+ label: e.label,
45
+ status: e.status,
46
+ values: Array.isArray(e.values)
47
+ ? e.values.map((v) => v.value)
48
+ : undefined,
49
+ coverage: typeof e.coverage === 'number' ? e.coverage : undefined,
50
+ lastSeenAt: e.lastSeenAt,
51
+ };
52
+ }
53
+ exports.listAttributes = (0, tool_1.defineTool)({
54
+ name: 'list_attributes',
55
+ title: 'List an agent’s attributes',
56
+ description: `The attribute catalog of one agent: the attributes it sends on fetch requests (or will), with key, type, label, enum values, status (observed: seen but undescribed; documented; retired), coverage (share of the agent's requests in the last 7 days that carry it, 0 to 1), and lastSeenAt. A rule can only use attributes in its agent's catalog, with operators that fit their type; check here before writing an audience or exclusions condition. Reference: ${CATALOG} Maps to GET /system/offer-manager/attributes.`,
57
+ kind: 'read',
58
+ roleFloor: 'viewer',
59
+ capability: 'offer-manager',
60
+ input: {
61
+ application: shared_1.application,
62
+ status: zod_1.z
63
+ .enum(['observed', 'documented', 'retired'])
64
+ .optional()
65
+ .describe('Only entries with this status.'),
66
+ },
67
+ async run({ client }, args) {
68
+ const body = await client.get(`${shared_1.OM}/attributes`, (0, shared_1.defined)(args));
69
+ return (Array.isArray(body) ? body : []).map(attributeRow);
70
+ },
71
+ });
72
+ exports.getAttribute = (0, tool_1.defineTool)({
73
+ name: 'get_attribute',
74
+ title: 'Get an attribute',
75
+ description: 'One catalog entry with every field, including its description, examples, coverage per moment, who wrote each field (writtenBy: observed, platform, marketer), and the rules whose conditions use it (rulesUsing). Maps to GET /system/offer-manager/attributes/{id}.',
76
+ kind: 'read',
77
+ roleFloor: 'viewer',
78
+ capability: 'offer-manager',
79
+ input: { id: (0, shared_1.id)('attribute') },
80
+ async run({ client }, { id: attributeId }) {
81
+ return client.get(`${shared_1.OM}/attributes/${(0, shared_1.enc)(attributeId)}`);
82
+ },
83
+ });
84
+ exports.addAttribute = (0, tool_1.defineTool)({
85
+ name: 'add_attribute',
86
+ title: 'Add an attribute',
87
+ description: 'Add an attribute to an agent’s catalog, before or after the agent starts sending it, so rules can use it. The entry is documented. Until the agent sends it, a rule on it matches no one; say so, and say what the agent’s team must send. A key the catalog already has is refused (409); use document_attribute or update_attribute on that entry instead. Maps to POST /system/offer-manager/attributes.',
88
+ kind: 'write',
89
+ roleFloor: 'editor',
90
+ capability: 'offer-manager',
91
+ input: { application: shared_1.application, ...fields },
92
+ approval: args => `Add ${(0, shared_1.quoted)(args.label ?? args.key, 'a detail')} to this agent’s customer details, so offers can use it to choose who sees them. An audience that uses it reaches no one until the agent sends “${args.key}”.`,
93
+ async run({ client }, args) {
94
+ const parsed = offer_rules_1.AttributeCreate.safeParse((0, shared_1.defined)(args));
95
+ if (!parsed.success) {
96
+ throw new shared_1.ToolInputError(`The attribute is not valid:\n${(0, shared_1.issues)(parsed.error)}`);
97
+ }
98
+ return client.post(`${shared_1.OM}/attributes`, parsed.data);
99
+ },
100
+ });
101
+ const nullable = (s, what) => s.describe(`${what} Pass null to clear yours; the agent platform’s value, if it registered one, shows again.`);
102
+ exports.documentAttribute = (0, tool_1.defineTool)({
103
+ name: 'document_attribute',
104
+ title: 'Document an attribute',
105
+ description: 'Write the marketer’s words on a catalog entry: its label, description, and examples. They are shown over what the agent platform registered, and they are what the console, rule cards, and translations call the attribute. Documenting an observed entry makes it documented. To change how values are read (type, enum values) or retire it, use update_attribute. Maps to PATCH /system/offer-manager/attributes/{id}.',
106
+ kind: 'write',
107
+ roleFloor: 'editor',
108
+ reader: 'get_attribute',
109
+ capability: 'offer-manager',
110
+ input: {
111
+ id: (0, shared_1.id)('attribute'),
112
+ label: nullable(U.label, 'What marketers call it, e.g. "Months at data limit in a row".'),
113
+ description: nullable(U.description, 'What it means and how it is computed, for people and for the Assistant.'),
114
+ examples: nullable(U.examples, 'Up to 10 sample values.'),
115
+ },
116
+ approval: (args, before) => {
117
+ const what = ['label', 'description', 'examples']
118
+ .filter(k => args[k] !== undefined)
119
+ .map(k => (k === 'label' ? 'name' : k));
120
+ const label = typeof args.label === 'string' && args.label !== before?.label
121
+ ? ` It will be called ${(0, shared_1.quoted)(args.label, '')}.`
122
+ : '';
123
+ return `Update the ${(0, shared_1.listWords)(what) || 'description'} of ${attrName(before ?? args)}.${label}`;
124
+ },
125
+ async run({ client }, args) {
126
+ const body = (0, shared_1.patchBody)(args);
127
+ const parsed = offer_rules_1.AttributeUpdate.safeParse(body);
128
+ if (!parsed.success) {
129
+ throw new shared_1.ToolInputError(`The change is not valid:\n${(0, shared_1.issues)(parsed.error)}`);
130
+ }
131
+ return client.patch(`${shared_1.OM}/attributes/${(0, shared_1.enc)(args.id)}`, parsed.data);
132
+ },
133
+ });
134
+ exports.updateAttribute = (0, tool_1.defineTool)({
135
+ name: 'update_attribute',
136
+ title: 'Update an attribute',
137
+ description: 'Change how a catalog entry is read: its type, enum values (null clears them), or source, or its status (documented, or retired so rules can no longer use it). For the label, description, or examples, use document_attribute. A type the agent platform registered cannot change, and a change that would break a saved rule is refused (409, naming the rules). Retiring is allowed while rules use it: get_attribute and the answer list them in rulesUsing; they keep serving as saved, but cannot be saved again until the condition is removed, so name them to the user before retiring. Maps to PATCH /system/offer-manager/attributes/{id}.',
138
+ kind: 'write',
139
+ roleFloor: 'editor',
140
+ reader: 'get_attribute',
141
+ capability: 'offer-manager',
142
+ input: {
143
+ id: (0, shared_1.id)('attribute'),
144
+ type: U.type.describe(fields.type.description ?? ''),
145
+ values: U.values.describe('For enum only: the allowed values, as { value, label? }. null clears them.'),
146
+ source: U.source.describe(fields.source.description ?? ''),
147
+ status: U.status.describe('documented, or retired: rules can no longer use it.'),
148
+ },
149
+ approval: (args, before) => {
150
+ const name = attrName(before ?? args);
151
+ const using = Array.isArray(before?.rulesUsing)
152
+ ? before.rulesUsing.length
153
+ : 0;
154
+ if (args.status === 'retired')
155
+ return `Retire ${name}: offers can no longer start using it.${using
156
+ ? ` ${using === 1 ? 'One audience uses it; it keeps' : `${using} audiences use it; they keep`} working as saved, but cannot be saved again until the detail is removed from ${using === 1 ? 'it' : 'them'}.`
157
+ : ''}`;
158
+ const what = [];
159
+ if (args.type !== undefined)
160
+ what.push('how its values are read');
161
+ if (args.values !== undefined)
162
+ what.push('its allowed values');
163
+ if (args.source !== undefined)
164
+ what.push('who supplies it');
165
+ if (args.status === 'documented')
166
+ what.push('its status, to documented');
167
+ return `Change ${(0, shared_1.listWords)(what) || 'the settings'} of ${name}.`;
168
+ },
169
+ async run({ client }, args) {
170
+ const body = (0, shared_1.patchBody)(args);
171
+ const parsed = offer_rules_1.AttributeUpdate.safeParse(body);
172
+ if (!parsed.success) {
173
+ throw new shared_1.ToolInputError(`The change is not valid:\n${(0, shared_1.issues)(parsed.error)}`);
174
+ }
175
+ return client.patch(`${shared_1.OM}/attributes/${(0, shared_1.enc)(args.id)}`, parsed.data);
176
+ },
177
+ });
178
+ exports.deleteAttribute = (0, tool_1.defineTool)({
179
+ name: 'delete_attribute',
180
+ title: 'Delete an attribute',
181
+ description: 'Remove an entry from an agent’s catalog. Refused (409) while a rule uses it; the error names those rules. Prefer retiring it with update_attribute. If the agent still sends the key, it returns as observed. Maps to DELETE /system/offer-manager/attributes/{id}.',
182
+ kind: 'destructive',
183
+ roleFloor: 'editor',
184
+ reader: 'get_attribute',
185
+ capability: 'offer-manager',
186
+ input: { id: (0, shared_1.id)('attribute') },
187
+ approval: (_args, before) => `Remove ${attrName(before ?? {})} from this agent’s customer details. If the agent still sends it, it comes back as seen but not described.`,
188
+ async run({ client }, { id: attributeId }) {
189
+ return client.delete(`${shared_1.OM}/attributes/${(0, shared_1.enc)(attributeId)}`);
190
+ },
191
+ });
192
+ exports.attributeTools = [
193
+ exports.listAttributes,
194
+ exports.getAttribute,
195
+ exports.addAttribute,
196
+ exports.documentAttribute,
197
+ exports.updateAttribute,
198
+ exports.deleteAttribute,
199
+ ];
200
+ //# sourceMappingURL=attributes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attributes.js","sourceRoot":"","sources":["../../src/tools/attributes.ts"],"names":[],"mappings":";;;AAiEA,oCAaC;AA9ED;;;;;;GAMG;AACH,+DAGuC;AACvC,6BAAwB;AACxB,kCAAqC;AACrC,q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AAE,eAAe,IAAA,YAAG,EAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC/D,CAAC;CACF,CAAC,CAAC;AAEU,QAAA,cAAc,GAAG;IAC5B,sBAAc;IACd,oBAAY;IACZ,oBAAY;IACZ,yBAAiB;IACjB,uBAAe;IACf,uBAAe;CAChB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { Doc } from './shared';
2
+ /** What each campaign state means, for the model to relay. */
3
+ export declare const CAMPAIGN_STATES: Record<string, string>;
4
+ /** A campaign as the list shows it. */
5
+ export declare function campaignRow(c: Doc): Doc;
6
+ export declare const listCampaigns: import("../tool").AnyTool;
7
+ export declare const getCampaign: import("../tool").AnyTool;
8
+ export declare const requestCampaign: import("../tool").AnyTool;
9
+ export declare const pauseCampaign: import("../tool").AnyTool;
10
+ export declare const resumeCampaign: import("../tool").AnyTool;
11
+ export declare const resubmitCampaign: import("../tool").AnyTool;
12
+ export declare const campaignTools: import("../tool").AnyTool[];
@@ -0,0 +1,230 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.campaignTools = exports.resubmitCampaign = exports.resumeCampaign = exports.pauseCampaign = exports.requestCampaign = exports.getCampaign = exports.listCampaigns = exports.CAMPAIGN_STATES = void 0;
4
+ exports.campaignRow = campaignRow;
5
+ /**
6
+ * Campaigns (Conversation Ads): paid traffic that starts conversations with
7
+ * one of the workspace's agents. A campaign is a request our team reviews.
8
+ * These tools do what the brand does in the console: read campaigns,
9
+ * request one, pause and resume it, and change and resubmit one our team
10
+ * rejected. A campaign's ads, other changes, and deleting it stay in the
11
+ * console. `/system/campaigns/campaign` needs the `advertise` capability.
12
+ */
13
+ const zod_1 = require("zod");
14
+ const tool_1 = require("../tool");
15
+ const shared_1 = require("./shared");
16
+ const CAMPAIGN = '/campaigns/campaign';
17
+ /** What each campaign state means, for the model to relay. */
18
+ exports.CAMPAIGN_STATES = {
19
+ pending: 'Submitted and waiting for our team’s review.',
20
+ active: 'Approved; serves within its dates.',
21
+ paused: 'Paused by the brand; resume_campaign makes it active again.',
22
+ rejected: 'Our team declined it; rejectionReason says why. resubmit_campaign changes what the review asks for and sends it back to review.',
23
+ ended: 'Its end date has passed.',
24
+ removed: 'Taken down; it does not return.',
25
+ };
26
+ /** A campaign as the list shows it. */
27
+ function campaignRow(c) {
28
+ return {
29
+ id: (0, shared_1.str)(c._id) ?? (0, shared_1.str)(c.id),
30
+ name: c.name,
31
+ agent: (0, shared_1.refId)(c.application),
32
+ goal: c.goal,
33
+ state: c.state,
34
+ rejectionReason: (0, shared_1.str)(c.rejectionReason),
35
+ startDate: c.startDate,
36
+ endDate: c.endDate,
37
+ dailyBudget: c.dailyBudget,
38
+ };
39
+ }
40
+ exports.listCampaigns = (0, tool_1.defineTool)({
41
+ name: 'list_campaigns',
42
+ title: 'List campaigns',
43
+ description: `The workspace’s campaigns: id, name, the agent conversations start with, goal (conversations, leads, or sales), state, the reason when our team rejected it, dates, and daily budget. startDate and endDate are whole days in the workspace’s time zone: read only the date part (2026-11-30T00:00:00.000Z is November 30), and a campaign runs from the start of its start date through the end of its end date there; no end date means it runs until the brand pauses it. States: ${Object.entries(exports.CAMPAIGN_STATES)
44
+ .map(([s, m]) => `${s} (${m})`)
45
+ .join('; ')} Filter by \`application\` (agent) or \`state\`. Results: get_results with section campaigns. Maps to GET /system/campaigns/campaign.`,
46
+ kind: 'read',
47
+ roleFloor: 'viewer',
48
+ capability: 'advertise',
49
+ input: {
50
+ application: shared_1.application.optional(),
51
+ state: zod_1.z
52
+ .enum(['pending', 'active', 'paused', 'rejected', 'ended', 'removed'])
53
+ .optional()
54
+ .describe('Only campaigns in this state.'),
55
+ ...shared_1.listShape,
56
+ },
57
+ async run({ client }, args) {
58
+ const body = await client.get(CAMPAIGN, (0, shared_1.defined)(args));
59
+ return (0, shared_1.rows)(body).map(campaignRow);
60
+ },
61
+ });
62
+ exports.getCampaign = (0, tool_1.defineTool)({
63
+ name: 'get_campaign',
64
+ title: 'Get a campaign',
65
+ description: 'One campaign with every field: the agent, goal, notes for our team, state and rejectionReason, dates (startDate and endDate are whole days in the workspace’s time zone: read only the date part, and the campaign runs through the whole end date there), daily budget, countries and languages (empty means anywhere and any language), and its ads. Maps to GET /system/campaigns/campaign/{id}.',
66
+ kind: 'read',
67
+ roleFloor: 'viewer',
68
+ capability: 'advertise',
69
+ input: { id: (0, shared_1.id)('campaign') },
70
+ async run({ client }, { id: campaignId }) {
71
+ return client.get(`${CAMPAIGN}/${(0, shared_1.enc)(campaignId)}`);
72
+ },
73
+ });
74
+ // ---------------------------------------------------------------------------
75
+ // Changes: what the brand does in the console, and nothing more.
76
+ const GOALS = ['conversations', 'leads', 'sales'];
77
+ const GOAL = 'What the brand wants from the conversations: conversations (as many people as possible start one), leads (people leave their details), or sales (people buy in the conversation).';
78
+ const goal = zod_1.z.enum(GOALS).describe(GOAL);
79
+ const day = (what) => zod_1.z
80
+ .string()
81
+ .regex(/^\d{4}-\d{2}-\d{2}$/, 'A date like 2026-11-01.')
82
+ .describe(`${what}, as YYYY-MM-DD: a whole day in the workspace’s time zone.`);
83
+ const AGENT = 'The agent (application) people talk to when they tap an ad, from list_applications.';
84
+ const dailyBudget = zod_1.z
85
+ .number()
86
+ .positive()
87
+ .describe('What the brand wants to spend a day, in US dollars.');
88
+ const codes = (what, example, empty) => zod_1.z
89
+ .array(zod_1.z.string().regex(/^[A-Za-z]{2}$/, `Two-letter ${what} codes.`))
90
+ .describe(`Two-letter ${what} codes, like ${example}. Empty: ${empty}.`);
91
+ const countries = codes('country', 'US or CA', 'anywhere');
92
+ const languages = codes('language', 'en or es', 'any language');
93
+ const notes = zod_1.z
94
+ .string()
95
+ .max(2000)
96
+ .describe('Notes for our team: who to reach, offers to mention, sites to avoid.');
97
+ /** The words for a campaign request's fields, for approval sentences. */
98
+ const REQUEST_WORDS = {
99
+ name: 'name',
100
+ application: 'agent',
101
+ goal: 'goal',
102
+ dailyBudget: 'daily budget',
103
+ startDate: 'dates',
104
+ endDate: 'dates',
105
+ countries: 'countries',
106
+ languages: 'languages',
107
+ notes: 'notes for our team',
108
+ };
109
+ /** `$50 a day`, or '' without a budget. */
110
+ function budgetWords(budget) {
111
+ if (typeof budget !== 'number' || !Number.isFinite(budget))
112
+ return '';
113
+ const amount = budget.toLocaleString('en-US', {
114
+ minimumFractionDigits: Number.isInteger(budget) ? 0 : 2,
115
+ maximumFractionDigits: 2,
116
+ });
117
+ return `$${amount} a day`;
118
+ }
119
+ exports.requestCampaign = (0, tool_1.defineTool)({
120
+ name: 'request_campaign',
121
+ title: 'Request a campaign',
122
+ description: 'Send our team a campaign request: the agent people talk to when they tap an ad, the goal, the daily budget, the dates, where and in which languages, and notes for our team. It starts pending; our team reviews it, sets up where the ads run, and approves or rejects it with a reason. Nothing runs until it is approved. The brand adds the campaign’s ads in the console. Maps to POST /system/campaigns/campaign.',
123
+ kind: 'write',
124
+ roleFloor: 'editor',
125
+ capability: 'advertise',
126
+ input: {
127
+ name: zod_1.z
128
+ .string()
129
+ .min(1)
130
+ .max(200)
131
+ .describe('For the brand and our team; customers never see it.'),
132
+ application: shared_1.application.describe(AGENT),
133
+ goal: zod_1.z.enum(GOALS).optional().describe(`${GOAL} Default conversations.`),
134
+ dailyBudget: dailyBudget.optional(),
135
+ startDate: day('When it starts; default today').optional(),
136
+ endDate: day('When it ends; omit to run until the brand pauses it').optional(),
137
+ countries: countries.optional(),
138
+ languages: languages.optional(),
139
+ notes: notes.optional(),
140
+ },
141
+ approval: args => {
142
+ const budget = budgetWords(args.dailyBudget);
143
+ const dates = args.startDate
144
+ ? args.endDate
145
+ ? `from ${args.startDate} to ${args.endDate}`
146
+ : `from ${args.startDate}`
147
+ : args.endDate
148
+ ? `until ${args.endDate}`
149
+ : '';
150
+ const terms = [budget, dates].filter(Boolean).join(', ');
151
+ return `Send our team a request for the campaign ${(0, shared_1.quoted)(args.name, '')}${terms ? `, ${terms}` : ''}. Nothing runs until our team approves it.`;
152
+ },
153
+ async run({ client }, args) {
154
+ return client.post(CAMPAIGN, (0, shared_1.defined)(args));
155
+ },
156
+ });
157
+ exports.pauseCampaign = (0, tool_1.defineTool)({
158
+ name: 'pause_campaign',
159
+ title: 'Pause a campaign',
160
+ description: 'Pause an active campaign: its ads stop showing at once. Undo with resume_campaign. Only an active campaign can be paused (422 otherwise). Returns the campaign with its new state. Maps to POST /system/campaigns/campaign/{id}/pause.',
161
+ kind: 'write',
162
+ roleFloor: 'editor',
163
+ reader: 'get_campaign',
164
+ capability: 'advertise',
165
+ input: { id: (0, shared_1.id)('campaign') },
166
+ approval: (_args, before) => `Pause ${(0, shared_1.named)('campaign', before?.name)}: its ads stop showing at once. You can resume it any time.`,
167
+ async run({ client }, { id: campaignId }) {
168
+ return client.post(`${CAMPAIGN}/${(0, shared_1.enc)(campaignId)}/pause`);
169
+ },
170
+ });
171
+ exports.resumeCampaign = (0, tool_1.defineTool)({
172
+ name: 'resume_campaign',
173
+ title: 'Resume a campaign',
174
+ description: 'Resume a paused campaign: it is active again and its ads show from the next request, within its dates. Only a paused campaign can be resumed (422 otherwise). Returns the campaign with its new state. Maps to POST /system/campaigns/campaign/{id}/resume.',
175
+ kind: 'write',
176
+ roleFloor: 'editor',
177
+ reader: 'get_campaign',
178
+ capability: 'advertise',
179
+ input: { id: (0, shared_1.id)('campaign') },
180
+ approval: (_args, before) => `Resume ${(0, shared_1.named)('campaign', before?.name)}: its ads start showing again from the next request.`,
181
+ async run({ client }, { id: campaignId }) {
182
+ return client.post(`${CAMPAIGN}/${(0, shared_1.enc)(campaignId)}/resume`);
183
+ },
184
+ });
185
+ exports.resubmitCampaign = (0, tool_1.defineTool)({
186
+ name: 'resubmit_campaign',
187
+ title: 'Send a campaign for review again',
188
+ description: 'Send a campaign our team rejected back for review, after changing what the review asks for (read its rejectionReason with get_campaign). Only the fields given change; null clears the daily budget or the end date, and an empty list means anywhere or any language. It returns to pending; nothing runs until our team approves it. Only a rejected campaign can be sent again: anything else is refused before a change is made. Returns the campaign. Maps to PATCH /system/campaigns/campaign/{id} (when fields change) and POST /system/campaigns/campaign/{id}/resubmit.',
189
+ kind: 'write',
190
+ roleFloor: 'editor',
191
+ reader: 'get_campaign',
192
+ capability: 'advertise',
193
+ input: {
194
+ id: (0, shared_1.id)('campaign'),
195
+ name: zod_1.z.string().min(1).max(200).optional(),
196
+ application: shared_1.application.describe(AGENT).optional(),
197
+ goal: goal.optional(),
198
+ dailyBudget: dailyBudget.nullable().optional(),
199
+ startDate: day('When it starts').optional(),
200
+ endDate: day('When it ends').nullable().optional(),
201
+ countries: countries.optional(),
202
+ languages: languages.optional(),
203
+ notes: notes.optional(),
204
+ },
205
+ approval: (args, before) => {
206
+ const what = (0, shared_1.changedWords)(args, REQUEST_WORDS);
207
+ const changes = what.length ? `, with a new ${(0, shared_1.listWords)(what)}` : '';
208
+ return `Send ${(0, shared_1.named)('campaign', before?.name)} to our team again${changes}. Nothing runs until our team approves it.`;
209
+ },
210
+ async run({ client }, args) {
211
+ const path = `${CAMPAIGN}/${(0, shared_1.enc)(args.id)}`;
212
+ const current = await client.get(path);
213
+ if (current?.state !== 'rejected') {
214
+ throw new shared_1.ToolInputError(`Only a campaign our team rejected can be sent for review again; this one is ${(0, shared_1.str)(current?.state) ?? 'not rejected'}. Nothing was changed.`);
215
+ }
216
+ const changes = Object.keys(args).some(k => k !== 'id' && args[k] !== undefined);
217
+ if (changes)
218
+ await client.patch(path, (0, shared_1.patchBody)(args));
219
+ return client.post(`${path}/resubmit`);
220
+ },
221
+ });
222
+ exports.campaignTools = [
223
+ exports.listCampaigns,
224
+ exports.getCampaign,
225
+ exports.requestCampaign,
226
+ exports.pauseCampaign,
227
+ exports.resumeCampaign,
228
+ exports.resubmitCampaign,
229
+ ];
230
+ //# sourceMappingURL=campaigns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"campaigns.js","sourceRoot":"","sources":["../../src/tools/campaigns.ts"],"names":[],"mappings":";;;AA0CA,kCAYC;AAtDD;;;;;;;GAOG;AACH,6BAAwB;AAC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O,EAAE,KAAK,CAAC,IAAI,cAAc,wBAAwB,CAC7I,CAAC;QACJ,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CACpC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,IAAI,CAAC,CAAsB,CAAC,KAAK,SAAS,CAC9D,CAAC;QACF,IAAI,OAAO;YAAE,MAAM,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,IAAA,kBAAS,EAAC,IAAI,CAAC,CAAC,CAAC;QACvD,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,WAAW,CAAC,CAAC;IACzC,CAAC;CACF,CAAC,CAAC;AAEU,QAAA,aAAa,GAAG;IAC3B,qBAAa;IACb,mBAAW;IACX,uBAAe;IACf,qBAAa;IACb,sBAAc;IACd,wBAAgB;CACjB,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { Doc } from './shared';
2
+ /** Plain meanings of the pipeline stages, in pipeline order. */
3
+ export declare const STAGE_MEANINGS: Record<string, string>;
4
+ /** Plain meanings of the request outcomes (ads `ErrorResponse` reasons). */
5
+ export declare const OUTCOME_MEANINGS: Record<string, string>;
6
+ /** Plain meanings of the ads elimination reason codes. */
7
+ export declare const REASON_MEANINGS: Record<string, string>;
8
+ /** The trace record (ads `DecisionTraceRecord`) in Offer Manager terms. */
9
+ export declare function explainTrace(record: Doc): Doc;
10
+ export declare const explainDecision: import("../tool").AnyTool;
11
+ export declare function journalRow(j: Doc): Doc;
12
+ export declare const findRequests: import("../tool").AnyTool;
13
+ export declare const getStats: import("../tool").AnyTool;
14
+ export declare const decisionTools: import("../tool").AnyTool[];