@dudefactory/payload-plugin-content-planner 3.1.0 → 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.
@@ -9,5 +9,11 @@ import { CollectionConfig } from 'payload';
9
9
  * - User Inputs: title, instructions, taskType, priority
10
10
  * - Agent Outputs: status, outputLink, lastError, reviewFeedback
11
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.
12
17
  */
18
+ export declare function createContentTasksCollection(outputCollections?: string[]): CollectionConfig;
13
19
  export declare const contentTasksCollection: CollectionConfig;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.contentTasksCollection = void 0;
4
+ exports.createContentTasksCollection = createContentTasksCollection;
4
5
  /**
5
6
  * Content Tasks Collection - The User Interface
6
7
  *
@@ -11,165 +12,176 @@ exports.contentTasksCollection = void 0;
11
12
  * - User Inputs: title, instructions, taskType, priority
12
13
  * - Agent Outputs: status, outputLink, lastError, reviewFeedback
13
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.
14
20
  */
15
- exports.contentTasksCollection = {
16
- slug: 'cp-content-tasks',
17
- admin: {
18
- useAsTitle: 'title',
19
- defaultColumns: ['title', 'taskType', 'status', 'priority', 'createdAt'],
20
- group: 'Content Planning',
21
- },
22
- fields: [
23
- // ========== USER INPUTS ==========
24
- {
25
- type: 'collapsible',
26
- label: 'User Inputs',
27
- fields: [
28
- {
29
- name: 'title',
30
- label: 'Task Title',
31
- type: 'text',
32
- required: true,
33
- maxLength: 150,
34
- admin: {
35
- placeholder: 'e.g., Write a blog post about cigar festivals in Miami',
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',
28
+ },
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
+ },
36
44
  },
37
- },
38
- {
39
- name: 'instructions',
40
- label: 'The Command',
41
- type: 'textarea',
42
- required: true,
43
- admin: {
44
- rows: 10,
45
- 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."',
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
+ },
46
54
  },
47
- },
48
- {
49
- name: 'taskType',
50
- label: 'Task Type',
51
- type: 'select',
52
- required: true,
53
- options: [
54
- { label: 'New Content', value: 'new-content' },
55
- { label: 'Update SEO', value: 'update-seo' },
56
- { label: 'Translation', value: 'translation' },
57
- { label: 'Social Media', value: 'social-media' },
58
- { label: 'Research', value: 'research' },
59
- ],
60
- defaultValue: 'new-content',
61
- },
62
- {
63
- name: 'priority',
64
- label: 'Priority',
65
- type: 'select',
66
- required: true,
67
- options: [
68
- { label: 'Low', value: 'low' },
69
- { label: 'Normal', value: 'normal' },
70
- { label: 'High', value: 'high' },
71
- ],
72
- defaultValue: 'normal',
73
- },
74
- {
75
- name: 'deadline',
76
- label: 'Deadline',
77
- type: 'date',
78
- required: false,
79
- admin: {
80
- placeholder: 'Optional: Set a deadline for this task',
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',
81
68
  },
82
- },
83
- ],
84
- },
85
- // ========== AGENT OUTPUTS ==========
86
- {
87
- type: 'collapsible',
88
- label: 'Agent Outputs',
89
- admin: {
90
- description: 'Automatically populated by the Agent. Do not edit manually.',
91
- },
92
- fields: [
93
- {
94
- name: 'status',
95
- label: 'Status',
96
- type: 'select',
97
- required: true,
98
- options: [
99
- { label: 'To Do', value: 'todo' },
100
- { label: 'In Progress', value: 'in-progress' },
101
- { label: 'In Review', value: 'review' },
102
- { label: 'Done', value: 'done' },
103
- { label: 'Failed', value: 'failed' },
104
- ],
105
- defaultValue: 'todo',
106
- admin: {
107
- description: 'Set to "Failed" if the Agent encounters an error.',
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',
108
80
  },
109
- },
110
- {
111
- name: 'outputLink',
112
- label: 'Output Link',
113
- type: 'relationship',
114
- relationTo: ['pages', 'posts', 'events'],
115
- admin: {
116
- description: 'Crucial: Points to the generated Post, Page, Event, or other content created by the Agent.',
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
+ },
117
89
  },
90
+ ],
91
+ },
92
+ // ========== AGENT OUTPUTS ==========
93
+ {
94
+ type: 'collapsible',
95
+ label: 'Agent Outputs',
96
+ admin: {
97
+ description: 'Automatically populated by the Agent. Do not edit manually.',
118
98
  },
119
- {
120
- name: 'lastError',
121
- label: 'Last Error',
122
- type: 'textarea',
123
- admin: {
124
- rows: 4,
125
- description: 'If status is "Failed", the Agent writes the technical error here.',
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
+ },
126
116
  },
127
- },
128
- {
129
- name: 'reviewFeedback',
130
- label: 'Review Feedback',
131
- type: 'richText',
132
- admin: {
133
- description: 'User notes for the Agent to "try again". Leave blank if not in review.',
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
+ },
134
126
  },
