@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.
- package/README.md +123 -18
- package/bin/auth.d.ts +46 -0
- package/bin/auth.js +186 -0
- package/bin/auth.js.map +1 -0
- package/bin/cli.js +79 -11
- package/bin/cli.js.map +1 -1
- package/bin/client.d.ts +70 -0
- package/bin/client.js +121 -0
- package/bin/client.js.map +1 -0
- package/bin/docs.d.ts +66 -0
- package/bin/docs.js +247 -0
- package/bin/docs.js.map +1 -0
- package/bin/flow/flowSchema.d.ts +298 -0
- package/bin/flow/flowSchema.js +234 -0
- package/bin/flow/flowSchema.js.map +1 -0
- package/bin/flow/flowValidator.d.ts +15 -0
- package/bin/flow/flowValidator.js +179 -0
- package/bin/flow/flowValidator.js.map +1 -0
- package/bin/flow/flowZod.d.ts +117 -0
- package/bin/flow/flowZod.js +130 -0
- package/bin/flow/flowZod.js.map +1 -0
- package/bin/format.d.ts +14 -0
- package/bin/format.js +50 -0
- package/bin/format.js.map +1 -0
- package/bin/index.d.ts +23 -1
- package/bin/index.js +65 -4
- package/bin/index.js.map +1 -1
- package/bin/routeInventory.d.ts +69 -0
- package/bin/routeInventory.js +201 -0
- package/bin/routeInventory.js.map +1 -0
- package/bin/serve.d.ts +24 -0
- package/bin/serve.js +196 -0
- package/bin/serve.js.map +1 -0
- package/bin/server.d.ts +24 -36
- package/bin/server.js +54 -182
- package/bin/server.js.map +1 -1
- package/bin/tool.d.ts +84 -0
- package/bin/tool.js +39 -0
- package/bin/tool.js.map +1 -0
- package/bin/tools/account.d.ts +2 -0
- package/bin/tools/account.js +47 -0
- package/bin/tools/account.js.map +1 -0
- package/bin/tools/attributes.d.ts +10 -0
- package/bin/tools/attributes.js +200 -0
- package/bin/tools/attributes.js.map +1 -0
- package/bin/tools/campaigns.d.ts +12 -0
- package/bin/tools/campaigns.js +230 -0
- package/bin/tools/campaigns.js.map +1 -0
- package/bin/tools/decisions.d.ts +14 -0
- package/bin/tools/decisions.js +309 -0
- package/bin/tools/decisions.js.map +1 -0
- package/bin/tools/docs.d.ts +3 -0
- package/bin/tools/docs.js +55 -0
- package/bin/tools/docs.js.map +1 -0
- package/bin/tools/index.d.ts +21 -0
- package/bin/tools/index.js +60 -0
- package/bin/tools/index.js.map +1 -0
- package/bin/tools/moments.d.ts +9 -0
- package/bin/tools/moments.js +143 -0
- package/bin/tools/moments.js.map +1 -0
- package/bin/tools/network.d.ts +5 -0
- package/bin/tools/network.js +99 -0
- package/bin/tools/network.js.map +1 -0
- package/bin/tools/offers.d.ts +11 -0
- package/bin/tools/offers.js +239 -0
- package/bin/tools/offers.js.map +1 -0
- package/bin/tools/results.d.ts +18 -0
- package/bin/tools/results.js +116 -0
- package/bin/tools/results.js.map +1 -0
- package/bin/tools/rules.d.ts +9 -0
- package/bin/tools/rules.js +318 -0
- package/bin/tools/rules.js.map +1 -0
- package/bin/tools/settings.d.ts +3 -0
- package/bin/tools/settings.js +54 -0
- package/bin/tools/settings.js.map +1 -0
- package/bin/tools/shared.d.ts +50 -0
- package/bin/tools/shared.js +171 -0
- package/bin/tools/shared.js.map +1 -0
- package/bin/tools/translation.d.ts +6 -0
- package/bin/tools/translation.js +139 -0
- package/bin/tools/translation.js.map +1 -0
- package/bin/version.d.ts +2 -0
- package/bin/version.js +6 -0
- package/bin/version.js.map +1 -0
- package/package.json +10 -7
|
@@ -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,EA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,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,UAAU,EAAE,CAAC;QACxE,MAAM,QAAQ,GACZ,MAAM,EAAE,MAAM,KAAK,SAAS;YAC1B,CAAC,CAAC,0DAA0D;YAC5D,CAAC,CAAC,EAAE,CAAC;QACT,OAAO,GAAG,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,6BAA6B,KAAK,IAAI,EAAE,IAAI,QAAQ,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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Doc } from './shared';
|
|
2
|
+
/** An offer as the list shows it. */
|
|
3
|
+
export declare function offerRow(c: Doc): Doc;
|
|
4
|
+
export declare const listOffers: import("../tool").AnyTool;
|
|
5
|
+
export declare const getOffer: import("../tool").AnyTool;
|
|
6
|
+
export declare const createOffer: import("../tool").AnyTool;
|
|
7
|
+
export declare const updateOffer: import("../tool").AnyTool;
|
|
8
|
+
export declare const publishOffer: import("../tool").AnyTool;
|
|
9
|
+
export declare const pauseOffer: import("../tool").AnyTool;
|
|
10
|
+
export declare const deleteOffer: import("../tool").AnyTool;
|
|
11
|
+
export declare const offerTools: import("../tool").AnyTool[];
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.offerTools = exports.deleteOffer = exports.pauseOffer = exports.publishOffer = exports.updateOffer = exports.createOffer = exports.getOffer = exports.listOffers = void 0;
|
|
4
|
+
exports.offerRow = offerRow;
|
|
5
|
+
/**
|
|
6
|
+
* Offers (the API's creatives): what a customer sees. Offers are an
|
|
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`.
|
|
10
|
+
*/
|
|
11
|
+
const offer_rules_1 = require("@advertising-chat/offer-rules");
|
|
12
|
+
const zod_1 = require("zod");
|
|
13
|
+
const flowValidator_1 = require("../flow/flowValidator");
|
|
14
|
+
const flowZod_1 = require("../flow/flowZod");
|
|
15
|
+
const tool_1 = require("../tool");
|
|
16
|
+
const shared_1 = require("./shared");
|
|
17
|
+
const FORMATS = ['Universal', 'Flow'];
|
|
18
|
+
const format = zod_1.z
|
|
19
|
+
.enum(FORMATS)
|
|
20
|
+
.describe('Universal is the card (title, subtitle, image, replies), rendered for each channel: a rich card on RCS, text and a link on SMS, a card on webchat. Flow is a short scripted conversation, served only to agents that ask for flows. The payload variant must match.');
|
|
21
|
+
const payload = zod_1.z
|
|
22
|
+
.object({
|
|
23
|
+
universal: zod_1.z
|
|
24
|
+
.object({
|
|
25
|
+
title: zod_1.z.string(),
|
|
26
|
+
subtitle: zod_1.z.string().optional(),
|
|
27
|
+
imageUrl: zod_1.z.string().optional(),
|
|
28
|
+
altText: zod_1.z.string().optional(),
|
|
29
|
+
})
|
|
30
|
+
.optional()
|
|
31
|
+
.describe('For Universal.'),
|
|
32
|
+
flow: flowZod_1.flowPayload
|
|
33
|
+
.optional()
|
|
34
|
+
.describe('For Flow: the conversation graph, checked against the flow spec before anything is sent.'),
|
|
35
|
+
})
|
|
36
|
+
.describe('The content, in the variant that matches `format`.');
|
|
37
|
+
const actions = zod_1.z
|
|
38
|
+
.array(zod_1.z.object({
|
|
39
|
+
actionType: zod_1.z.enum(['Text', 'Navigate', 'Call']),
|
|
40
|
+
text: zod_1.z.string().optional().describe('The reply or button label.'),
|
|
41
|
+
action: zod_1.z
|
|
42
|
+
.string()
|
|
43
|
+
.describe('The URL for Navigate, the number for Call, the text for Text.'),
|
|
44
|
+
role: zod_1.z
|
|
45
|
+
.enum(offer_rules_1.REPLY_ROLES)
|
|
46
|
+
.optional()
|
|
47
|
+
.describe('What tapping it means: `accept` records an acceptance of the offer, `decline` a decline. History conditions in rules count them.'),
|
|
48
|
+
}))
|
|
49
|
+
.describe('Replies and buttons shown with the offer. Not for Flow.');
|
|
50
|
+
const properties = zod_1.z
|
|
51
|
+
.array(zod_1.z.object({ name: zod_1.z.string(), value: zod_1.z.string() }))
|
|
52
|
+
.describe('Custom name and value pairs returned to the agent with the offer.');
|
|
53
|
+
/** Client-side flow checks, so authoring errors come back before a write. */
|
|
54
|
+
function checkOfferBody(body, isUpdate) {
|
|
55
|
+
const flow = body.payload?.flow;
|
|
56
|
+
if (body.format !== 'Flow' && flow === undefined)
|
|
57
|
+
return;
|
|
58
|
+
if (!isUpdate || body.format === 'Flow') {
|
|
59
|
+
if (flow === undefined)
|
|
60
|
+
throw new shared_1.ToolInputError('A Flow offer needs payload.flow.');
|
|
61
|
+
}
|
|
62
|
+
if (body.payload?.universal)
|
|
63
|
+
throw new shared_1.ToolInputError('A Flow offer carries only payload.flow, no other payload variant.');
|
|
64
|
+
if (body.actions?.length)
|
|
65
|
+
throw new shared_1.ToolInputError('A Flow offer has no top-level actions: its actions are nodes in the graph.');
|
|
66
|
+
if (flow !== undefined) {
|
|
67
|
+
const result = (0, flowValidator_1.validateFlowPayload)(flow);
|
|
68
|
+
if (!result.valid)
|
|
69
|
+
throw new shared_1.ToolInputError(`The flow is invalid; nothing was sent. Fix these and retry:\n- ${result.errors.join('\n- ')}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** An offer as the list shows it. */
|
|
73
|
+
function offerRow(c) {
|
|
74
|
+
return {
|
|
75
|
+
id: (0, shared_1.str)(c._id) ?? (0, shared_1.str)(c.id),
|
|
76
|
+
name: c.name,
|
|
77
|
+
format: c.format,
|
|
78
|
+
status: c.status,
|
|
79
|
+
title: (0, shared_1.str)(c.payload?.universal?.title),
|
|
80
|
+
rules: Array.isArray(c.rules) ? c.rules.length : undefined,
|
|
81
|
+
last7Days: c.last7Days,
|
|
82
|
+
};
|
|
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
|
+
}
|
|
100
|
+
exports.listOffers = (0, tool_1.defineTool)({
|
|
101
|
+
name: 'list_offers',
|
|
102
|
+
title: 'List offers',
|
|
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.`,
|
|
104
|
+
kind: 'read',
|
|
105
|
+
roleFloor: 'viewer',
|
|
106
|
+
capability: 'offer-manager',
|
|
107
|
+
input: {},
|
|
108
|
+
async run({ client }) {
|
|
109
|
+
const body = await client.get(`${shared_1.OM}/offers`);
|
|
110
|
+
return (0, shared_1.rows)(body).map(offerRow);
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
exports.getOffer = (0, tool_1.defineTool)({
|
|
114
|
+
name: 'get_offer',
|
|
115
|
+
title: 'Get an offer',
|
|
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}.`,
|
|
117
|
+
kind: 'read',
|
|
118
|
+
roleFloor: 'viewer',
|
|
119
|
+
capability: 'offer-manager',
|
|
120
|
+
input: { id: (0, shared_1.id)('offer') },
|
|
121
|
+
async run({ client }, { id: offerId }) {
|
|
122
|
+
return client.get(`${shared_1.OM}/offers/${(0, shared_1.enc)(offerId)}`);
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
exports.createOffer = (0, tool_1.defineTool)({
|
|
126
|
+
name: 'create_offer',
|
|
127
|
+
title: 'Create an offer',
|
|
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.',
|
|
129
|
+
kind: 'write',
|
|
130
|
+
roleFloor: 'editor',
|
|
131
|
+
capability: 'offer-manager',
|
|
132
|
+
input: {
|
|
133
|
+
name: zod_1.z.string().min(1).max(200).describe('Display name.'),
|
|
134
|
+
format,
|
|
135
|
+
description: zod_1.z.string().optional(),
|
|
136
|
+
payload: payload.optional(),
|
|
137
|
+
actions: actions.optional(),
|
|
138
|
+
properties: properties.optional(),
|
|
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.`,
|
|
141
|
+
async run({ client }, args) {
|
|
142
|
+
const body = (0, shared_1.defined)(args);
|
|
143
|
+
checkOfferBody(body, false);
|
|
144
|
+
return client.post(`${shared_1.OM}/creative`, body);
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
exports.updateOffer = (0, tool_1.defineTool)({
|
|
148
|
+
name: 'update_offer',
|
|
149
|
+
title: 'Update an offer',
|
|
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}.',
|
|
151
|
+
kind: 'write',
|
|
152
|
+
roleFloor: 'editor',
|
|
153
|
+
reader: 'get_offer',
|
|
154
|
+
capability: 'offer-manager',
|
|
155
|
+
input: {
|
|
156
|
+
id: (0, shared_1.id)('offer'),
|
|
157
|
+
name: zod_1.z.string().min(1).max(200).optional(),
|
|
158
|
+
format: format.optional(),
|
|
159
|
+
description: zod_1.z.string().optional(),
|
|
160
|
+
payload: payload.optional(),
|
|
161
|
+
actions: actions.optional(),
|
|
162
|
+
properties: properties.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)}`;
|
|
174
|
+
},
|
|
175
|
+
async run({ client }, args) {
|
|
176
|
+
const body = (0, shared_1.patchBody)(args);
|
|
177
|
+
checkOfferBody(body, true);
|
|
178
|
+
return client.patch(`${shared_1.OM}/creative/${(0, shared_1.enc)(args.id)}`, body);
|
|
179
|
+
},
|
|
180
|
+
});
|
|
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.',
|
|
192
|
+
kind: 'write',
|
|
193
|
+
roleFloor: 'editor',
|
|
194
|
+
reader: 'get_offer',
|
|
195
|
+
capability: 'offer-manager',
|
|
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.`,
|
|
198
|
+
async run({ client }, { id: offerId }) {
|
|
199
|
+
return client.post(`${shared_1.OM}/offers/${(0, shared_1.enc)(offerId)}/publish`);
|
|
200
|
+
},
|
|
201
|
+
});
|
|
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.',
|
|
206
|
+
kind: 'write',
|
|
207
|
+
roleFloor: 'editor',
|
|
208
|
+
reader: 'get_offer',
|
|
209
|
+
capability: 'offer-manager',
|
|
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.`,
|
|
212
|
+
async run({ client }, { id: offerId }) {
|
|
213
|
+
return client.post(`${shared_1.OM}/offers/${(0, shared_1.enc)(offerId)}/pause`);
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
exports.deleteOffer = (0, tool_1.defineTool)({
|
|
217
|
+
name: 'delete_offer',
|
|
218
|
+
title: 'Delete an offer',
|
|
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}.',
|
|
220
|
+
kind: 'destructive',
|
|
221
|
+
roleFloor: 'editor',
|
|
222
|
+
reader: 'get_offer',
|
|
223
|
+
capability: 'offer-manager',
|
|
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.`,
|
|
226
|
+
async run({ client }, { id: offerId }) {
|
|
227
|
+
return client.delete(`${shared_1.OM}/offers/${(0, shared_1.enc)(offerId)}`);
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
exports.offerTools = [
|
|
231
|
+
exports.listOffers,
|
|
232
|
+
exports.getOffer,
|
|
233
|
+
exports.createOffer,
|
|
234
|
+
exports.updateOffer,
|
|
235
|
+
exports.publishOffer,
|
|
236
|
+
exports.pauseOffer,
|
|
237
|
+
exports.deleteOffer,
|
|
238
|
+
];
|
|
239
|
+
//# sourceMappingURL=offers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"offers.js","sourceRoot":"","sources":["../../src/tools/offers.ts"],"names":[],"mappings":";;;AA0GA,4BAUC;AApHD;;;;;GAKG;AACH,+DAA4D;AAC5D,6BAAwB;AACxB,yDAA4D;AAC5D,6CAA8C;AAC9C,kCAAqC;AACrC,qCAckB;AAElB,MAAM,OAAO,GAAG,CAAC,WAAW,EAAE,MAAM,CAAU,CAAC;AAE/C,MAAM,MAAM,GAAG,OAAC;KACb,IAAI,CAAC,OAAO,CAAC;KACb,QAAQ,CACP,qQAAqQ,CACtQ,CAAC;AAEJ,MAAM,OAAO,GAAG,OAAC;KACd,MAAM,CAAC;IACN,SAAS,EAAE,OAAC;SACT,MAAM,CAAC;QACN,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;QACjB,QAAQ,EAAE,OAAC,CAA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AE,EAAE,EAAE,EAAE,OAAO,EAAE;QACnC,OAAO,MAAM,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
|
+
//# sourceMappingUR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AAI,uBAAc,CACtB,GAAG,GAAG,wBAAwB,OAAO,8BAA8B,CACpE,CAAC;QACN,CAAC;QACD,oDAAoD;QACpD,MAAM,KAAK,GAAG,CAAC,CAAyC,EAAE,EAAE,CAC1D,MAAM,CAAC,GAAG,CACR,UAAU,EACV,IAAA,gBAAO,EAAC;YACN,GAAG,IAAI;YACP,KAAK,EAAE,CAAC,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;YACtD,QAAQ,EAAE,CAAC,CAAC,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;YAC/D,GAAG,CAAC;SACL,CAAC,CACH,CAAC;QACJ,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/C,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;QACnD,OAAO;YACL,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC7B,GAAI,CAAS;gBACb,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO;gBACzB,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI,KAAK;aACnC,CAAC,CAAC;SACJ,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEU,QAAA,YAAY,GAAG,CAAC,kBAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Doc } from './shared';
|
|
2
|
+
/** A rule as the list shows it. */
|
|
3
|
+
export declare function ruleRow(r: Doc): Doc;
|
|
4
|
+
export declare const listRules: import("../tool").AnyTool;
|
|
5
|
+
export declare const getRule: import("../tool").AnyTool;
|
|
6
|
+
export declare const createRule: import("../tool").AnyTool;
|
|
7
|
+
export declare const updateRule: import("../tool").AnyTool;
|
|
8
|
+
export declare const deleteRule: import("../tool").AnyTool;
|
|
9
|
+
export declare const ruleTools: import("../tool").AnyTool[];
|