@dudefactory/payload-plugin-content-planner 3.0.1 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/dist/collections/AuditLogs.d.ts +10 -0
- package/dist/collections/AuditLogs.js +93 -0
- package/dist/collections/ContentTasks.d.ts +17 -0
- package/dist/collections/ContentTasks.js +180 -79
- package/dist/collections/Performance.d.ts +12 -0
- package/dist/collections/Performance.js +142 -0
- package/dist/index.d.ts +45 -7
- package/dist/index.js +38 -10
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CollectionConfig } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Audit Logs Collection - The Agent Trace
|
|
4
|
+
*
|
|
5
|
+
* Essential for enterprise customers who want to see how the Agent decided on a headline,
|
|
6
|
+
* what APIs were called, what data was transformed, and when each step happened.
|
|
7
|
+
*
|
|
8
|
+
* This is read-only from the UI perspective. Agents append logs via MCP tools.
|
|
9
|
+
*/
|
|
10
|
+
export declare const auditLogsCollection: CollectionConfig;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.auditLogsCollection = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Audit Logs Collection - The Agent Trace
|
|
6
|
+
*
|
|
7
|
+
* Essential for enterprise customers who want to see how the Agent decided on a headline,
|
|
8
|
+
* what APIs were called, what data was transformed, and when each step happened.
|
|
9
|
+
*
|
|
10
|
+
* This is read-only from the UI perspective. Agents append logs via MCP tools.
|
|
11
|
+
*/
|
|
12
|
+
exports.auditLogsCollection = {
|
|
13
|
+
slug: 'cp-audit-logs',
|
|
14
|
+
admin: {
|
|
15
|
+
useAsTitle: 'action',
|
|
16
|
+
defaultColumns: ['action', 'task', 'timestamp', 'createdAt'],
|
|
17
|
+
group: 'Content Planning',
|
|
18
|
+
description: 'Agent execution trace. Read-only. Helps enterprise customers audit AI decisions.',
|
|
19
|
+
},
|
|
20
|
+
access: {
|
|
21
|
+
create: () => true, // Only via Agent/MCP
|
|
22
|
+
read: () => true,
|
|
23
|
+
update: () => false, // Immutable logs
|
|
24
|
+
delete: () => false, // Immutable logs
|
|
25
|
+
},
|
|
26
|
+
fields: [
|
|
27
|
+
{
|
|
28
|
+
name: 'task',
|
|
29
|
+
label: 'Related Content Task',
|
|
30
|
+
type: 'relationship',
|
|
31
|
+
relationTo: 'cp-content-tasks',
|
|
32
|
+
required: true,
|
|
33
|
+
admin: {
|
|
34
|
+
description: 'The content task this log entry belongs to.',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'action',
|
|
39
|
+
label: 'Action',
|
|
40
|
+
type: 'select',
|
|
41
|
+
required: true,
|
|
42
|
+
options: [
|
|
43
|
+
{ label: 'Task Started', value: 'task-started' },
|
|
44
|
+
{ label: 'Scraping URL', value: 'scraping-url' },
|
|
45
|
+
{ label: 'Generating Draft', value: 'generating-draft' },
|
|
46
|
+
{ label: 'Calling External API', value: 'calling-external-api' },
|
|
47
|
+
{ label: 'Image Generation', value: 'image-generation' },
|
|
48
|
+
{ label: 'SEO Optimization', value: 'seo-optimization' },
|
|
49
|
+
{ label: 'Review Submission', value: 'review-submission' },
|
|
50
|
+
{ label: 'Error Encountered', value: 'error-encountered' },
|
|
51
|
+
{ label: 'Task Completed', value: 'task-completed' },
|
|
52
|
+
{ label: 'Custom', value: 'custom' },
|
|
53
|
+
],
|
|
54
|
+
admin: {
|
|
55
|
+
description: 'What action the Agent performed at this step.',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'stepDescription',
|
|
60
|
+
label: 'Step Description',
|
|
61
|
+
type: 'text',
|
|
62
|
+
admin: {
|
|
63
|
+
description: 'Human-readable description of what happened (e.g., "Fetched blog post from myblog.com")',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'modelSnapshot',
|
|
68
|
+
label: 'Model Snapshot',
|
|
69
|
+
type: 'json',
|
|
70
|
+
admin: {
|
|
71
|
+
description: 'The prompt sent to the AI model and the response received. Crucial for debugging.',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: 'metadata',
|
|
76
|
+
label: 'Additional Metadata',
|
|
77
|
+
type: 'json',
|
|
78
|
+
admin: {
|
|
79
|
+
description: 'Any extra context: API responses, timing info, intermediate calculations, etc.',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: 'errorDetails',
|
|
84
|
+
label: 'Error Details',
|
|
85
|
+
type: 'textarea',
|
|
86
|
+
admin: {
|
|
87
|
+
rows: 4,
|
|
88
|
+
description: 'If action is "error-encountered", detailed error message and stack trace.',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
timestamps: true,
|
|
93
|
+
};
|
|
@@ -1,2 +1,19 @@
|
|
|
1
1
|
import { CollectionConfig } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Content Tasks Collection - The User Interface
|
|
4
|
+
*
|
|
5
|
+
* Where the user spends 10 seconds giving an order.
|
|
6
|
+
* Where the Agent spends 10 minutes executing it.
|
|
7
|
+
*
|
|
8
|
+
* Group structure:
|
|
9
|
+
* - User Inputs: title, instructions, taskType, priority
|
|
10
|
+
* - Agent Outputs: status, outputLink, lastError, reviewFeedback
|
|
11
|
+
* - System: agentMetadata, parentTask, customParams
|
|
12
|
+
*
|
|
13
|
+
* @param outputCollections - The Payload collection slugs that the Agent can link
|
|
14
|
+
* to via `outputLink`. Pass the slug names of every collection the Agent may
|
|
15
|
+
* create content in (e.g. ['posts', 'public-events', 'factories']).
|
|
16
|
+
* Defaults to ['posts'] when omitted.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createContentTasksCollection(outputCollections?: string[]): CollectionConfig;
|
|
2
19
|
export declare const contentTasksCollection: CollectionConfig;
|
|
@@ -1,86 +1,187 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.contentTasksCollection = void 0;
|
|
4
|
-
exports.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
4
|
+
exports.createContentTasksCollection = createContentTasksCollection;
|
|
5
|
+
/**
|
|
6
|
+
* Content Tasks Collection - The User Interface
|
|
7
|
+
*
|
|
8
|
+
* Where the user spends 10 seconds giving an order.
|
|
9
|
+
* Where the Agent spends 10 minutes executing it.
|
|
10
|
+
*
|
|
11
|
+
* Group structure:
|
|
12
|
+
* - User Inputs: title, instructions, taskType, priority
|
|
13
|
+
* - Agent Outputs: status, outputLink, lastError, reviewFeedback
|
|
14
|
+
* - System: agentMetadata, parentTask, customParams
|
|
15
|
+
*
|
|
16
|
+
* @param outputCollections - The Payload collection slugs that the Agent can link
|
|
17
|
+
* to via `outputLink`. Pass the slug names of every collection the Agent may
|
|
18
|
+
* create content in (e.g. ['posts', 'public-events', 'factories']).
|
|
19
|
+
* Defaults to ['posts'] when omitted.
|
|
20
|
+
*/
|
|
21
|
+
function createContentTasksCollection(outputCollections = ['posts']) {
|
|
22
|
+
return {
|
|
23
|
+
slug: 'cp-content-tasks',
|
|
24
|
+
admin: {
|
|
25
|
+
useAsTitle: 'title',
|
|
26
|
+
defaultColumns: ['title', 'taskType', 'status', 'priority', 'createdAt'],
|
|
27
|
+
group: 'Content Planning',
|
|
18
28
|
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
fields: [
|
|
30
|
+
// ========== USER INPUTS ==========
|
|
31
|
+
{
|
|
32
|
+
type: 'collapsible',
|
|
33
|
+
label: 'User Inputs',
|
|
34
|
+
fields: [
|
|
35
|
+
{
|
|
36
|
+
name: 'title',
|
|
37
|
+
label: 'Task Title',
|
|
38
|
+
type: 'text',
|
|
39
|
+
required: true,
|
|
40
|
+
maxLength: 150,
|
|
41
|
+
admin: {
|
|
42
|
+
placeholder: 'e.g., Write a blog post about cigar festivals in Miami',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'instructions',
|
|
47
|
+
label: 'The Command',
|
|
48
|
+
type: 'textarea',
|
|
49
|
+
required: true,
|
|
50
|
+
admin: {
|
|
51
|
+
rows: 10,
|
|
52
|
+
placeholder: 'Detailed instructions for the Agent. e.g., "Write a blog post about cigar festivals in Miami. Include at least 3 events, 500 words, SEO keywords: cigars, Miami, festivals. Tone: conversational."',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'taskType',
|
|
57
|
+
label: 'Task Type',
|
|
58
|
+
type: 'select',
|
|
59
|
+
required: true,
|
|
60
|
+
options: [
|
|
61
|
+
{ label: 'New Content', value: 'new-content' },
|
|
62
|
+
{ label: 'Update SEO', value: 'update-seo' },
|
|
63
|
+
{ label: 'Translation', value: 'translation' },
|
|
64
|
+
{ label: 'Social Media', value: 'social-media' },
|
|
65
|
+
{ label: 'Research', value: 'research' },
|
|
66
|
+
],
|
|
67
|
+
defaultValue: 'new-content',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'priority',
|
|
71
|
+
label: 'Priority',
|
|
72
|
+
type: 'select',
|
|
73
|
+
required: true,
|
|
74
|
+
options: [
|
|
75
|
+
{ label: 'Low', value: 'low' },
|
|
76
|
+
{ label: 'Normal', value: 'normal' },
|
|
77
|
+
{ label: 'High', value: 'high' },
|
|
78
|
+
],
|
|
79
|
+
defaultValue: 'normal',
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'deadline',
|
|
83
|
+
label: 'Deadline',
|
|
84
|
+
type: 'date',
|
|
85
|
+
required: false,
|
|
86
|
+
admin: {
|
|
87
|
+
placeholder: 'Optional: Set a deadline for this task',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
],
|
|
26
91
|
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
options: [
|
|
34
|
-
{ label: 'To Do', value: 'todo' },
|
|
35
|
-
{ label: 'In Progress', value: 'in-progress' },
|
|
36
|
-
{ label: 'In Review', value: 'review' },
|
|
37
|
-
{ label: 'Done', value: 'done' },
|
|
38
|
-
{ label: 'Blocked', value: 'blocked' },
|
|
39
|
-
],
|
|
40
|
-
defaultValue: 'todo',
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
name: 'priority',
|
|
44
|
-
label: 'Priority',
|
|
45
|
-
type: 'select',
|
|
46
|
-
required: true,
|
|
47
|
-
options: [
|
|
48
|
-
{ label: 'Low', value: 'low' },
|
|
49
|
-
{ label: 'Normal', value: 'normal' },
|
|
50
|
-
{ label: 'High', value: 'high' },
|
|
51
|
-
],
|
|
52
|
-
defaultValue: 'normal',
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
name: 'deadline',
|
|
56
|
-
label: 'Deadline',
|
|
57
|
-
type: 'date',
|
|
58
|
-
required: true,
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
name: 'tags',
|
|
62
|
-
label: 'Tags',
|
|
63
|
-
type: 'array',
|
|
64
|
-
fields: [
|
|
65
|
-
{
|
|
66
|
-
name: 'tag',
|
|
67
|
-
type: 'text',
|
|
92
|
+
// ========== AGENT OUTPUTS ==========
|
|
93
|
+
{
|
|
94
|
+
type: 'collapsible',
|
|
95
|
+
label: 'Agent Outputs',
|
|
96
|
+
admin: {
|
|
97
|
+
description: 'Automatically populated by the Agent. Do not edit manually.',
|
|
68
98
|
},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
99
|
+
fields: [
|
|
100
|
+
{
|
|
101
|
+
name: 'status',
|
|
102
|
+
label: 'Status',
|
|
103
|
+
type: 'select',
|
|
104
|
+
required: true,
|
|
105
|
+
options: [
|
|
106
|
+
{ label: 'To Do', value: 'todo' },
|
|
107
|
+
{ label: 'In Progress', value: 'in-progress' },
|
|
108
|
+
{ label: 'In Review', value: 'review' },
|
|
109
|
+
{ label: 'Done', value: 'done' },
|
|
110
|
+
{ label: 'Failed', value: 'failed' },
|
|
111
|
+
],
|
|
112
|
+
defaultValue: 'todo',
|
|
113
|
+
admin: {
|
|
114
|
+
description: 'Set to "Failed" if the Agent encounters an error.',
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: 'outputLink',
|
|
119
|
+
label: 'Output Link',
|
|
120
|
+
type: 'relationship',
|
|
121
|
+
// Injected at plugin registration time by the consuming project
|
|
122
|
+
relationTo: outputCollections,
|
|
123
|
+
admin: {
|
|
124
|
+
description: 'Crucial: Points to the generated Post, Page, Event, or other content created by the Agent.',
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: 'lastError',
|
|
129
|
+
label: 'Last Error',
|
|
130
|
+
type: 'textarea',
|
|
131
|
+
admin: {
|
|
132
|
+
rows: 4,
|
|
133
|
+
description: 'If status is "Failed", the Agent writes the technical error here.',
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: 'reviewFeedback',
|
|
138
|
+
label: 'Review Feedback',
|
|
139
|
+
type: 'richText',
|
|
140
|
+
admin: {
|
|
141
|
+
description: 'User notes for the Agent to "try again". Leave blank if not in review.',
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
],
|
|
77
145
|
},
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
146
|
+
// ========== SYSTEM / AGENT METADATA ==========
|
|
147
|
+
{
|
|
148
|
+
type: 'collapsible',
|
|
149
|
+
label: 'System & Configuration',
|
|
150
|
+
admin: {
|
|
151
|
+
description: 'Advanced settings for the Agent and system integration.',
|
|
152
|
+
},
|
|
153
|
+
fields: [
|
|
154
|
+
{
|
|
155
|
+
name: 'agentMetadata',
|
|
156
|
+
label: 'Agent Metadata',
|
|
157
|
+
type: 'json',
|
|
158
|
+
admin: {
|
|
159
|
+
description: 'Stores tokens consumed, model used, estimated cost, latency (ms). Auto-populated by Agent.',
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
name: 'parentTask',
|
|
164
|
+
label: 'Parent Task',
|
|
165
|
+
type: 'relationship',
|
|
166
|
+
relationTo: 'cp-content-tasks',
|
|
167
|
+
admin: {
|
|
168
|
+
description: 'Links to a parent Campaign, Epic, or meta-task if this is a subtask.',
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
name: 'customParams',
|
|
173
|
+
label: 'Custom Parameters',
|
|
174
|
+
type: 'json',
|
|
175
|
+
admin: {
|
|
176
|
+
description: 'The Escape Hatch: Use this if you need to pass data you forgot to add to the schema. Agent-writable.',
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
timestamps: true,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
// Backwards-compatible named export — uses ['posts'] as default fallback.
|
|
186
|
+
// Prefer using createContentTasksCollection() directly via the plugin config.
|
|
187
|
+
exports.contentTasksCollection = createContentTasksCollection();
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CollectionConfig } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Performance Collection - Analytics & ROI Tracking
|
|
4
|
+
*
|
|
5
|
+
* Read-only for the user. Aggregates data by taskType to show:
|
|
6
|
+
* - Average tokens consumed per task type
|
|
7
|
+
* - Estimated costs (for billing / ROI calculations)
|
|
8
|
+
* - Success rates
|
|
9
|
+
*
|
|
10
|
+
* This helps customers calculate the ROI and efficiency of the plugin.
|
|
11
|
+
*/
|
|
12
|
+
export declare const performanceCollection: CollectionConfig;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.performanceCollection = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Performance Collection - Analytics & ROI Tracking
|
|
6
|
+
*
|
|
7
|
+
* Read-only for the user. Aggregates data by taskType to show:
|
|
8
|
+
* - Average tokens consumed per task type
|
|
9
|
+
* - Estimated costs (for billing / ROI calculations)
|
|
10
|
+
* - Success rates
|
|
11
|
+
*
|
|
12
|
+
* This helps customers calculate the ROI and efficiency of the plugin.
|
|
13
|
+
*/
|
|
14
|
+
exports.performanceCollection = {
|
|
15
|
+
slug: 'cp-performance',
|
|
16
|
+
admin: {
|
|
17
|
+
useAsTitle: 'taskType',
|
|
18
|
+
defaultColumns: [
|
|
19
|
+
'taskType',
|
|
20
|
+
'totalTasks',
|
|
21
|
+
'successCount',
|
|
22
|
+
'averageTokens',
|
|
23
|
+
'estimatedTotalCost',
|
|
24
|
+
],
|
|
25
|
+
group: 'Content Planning',
|
|
26
|
+
description: 'Analytics dashboard. Track token usage, costs, and success rates by task type. Read-only.',
|
|
27
|
+
},
|
|
28
|
+
access: {
|
|
29
|
+
create: () => true, // Only via Agent aggregation
|
|
30
|
+
read: () => true,
|
|
31
|
+
update: () => true, // Agent updates counts
|
|
32
|
+
delete: () => false, // Never delete analytics
|
|
33
|
+
},
|
|
34
|
+
fields: [
|
|
35
|
+
{
|
|
36
|
+
name: 'taskType',
|
|
37
|
+
label: 'Task Type',
|
|
38
|
+
type: 'select',
|
|
39
|
+
required: true,
|
|
40
|
+
unique: true,
|
|
41
|
+
options: [
|
|
42
|
+
{ label: 'New Content', value: 'new-content' },
|
|
43
|
+
{ label: 'Update SEO', value: 'update-seo' },
|
|
44
|
+
{ label: 'Translation', value: 'translation' },
|
|
45
|
+
{ label: 'Social Media', value: 'social-media' },
|
|
46
|
+
{ label: 'Research', value: 'research' },
|
|
47
|
+
{ label: 'All', value: 'all' },
|
|
48
|
+
],
|
|
49
|
+
admin: {
|
|
50
|
+
description: 'The type of task being tracked.',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'totalTasks',
|
|
55
|
+
label: 'Total Tasks',
|
|
56
|
+
type: 'number',
|
|
57
|
+
defaultValue: 0,
|
|
58
|
+
admin: {
|
|
59
|
+
description: 'Total number of tasks of this type completed.',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'successCount',
|
|
64
|
+
label: 'Successful Tasks',
|
|
65
|
+
type: 'number',
|
|
66
|
+
defaultValue: 0,
|
|
67
|
+
admin: {
|
|
68
|
+
description: 'Number of tasks that completed successfully (status: "done").',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'failureCount',
|
|
73
|
+
label: 'Failed Tasks',
|
|
74
|
+
type: 'number',
|
|
75
|
+
defaultValue: 0,
|
|
76
|
+
admin: {
|
|
77
|
+
description: 'Number of tasks that failed (status: "failed").',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: 'successRate',
|
|
82
|
+
label: 'Success Rate (%)',
|
|
83
|
+
type: 'number',
|
|
84
|
+
admin: {
|
|
85
|
+
description: 'Computed: (successCount / totalTasks) * 100. Read-only.',
|
|
86
|
+
readOnly: true,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: 'totalTokens',
|
|
91
|
+
label: 'Total Tokens Used',
|
|
92
|
+
type: 'number',
|
|
93
|
+
defaultValue: 0,
|
|
94
|
+
admin: {
|
|
95
|
+
description: 'Cumulative tokens consumed across all tasks of this type.',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: 'averageTokens',
|
|
100
|
+
label: 'Average Tokens Per Task',
|
|
101
|
+
type: 'number',
|
|
102
|
+
admin: {
|
|
103
|
+
description: 'Computed: totalTokens / totalTasks. Read-only.',
|
|
104
|
+
readOnly: true,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: 'estimatedTotalCost',
|
|
109
|
+
label: 'Estimated Total Cost ($)',
|
|
110
|
+
type: 'number',
|
|
111
|
+
admin: {
|
|
112
|
+
description: 'Based on token usage and current model pricing. Helpful for ROI calculation.',
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
name: 'estimatedAverageCost',
|
|
117
|
+
label: 'Estimated Avg Cost Per Task ($)',
|
|
118
|
+
type: 'number',
|
|
119
|
+
admin: {
|
|
120
|
+
description: 'Computed: estimatedTotalCost / successCount. Read-only.',
|
|
121
|
+
readOnly: true,
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: 'lastUpdated',
|
|
126
|
+
label: 'Last Updated',
|
|
127
|
+
type: 'date',
|
|
128
|
+
admin: {
|
|
129
|
+
description: 'When these metrics were last calculated.',
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: 'metadata',
|
|
134
|
+
label: 'Metadata',
|
|
135
|
+
type: 'json',
|
|
136
|
+
admin: {
|
|
137
|
+
description: 'Additional context: model versions used, pricing assumptions, calculation method, etc.',
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
timestamps: true,
|
|
142
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { Config } from 'payload';
|
|
2
|
+
import { createContentTasksCollection, contentTasksCollection } from './collections/ContentTasks';
|
|
3
|
+
import { keywordsCollection } from './collections/Keywords';
|
|
4
|
+
import { instructionsCollection } from './collections/Instructions';
|
|
5
|
+
import { auditLogsCollection } from './collections/AuditLogs';
|
|
6
|
+
import { performanceCollection } from './collections/Performance';
|
|
2
7
|
import { generateInitInstruction, warmupInitialization, setupInstructions, generateContentTask, executeContentTask } from './mcp/prompts-handlers';
|
|
3
8
|
export declare const contentPlannerPrompts: ({
|
|
4
9
|
name: string;
|
|
@@ -124,28 +129,61 @@ export declare const contentPlannerPrompts: ({
|
|
|
124
129
|
};
|
|
125
130
|
})[];
|
|
126
131
|
export { generateInitInstruction, warmupInitialization, setupInstructions, generateContentTask, executeContentTask, };
|
|
132
|
+
export { createContentTasksCollection, contentTasksCollection, keywordsCollection, instructionsCollection, auditLogsCollection, performanceCollection, };
|
|
127
133
|
export interface ContentPlannerPluginConfig {
|
|
128
134
|
enabled?: boolean;
|
|
135
|
+
/**
|
|
136
|
+
* The Payload collection slugs that the Agent can link output documents to
|
|
137
|
+
* via the `outputLink` relationship field on cp-content-tasks.
|
|
138
|
+
*
|
|
139
|
+
* List every collection slug in your project that the Agent may create
|
|
140
|
+
* content in. For example:
|
|
141
|
+
*
|
|
142
|
+
* ```ts
|
|
143
|
+
* outputCollections: ['posts', 'public-events', 'factories', 'cities']
|
|
144
|
+
* ```
|
|
145
|
+
*
|
|
146
|
+
* Defaults to `['posts']` when omitted.
|
|
147
|
+
*/
|
|
148
|
+
outputCollections?: string[];
|
|
129
149
|
}
|
|
130
150
|
/**
|
|
131
151
|
* Payload Content Planner Plugin
|
|
132
152
|
*
|
|
133
|
-
* Extends your existing Payload
|
|
134
|
-
*
|
|
153
|
+
* Extends your existing Payload implementation with:
|
|
154
|
+
*
|
|
155
|
+
* **Core Collections:**
|
|
156
|
+
* - ContentTasks (cp-content-tasks): The user interface. Where users spend 10 seconds giving an order.
|
|
157
|
+
* - Keywords (cp-keywords): Reference data for content optimization.
|
|
158
|
+
* - Instructions (cp-instructions): Reusable agent instructions.
|
|
159
|
+
*
|
|
160
|
+
* **Agent Ledger Tables:**
|
|
161
|
+
* - AuditLogs (cp-audit-logs): Complete trace of agent execution. Essential for enterprise customers to audit AI decisions.
|
|
162
|
+
* - Performance (cp-performance): Analytics and ROI tracking. Shows token usage, costs, and success rates by task type.
|
|
163
|
+
*
|
|
164
|
+
* **Integration with MCP:**
|
|
135
165
|
* - MCP tools and prompts (register with your MCP plugin)
|
|
166
|
+
* - Each project installs independently. No cross-project sync.
|
|
136
167
|
*
|
|
137
|
-
*
|
|
168
|
+
* **Schema Notes:**
|
|
169
|
+
* - The schema is minimal for humans (one simple command) but extremely descriptive for Agents.
|
|
170
|
+
* - CustomParams in ContentTasks provides an escape hatch for future extensibility.
|
|
171
|
+
* - All fields are designed to prevent schema changes in production environments.
|
|
138
172
|
*
|
|
139
173
|
* Usage:
|
|
140
174
|
* ```typescript
|
|
141
175
|
* import { buildConfig } from 'payload/config'
|
|
142
|
-
* import { contentPlannerPlugin,
|
|
176
|
+
* import { contentPlannerPlugin, contentPlannerPrompts } from '@dudefactory/payload-plugin-content-planner'
|
|
143
177
|
*
|
|
144
178
|
* export default buildConfig({
|
|
145
179
|
* plugins: [
|
|
146
|
-
* contentPlannerPlugin({
|
|
147
|
-
*
|
|
148
|
-
*
|
|
180
|
+
* contentPlannerPlugin({
|
|
181
|
+
* enabled: true,
|
|
182
|
+
* // Tell the plugin which collections exist in YOUR project
|
|
183
|
+
* outputCollections: ['posts', 'public-events', 'factories', 'cities'],
|
|
184
|
+
* }),
|
|
185
|
+
* // Add to your existing MCP plugin to enable agent execution:
|
|
186
|
+
* // mcpPlugin({ prompts: contentPlannerPrompts })
|
|
149
187
|
* ],
|
|
150
188
|
* })
|
|
151
189
|
* ```
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.contentPlannerPlugin = exports.executeContentTask = exports.generateContentTask = exports.setupInstructions = exports.warmupInitialization = exports.generateInitInstruction = exports.contentPlannerPrompts = void 0;
|
|
3
|
+
exports.contentPlannerPlugin = exports.performanceCollection = exports.auditLogsCollection = exports.instructionsCollection = exports.keywordsCollection = exports.contentTasksCollection = exports.createContentTasksCollection = exports.executeContentTask = exports.generateContentTask = exports.setupInstructions = exports.warmupInitialization = exports.generateInitInstruction = exports.contentPlannerPrompts = void 0;
|
|
4
4
|
const ContentTasks_1 = require("./collections/ContentTasks");
|
|
5
|
+
Object.defineProperty(exports, "createContentTasksCollection", { enumerable: true, get: function () { return ContentTasks_1.createContentTasksCollection; } });
|
|
6
|
+
Object.defineProperty(exports, "contentTasksCollection", { enumerable: true, get: function () { return ContentTasks_1.contentTasksCollection; } });
|
|
5
7
|
const Keywords_1 = require("./collections/Keywords");
|
|
8
|
+
Object.defineProperty(exports, "keywordsCollection", { enumerable: true, get: function () { return Keywords_1.keywordsCollection; } });
|
|
6
9
|
const Instructions_1 = require("./collections/Instructions");
|
|
10
|
+
Object.defineProperty(exports, "instructionsCollection", { enumerable: true, get: function () { return Instructions_1.instructionsCollection; } });
|
|
11
|
+
const AuditLogs_1 = require("./collections/AuditLogs");
|
|
12
|
+
Object.defineProperty(exports, "auditLogsCollection", { enumerable: true, get: function () { return AuditLogs_1.auditLogsCollection; } });
|
|
13
|
+
const Performance_1 = require("./collections/Performance");
|
|
14
|
+
Object.defineProperty(exports, "performanceCollection", { enumerable: true, get: function () { return Performance_1.performanceCollection; } });
|
|
7
15
|
const prompts_handlers_1 = require("./mcp/prompts-handlers");
|
|
8
16
|
Object.defineProperty(exports, "generateInitInstruction", { enumerable: true, get: function () { return prompts_handlers_1.generateInitInstruction; } });
|
|
9
17
|
Object.defineProperty(exports, "warmupInitialization", { enumerable: true, get: function () { return prompts_handlers_1.warmupInitialization; } });
|
|
@@ -21,28 +29,46 @@ exports.contentPlannerPrompts = [
|
|
|
21
29
|
/**
|
|
22
30
|
* Payload Content Planner Plugin
|
|
23
31
|
*
|
|
24
|
-
* Extends your existing Payload
|
|
25
|
-
*
|
|
32
|
+
* Extends your existing Payload implementation with:
|
|
33
|
+
*
|
|
34
|
+
* **Core Collections:**
|
|
35
|
+
* - ContentTasks (cp-content-tasks): The user interface. Where users spend 10 seconds giving an order.
|
|
36
|
+
* - Keywords (cp-keywords): Reference data for content optimization.
|
|
37
|
+
* - Instructions (cp-instructions): Reusable agent instructions.
|
|
38
|
+
*
|
|
39
|
+
* **Agent Ledger Tables:**
|
|
40
|
+
* - AuditLogs (cp-audit-logs): Complete trace of agent execution. Essential for enterprise customers to audit AI decisions.
|
|
41
|
+
* - Performance (cp-performance): Analytics and ROI tracking. Shows token usage, costs, and success rates by task type.
|
|
42
|
+
*
|
|
43
|
+
* **Integration with MCP:**
|
|
26
44
|
* - MCP tools and prompts (register with your MCP plugin)
|
|
45
|
+
* - Each project installs independently. No cross-project sync.
|
|
27
46
|
*
|
|
28
|
-
*
|
|
47
|
+
* **Schema Notes:**
|
|
48
|
+
* - The schema is minimal for humans (one simple command) but extremely descriptive for Agents.
|
|
49
|
+
* - CustomParams in ContentTasks provides an escape hatch for future extensibility.
|
|
50
|
+
* - All fields are designed to prevent schema changes in production environments.
|
|
29
51
|
*
|
|
30
52
|
* Usage:
|
|
31
53
|
* ```typescript
|
|
32
54
|
* import { buildConfig } from 'payload/config'
|
|
33
|
-
* import { contentPlannerPlugin,
|
|
55
|
+
* import { contentPlannerPlugin, contentPlannerPrompts } from '@dudefactory/payload-plugin-content-planner'
|
|
34
56
|
*
|
|
35
57
|
* export default buildConfig({
|
|
36
58
|
* plugins: [
|
|
37
|
-
* contentPlannerPlugin({
|
|
38
|
-
*
|
|
39
|
-
*
|
|
59
|
+
* contentPlannerPlugin({
|
|
60
|
+
* enabled: true,
|
|
61
|
+
* // Tell the plugin which collections exist in YOUR project
|
|
62
|
+
* outputCollections: ['posts', 'public-events', 'factories', 'cities'],
|
|
63
|
+
* }),
|
|
64
|
+
* // Add to your existing MCP plugin to enable agent execution:
|
|
65
|
+
* // mcpPlugin({ prompts: contentPlannerPrompts })
|
|
40
66
|
* ],
|
|
41
67
|
* })
|
|
42
68
|
* ```
|
|
43
69
|
*/
|
|
44
70
|
const contentPlannerPlugin = (config = {}) => (incomingConfig) => {
|
|
45
|
-
const { enabled = true } = config;
|
|
71
|
+
const { enabled = true, outputCollections = ['posts'] } = config;
|
|
46
72
|
if (!enabled) {
|
|
47
73
|
return incomingConfig;
|
|
48
74
|
}
|
|
@@ -50,9 +76,11 @@ const contentPlannerPlugin = (config = {}) => (incomingConfig) => {
|
|
|
50
76
|
...incomingConfig,
|
|
51
77
|
collections: [
|
|
52
78
|
...(incomingConfig.collections || []),
|
|
53
|
-
ContentTasks_1.
|
|
79
|
+
(0, ContentTasks_1.createContentTasksCollection)(outputCollections),
|
|
54
80
|
Keywords_1.keywordsCollection,
|
|
55
81
|
Instructions_1.instructionsCollection,
|
|
82
|
+
AuditLogs_1.auditLogsCollection,
|
|
83
|
+
Performance_1.performanceCollection,
|
|
56
84
|
],
|
|
57
85
|
};
|
|
58
86
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dudefactory/payload-plugin-content-planner",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "Payload CMS plugin that extends MCP with content planning collections and data sources",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -39,5 +39,6 @@
|
|
|
39
39
|
"repository": {
|
|
40
40
|
"type": "git",
|
|
41
41
|
"url": "https://github.com/DudeFactory/payload-plugin-content-planner.git"
|
|
42
|
-
}
|
|
42
|
+
},
|
|
43
|
+
"packageManager": "pnpm@10.27.0+sha512.72d699da16b1179c14ba9e64dc71c9a40988cbdc65c264cb0e489db7de917f20dcf4d64d8723625f2969ba52d4b7e2a1170682d9ac2a5dcaeaab732b7e16f04a"
|
|
43
44
|
}
|