@businesskit/agent 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.json +16 -0
- package/.claude/settings.local.json +11 -0
- package/.env.example +10 -0
- package/CLAUDE.md +32 -13
- package/PLAN.md +95 -134
- package/REFERENCE.md +60 -24
- package/agents/_base.ts +352 -44
- package/agents/analytics/SOUL.md +11 -0
- package/agents/analytics/analytics.ts +405 -0
- package/agents/business/SOUL.md +11 -0
- package/agents/{csuite/cbo.ts → business/business.ts} +2 -2
- package/agents/ceo/SOUL.md +15 -0
- package/agents/{csuite → ceo}/ceo.ts +33 -8
- package/agents/content/SOUL.md +11 -0
- package/agents/content/content.ts +379 -0
- package/agents/copywriting/SOUL.md +11 -0
- package/agents/courses/SOUL.md +11 -0
- package/agents/courses/courses.ts +451 -0
- package/agents/docs/SOUL.md +11 -0
- package/agents/forms/SOUL.md +11 -0
- package/agents/forms/forms.ts +364 -0
- package/agents/hiring/SOUL.md +11 -0
- package/agents/hiring/hiring.ts +314 -0
- package/agents/marketing/SOUL.md +15 -0
- package/agents/{csuite/cmo.ts → marketing/marketing.ts} +3 -3
- package/agents/newsletter/SOUL.md +11 -0
- package/agents/operations/SOUL.md +11 -0
- package/agents/operations/operations.ts +157 -0
- package/agents/sales/SOUL.md +44 -0
- package/agents/sales/sales.ts +883 -0
- package/agents/scheduler/SOUL.md +11 -0
- package/agents/{growth → scheduler}/scheduler.ts +2 -2
- package/agents/seo/SOUL.md +11 -0
- package/agents/{growth/seo-agent.ts → seo/seo.ts} +60 -54
- package/agents/social/SOUL.md +11 -0
- package/agents/social/social.ts +744 -0
- package/agents/store/SOUL.md +11 -0
- package/agents/store/store.ts +514 -0
- package/cli.ts +44 -25
- package/lib/cms.ts +88 -0
- package/lib/db.ts +58 -11
- package/lib/enums.ts +25 -0
- package/lib/groups.ts +122 -0
- package/lib/id.ts +38 -10
- package/lib/profile.ts +44 -8
- package/lib/schema.ts +2015 -0
- package/lib/validate.ts +33 -0
- package/package.json +1 -1
- package/scripts/generate-schema.ts +244 -0
- package/setup.ts +16 -2
- package/skills/schema/SKILL.md +57 -16
- package/tsconfig.json +2 -1
- package/agents/creators/blog-writer.ts +0 -347
- package/agents/creators/course-creator.ts +0 -106
- package/agents/creators/crm-agent.ts +0 -479
- package/agents/creators/forms-builder.ts +0 -90
- package/agents/creators/jobs-manager.ts +0 -82
- package/agents/creators/store-manager.ts +0 -138
- package/agents/csuite/coo.ts +0 -115
- package/agents/growth/analytics-agent.ts +0 -52
- package/agents/growth/social-agent.ts +0 -346
- /package/{ingest.md → .claude/commands/ingest.md} +0 -0
- /package/agents/{creators/copywriter.ts → copywriting/copywriting.ts} +0 -0
- /package/agents/{creators/docs-writer.ts → docs/docs.ts} +0 -0
- /package/agents/{creators/newsletter-writer.ts → newsletter/newsletter.ts} +0 -0
- /package/{ABOUT-ME.md → context/about-me.md} +0 -0
- /package/{brand-voice.md → context/brand-voice.md} +0 -0
- /package/{working-style.md → context/working-style.md} +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# marketing
|
|
2
|
+
|
|
3
|
+
Marketing, content calendar, growth planning, brand strategy. Handles what CMO would do. Delegates to content, social, seo, newsletter agents.
|
|
4
|
+
|
|
5
|
+
## Rules
|
|
6
|
+
|
|
7
|
+
- Load skills on demand
|
|
8
|
+
- Draft before publish
|
|
9
|
+
- Archive not delete (hidden=1)
|
|
10
|
+
- Log every action to agent_memory
|
|
11
|
+
- Push reports to agent_reports mid-session
|
|
12
|
+
|
|
13
|
+
## Skills
|
|
14
|
+
|
|
15
|
+
See skills/marketing/SKILL.md and CLAUDE.md skills table.
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { BaseAgent, db } from '../_base.ts'
|
|
10
|
-
import { analyticsAgent } from '../
|
|
11
|
-
import { blogWriter } from '../
|
|
10
|
+
import { analyticsAgent } from '../analytics/analytics.ts'
|
|
11
|
+
import { blogWriter } from '../content/content.ts'
|
|
12
12
|
|
|
13
13
|
export class CMO extends BaseAgent {
|
|
14
14
|
readonly name = 'NOVA'
|
|
@@ -56,7 +56,7 @@ export class CMO extends BaseAgent {
|
|
|
56
56
|
async growthAudit() {
|
|
57
57
|
await this.init()
|
|
58
58
|
const snap = await analyticsAgent.snapshot()
|
|
59
|
-
const drafts = await blogWriter.
|
|
59
|
+
const drafts = await blogWriter.listDrafts()
|
|
60
60
|
|
|
61
61
|
const totalTraffic = snap.profile?.total_clicks ?? 0
|
|
62
62
|
const totalRevenue = snap.products.reduce((a, p) => a + p.revenue, 0)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# newsletter
|
|
2
|
+
|
|
3
|
+
Placeholder SOUL. See CLAUDE.md routing table and skills/newsletter/SKILL.md (if present) for scope.
|
|
4
|
+
|
|
5
|
+
## Rules
|
|
6
|
+
|
|
7
|
+
- Load skills on demand
|
|
8
|
+
- Draft before publish
|
|
9
|
+
- Archive not delete (hidden=1)
|
|
10
|
+
- Log every action to agent_memory
|
|
11
|
+
- Push reports to agent_reports mid-session
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# operations
|
|
2
|
+
|
|
3
|
+
Placeholder SOUL. See CLAUDE.md routing table and skills/operations/SKILL.md (if present) for scope.
|
|
4
|
+
|
|
5
|
+
## Rules
|
|
6
|
+
|
|
7
|
+
- Load skills on demand
|
|
8
|
+
- Draft before publish
|
|
9
|
+
- Archive not delete (hidden=1)
|
|
10
|
+
- Log every action to agent_memory
|
|
11
|
+
- Push reports to agent_reports mid-session
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OTTO — Chief Operating Officer
|
|
3
|
+
* "Pipelines don't run themselves. I make sure they do."
|
|
4
|
+
* Manages: publish queue, draft pipeline, scheduling
|
|
5
|
+
* Phase 3: becomes the CF Durable Object that runs everything autonomously
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { BaseAgent, db, now, iso } from '../_base.ts'
|
|
9
|
+
|
|
10
|
+
interface ScheduledItem {
|
|
11
|
+
table: string; id: string; title: string; scheduled_for: string | number
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class COO extends BaseAgent {
|
|
15
|
+
readonly name = 'OTTO'
|
|
16
|
+
readonly title = 'Chief Operating Officer'
|
|
17
|
+
|
|
18
|
+
/** All drafts across every content type. Content lives in the unified
|
|
19
|
+
* `content` table — we split it by cms.slug for the pipeline view. */
|
|
20
|
+
async draftPipeline() {
|
|
21
|
+
await this.init()
|
|
22
|
+
|
|
23
|
+
const { rows: contentRows } = await db.execute({
|
|
24
|
+
sql: `SELECT c.id, c.title, c.date AS scheduled_for, cms.slug AS kind
|
|
25
|
+
FROM content c
|
|
26
|
+
JOIN cms ON cms.id = c.cms_id
|
|
27
|
+
WHERE c.profile_id=? AND c.published=0 AND c.hidden=0
|
|
28
|
+
ORDER BY c.updated_at DESC`,
|
|
29
|
+
args: [this.profileId],
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
const byKind: Record<string, { label: string; table: string; drafts: any[] }> = {}
|
|
33
|
+
for (const r of contentRows) {
|
|
34
|
+
const kind = String(r.kind ?? 'content')
|
|
35
|
+
const entry = byKind[kind] ??= { label: titleCase(kind), table: kind, drafts: [] }
|
|
36
|
+
entry.drafts.push({ id: r.id, title: r.title, scheduled_for: r.scheduled_for })
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const others = await Promise.all(
|
|
40
|
+
[
|
|
41
|
+
{ table: 'products', label: 'Products', dateCol: 'created_at' },
|
|
42
|
+
{ table: 'pages', label: 'Pages', dateCol: 'created_at' },
|
|
43
|
+
{ table: 'job_listings', label: 'Jobs', dateCol: 'created_at' },
|
|
44
|
+
{ table: 'forms', label: 'Forms', dateCol: 'created_at' },
|
|
45
|
+
].map(async ({ table, label, dateCol }) => {
|
|
46
|
+
const { rows } = await db.execute({
|
|
47
|
+
sql: `SELECT id, title, ${dateCol} AS scheduled_for
|
|
48
|
+
FROM ${table} WHERE profile_id=? AND published=0 AND hidden=0
|
|
49
|
+
ORDER BY created_at DESC`,
|
|
50
|
+
args: [this.profileId],
|
|
51
|
+
})
|
|
52
|
+
return { label, table, drafts: rows }
|
|
53
|
+
}),
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
return [...Object.values(byKind), ...others].filter(r => r.drafts.length > 0)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Content due for publish right now */
|
|
60
|
+
async publishQueue(): Promise<ScheduledItem[]> {
|
|
61
|
+
await this.init()
|
|
62
|
+
const nowUnix = now()
|
|
63
|
+
const nowISO = iso()
|
|
64
|
+
const queue: ScheduledItem[] = []
|
|
65
|
+
|
|
66
|
+
// content table: `date` is ISO TEXT
|
|
67
|
+
const { rows: contentDue } = await db.execute({
|
|
68
|
+
sql: `SELECT id, title, date AS scheduled_for
|
|
69
|
+
FROM content
|
|
70
|
+
WHERE profile_id=? AND published=0 AND hidden=0
|
|
71
|
+
AND date IS NOT NULL AND date <= ?
|
|
72
|
+
ORDER BY date ASC`,
|
|
73
|
+
args: [this.profileId, nowISO],
|
|
74
|
+
})
|
|
75
|
+
contentDue.forEach(r => queue.push({
|
|
76
|
+
table: 'content', id: r.id as string,
|
|
77
|
+
title: r.title as string, scheduled_for: r.scheduled_for as string,
|
|
78
|
+
}))
|
|
79
|
+
|
|
80
|
+
// job_listings: ISO `date`
|
|
81
|
+
const { rows: jobs } = await db.execute({
|
|
82
|
+
sql: `SELECT id, title, date AS scheduled_for FROM job_listings
|
|
83
|
+
WHERE profile_id=? AND published=0 AND hidden=0
|
|
84
|
+
AND date IS NOT NULL AND date <= ? ORDER BY date ASC`,
|
|
85
|
+
args: [this.profileId, nowISO],
|
|
86
|
+
})
|
|
87
|
+
jobs.forEach(r => queue.push({
|
|
88
|
+
table: 'job_listings', id: r.id as string,
|
|
89
|
+
title: r.title as string, scheduled_for: r.scheduled_for as string,
|
|
90
|
+
}))
|
|
91
|
+
|
|
92
|
+
// products: unix `published_at`
|
|
93
|
+
const { rows: products } = await db.execute({
|
|
94
|
+
sql: `SELECT id, title, published_at AS scheduled_for FROM products
|
|
95
|
+
WHERE profile_id=? AND published=0 AND hidden=0
|
|
96
|
+
AND published_at IS NOT NULL AND published_at <= ?
|
|
97
|
+
ORDER BY published_at ASC`,
|
|
98
|
+
args: [this.profileId, nowUnix],
|
|
99
|
+
})
|
|
100
|
+
products.forEach(r => queue.push({
|
|
101
|
+
table: 'products', id: r.id as string,
|
|
102
|
+
title: r.title as string, scheduled_for: r.scheduled_for as number,
|
|
103
|
+
}))
|
|
104
|
+
|
|
105
|
+
return queue
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Run the publish queue — flips published=1 on all due items.
|
|
110
|
+
* Phase 1: call manually. Phase 3: called by CF Durable Object on cron.
|
|
111
|
+
*/
|
|
112
|
+
async runPublishQueue(): Promise<ScheduledItem[]> {
|
|
113
|
+
await this.init()
|
|
114
|
+
const { n8n_webhook_url } = this.ctx.credentials
|
|
115
|
+
const queue = await this.publishQueue()
|
|
116
|
+
if (!queue.length) return []
|
|
117
|
+
|
|
118
|
+
const isoTables = new Set(['content', 'job_listings'])
|
|
119
|
+
const statements = queue.map(item => ({
|
|
120
|
+
sql: `UPDATE ${item.table} SET published=1, updated_at=?
|
|
121
|
+
WHERE id=? AND profile_id=?`,
|
|
122
|
+
args: [isoTables.has(item.table) ? iso() : now(), item.id, this.profileId],
|
|
123
|
+
}))
|
|
124
|
+
await db.batch(statements)
|
|
125
|
+
|
|
126
|
+
if (n8n_webhook_url) {
|
|
127
|
+
fetch(n8n_webhook_url, {
|
|
128
|
+
method: 'POST',
|
|
129
|
+
headers: { 'Content-Type': 'application/json' },
|
|
130
|
+
body: JSON.stringify({ event: 'content_published', business: this.ctx.profile.title, items: queue }),
|
|
131
|
+
}).catch(() => { /* non-blocking */ })
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return queue
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** Schedule any content for future publish. */
|
|
138
|
+
async schedule(table: 'content' | 'products' | 'job_listings', id: string, at: Date) {
|
|
139
|
+
await this.init()
|
|
140
|
+
const isISO = table !== 'products'
|
|
141
|
+
const dateCol = table === 'products' ? 'published_at' : 'date'
|
|
142
|
+
const val = isISO ? at.toISOString().slice(0, 19) + 'Z' : Math.floor(at.getTime() / 1000)
|
|
143
|
+
const updCol = isISO ? `updated_at='${iso()}'` : `updated_at=${now()}`
|
|
144
|
+
|
|
145
|
+
await db.write({
|
|
146
|
+
sql: `UPDATE ${table} SET published=0, ${dateCol}=?, ${updCol}
|
|
147
|
+
WHERE id=? AND profile_id=?`,
|
|
148
|
+
args: [val, id, this.profileId],
|
|
149
|
+
})
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function titleCase(s: string): string {
|
|
154
|
+
return s.charAt(0).toUpperCase() + s.slice(1)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export const coo = new COO()
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# sales
|
|
2
|
+
|
|
3
|
+
Manages the full CRM pipeline — contacts, deals, outreach, proposals, invoices, tasks, inbox.
|
|
4
|
+
Dashboard route: /dashboard/contacts/ (not /crm/).
|
|
5
|
+
|
|
6
|
+
## What I do
|
|
7
|
+
|
|
8
|
+
- Contact management: add leads, enrich, score (0-100), track outreach status
|
|
9
|
+
- Deal pipeline: stages (new → contacted → proposal → negotiation → won → lost)
|
|
10
|
+
- Outreach: draft DMs and emails, queue for approval, log replies
|
|
11
|
+
- Proposals: draft, send, track opens/clicks, collect signatures
|
|
12
|
+
- Invoices: create, send, track payment
|
|
13
|
+
- Tasks: follow-up reminders, due dates, priorities
|
|
14
|
+
- Inbox: inbound replies, sentiment, next action
|
|
15
|
+
|
|
16
|
+
## Approval gate — non-negotiable
|
|
17
|
+
|
|
18
|
+
ALL outbound activities (DMs, emails, proposals) start as:
|
|
19
|
+
approval_status = 'pending_approval'
|
|
20
|
+
Never set auto_sent unless contact.auto_approve = 1.
|
|
21
|
+
Surface pending approvals at session start.
|
|
22
|
+
|
|
23
|
+
## Rules
|
|
24
|
+
|
|
25
|
+
- crm_activities is APPEND-ONLY — never UPDATE, insert correcting row instead
|
|
26
|
+
- crm_analytics is TRIGGER-managed — never write to it directly
|
|
27
|
+
- Groups: use lib/groups.ts helpers, never LIKE '%grp_x%'
|
|
28
|
+
- load_score must be 0-100 — use validate.leadScore() from lib/validate.ts
|
|
29
|
+
- Proposals + invoices: email tracking columns written by triggers — don't touch
|
|
30
|
+
- Archive contacts: hidden=1, never hard delete
|
|
31
|
+
- Log every action to agent_memory after completion
|
|
32
|
+
|
|
33
|
+
## Tables I use
|
|
34
|
+
|
|
35
|
+
crm_contacts, crm_deals, crm_activities, crm_tasks, crm_notes,
|
|
36
|
+
crm_groups, crm_contact_groups, crm_templates, crm_proposals,
|
|
37
|
+
crm_invoices, crm_imports, crm_analytics (read-only)
|
|
38
|
+
|
|
39
|
+
## Session start
|
|
40
|
+
|
|
41
|
+
1. Check crm_analytics.total_pending_approvals
|
|
42
|
+
2. Show pending activities needing approval
|
|
43
|
+
3. Show tasks due today
|
|
44
|
+
4. Show hot leads (lead_score DESC, outreach_status = 'outreach_ready')
|