stagent 0.6.2 → 0.7.0

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.
Files changed (176) hide show
  1. package/README.md +21 -2
  2. package/dist/cli.js +272 -1
  3. package/docs/.coverage-gaps.json +66 -16
  4. package/docs/.last-generated +1 -1
  5. package/docs/features/dashboard-kanban.md +13 -7
  6. package/docs/features/settings.md +15 -3
  7. package/docs/features/tables.md +122 -0
  8. package/docs/index.md +3 -2
  9. package/docs/journeys/developer.md +26 -16
  10. package/docs/journeys/personal-use.md +23 -9
  11. package/docs/journeys/power-user.md +40 -14
  12. package/docs/journeys/work-use.md +43 -15
  13. package/docs/manifest.json +27 -17
  14. package/package.json +3 -2
  15. package/src/app/api/chat/entities/search/route.ts +12 -3
  16. package/src/app/api/documents/[id]/route.ts +5 -1
  17. package/src/app/api/documents/[id]/versions/route.ts +53 -0
  18. package/src/app/api/documents/route.ts +5 -1
  19. package/src/app/api/projects/[id]/documents/route.ts +124 -0
  20. package/src/app/api/projects/[id]/route.ts +72 -3
  21. package/src/app/api/projects/__tests__/delete-project.test.ts +13 -0
  22. package/src/app/api/schedules/route.ts +19 -1
  23. package/src/app/api/snapshots/[id]/restore/route.ts +62 -0
  24. package/src/app/api/snapshots/[id]/route.ts +44 -0
  25. package/src/app/api/snapshots/route.ts +54 -0
  26. package/src/app/api/snapshots/settings/route.ts +67 -0
  27. package/src/app/api/tables/[id]/charts/[chartId]/route.ts +89 -0
  28. package/src/app/api/tables/[id]/charts/route.ts +72 -0
  29. package/src/app/api/tables/[id]/columns/route.ts +70 -0
  30. package/src/app/api/tables/[id]/export/route.ts +94 -0
  31. package/src/app/api/tables/[id]/history/route.ts +15 -0
  32. package/src/app/api/tables/[id]/import/route.ts +111 -0
  33. package/src/app/api/tables/[id]/route.ts +86 -0
  34. package/src/app/api/tables/[id]/rows/[rowId]/history/route.ts +32 -0
  35. package/src/app/api/tables/[id]/rows/[rowId]/route.ts +51 -0
  36. package/src/app/api/tables/[id]/rows/route.ts +101 -0
  37. package/src/app/api/tables/[id]/triggers/[triggerId]/route.ts +65 -0
  38. package/src/app/api/tables/[id]/triggers/route.ts +122 -0
  39. package/src/app/api/tables/route.ts +65 -0
  40. package/src/app/api/tables/templates/route.ts +92 -0
  41. package/src/app/api/tasks/[id]/route.ts +37 -2
  42. package/src/app/api/tasks/[id]/siblings/route.ts +48 -0
  43. package/src/app/api/tasks/route.ts +8 -9
  44. package/src/app/api/workflows/[id]/documents/route.ts +209 -0
  45. package/src/app/api/workflows/[id]/execute/route.ts +6 -2
  46. package/src/app/api/workflows/[id]/route.ts +16 -3
  47. package/src/app/api/workflows/[id]/status/route.ts +18 -2
  48. package/src/app/api/workflows/route.ts +13 -2
  49. package/src/app/documents/page.tsx +5 -1
  50. package/src/app/layout.tsx +0 -1
  51. package/src/app/manifest.ts +3 -3
  52. package/src/app/projects/[id]/page.tsx +62 -2
  53. package/src/app/settings/page.tsx +2 -0
  54. package/src/app/tables/[id]/page.tsx +67 -0
  55. package/src/app/tables/page.tsx +21 -0
  56. package/src/app/tables/templates/page.tsx +19 -0
  57. package/src/components/chat/chat-table-result.tsx +139 -0
  58. package/src/components/documents/document-browser.tsx +1 -1
  59. package/src/components/documents/document-chip-bar.tsx +17 -1
  60. package/src/components/documents/document-detail-view.tsx +51 -0
  61. package/src/components/documents/document-grid.tsx +5 -0
  62. package/src/components/documents/document-table.tsx +4 -0
  63. package/src/components/documents/types.ts +3 -0
  64. package/src/components/projects/project-form-sheet.tsx +109 -2
  65. package/src/components/schedules/schedule-form.tsx +91 -1
  66. package/src/components/settings/data-management-section.tsx +17 -12
  67. package/src/components/settings/database-snapshots-section.tsx +469 -0
  68. package/src/components/shared/app-sidebar.tsx +2 -0
  69. package/src/components/shared/document-picker-sheet.tsx +486 -0
  70. package/src/components/tables/table-browser.tsx +234 -0
  71. package/src/components/tables/table-cell-editor.tsx +226 -0
  72. package/src/components/tables/table-chart-builder.tsx +288 -0
  73. package/src/components/tables/table-chart-view.tsx +146 -0
  74. package/src/components/tables/table-column-header.tsx +103 -0
  75. package/src/components/tables/table-column-sheet.tsx +331 -0
  76. package/src/components/tables/table-create-sheet.tsx +240 -0
  77. package/src/components/tables/table-detail-sheet.tsx +144 -0
  78. package/src/components/tables/table-detail-tabs.tsx +278 -0
  79. package/src/components/tables/table-grid.tsx +61 -0
  80. package/src/components/tables/table-history-tab.tsx +148 -0
  81. package/src/components/tables/table-import-wizard.tsx +542 -0
  82. package/src/components/tables/table-list-table.tsx +95 -0
  83. package/src/components/tables/table-relation-combobox.tsx +217 -0
  84. package/src/components/tables/table-spreadsheet.tsx +499 -0
  85. package/src/components/tables/table-template-gallery.tsx +162 -0
  86. package/src/components/tables/table-template-preview.tsx +219 -0
  87. package/src/components/tables/table-toolbar.tsx +79 -0
  88. package/src/components/tables/table-triggers-tab.tsx +446 -0
  89. package/src/components/tables/types.ts +6 -0
  90. package/src/components/tables/use-spreadsheet-keys.ts +171 -0
  91. package/src/components/tables/utils.ts +29 -0
  92. package/src/components/tasks/task-card.tsx +8 -1
  93. package/src/components/tasks/task-create-panel.tsx +111 -14
  94. package/src/components/tasks/task-detail-view.tsx +47 -0
  95. package/src/components/tasks/task-edit-dialog.tsx +103 -2
  96. package/src/components/workflows/workflow-form-view.tsx +207 -7
  97. package/src/components/workflows/workflow-kanban-card.tsx +8 -1
  98. package/src/components/workflows/workflow-list.tsx +90 -45
  99. package/src/components/workflows/workflow-status-view.tsx +168 -23
  100. package/src/instrumentation.ts +3 -0
  101. package/src/lib/__tests__/npx-process-cwd.test.ts +17 -2
  102. package/src/lib/agents/__tests__/claude-agent.test.ts +5 -1
  103. package/src/lib/agents/claude-agent.ts +3 -1
  104. package/src/lib/agents/profiles/registry.ts +6 -3
  105. package/src/lib/agents/runtime/anthropic-direct.ts +29 -0
  106. package/src/lib/agents/runtime/openai-direct.ts +29 -0
  107. package/src/lib/book/__tests__/chapter-slugs.test.ts +80 -0
  108. package/src/lib/book/chapter-generator.ts +4 -19
  109. package/src/lib/book/chapter-mapping.ts +17 -0
  110. package/src/lib/book/content.ts +5 -16
  111. package/src/lib/book/update-detector.ts +3 -16
  112. package/src/lib/chat/engine.ts +1 -0
  113. package/src/lib/chat/stagent-tools.ts +2 -0
  114. package/src/lib/chat/system-prompt.ts +9 -1
  115. package/src/lib/chat/tool-catalog.ts +35 -0
  116. package/src/lib/chat/tools/settings-tools.ts +109 -0
  117. package/src/lib/chat/tools/table-tools.ts +955 -0
  118. package/src/lib/chat/tools/workflow-tools.ts +145 -2
  119. package/src/lib/constants/table-status.ts +68 -0
  120. package/src/lib/data/__tests__/clear.test.ts +1 -1
  121. package/src/lib/data/clear.ts +57 -0
  122. package/src/lib/data/seed-data/__tests__/profiles.test.ts +28 -23
  123. package/src/lib/data/seed-data/conversations.ts +350 -42
  124. package/src/lib/data/seed-data/documents.ts +564 -591
  125. package/src/lib/data/seed-data/learned-context.ts +101 -22
  126. package/src/lib/data/seed-data/notifications.ts +344 -70
  127. package/src/lib/data/seed-data/profile-test-results.ts +92 -11
  128. package/src/lib/data/seed-data/profiles.ts +144 -46
  129. package/src/lib/data/seed-data/projects.ts +50 -18
  130. package/src/lib/data/seed-data/repo-imports.ts +28 -13
  131. package/src/lib/data/seed-data/schedules.ts +208 -41
  132. package/src/lib/data/seed-data/table-templates.ts +234 -0
  133. package/src/lib/data/seed-data/tasks.ts +614 -116
  134. package/src/lib/data/seed-data/usage-ledger.ts +182 -103
  135. package/src/lib/data/seed-data/user-tables.ts +203 -0
  136. package/src/lib/data/seed-data/views.ts +52 -7
  137. package/src/lib/data/seed-data/workflows.ts +231 -84
  138. package/src/lib/data/seed.ts +55 -14
  139. package/src/lib/data/tables.ts +417 -0
  140. package/src/lib/db/bootstrap.ts +275 -0
  141. package/src/lib/db/index.ts +9 -0
  142. package/src/lib/db/migrations/0016_add_workflow_document_inputs.sql +13 -0
  143. package/src/lib/db/migrations/0017_add_document_picker_tables.sql +25 -0
  144. package/src/lib/db/migrations/0018_add_workflow_run_number.sql +2 -0
  145. package/src/lib/db/migrations/0019_add_tables_feature.sql +160 -0
  146. package/src/lib/db/migrations/0020_add_table_triggers.sql +19 -0
  147. package/src/lib/db/migrations/0021_add_row_history.sql +15 -0
  148. package/src/lib/db/schema.ts +445 -0
  149. package/src/lib/docs/reader.ts +2 -3
  150. package/src/lib/documents/context-builder.ts +75 -2
  151. package/src/lib/documents/document-resolver.ts +119 -0
  152. package/src/lib/documents/processors/spreadsheet.ts +2 -1
  153. package/src/lib/schedules/scheduler.ts +31 -1
  154. package/src/lib/snapshots/auto-backup.ts +132 -0
  155. package/src/lib/snapshots/retention.ts +64 -0
  156. package/src/lib/snapshots/snapshot-manager.ts +429 -0
  157. package/src/lib/tables/computed.ts +61 -0
  158. package/src/lib/tables/context-builder.ts +139 -0
  159. package/src/lib/tables/formula-engine.ts +415 -0
  160. package/src/lib/tables/history.ts +115 -0
  161. package/src/lib/tables/import.ts +343 -0
  162. package/src/lib/tables/query-builder.ts +152 -0
  163. package/src/lib/tables/trigger-evaluator.ts +146 -0
  164. package/src/lib/tables/types.ts +141 -0
  165. package/src/lib/tables/validation.ts +119 -0
  166. package/src/lib/utils/app-root.ts +20 -0
  167. package/src/lib/utils/stagent-paths.ts +20 -0
  168. package/src/lib/validators/__tests__/task.test.ts +43 -10
  169. package/src/lib/validators/task.ts +7 -1
  170. package/src/lib/workflows/blueprints/registry.ts +3 -3
  171. package/src/lib/workflows/engine.ts +24 -8
  172. package/src/lib/workflows/types.ts +14 -0
  173. package/tsconfig.json +3 -1
  174. package/public/icon.svg +0 -13
  175. package/src/components/tasks/file-upload.tsx +0 -120
  176. /package/docs/features/{playbook.md → user-guide.md} +0 -0
