@businesskit/agent 1.0.4 → 1.0.7
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-plugin/plugin.json +1 -1
- package/.cursor-plugin/plugin.json +25 -0
- package/.cursorrules +10 -0
- package/.superconsole-plugin/plugin.json +62 -0
- package/AGENTS.md +105 -63
- package/CLAUDE.md +11 -84
- package/GEMINI.md +11 -34
- package/README.md +95 -154
- package/assets/logo.svg +3 -0
- package/bin/businesskit.js +45 -18
- package/commands/add-contact.md +47 -0
- package/commands/add-inventory-from-invoice.md +80 -0
- package/commands/adjust-stock.md +46 -0
- package/commands/brief.md +12 -0
- package/commands/capabilities.md +33 -0
- package/commands/chase.md +12 -0
- package/commands/check-stock.md +43 -0
- package/commands/create-component.md +109 -0
- package/commands/create-invoice.md +69 -0
- package/commands/create-new-bill.md +65 -0
- package/commands/create-page.md +124 -0
- package/commands/crm.md +13 -0
- package/commands/followups.md +13 -0
- package/commands/list-components.md +41 -0
- package/commands/list-content.md +46 -0
- package/commands/list-pages.md +45 -0
- package/commands/pipeline.md +13 -0
- package/commands/publish-page.md +64 -0
- package/commands/send-invoice.md +42 -0
- package/commands/seo-audit.md +36 -0
- package/commands/update-agent.md +33 -0
- package/commands/update-contact.md +46 -0
- package/commands/update-content.md +48 -0
- package/commands/update-page.md +56 -0
- package/commands/update-price.md +47 -0
- package/commands/write-blog.md +56 -0
- package/commands/write-docs.md +90 -0
- package/commands/write-guide.md +51 -0
- package/commands/write-newsletter.md +50 -0
- package/dist/server.js +4099 -0
- package/mcp_config.json +12 -0
- package/package.json +54 -25
- package/plugin.json +32 -0
- package/scripts/setup.sh +169 -0
- package/scripts/setup.ts +129 -0
- package/scripts/update.sh +56 -0
- package/server.json +21 -0
- package/skills/README.md +20 -27
- package/skills/billing/SKILL.md +64 -0
- package/skills/brand/SKILL.md +30 -86
- package/skills/cms/SKILL.md +111 -0
- package/skills/cms/references/cms-hubs.md +84 -0
- package/skills/cms/references/html-blocks.md +177 -0
- package/skills/copywriting/SKILL.md +1 -1
- package/skills/crm/SKILL.md +24 -0
- package/skills/docs/SKILL.md +65 -0
- package/skills/docs/references/how-to.md +155 -0
- package/skills/inbox/SKILL.md +49 -0
- package/skills/inventory/SKILL.md +69 -0
- package/skills/pages/SKILL.md +214 -0
- package/skills/pages/references/sections-catalog.json +1183 -0
- package/skills/social/SKILL.md +84 -211
- package/skills/social/evals/evals.json +66 -0
- package/skills/social/evals/rubric.md +26 -0
- package/skills/social/examples/repurposing-blog-to-social.md +93 -0
- package/skills/social/examples/weekly-content-calendar.md +30 -0
- package/skills/social/linkedin/SKILL.md +107 -0
- package/skills/social/linkedin/evals/evals.json +106 -0
- package/skills/social/linkedin/evals/rubric.md +28 -0
- package/skills/social/linkedin/examples/gasp-weekly-sprint.md +24 -0
- package/skills/social/linkedin/examples/growth-posts-by-format.md +140 -0
- package/skills/social/linkedin/references/gasp-funnel-and-calibration.md +90 -0
- package/skills/social/linkedin/references/six-growth-formats.md +114 -0
- package/skills/social/references/platforms.md +76 -0
- package/skills/social/references/post-templates.md +105 -0
- package/skills/social/references/reverse-engineering.md +62 -0
- package/src/data/sections-catalog.json +950 -0
- package/src/db.ts +170 -0
- package/src/server.ts +75 -0
- package/src/tools/content.ts +326 -0
- package/src/tools/crm.ts +1416 -0
- package/src/tools/domains.ts +89 -0
- package/src/tools/inbox.ts +270 -0
- package/src/tools/index.ts +116 -0
- package/src/tools/pages.ts +1217 -0
- package/src/tools/shop.ts +771 -0
- package/src/tools/system.ts +94 -0
- package/src/tools/types.ts +17 -0
- package/templates/antigravity.json +8 -0
- package/templates/claude-code.mcp.json +8 -0
- package/templates/cursor.mcp.json +8 -0
- package/templates/vscode.mcp.json +9 -0
- package/.claude/commands/analytics.md +0 -7
- package/.claude/commands/blog-writer.md +0 -9
- package/.claude/commands/cbo.md +0 -7
- package/.claude/commands/ceo.md +0 -10
- package/.claude/commands/cmo.md +0 -7
- package/.claude/commands/compress.md +0 -73
- package/.claude/commands/coo.md +0 -11
- package/.claude/commands/copywriter.md +0 -15
- package/.claude/commands/course-creator.md +0 -9
- package/.claude/commands/crm.md +0 -591
- package/.claude/commands/deep.md +0 -50
- package/.claude/commands/docs-writer.md +0 -8
- package/.claude/commands/forms-builder.md +0 -10
- package/.claude/commands/ingest.md +0 -110
- package/.claude/commands/jobs-manager.md +0 -8
- package/.claude/commands/kb.md +0 -107
- package/.claude/commands/newsletter-writer.md +0 -9
- package/.claude/commands/preserve.md +0 -64
- package/.claude/commands/resume.md +0 -67
- package/.claude/commands/scheduler.md +0 -8
- package/.claude/commands/seo.md +0 -60
- package/.claude/commands/social.md +0 -51
- package/.claude/commands/store-manager.md +0 -11
- package/.claude/settings.json +0 -16
- package/.claude/settings.local.json +0 -11
- package/.env.example +0 -12
- package/.mcp.json +0 -3
- package/HEARTBEAT.md +0 -105
- package/PLAN.md +0 -345
- package/PRD-Agent-Composition.md +0 -149
- package/PRD-Agent-Harness.md +0 -316
- package/REFERENCE.md +0 -160
- package/SOUL.md +0 -148
- package/SYSTEM.md +0 -71
- package/agents/_base.ts +0 -371
- package/agents/analytics/SOUL.md +0 -11
- package/agents/analytics/analytics.ts +0 -405
- package/agents/business/SOUL.md +0 -11
- package/agents/business/business.ts +0 -109
- package/agents/ceo/SOUL.md +0 -15
- package/agents/ceo/ceo.ts +0 -146
- package/agents/content/SOUL.md +0 -11
- package/agents/content/content.ts +0 -379
- package/agents/copywriting/SOUL.md +0 -11
- package/agents/copywriting/copywriting.ts +0 -89
- package/agents/courses/SOUL.md +0 -11
- package/agents/courses/courses.ts +0 -451
- package/agents/docs/SOUL.md +0 -11
- package/agents/docs/docs.ts +0 -77
- package/agents/forms/SOUL.md +0 -11
- package/agents/forms/forms.ts +0 -364
- package/agents/hiring/SOUL.md +0 -11
- package/agents/hiring/hiring.ts +0 -314
- package/agents/marketing/SOUL.md +0 -15
- package/agents/marketing/marketing.ts +0 -109
- package/agents/newsletter/SOUL.md +0 -11
- package/agents/newsletter/newsletter.ts +0 -91
- package/agents/operations/SOUL.md +0 -11
- package/agents/operations/operations.ts +0 -157
- package/agents/sales/SOUL.md +0 -44
- package/agents/sales/sales.ts +0 -883
- package/agents/scheduler/SOUL.md +0 -11
- package/agents/scheduler/scheduler.ts +0 -68
- package/agents/seo/SOUL.md +0 -11
- package/agents/seo/seo.ts +0 -288
- package/agents/social/SOUL.md +0 -11
- package/agents/social/social.ts +0 -744
- package/agents/store/SOUL.md +0 -11
- package/agents/store/store.ts +0 -514
- package/cli.ts +0 -144
- package/context/about-me.md +0 -96
- package/context/brand-voice.md +0 -127
- package/context/brand.md +0 -80
- package/context/business.md +0 -66
- package/context/working-style.md +0 -87
- package/lib/analytics.ts +0 -81
- package/lib/cms.ts +0 -88
- package/lib/db.adapter.ts +0 -30
- package/lib/db.ts +0 -63
- package/lib/enums.ts +0 -25
- package/lib/groups.ts +0 -122
- package/lib/id.ts +0 -43
- package/lib/kb.ts +0 -337
- package/lib/memory.ts +0 -219
- package/lib/pattern-detector.ts +0 -169
- package/lib/profile.ts +0 -155
- package/lib/schema.ts +0 -2015
- package/lib/slug.ts +0 -30
- package/lib/validate.ts +0 -33
- package/setup.ts +0 -141
- package/skills/agents/SKILL.md +0 -56
- package/skills/analytics/SKILL.md +0 -52
- package/skills/blog-writer/SKILL.md +0 -452
- package/skills/ceo/SKILL.md +0 -25
- package/skills/cmo/SKILL.md +0 -8
- package/skills/schema/SKILL.md +0 -86
- package/skills/store/SKILL.md +0 -62
- package/tsconfig.json +0 -14
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// src/tools/domains.ts
|
|
2
|
+
// Domain Management MCP Tools: Expiry Tracking & Domain Notes
|
|
3
|
+
|
|
4
|
+
import { execute, query } from '../db.js';
|
|
5
|
+
import type { ToolDefinition, ToolContext } from './types.js';
|
|
6
|
+
|
|
7
|
+
export const domainTools: ToolDefinition[] = [
|
|
8
|
+
{
|
|
9
|
+
name: 'domain_list_expiring',
|
|
10
|
+
domain: 'domains',
|
|
11
|
+
description:
|
|
12
|
+
'List tracked domains from my_domains that are expired or expiring within N days (defaults to 30 days). Returns days left, registrar, auto-renew status, renewal price, and notes.',
|
|
13
|
+
inputSchema: {
|
|
14
|
+
type: 'object',
|
|
15
|
+
properties: {
|
|
16
|
+
days: { type: 'number', description: 'Lookahead horizon in days (e.g. 7, 30, 60). Defaults to 30.' },
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
handler: async (args: Record<string, any>, ctx: ToolContext) => {
|
|
20
|
+
const profileId = ctx.profileId;
|
|
21
|
+
const days = Number(args.days || 30);
|
|
22
|
+
const horizonSecs = Math.floor(Date.now() / 1000) + days * 86400;
|
|
23
|
+
|
|
24
|
+
const rows = await query(
|
|
25
|
+
`SELECT id, domain_name, registrar, expiry_date, auto_renew, renewal_price, agent_notes, status
|
|
26
|
+
FROM my_domains
|
|
27
|
+
WHERE profile_id = ? AND (expiry_date <= ? OR status = 'expired')
|
|
28
|
+
ORDER BY expiry_date ASC LIMIT 50`,
|
|
29
|
+
[profileId, horizonSecs]
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
lookahead_days: days,
|
|
34
|
+
total: rows.length,
|
|
35
|
+
domains: rows.map((r: any) => ({
|
|
36
|
+
id: r.id,
|
|
37
|
+
domain: r.domain_name,
|
|
38
|
+
registrar: r.registrar,
|
|
39
|
+
expiry_date: r.expiry_date,
|
|
40
|
+
auto_renew: Boolean(r.auto_renew),
|
|
41
|
+
renewal_price: r.renewal_price,
|
|
42
|
+
agent_notes: r.agent_notes,
|
|
43
|
+
status: r.status,
|
|
44
|
+
})),
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'domain_set_agent_notes',
|
|
50
|
+
domain: 'domains',
|
|
51
|
+
description:
|
|
52
|
+
'Record agent analysis, recommendation, or renewal reminders into agent_notes on a domain without overwriting user notes.',
|
|
53
|
+
inputSchema: {
|
|
54
|
+
type: 'object',
|
|
55
|
+
properties: {
|
|
56
|
+
id: { type: 'string', description: "Domain row ID or domain name (e.g. 'dom_xyz' or 'example.com')" },
|
|
57
|
+
text: { type: 'string', description: 'Agent analysis or notes to save' },
|
|
58
|
+
},
|
|
59
|
+
required: ['id', 'text'],
|
|
60
|
+
},
|
|
61
|
+
handler: async (args: Record<string, any>, ctx: ToolContext) => {
|
|
62
|
+
const profileId = ctx.profileId;
|
|
63
|
+
const ref = String(args.id).trim();
|
|
64
|
+
const text = String(args.text).trim();
|
|
65
|
+
|
|
66
|
+
const domains = await query<{ id: string; domain_name: string }>(
|
|
67
|
+
'SELECT id, domain_name FROM my_domains WHERE profile_id = ? AND (id = ? OR domain_name = ?) LIMIT 1',
|
|
68
|
+
[profileId, ref, ref]
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
if (domains.length === 0) {
|
|
72
|
+
throw new Error(`Domain not found with identifier: ${ref}`);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const domain = domains[0];
|
|
76
|
+
await execute(
|
|
77
|
+
"UPDATE my_domains SET agent_notes = ?, updated_at = strftime('%s','now') WHERE id = ? AND profile_id = ?",
|
|
78
|
+
[text, domain.id, profileId]
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
id: domain.id,
|
|
83
|
+
domain: domain.domain_name,
|
|
84
|
+
agent_notes: text,
|
|
85
|
+
status: 'updated',
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
];
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
// src/tools/inbox.ts
|
|
2
|
+
// Unified Inbox MCP Tools: Thread Triage, Labelling, Reply Drafting & Archiving
|
|
3
|
+
|
|
4
|
+
import { execute, generateId, query } from '../db.js';
|
|
5
|
+
import type { ToolDefinition, ToolContext } from './types.js';
|
|
6
|
+
|
|
7
|
+
export const inboxTools: ToolDefinition[] = [
|
|
8
|
+
{
|
|
9
|
+
name: 'inbox_tool_set_category',
|
|
10
|
+
domain: 'inbox',
|
|
11
|
+
description: "Classify an email thread into a named category bucket (e.g. 'billing', 'support', 'sales', 'spam').",
|
|
12
|
+
inputSchema: {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
thread_id: { type: 'string', description: 'Thread ID to classify (e.g. th_...)' },
|
|
16
|
+
category: { type: 'string', description: "Category label to apply (e.g. 'billing', 'support', 'sales')" },
|
|
17
|
+
},
|
|
18
|
+
required: ['thread_id', 'category'],
|
|
19
|
+
},
|
|
20
|
+
handler: async (args: Record<string, any>, ctx: ToolContext) => {
|
|
21
|
+
const profileId = ctx.profileId;
|
|
22
|
+
const threadId = String(args.thread_id).trim();
|
|
23
|
+
const category = String(args.category).trim();
|
|
24
|
+
|
|
25
|
+
await execute(
|
|
26
|
+
"UPDATE inbox_threads SET category = ?, updated_at = strftime('%s','now') WHERE id = ? AND profile_id = ?",
|
|
27
|
+
[category, threadId, profileId]
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
return { thread_id: threadId, category, status: 'updated' };
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'inbox_tool_set_state',
|
|
35
|
+
domain: 'inbox',
|
|
36
|
+
description: 'Transition an email thread state: open → snoozed, closed, or archived.',
|
|
37
|
+
inputSchema: {
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: {
|
|
40
|
+
thread_id: { type: 'string', description: 'Thread ID (e.g. th_...)' },
|
|
41
|
+
state: { type: 'string', enum: ['open', 'snoozed', 'closed', 'archived'], description: 'New thread state' },
|
|
42
|
+
},
|
|
43
|
+
required: ['thread_id', 'state'],
|
|
44
|
+
},
|
|
45
|
+
handler: async (args: Record<string, any>, ctx: ToolContext) => {
|
|
46
|
+
const profileId = ctx.profileId;
|
|
47
|
+
const threadId = String(args.thread_id).trim();
|
|
48
|
+
const state = String(args.state).trim();
|
|
49
|
+
|
|
50
|
+
await execute(
|
|
51
|
+
"UPDATE inbox_threads SET state = ?, updated_at = strftime('%s','now') WHERE id = ? AND profile_id = ?",
|
|
52
|
+
[state, threadId, profileId]
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
return { thread_id: threadId, state, status: 'updated' };
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'inbox_tool_add_label',
|
|
60
|
+
domain: 'inbox',
|
|
61
|
+
description: "Append a label tag to a thread's label list.",
|
|
62
|
+
inputSchema: {
|
|
63
|
+
type: 'object',
|
|
64
|
+
properties: {
|
|
65
|
+
thread_id: { type: 'string', description: 'Thread ID' },
|
|
66
|
+
label: { type: 'string', description: "Label to add (e.g. 'vip', 'follow-up')" },
|
|
67
|
+
},
|
|
68
|
+
required: ['thread_id', 'label'],
|
|
69
|
+
},
|
|
70
|
+
handler: async (args: Record<string, any>, ctx: ToolContext) => {
|
|
71
|
+
const profileId = ctx.profileId;
|
|
72
|
+
const threadId = String(args.thread_id).trim();
|
|
73
|
+
const label = String(args.label).trim();
|
|
74
|
+
|
|
75
|
+
const threads = await query<{ labels: string }>(
|
|
76
|
+
'SELECT labels FROM inbox_threads WHERE id = ? AND profile_id = ? LIMIT 1',
|
|
77
|
+
[threadId, profileId]
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
let labels: string[] = [];
|
|
81
|
+
if (threads.length > 0 && threads[0].labels) {
|
|
82
|
+
try {
|
|
83
|
+
labels = JSON.parse(threads[0].labels);
|
|
84
|
+
} catch {}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (!labels.includes(label)) {
|
|
88
|
+
labels.push(label);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
await execute(
|
|
92
|
+
"UPDATE inbox_threads SET labels = ?, updated_at = strftime('%s','now') WHERE id = ? AND profile_id = ?",
|
|
93
|
+
[JSON.stringify(labels), threadId, profileId]
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
return { thread_id: threadId, labels, status: 'updated' };
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'inbox_tool_link_entity',
|
|
101
|
+
domain: 'inbox',
|
|
102
|
+
description: 'Link an email thread to a CRM entity such as a contact, deal, or order.',
|
|
103
|
+
inputSchema: {
|
|
104
|
+
type: 'object',
|
|
105
|
+
properties: {
|
|
106
|
+
thread_id: { type: 'string', description: 'Thread ID' },
|
|
107
|
+
entity_type: { type: 'string', description: "Entity type (e.g. 'contact', 'deal', 'order')" },
|
|
108
|
+
entity_id: { type: 'string', description: 'Entity ID (e.g. ct_..., deal_...)' },
|
|
109
|
+
},
|
|
110
|
+
required: ['thread_id', 'entity_type', 'entity_id'],
|
|
111
|
+
},
|
|
112
|
+
handler: async (args: Record<string, any>, ctx: ToolContext) => {
|
|
113
|
+
const profileId = ctx.profileId;
|
|
114
|
+
const threadId = String(args.thread_id).trim();
|
|
115
|
+
const entityType = String(args.entity_type).trim();
|
|
116
|
+
const entityId = String(args.entity_id).trim();
|
|
117
|
+
|
|
118
|
+
await execute(
|
|
119
|
+
"UPDATE inbox_threads SET entity_type = ?, entity_id = ?, updated_at = strftime('%s','now') WHERE id = ? AND profile_id = ?",
|
|
120
|
+
[entityType, entityId, threadId, profileId]
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
return { thread_id: threadId, entity_type: entityType, entity_id: entityId, status: 'linked' };
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: 'inbox_tool_draft_reply',
|
|
128
|
+
domain: 'inbox',
|
|
129
|
+
description: 'Draft an outbound email reply stored with author=agent.',
|
|
130
|
+
inputSchema: {
|
|
131
|
+
type: 'object',
|
|
132
|
+
properties: {
|
|
133
|
+
thread_id: { type: 'string', description: 'Thread ID to reply to' },
|
|
134
|
+
mailbox_id: { type: 'string', description: 'Mailbox ID to send from' },
|
|
135
|
+
body: { type: 'string', description: 'Email body text' },
|
|
136
|
+
subject: { type: 'string', description: "Email subject line (default: 'Re:')" },
|
|
137
|
+
to_addrs: { type: 'string', description: 'Comma-separated recipient addresses' },
|
|
138
|
+
},
|
|
139
|
+
required: ['thread_id', 'mailbox_id', 'body'],
|
|
140
|
+
},
|
|
141
|
+
handler: async (args: Record<string, any>, ctx: ToolContext) => {
|
|
142
|
+
const profileId = ctx.profileId;
|
|
143
|
+
const msgId = generateId('msg');
|
|
144
|
+
const threadId = String(args.thread_id).trim();
|
|
145
|
+
const mailboxId = String(args.mailbox_id).trim();
|
|
146
|
+
const body = String(args.body);
|
|
147
|
+
const subject = String(args.subject || 'Re:');
|
|
148
|
+
const toAddrs = String(args.to_addrs || '');
|
|
149
|
+
|
|
150
|
+
await execute(
|
|
151
|
+
`INSERT INTO inbox_messages
|
|
152
|
+
(id, profile_id, thread_id, mailbox_id, direction, author, subject, body_html, to_addrs, state, created_at, updated_at)
|
|
153
|
+
VALUES (?, ?, ?, ?, 'outbound', 'agent', ?, ?, ?, 'draft', strftime('%s','now'), strftime('%s','now'))`,
|
|
154
|
+
[msgId, profileId, threadId, mailboxId, subject, body, toAddrs]
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
message_id: msgId,
|
|
159
|
+
thread_id: threadId,
|
|
160
|
+
status: 'draft_created',
|
|
161
|
+
author: 'agent',
|
|
162
|
+
};
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: 'inbox_tool_schedule_send',
|
|
167
|
+
domain: 'inbox',
|
|
168
|
+
description: 'Schedule a draft message to be sent at a future Unix timestamp.',
|
|
169
|
+
inputSchema: {
|
|
170
|
+
type: 'object',
|
|
171
|
+
properties: {
|
|
172
|
+
message_id: { type: 'string', description: 'Draft message ID' },
|
|
173
|
+
send_after: { type: 'integer', description: 'Unix timestamp (seconds) when to send' },
|
|
174
|
+
},
|
|
175
|
+
required: ['message_id', 'send_after'],
|
|
176
|
+
},
|
|
177
|
+
handler: async (args: Record<string, any>, ctx: ToolContext) => {
|
|
178
|
+
const profileId = ctx.profileId;
|
|
179
|
+
const msgId = String(args.message_id).trim();
|
|
180
|
+
const sendAfter = Number(args.send_after);
|
|
181
|
+
|
|
182
|
+
await execute(
|
|
183
|
+
"UPDATE inbox_messages SET send_after = ?, state = 'scheduled', updated_at = strftime('%s','now') WHERE id = ? AND profile_id = ?",
|
|
184
|
+
[sendAfter, msgId, profileId]
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
return { message_id: msgId, send_after: sendAfter, status: 'scheduled' };
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
name: 'inbox_tool_archive',
|
|
192
|
+
domain: 'inbox',
|
|
193
|
+
description: 'Archive an email thread — sets state=archived.',
|
|
194
|
+
inputSchema: {
|
|
195
|
+
type: 'object',
|
|
196
|
+
properties: {
|
|
197
|
+
thread_id: { type: 'string', description: 'Thread ID to archive' },
|
|
198
|
+
},
|
|
199
|
+
required: ['thread_id'],
|
|
200
|
+
},
|
|
201
|
+
handler: async (args: Record<string, any>, ctx: ToolContext) => {
|
|
202
|
+
const profileId = ctx.profileId;
|
|
203
|
+
const threadId = String(args.thread_id).trim();
|
|
204
|
+
|
|
205
|
+
await execute(
|
|
206
|
+
"UPDATE inbox_threads SET state = 'archived', updated_at = strftime('%s','now') WHERE id = ? AND profile_id = ?",
|
|
207
|
+
[threadId, profileId]
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
return { thread_id: threadId, status: 'archived' };
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: 'inbox_tool_extract_verification_code',
|
|
215
|
+
domain: 'inbox',
|
|
216
|
+
description: 'Extract an OTP, PIN, or verification code from the latest inbound message in a thread.',
|
|
217
|
+
inputSchema: {
|
|
218
|
+
type: 'object',
|
|
219
|
+
properties: {
|
|
220
|
+
thread_id: { type: 'string', description: 'Thread ID to scan for verification codes' },
|
|
221
|
+
},
|
|
222
|
+
required: ['thread_id'],
|
|
223
|
+
},
|
|
224
|
+
handler: async (args: Record<string, any>, ctx: ToolContext) => {
|
|
225
|
+
const profileId = ctx.profileId;
|
|
226
|
+
const threadId = String(args.thread_id).trim();
|
|
227
|
+
|
|
228
|
+
const msgs = await query<{ body_html: string }>(
|
|
229
|
+
"SELECT body_html FROM inbox_messages WHERE thread_id = ? AND profile_id = ? AND direction = 'inbound' ORDER BY created_at DESC LIMIT 1",
|
|
230
|
+
[threadId, profileId]
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
if (msgs.length === 0) {
|
|
234
|
+
return { thread_id: threadId, code: null, message: 'No inbound messages found in thread' };
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const text = msgs[0].body_html || '';
|
|
238
|
+
// Common OTP patterns (4-8 digits)
|
|
239
|
+
const match = text.match(/\b(?:\d{4}|\d{6}|\d{8})\b/);
|
|
240
|
+
|
|
241
|
+
return {
|
|
242
|
+
thread_id: threadId,
|
|
243
|
+
code: match ? match[0] : null,
|
|
244
|
+
};
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
name: 'inbox_tool_save_attachments',
|
|
249
|
+
domain: 'inbox',
|
|
250
|
+
description: 'Flag all attachments on a message to be auto-filed into the media library.',
|
|
251
|
+
inputSchema: {
|
|
252
|
+
type: 'object',
|
|
253
|
+
properties: {
|
|
254
|
+
message_id: { type: 'string', description: 'Message ID whose attachments should be filed' },
|
|
255
|
+
},
|
|
256
|
+
required: ['message_id'],
|
|
257
|
+
},
|
|
258
|
+
handler: async (args: Record<string, any>, ctx: ToolContext) => {
|
|
259
|
+
const profileId = ctx.profileId;
|
|
260
|
+
const messageId = String(args.message_id).trim();
|
|
261
|
+
|
|
262
|
+
await execute(
|
|
263
|
+
"UPDATE inbox_attachments SET storage = 'media' WHERE message_id = ? AND profile_id = ?",
|
|
264
|
+
[messageId, profileId]
|
|
265
|
+
);
|
|
266
|
+
|
|
267
|
+
return { message_id: messageId, status: 'attachments_filed' };
|
|
268
|
+
},
|
|
269
|
+
},
|
|
270
|
+
];
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// src/tools/index.ts
|
|
2
|
+
// Aggregated BusinessKit MCP Tool Registry
|
|
3
|
+
|
|
4
|
+
import { shopTools } from './shop.js';
|
|
5
|
+
import { crmTools } from './crm.js';
|
|
6
|
+
import { contentTools } from './content.js';
|
|
7
|
+
import { pagesTools } from './pages.js';
|
|
8
|
+
import { domainTools } from './domains.js';
|
|
9
|
+
import { inboxTools } from './inbox.js';
|
|
10
|
+
import { systemTools } from './system.js';
|
|
11
|
+
import { getActiveProfileId, isDbConfigured, isDbReadOnly } from '../db.js';
|
|
12
|
+
import type { ToolDefinition, ToolContext } from './types.js';
|
|
13
|
+
|
|
14
|
+
export * from './types.js';
|
|
15
|
+
|
|
16
|
+
export const allTools: ToolDefinition[] = [
|
|
17
|
+
...shopTools,
|
|
18
|
+
...crmTools,
|
|
19
|
+
...contentTools,
|
|
20
|
+
...pagesTools,
|
|
21
|
+
...domainTools,
|
|
22
|
+
...inboxTools,
|
|
23
|
+
...systemTools,
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
const toolMap = new Map<string, ToolDefinition>();
|
|
27
|
+
for (const tool of allTools) {
|
|
28
|
+
toolMap.set(tool.name, tool);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const WRITE_TOOLS = new Set([
|
|
32
|
+
'inventory_receive_purchase_invoice',
|
|
33
|
+
'product_update_pricing',
|
|
34
|
+
'inventory_add_stock',
|
|
35
|
+
'invoice_create',
|
|
36
|
+
'invoice_send',
|
|
37
|
+
'shop_create_new_bill',
|
|
38
|
+
'contact_create',
|
|
39
|
+
'contact_update',
|
|
40
|
+
'crm_log_activity',
|
|
41
|
+
'crm_add_note',
|
|
42
|
+
'crm_create_task',
|
|
43
|
+
'crm_add_tag',
|
|
44
|
+
'crm_create_contact_from_mail',
|
|
45
|
+
'crm_propose_deal',
|
|
46
|
+
'crm_update_deal_stage',
|
|
47
|
+
'crm_merge_contacts',
|
|
48
|
+
'crm_create_proposal_draft',
|
|
49
|
+
'crm_draft_followup',
|
|
50
|
+
'crm_draft_payment_chase',
|
|
51
|
+
'crm_set_stages',
|
|
52
|
+
'crm_create_group',
|
|
53
|
+
'crm_add_to_group',
|
|
54
|
+
'crm_create_template',
|
|
55
|
+
'blog_post_create',
|
|
56
|
+
'content_update',
|
|
57
|
+
'page_create',
|
|
58
|
+
'page_update',
|
|
59
|
+
'page_publish',
|
|
60
|
+
'component_create',
|
|
61
|
+
'domain_set_agent_notes',
|
|
62
|
+
'inbox_tool_set_category',
|
|
63
|
+
'inbox_tool_set_state',
|
|
64
|
+
'inbox_tool_add_label',
|
|
65
|
+
'inbox_tool_link_entity',
|
|
66
|
+
'inbox_tool_draft_reply',
|
|
67
|
+
'inbox_tool_schedule_send',
|
|
68
|
+
'inbox_tool_archive',
|
|
69
|
+
'inbox_tool_save_attachments',
|
|
70
|
+
'profile_switch',
|
|
71
|
+
]);
|
|
72
|
+
|
|
73
|
+
export function getToolDefinition(name: string): ToolDefinition | undefined {
|
|
74
|
+
return toolMap.get(name);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function getAllToolDefinitions() {
|
|
78
|
+
return allTools.map((t) => ({
|
|
79
|
+
name: t.name,
|
|
80
|
+
description: t.description,
|
|
81
|
+
inputSchema: t.inputSchema,
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export async function dispatchTool(name: string, args: Record<string, any>): Promise<any> {
|
|
86
|
+
const tool = toolMap.get(name);
|
|
87
|
+
if (!tool) {
|
|
88
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Tools that don't need database connection
|
|
92
|
+
const offlineTools = ['system_get_capabilities', 'page_get_section_schema'];
|
|
93
|
+
if (offlineTools.includes(name)) {
|
|
94
|
+
return await tool.handler(args, { profileId: 'system' });
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (!isDbConfigured()) {
|
|
98
|
+
throw new Error(
|
|
99
|
+
`Database connection not configured. To execute '${name}', please set TURSO_DATABASE_URL and TURSO_AUTH_TOKEN in your .env file or environment variables.`
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Enforce read-only token on write operations immediately
|
|
104
|
+
if (WRITE_TOOLS.has(name) && isDbReadOnly()) {
|
|
105
|
+
throw new Error(
|
|
106
|
+
`Operation rejected: Database is connected in read-only mode (read-only token). Write tool '${name}' is disabled.`
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const profileId = await getActiveProfileId();
|
|
111
|
+
const ctx: ToolContext = {
|
|
112
|
+
profileId,
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
return await tool.handler(args, ctx);
|
|
116
|
+
}
|