135
- },
136
- ],
137
- },
138
- // ========== SYSTEM / AGENT METADATA ==========
139
- {
140
- type: 'collapsible',
141
- label: 'System & Configuration',
142
- admin: {
143
- description: 'Advanced settings for the Agent and system integration.',
144
- },
145
- fields: [
146
- {
147
- name: 'agentMetadata',
148
- label: 'Agent Metadata',
149
- type: 'json',
150
- admin: {
151
- description: 'Stores tokens consumed, model used, estimated cost, latency (ms). Auto-populated by Agent.',
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
+ },
152
135
  },
153
- },
154
- {
155
- name: 'parentTask',
156
- label: 'Parent Task',
157
- type: 'relationship',
158
- relationTo: 'cp-content-tasks',
159
- admin: {
160
- description: 'Links to a parent Campaign, Epic, or meta-task if this is a subtask.',
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
+ },
161
143
  },
144
+ ],
145
+ },
146
+ // ========== SYSTEM / AGENT METADATA ==========
147
+ {
148
+ type: 'collapsible',
149
+ label: 'System & Configuration',
150
+ admin: {
151
+ description: 'Advanced settings for the Agent and system integration.',
162
152
  },
163
- {
164
- name: 'customParams',
165
- label: 'Custom Parameters',
166
- type: 'json',
167
- admin: {
168
- description: 'The Escape Hatch: Use this if you need to pass data you forgot to add to the schema. Agent-writable.',
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
+ },
169
161
  },
170
- },
171
- ],
172
- },
173
- ],
174
- timestamps: true,
175
- };
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();
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Config } from 'payload';
2
- import { contentTasksCollection } from './collections/ContentTasks';
2
+ import { createContentTasksCollection, contentTasksCollection } from './collections/ContentTasks';
3
3
  import { keywordsCollection } from './collections/Keywords';
4
4
  import { instructionsCollection } from './collections/Instructions';
5
5
  import { auditLogsCollection } from './collections/AuditLogs';
@@ -129,9 +129,23 @@ export declare const contentPlannerPrompts: ({
129
129
  };
130
130
  })[];
131
131
  export { generateInitInstruction, warmupInitialization, setupInstructions, generateContentTask, executeContentTask, };
132
- export { contentTasksCollection, keywordsCollection, instructionsCollection, auditLogsCollection, performanceCollection, };
132
+ export { createContentTasksCollection, contentTasksCollection, keywordsCollection, instructionsCollection, auditLogsCollection, performanceCollection, };
133
133
  export interface ContentPlannerPluginConfig {
134
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[];
135
149
  }
136
150
  /**
137
151
  * Payload Content Planner Plugin
@@ -163,7 +177,11 @@ export interface ContentPlannerPluginConfig {
163
177
  *
164
178
  * export default buildConfig({
165
179
  * plugins: [
166
- * contentPlannerPlugin({ enabled: true }),
180
+ * contentPlannerPlugin({
181
+ * enabled: true,
182
+ * // Tell the plugin which collections exist in YOUR project
183
+ * outputCollections: ['posts', 'public-events', 'factories', 'cities'],
184
+ * }),
167
185
  * // Add to your existing MCP plugin to enable agent execution:
168
186
  * // mcpPlugin({ prompts: contentPlannerPrompts })
169
187
  * ],
package/dist/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.contentPlannerPlugin = exports.performanceCollection = exports.auditLogsCollection = exports.instructionsCollection = exports.keywordsCollection = exports.contentTasksCollection = 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; } });
5
6
  Object.defineProperty(exports, "contentTasksCollection", { enumerable: true, get: function () { return ContentTasks_1.contentTasksCollection; } });
6
7
  const Keywords_1 = require("./collections/Keywords");
7
8
  Object.defineProperty(exports, "keywordsCollection", { enumerable: true, get: function () { return Keywords_1.keywordsCollection; } });
@@ -55,7 +56,11 @@ exports.contentPlannerPrompts = [
55
56
  *
56
57
  * export default buildConfig({
57
58
  * plugins: [
58
- * contentPlannerPlugin({ enabled: true }),
59
+ * contentPlannerPlugin({
60
+ * enabled: true,
61
+ * // Tell the plugin which collections exist in YOUR project
62
+ * outputCollections: ['posts', 'public-events', 'factories', 'cities'],
63
+ * }),
59
64
  * // Add to your existing MCP plugin to enable agent execution:
60
65
  * // mcpPlugin({ prompts: contentPlannerPrompts })
61
66
  * ],
@@ -63,7 +68,7 @@ exports.contentPlannerPrompts = [
63
68
  * ```
64
69
  */
65
70
  const contentPlannerPlugin = (config = {}) => (incomingConfig) => {
66
- const { enabled = true } = config;
71
+ const { enabled = true, outputCollections = ['posts'] } = config;
67
72
  if (!enabled) {
68
73
  return incomingConfig;
69
74
  }
@@ -71,7 +76,7 @@ const contentPlannerPlugin = (config = {}) => (incomingConfig) => {
71
76
  ...incomingConfig,
72
77
  collections: [
73
78
  ...(incomingConfig.collections || []),
74
- ContentTasks_1.contentTasksCollection,
79
+ (0, ContentTasks_1.createContentTasksCollection)(outputCollections),
75
80
  Keywords_1.keywordsCollection,
76
81
  Instructions_1.instructionsCollection,
77
82
  AuditLogs_1.auditLogsCollection,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dudefactory/payload-plugin-content-planner",
3
- "version": "3.1.0",
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",