@@ -28,168 +28,476 @@ export function createConversations(
28
28
  ): ConversationsResult {
29
29
  const now = Date.now();
30
30
  const DAY = 86_400_000;
31
- const HOUR = 3_600_000;
32
31
  const MIN = 60_000;
33
32
 
34
- const [investmentProject, launchProject, leadGenProject] = projectIds;
33
+ const [launchProject, contentProject, csProject, tvpProject, greenleafProject, , revopsProject] = projectIds;
35
34
 
36
35
  const conv1Id = crypto.randomUUID();
37
36
  const conv2Id = crypto.randomUUID();
38
37
  const conv3Id = crypto.randomUUID();
38
+ const conv4Id = crypto.randomUUID();
39
+ const conv5Id = crypto.randomUUID();
40
+ const conv6Id = crypto.randomUUID();
39
41
 
40
42
  const conversations: ConversationSeed[] = [
41
43
  {
42
44
  id: conv1Id,
43
- projectId: investmentProject,
44
- title: "Portfolio rebalancing strategy",
45
+ projectId: launchProject,
46
+ title: "Launch copy strategy",
45
47
  runtimeId: "claude-agent-sdk",
46
48
  modelId: "claude-sonnet-4-5-20250514",
47
49
  status: "active",
48
- createdAt: new Date(now - 3 * DAY),
49
- updatedAt: new Date(now - 3 * DAY + 20 * MIN),
50
+ createdAt: new Date(now - 5 * DAY),
51
+ updatedAt: new Date(now - 5 * DAY + 30 * MIN),
50
52
  },
51
53
  {
52
54
  id: conv2Id,
53
- projectId: launchProject,
54
- title: "Landing page headline options",
55
+ projectId: contentProject,
56
+ title: "SEO content plan for Q2",
55
57
  runtimeId: "claude-agent-sdk",
56
58
  modelId: "claude-sonnet-4-5-20250514",
57
59
  status: "active",
58
- createdAt: new Date(now - 1 * DAY),
59
- updatedAt: new Date(now - 1 * DAY + 15 * MIN),
60
+ createdAt: new Date(now - 3 * DAY),
61
+ updatedAt: new Date(now - 3 * DAY + 25 * MIN),
60
62
  },
61
63
  {
62
64
  id: conv3Id,
63
- projectId: leadGenProject,
64
- title: "Outreach sequence review",
65
+ projectId: csProject,
66
+ title: "Churn risk for Enterprise accounts",
65
67
  runtimeId: "claude-agent-sdk",
66
68
  modelId: "claude-sonnet-4-5-20250514",
67
- status: "archived",
69
+ status: "active",
70
+ createdAt: new Date(now - 2 * DAY),
71
+ updatedAt: new Date(now - 2 * DAY + 20 * MIN),
72
+ },
73
+ {
74
+ id: conv4Id,
75
+ projectId: tvpProject,
76
+ title: "TechVenture due diligence scope",
77
+ runtimeId: "claude-agent-sdk",
78
+ modelId: "claude-sonnet-4-5-20250514",
79
+ status: "active",
68
80
  createdAt: new Date(now - 7 * DAY),
69
- updatedAt: new Date(now - 6 * DAY),
81
+ updatedAt: new Date(now - 7 * DAY + 35 * MIN),
82
+ },
83
+ {
84
+ id: conv5Id,
85
+ projectId: revopsProject,
86
+ title: "Deal review: Meridian Corp stall",
87
+ runtimeId: "claude-agent-sdk",
88
+ modelId: "claude-sonnet-4-5-20250514",
89
+ status: "active",
90
+ createdAt: new Date(now - 1 * DAY),
91
+ updatedAt: new Date(now - 1 * DAY + 40 * MIN),
92
+ },
93
+ {
94
+ id: conv6Id,
95
+ projectId: greenleafProject,
96
+ title: "Product listing A/B results",
97
+ runtimeId: "openai-codex-app-server",
98
+ modelId: "codex-mini-latest",
99
+ status: "archived",
100
+ createdAt: new Date(now - 10 * DAY),
101
+ updatedAt: new Date(now - 8 * DAY),
70
102
  },
71
103
  ];
72
104
 
73
105
  const messages: ChatMessageSeed[] = [
74
- // Conversation 1: Portfolio rebalancing
106
+ // ── Conv 1: Launch copy strategy (8 messages) ───────────────────
75
107
  {
76
108
  id: crypto.randomUUID(),
77
109
  conversationId: conv1Id,
78
110
  role: "user",
79
111
  content:
80
- "My tech allocation is at 42% after the recent rally. What's a sensible rebalancing target?",
112
+ "We need to finalize the hero headline for the v2 launch page. The 3 variants are: A) 'Your Business, Run by AI' B) 'Stop Stitching — Start Orchestrating' C) '52 Agents. One Command Center.' Which resonates best for mid-market ops buyers?",
81
113
  status: "complete",
82
- createdAt: new Date(now - 3 * DAY),
114
+ createdAt: new Date(now - 5 * DAY),
83
115
  },
84
116
  {
85
117
  id: crypto.randomUUID(),
86
118
  conversationId: conv1Id,
87
119
  role: "assistant",
88
120
  content:
89
- "A 42% tech concentration is elevated. For a growth-oriented portfolio, 30-35% is a common target. I'd suggest trimming in two tranches over the next month to reduce timing risk, starting with your most appreciated positions.",
121
+ "For mid-market ops buyers, I'd rank them: **A > B > C**.\n\nVariant A ('Your Business, Run by AI') works because it promises a business outcome, not a feature. Ops buyers think in terms of workflows and results, not agent counts.\n\nVariant B is strong but assumes the reader already knows about the 'stitching problem' — it requires context that cold traffic won't have.\n\nVariant C is impressive but speaks to engineers more than ops leaders. '52 agents' is a feature metric, not a benefit.\n\nRecommendation: A/B test A vs B. A for broad traffic, B for retargeting (they already know the problem).",
90
122
  status: "complete",
91
- createdAt: new Date(now - 3 * DAY + 2 * MIN),
123
+ createdAt: new Date(now - 5 * DAY + 2 * MIN),
92
124
  },
93
125
  {
94
126
  id: crypto.randomUUID(),
95
127
  conversationId: conv1Id,
96
128
  role: "user",
97
- content: "What sectors should I rotate into?",
129
+ content: "Good analysis. What about the supporting subheadline for variant A?",
98
130
  status: "complete",
99
- createdAt: new Date(now - 3 * DAY + 10 * MIN),
131
+ createdAt: new Date(now - 5 * DAY + 8 * MIN),
100
132
  },
101
133
  {
102
134
  id: crypto.randomUUID(),
103
135
  conversationId: conv1Id,
104
136
  role: "assistant",
105
137
  content:
106
- "Given your current underweight in healthcare (8%) and industrials (5%), those are natural recipients. Healthcare offers defensive characteristics while industrials give you cyclical upside. A 5% shift into each would bring you to a more balanced allocation.",
138
+ "For Variant A, the subheadline should bridge from the aspirational headline to a concrete capability. Two options:\n\n1. **Capability-led:** \"Orchestrate 52+ AI agents across marketing, sales, and ops — with governance, auditability, and one dashboard.\"\n\n2. **Pain-led:** \"Stop stitching together 15 tools. One platform to plan, build, run, and scale your AI operations.\"\n\nI'd go with #2 — it turns B's insight into supporting copy for A, giving you the best of both angles.",
107
139
  status: "complete",
108
- createdAt: new Date(now - 3 * DAY + 12 * MIN),
140
+ createdAt: new Date(now - 5 * DAY + 10 * MIN),
109
141
  },
110
142
  {
111
143
  id: crypto.randomUUID(),
112
144
  conversationId: conv1Id,
113
145
  role: "user",
114
- content: "Makes sense. Draft a rebalancing plan I can review this weekend.",
146
+ content: "Love it. Now draft the 3-email launch sequence Day 0 announcement, Day 3 deep dive, Day 7 social proof.",
115
147
  status: "complete",
116
- createdAt: new Date(now - 3 * DAY + 20 * MIN),
148
+ createdAt: new Date(now - 5 * DAY + 15 * MIN),
149
+ },
150
+ {
151
+ id: crypto.randomUUID(),
152
+ conversationId: conv1Id,
153
+ role: "assistant",
154
+ content:
155
+ "**Day 0 — Launch Announcement**\nSubject: \"Your Business, Run by AI — Stagent v2 is live\"\nHook: The gap between 'run this agent' and 'run my business' just closed.\nBody: Quick overview of what's new (multi-runtime, heartbeat scheduling, governed execution). CTA: Start free.\n\n**Day 3 — Feature Deep Dive**\nSubject: \"How 52 agents work together (without chaos)\"\nHook: Most AI tools add agents. We added orchestration.\nBody: Workflow patterns, governance model, cost controls. CTA: See it in action (2-min demo video).\n\n**Day 7 — Social Proof**\nSubject: \"A solo founder runs 3 businesses with Stagent\"\nHook: Meet Alex, who replaced 8 SaaS tools with one dashboard.\nBody: Before/after, specific workflows, time saved. CTA: Start your free trial.",
156
+ status: "complete",
157
+ createdAt: new Date(now - 5 * DAY + 18 * MIN),
158
+ },
159
+ {
160
+ id: crypto.randomUUID(),
161
+ conversationId: conv1Id,
162
+ role: "user",
163
+ content: "The Day 7 subject line is good but 'Alex' feels generic. Can we use a more specific persona?",
164
+ status: "complete",
165
+ createdAt: new Date(now - 5 * DAY + 25 * MIN),
166
+ },
167
+ {
168
+ id: crypto.randomUUID(),
169
+ conversationId: conv1Id,
170
+ role: "assistant",
171
+ content:
172
+ "Agreed — specificity builds trust. Revised options:\n\n1. \"How a DTC founder cut ops overhead by 60% with AI agents\"\n2. \"From 15 tools to 1: an agency owner's AI stack consolidation\"\n3. \"'I run my entire GTM with 12 agents' — a founder's story\"\n\n#3 is the strongest — it's specific, quotable, and the number '12 agents' makes it tangible without being overwhelming. It also targets our primary persona (solo founder doing GTM).",
173
+ status: "complete",
174
+ createdAt: new Date(now - 5 * DAY + 28 * MIN),
117
175
  },
118
176
 
119
- // Conversation 2: Landing page headlines
177
+ // ── Conv 2: SEO content plan (7 messages) ───────────────────────
120
178
  {
121
179
  id: crypto.randomUUID(),
122
180
  conversationId: conv2Id,
123
181
  role: "user",
124
182
  content:
125
- "We need three headline variants for the SaaS launch page. Target audience is mid-market ops teams.",
183
+ "Let's plan the Q2 content calendar. Our top keyword cluster is around 'AI agent orchestration' but we also need to cover governance and multi-runtime topics. What's the best sequencing?",
126
184
  status: "complete",
127
- createdAt: new Date(now - 1 * DAY),
185
+ createdAt: new Date(now - 3 * DAY),
128
186
  },
129
187
  {
130
188
  id: crypto.randomUUID(),
131
189
  conversationId: conv2Id,
132
190
  role: "assistant",
133
191
  content:
134
- 'Here are three angles:\n\n1. **Pain-led:** "Stop losing 12 hours a week to manual handoffs"\n2. **Outcome-led:** "Ship ops workflows in minutes, not sprints"\n3. **Social proof:** "Join 400+ ops teams that automated their first workflow in under a day"\n\nI\'d recommend A/B testing #1 vs #2 first pain-led headlines typically outperform on cold traffic.',
192
+ "Here's the recommended sequence based on keyword difficulty and topic dependencies:\n\n**Week 14:** \"AI Agent Orchestration Guide\" (KD 38, 2.4K vol) — pillar page, already published\n**Week 15:** \"Multi-Agent Workflows Explained\" (KD 42, 1.8K) — builds on the pillar\n**Week 16:** \"Governance for Agentic AI\" (KD 22, 890) — low competition, unique angle\n**Week 17:** \"AI Ops for Solo Founders\" (KD 30, 1.2K) — persona-specific\n**Week 18:** \"Heartbeat Scheduling Deep Dive\" (KD 12, 180) niche but high-intent\n\nThe logic: start with the highest-volume pillar, then branch into sub-topics that link back. Save niche pieces for later when the pillar is ranking.",
135
193
  status: "complete",
136
- createdAt: new Date(now - 1 * DAY + 3 * MIN),
194
+ createdAt: new Date(now - 3 * DAY + 3 * MIN),
137
195
  },
138
196
  {
139
197
  id: crypto.randomUUID(),
140
198
  conversationId: conv2Id,
141
199
  role: "user",
200
+ content: "The governance piece has low volume. Is it worth prioritizing?",
201
+ status: "complete",
202
+ createdAt: new Date(now - 3 * DAY + 8 * MIN),
203
+ },
204
+ {
205
+ id: crypto.randomUUID(),
206
+ conversationId: conv2Id,
207
+ role: "assistant",
142
208
  content:
143
- "I like #1 and #2. Can you write the supporting subheadline for each?",
209
+ "Great question. The volume is low but the strategic value is high for three reasons:\n\n1. **Zero competition** no one has written a comprehensive governance piece for agentic AI. We'd own the SERP.\n2. **High intent** — people searching 'agent governance' are evaluating platforms, not just learning. These are bottom-funnel keywords.\n3. **Differentiation** — governance is our moat. Publishing thought leadership here positions us as the authority before competitors catch up.\n\nI'd keep it in Week 16 but optimize for a long-tail cluster: 'AI agent governance framework', 'agent permission management', 'governed AI execution'.",
210
+ status: "complete",
211
+ createdAt: new Date(now - 3 * DAY + 11 * MIN),
212
+ },
213
+ {
214
+ id: crypto.randomUUID(),
215
+ conversationId: conv2Id,
216
+ role: "user",
217
+ content: "Convinced. What about distribution for these articles?",
144
218
  status: "complete",
145
- createdAt: new Date(now - 1 * DAY + 8 * MIN),
219
+ createdAt: new Date(now - 3 * DAY + 15 * MIN),
146
220
  },
147
221
  {
148
222
  id: crypto.randomUUID(),
149
223
  conversationId: conv2Id,
150
224
  role: "assistant",
151
225
  content:
152
- 'For #1: "Automate approvals, routing, and status updates across your stack no code required."\n\nFor #2: "Drag-and-drop workflow builder with 50+ integrations. Your team ships faster from day one."',
226
+ "Distribution matrix per article:\n\n- **LinkedIn** (all articles): Hook post + 3 takeaways, published same day as blog\n- **Newsletter** (all articles): Featured in weekly edition with editorial intro\n- **Dev.to** (technical pieces only: orchestration, multi-runtime): Cross-post 3 days after publish for backlink equity\n- **Twitter/X** (all articles): Thread format — 5 tweets per article\n- **Hacker News** (orchestration + governance): Submit with discussion-friendly title\n\nKey rule: LinkedIn posts go out at 8:30am ET Tuesday/Thursday for maximum engagement with our ops buyer persona.",
227
+ status: "complete",
228
+ createdAt: new Date(now - 3 * DAY + 18 * MIN),
229
+ },
230
+ {
231
+ id: crypto.randomUUID(),
232
+ conversationId: conv2Id,
233
+ role: "user",
234
+ content: "Perfect. Add this to the editorial calendar and set up the recurring content check-in schedule.",
153
235
  status: "complete",
154
- createdAt: new Date(now - 1 * DAY + 10 * MIN),
236
+ createdAt: new Date(now - 3 * DAY + 22 * MIN),
155
237
  },
156
238
 
157
- // Conversation 3: Outreach sequence (archived)
239
+ // ── Conv 3: Churn risk analysis (6 messages) ────────────────────
158
240
  {
159
241
  id: crypto.randomUUID(),
160
242
  conversationId: conv3Id,
161
243
  role: "user",
244
+ content: "We just got the Q1 NPS results back. Several enterprise accounts dropped significantly. Can you analyze the churn risk across the cohort?",
245
+ status: "complete",
246
+ createdAt: new Date(now - 2 * DAY),
247
+ },
248
+ {
249
+ id: crypto.randomUUID(),
250
+ conversationId: conv3Id,
251
+ role: "assistant",
162
252
  content:
163
- "Review our 5-step outreach sequence. Open rates are good but reply rates dropped below 3%.",
253
+ "I've analyzed the Q1 cohort (47 accounts). Here's the breakdown:\n\n**Green (healthy):** 31 accounts (66%) — regular usage, NPS 50+\n**Yellow (watch):** 11 accounts (23%) — reduced activity or NPS 30-50\n**Red (at-risk):** 5 accounts (11%) — significant churn signals\n\nThe 5 red accounts:\n1. **BrightPath** NPS dropped to 28, no login in 19 days, 5 open tickets\n2. **TechStart** — NPS 22, no login in 34 days, 6 tickets (likely already churned)\n3. **NexaPay** — NPS 38 (declining), onboarding stalled at Day 3\n4. **DataFlow AI** — NPS 45 but 3 tickets this week (spike)\n5. **Meridian Corp** — NPS 42, login gap growing\n\nCommon pattern: **no workflow created by Day 7** correlates with churn at 82%.",
164
254
  status: "complete",
165
- createdAt: new Date(now - 7 * DAY),
255
+ createdAt: new Date(now - 2 * DAY + 3 * MIN),
256
+ },
257
+ {
258
+ id: crypto.randomUUID(),
259
+ conversationId: conv3Id,
260
+ role: "user",
261
+ content: "That Day 7 workflow insight is huge. Can we use it as an early warning trigger?",
262
+ status: "complete",
263
+ createdAt: new Date(now - 2 * DAY + 8 * MIN),
166
264
  },
167
265
  {
168
266
  id: crypto.randomUUID(),
169
267
  conversationId: conv3Id,
170
268
  role: "assistant",
171
269
  content:
172
- "The main issue is steps 3-5they repeat the value prop without adding new information. Each follow-up should introduce a distinct proof point: a case study, a metric, or a relevant trigger event. I'd also shorten step 4 to under 50 words brevity drives replies in later sequence steps.",
270
+ "Absolutely I'd recommend a two-tier early warning system:\n\n**Tier 1 Day 5 (soft nudge):** If no workflow created by Day 5, send a targeted email: 'Build your first workflow in 3 minutes' with a template gallery link. This gives them 2 days before the critical threshold.\n\n**Tier 2 — Day 7 (CSM outreach):** If still no workflow, auto-create a task for the assigned CSM: 'Schedule onboarding call account has not created first workflow.' Include the account health data.\n\nThis catches 82% of potential churners before they disengage. We can configure this as a heartbeat schedule that evaluates daily.",
173
271
  status: "complete",
174
- createdAt: new Date(now - 7 * DAY + 4 * MIN),
272
+ createdAt: new Date(now - 2 * DAY + 11 * MIN),
175
273
  },
176
274
  {
177
275
  id: crypto.randomUUID(),
178
276
  conversationId: conv3Id,
179
277
  role: "user",
180
- content: "Rewrite steps 3-5 with that approach.",
278
+ content: "What about the 5 red accounts right now? What's the rescue plan?",
181
279
  status: "complete",
182
- createdAt: new Date(now - 7 * DAY + 12 * MIN),
280
+ createdAt: new Date(now - 2 * DAY + 15 * MIN),
183
281
  },
184
282
  {
185
283
  id: crypto.randomUUID(),
186
284
  conversationId: conv3Id,
187
285
  role: "assistant",
188
286
  content:
189
- '**Step 3 (Day 5):** "Quick note[Company] cut their approval cycle from 3 days to 4 hours with our workflow builder. Worth a 15-min look?"\n\n**Step 4 (Day 8):** "Saw your team just posted a RevOps role. Happy to share how others automated that work instead."\n\n**Step 5 (Day 12):** "Last reach-outhere\'s a 2-min demo showing the exact workflow your peers use. [link]"',
287
+ "Here's the triage plan by urgency:\n\n1. **TechStart** (34 days no login)likely gone. Send a 'we miss you' email with a re-activation offer. If no response in 5 days, tag as lost.\n2. **BrightPath** (19 days, 5 tickets) — active issues driving disengagement. Escalate to CS manager for personal call + ticket fast-track.\n3. **NexaPay** (stalled onboarding) — book a 30-min guided setup session this week. They need hands-on help.\n4. **DataFlow AI** (ticket spike) investigate the 3 tickets — could be a bug. If product issue, escalate to eng; if confusion, send a focused tutorial.\n5. **Meridian Corp** (growing gap) proactive NPS follow-up call. Their NPS is 42 still recoverable with attention.\n\nI can create tasks for each intervention and assign to the right CSM. Want me to proceed?",
288
+ status: "complete",
289
+ createdAt: new Date(now - 2 * DAY + 18 * MIN),
290
+ },
291
+
292
+ // ── Conv 4: TechVenture DD scope (8 messages) ───────────────────
293
+ {
294
+ id: crypto.randomUUID(),
295
+ conversationId: conv4Id,
296
+ role: "user",
297
+ content: "We're looking at HealthSync as a potential investment. They're an AI-powered scheduling platform for healthcare. Can you help scope the due diligence?",
298
+ status: "complete",
299
+ createdAt: new Date(now - 7 * DAY),
300
+ },
301
+ {
302
+ id: crypto.randomUUID(),
303
+ conversationId: conv4Id,
304
+ role: "assistant",
305
+ content:
306
+ "Happy to help scope this. For a healthcare AI investment, I'd recommend a 5-phase DD framework:\n\n1. **Financial deep dive** — ARR, margins, retention, burn rate (3 years)\n2. **Market sizing** — TAM/SAM/SOM for AI healthcare scheduling\n3. **Competitive positioning** — incumbent analysis, switching costs, moat\n4. **Regulatory assessment** — HIPAA compliance, data handling, liability\n5. **Team & tech evaluation** — founding team, tech stack, IP\n\nWhat's the investment thesis driving this? That'll help me prioritize which areas go deepest.",
307
+ status: "complete",
308
+ createdAt: new Date(now - 7 * DAY + 2 * MIN),
309
+ },
310
+ {
311
+ id: crypto.randomUUID(),
312
+ conversationId: conv4Id,
313
+ role: "user",
314
+ content: "The thesis is that AI-native scheduling can reduce no-shows by 30%+ and that's a massive cost savings for practices. They claim 35% reduction.",
315
+ status: "complete",
316
+ createdAt: new Date(now - 7 * DAY + 6 * MIN),
317
+ },
318
+ {
319
+ id: crypto.randomUUID(),
320
+ conversationId: conv4Id,
321
+ role: "assistant",
322
+ content:
323
+ "That's a strong thesis. No-shows cost the US healthcare system $150B annually, so a 35% reduction is a compelling value prop.\n\nTo validate this, I'll need:\n- **Cohort data**: Is the 35% sustained across different practice types, or only for specific specialties?\n- **Methodology**: How is it measured? Before/after on the same practice vs. benchmark comparison?\n- **Retention signal**: Practices that see 35% reduction should have exceptional retention. Let's check net retention as a proxy.\n\nI'll prioritize the financial deep dive and market sizing first. Regulatory can run in parallel since it's mostly checkbox verification for a SOC 2 / HIPAA BAA company.",
324
+ status: "complete",
325
+ createdAt: new Date(now - 7 * DAY + 9 * MIN),
326
+ },
327
+ {
328
+ id: crypto.randomUUID(),
329
+ conversationId: conv4Id,
330
+ role: "user",
331
+ content: "They shared a data room. Here's the financial package — 3 years of quarterlies.",
190
332
  status: "complete",
191
333
  createdAt: new Date(now - 7 * DAY + 15 * MIN),
192
334
  },
335
+ {
336
+ id: crypto.randomUUID(),
337
+ conversationId: conv4Id,
338
+ role: "assistant",
339
+ content:
340
+ "I've reviewed the financial package. Initial findings:\n\n- **ARR trajectory**: $3.2M → $8.2M over 9 quarters (42% YoY, strong)\n- **Gross margin**: Improved from 74% to 78% (good leverage)\n- **Net retention**: 118% (excellent — expansion revenue from existing accounts)\n- **Burn**: $380K/mo, 14-month runway (needs funding or profitability path)\n- **Concern**: Average contract value declining ($76K → $59K) — could indicate SMB drift\n\nThe declining ACV is worth investigating. If they're moving downmarket, the no-show reduction claim needs to hold for smaller practices too. I'll model three scenarios next.",
341
+ status: "complete",
342
+ createdAt: new Date(now - 7 * DAY + 20 * MIN),
343
+ },
344
+ {
345
+ id: crypto.randomUUID(),
346
+ conversationId: conv4Id,
347
+ role: "user",
348
+ content: "Good catch on the ACV decline. Can you also check customer concentration risk? I've heard their top accounts are heavy.",
349
+ status: "complete",
350
+ createdAt: new Date(now - 7 * DAY + 28 * MIN),
351
+ },
352
+ {
353
+ id: crypto.randomUUID(),
354
+ conversationId: conv4Id,
355
+ role: "assistant",
356
+ content:
357
+ "Customer concentration is indeed a risk. From the data room:\n\n- **Top 5 accounts = 62% of ARR** ($5.1M of $8.2M)\n- **Largest account = 18% of ARR** ($1.5M — a large health system)\n- **Top 10 = 78% of ARR**\n\nThis is elevated. Best practice for a Series B company is top 5 under 40%. They need a logo diversification plan.\n\nHowever, the 118% net retention partially mitigates this — existing accounts are expanding, suggesting deep product fit. The risk is binary: lose a top-5 account and you lose 10-18% of ARR overnight.\n\nI'll include this as Risk #1 in the DD memo with a recommended condition: 'Invest at $45M with condition that they add 3 new enterprise logos in 6 months to de-risk concentration.'",
358
+ status: "complete",
359
+ createdAt: new Date(now - 7 * DAY + 32 * MIN),
360
+ },
361
+
362
+ // ── Conv 5: Deal review — Meridian stall (9 messages) ───────────
363
+ {
364
+ id: crypto.randomUUID(),
365
+ conversationId: conv5Id,
366
+ role: "user",
367
+ content: "Meridian Corp deal has been stalled for 12 days. It's a $220K opportunity. What's going on and how do we rescue it?",
368
+ status: "complete",
369
+ createdAt: new Date(now - 1 * DAY),
370
+ },
371
+ {
372
+ id: crypto.randomUUID(),
373
+ conversationId: conv5Id,
374
+ role: "assistant",
375
+ content:
376
+ "Let me pull the activity data for Meridian Corp.\n\n**Deal details:**\n- Amount: $220K | Stage: Proposal | Owner: Sarah K\n- Days in stage: 12 (avg for this stage is 6)\n- Last activity: Email sent March 22, no reply\n- Champion: VP Ops, Jennifer Torres\n- Decision-maker: CTO, absent from last 2 calls\n\n**Red flags:**\n1. Champion hasn't opened last 2 emails (possible OOO or disengagement)\n2. CTO hasn't attended since the demo — may not be bought in\n3. No defined next step in CRM\n\nThis looks like a champion-goes-dark + missing executive sponsor pattern. Very recoverable but needs immediate action.",
377
+ status: "complete",
378
+ createdAt: new Date(now - 1 * DAY + 2 * MIN),
379
+ },
380
+ {
381
+ id: crypto.randomUUID(),
382
+ conversationId: conv5Id,
383
+ role: "user",
384
+ content: "What's the rescue playbook for this pattern?",
385
+ status: "complete",
386
+ createdAt: new Date(now - 1 * DAY + 6 * MIN),
387
+ },
388
+ {
389
+ id: crypto.randomUUID(),
390
+ conversationId: conv5Id,
391
+ role: "assistant",
392
+ content:
393
+ "Three-step rescue for champion-dark + missing exec:\n\n**Step 1 — Multi-channel reach (today):**\nSend Jennifer a brief LinkedIn message: 'Quick check — noticed our last few emails may have gotten buried. Happy to reconnect when timing is right.' This bypasses a full inbox.\n\n**Step 2 — Executive air cover (this week):**\nHave your VP of Sales reach out to Meridian's CTO directly. Peer-to-peer outreach works 3x better than rep-to-exec. Frame it as: 'I noticed our teams have been talking — wanted to personally make sure we're aligned on the value.'\n\n**Step 3 — Value reinforcement (within 48h):**\nSend Jennifer a short case study relevant to her team's pain point. Don't ask for a meeting — just provide value. If she engages, propose a 15-min recap call.\n\n**If no response in 5 business days:** Escalate to deal qualification review. A $220K deal with no champion response for 17+ days may need to be moved to pipeline at risk.",
394
+ status: "complete",
395
+ createdAt: new Date(now - 1 * DAY + 9 * MIN),
396
+ },
397
+ {
398
+ id: crypto.randomUUID(),
399
+ conversationId: conv5Id,
400
+ role: "user",
401
+ content: "Good plan. Draft the LinkedIn message for Sarah to send.",
402
+ status: "complete",
403
+ createdAt: new Date(now - 1 * DAY + 14 * MIN),
404
+ },
405
+ {
406
+ id: crypto.randomUUID(),
407
+ conversationId: conv5Id,
408
+ role: "assistant",
409
+ content:
410
+ "Here's the LinkedIn message for Sarah:\n\n---\n\n\"Hi Jennifer — hope you're having a good week. I wanted to pop over here in case my emails got lost in the mix. We'd put together a proposal based on your team's workflow needs and I want to make sure it's still on your radar.\n\nNo rush at all — if timing has shifted, I totally understand. Just let me know if it makes sense to reconnect, even for a quick 10 minutes.\n\nLooking forward to hearing from you!\"\n\n---\n\n**Why this works:** Casual tone (LinkedIn ≠ email formality), acknowledges she might be busy without being pushy, low commitment ask (10 min), and positions the ball in her court.",
411
+ status: "complete",
412
+ createdAt: new Date(now - 1 * DAY + 16 * MIN),
413
+ },
414
+ {
415
+ id: crypto.randomUUID(),
416
+ conversationId: conv5Id,
417
+ role: "user",
418
+ content: "Now draft the VP-to-CTO email for the executive air cover.",
419
+ status: "complete",
420
+ createdAt: new Date(now - 1 * DAY + 22 * MIN),
421
+ },
422
+ {
423
+ id: crypto.randomUUID(),
424
+ conversationId: conv5Id,
425
+ role: "assistant",
426
+ content:
427
+ "Here's the VP-to-CTO outreach:\n\n---\n\nSubject: Quick question about your AI ops evaluation\n\nHi [CTO name],\n\nI noticed our teams have been in conversation about how Stagent could support Meridian's operations team. Wanted to personally reach out — our VP Ops champions tend to see the most value when there's alignment at the technology leadership level too.\n\nWould you have 15 minutes this week for a quick technical overview? Happy to focus specifically on the governance and security model, which I know matters for CTO-level sign-off.\n\nEither way, appreciate you considering us.\n\nBest,\n[VP Sales name]\n\n---\n\n**Coaching note for Sarah:** Time this 24 hours after the LinkedIn message to Jennifer. If Jennifer responds first, adjust the CTO email to reference her engagement.",
428
+ status: "complete",
429
+ createdAt: new Date(now - 1 * DAY + 25 * MIN),
430
+ },
431
+ {
432
+ id: crypto.randomUUID(),
433
+ conversationId: conv5Id,
434
+ role: "user",
435
+ content: "What should we do about the other stalled deals — Atlas Financial and Pinnacle Tech?",
436
+ status: "complete",
437
+ createdAt: new Date(now - 1 * DAY + 32 * MIN),
438
+ },
439
+ {
440
+ id: crypto.randomUUID(),
441
+ conversationId: conv5Id,
442
+ role: "assistant",
443
+ content:
444
+ "Different patterns, different plays:\n\n**Atlas Financial ($95K, competitive threat):**\n- They mentioned CrewAI in the last call. This is a competitive deal.\n- **Action:** Send the competitive battle card (Stagent vs CrewAI) to Mike R. Key differentiators: governance model, multi-runtime support, and enterprise audit trail — things CrewAI doesn't have.\n- **Timeline:** Demo focused on governance this week. If they're evaluating both, we need to be the last demo they see.\n\n**Pinnacle Tech ($65K, qualification concern):**\n- Close date pushed 3 times. No executive sponsor identified.\n- **Action:** Honest qualification check with Jordan L. Questions to answer: Is there budget? Is there a timeline? Is there a decision-maker we haven't met?\n- **Recommendation:** If the answer to any of those is 'no', move to nurture. A $65K deal that's been stalled for 15 days and pushed 3x is likely not ready to buy this quarter.\n\nI can create tasks for both rescue plans and assign to the right reps.",
445
+ status: "complete",
446
+ createdAt: new Date(now - 1 * DAY + 38 * MIN),
447
+ },
448
+
449
+ // ── Conv 6: Product listing A/B results — archived (6 messages) ─
450
+ {
451
+ id: crypto.randomUUID(),
452
+ conversationId: conv6Id,
453
+ role: "user",
454
+ content: "The A/B test on the Bamboo Kitchen Set listing has been running for 2 weeks. What are the results?",
455
+ status: "complete",
456
+ createdAt: new Date(now - 10 * DAY),
457
+ },
458
+ {
459
+ id: crypto.randomUUID(),
460
+ conversationId: conv6Id,
461
+ role: "assistant",
462
+ content:
463
+ "Results for SKU-1042 (Bamboo Kitchen Set) A/B test:\n\n**Control (original listing):**\n- Click-through: 2.1% | Conversion: 8.4% | Revenue: $1,240\n\n**Variant (optimized copy):**\n- Click-through: 3.4% | Conversion: 11.2% | Revenue: $1,890\n\n**Lift:** +62% CTR, +33% conversion, +52% revenue\n\nThe variant is a clear winner with 99.2% statistical confidence. The primary driver was the keyword-optimized title — 'Bamboo Kitchen Set' moved from position 14 to position 3 in the first 80 characters.",
464
+ status: "complete",
465
+ createdAt: new Date(now - 10 * DAY + 3 * MIN),
466
+ },
467
+ {
468
+ id: crypto.randomUUID(),
469
+ conversationId: conv6Id,
470
+ role: "user",
471
+ content: "Great results. Roll out the variant and start the next test.",
472
+ status: "complete",
473
+ createdAt: new Date(now - 10 * DAY + 8 * MIN),
474
+ },
475
+ {
476
+ id: crypto.randomUUID(),
477
+ conversationId: conv6Id,
478
+ role: "assistant",
479
+ content:
480
+ "Done. I've staged the variant as the new default for SKU-1042 and queued the next A/B test:\n\n**Next test: Organic Cotton Sheets (SKU-1108)**\n- Current: Strong reviews (4.6, 1,205 reviews) but title is keyword-weak\n- Hypothesis: Adding 'Queen Size' and '100% GOTS Certified' to the title will improve relevance for high-intent searches\n- Test duration: 14 days\n- Success metric: +20% CTR (baseline 2.8%)\n\nI'll report results in 2 weeks. Want me to also queue the Recycled Glass Vases test to run in parallel?",
481
+ status: "complete",
482
+ createdAt: new Date(now - 10 * DAY + 11 * MIN),
483
+ },
484
+ {
485
+ id: crypto.randomUUID(),
486
+ conversationId: conv6Id,
487
+ role: "user",
488
+ content: "Yes, run both in parallel. Different products so no conflict.",
489
+ status: "complete",
490
+ createdAt: new Date(now - 10 * DAY + 15 * MIN),
491
+ },
492
+ {
493
+ id: crypto.randomUUID(),
494
+ conversationId: conv6Id,
495
+ role: "assistant",
496
+ content:
497
+ "Both tests are now live:\n\n1. **Organic Cotton Sheets** — testing keyword-enriched title (14 days)\n2. **Recycled Glass Vases** — testing benefit-led bullet points vs feature-led (14 days)\n\nI'll monitor daily for any anomalies and send a summary at the halfway point. The GreenLeaf Commerce project dashboard will show real-time test status.\n\nOverall listing optimization progress: 3 of 10 SKUs tested, 1 winner deployed. On track to complete all 10 by end of month.",
498
+ status: "complete",
499
+ createdAt: new Date(now - 10 * DAY + 18 * MIN),
500
+ },
193
501
  ];
194
502
 
195
503
  return { conversations, messages };