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
@@ -13,110 +13,238 @@ export interface NotificationSeed {
13
13
  }
14
14
 
15
15
  /**
16
- * Task title → index mapping (from the tasks array order):
17
- * 0: Analyze portfolio, 1: Research ETFs, 2: Dividend yield (running)
18
- * 5: Audit competitors, 6: Write hero copy, 7: Design hero (running)
19
- * 10: Search LinkedIn, 11: Enrich prospect (failed), 12: Draft outreach (queued)
20
- * 15: Book flights, 17: Create itinerary
21
- * 20: Gather W-2s, 21: Categorize deductions (running), 22: Calculate home office (queued)
16
+ * Task index reference (6 per project, 48 total):
17
+ * P1 (Launch): 0-5 — [0] comp analysis (done), [1] copy (done), [2] landing (running), [3] A/B (queued), [4] PH (planned), [5] social (failed)
18
+ * P2 (Content): 6-11 — [6] keyword (done), [7] article (done), [8] LinkedIn (done), [9] newsletter (running), [10] dashboard (queued), [11] research (planned)
19
+ * P3 (CS): 12-17 [12] onboarding (done), [13] churn (done), [14] playbook (running), [15] NPS (running), [16] triage (queued), [17] health dash (planned)
20
+ * P4 (TVP): 18-23 [18] financials (done), [19] market (done), [20] DD memo (done), [21] board deck (running), [22] DataPulse (planned), [23] NovaPay (failed)
21
+ * P5 (GreenLeaf): 24-29 — [24] scrape (done), [25] rewrite (done), [26] sentiment (running), [27] ad copy (queued), [28] pricing (queued), [29] tracker (planned)
22
+ * P6 (MedReach): 30-35 — [30] landing (done), [31] HIPAA review (done), [32] email templates (done), [33] social calendar (done), [34] analytics (planned), [35] legal (cancelled)
23
+ * P7 (RevOps): 36-41 — [36] pipeline (done), [37] risk score (done), [38] coaching (running), [39] exec note (running), [40] forecast (queued), [41] win/loss (planned)
24
+ * P8 (Compliance): 42-47 — [42] gather logs (done), [43] SOC2 (done), [44] report (done), [45] brief (done), [46] escalation (done), [47] April scope (planned)
22
25
  */
23
26
  export function createNotifications(taskIds: string[]): NotificationSeed[] {
24
27
  const now = Date.now();
25
28
  const DAY = 86_400_000;
26
29
  const HOUR = 3_600_000;
30
+ const MIN = 60_000;
27
31
 
28
32
  return [
33
+ // ── task_completed (5) ──────────────────────────────────────────
29
34
  {
30
35
  id: crypto.randomUUID(),
31
- taskId: taskIds[0], // Analyze portfoliocompleted
36
+ taskId: taskIds[0], // Competitive analysisP1
32
37
  type: "task_completed",
33
- title: "Portfolio analysis complete",
34
- body: "Analyzed allocation across 15 holdings. Tech exposure at 42% recommend rebalancing below 35%.",
38
+ title: "Competitive analysis complete",
39
+ body: "Analyzed 5 AI copilot products. Key gap: none address multi-agent orchestration or governance. Our 'business operations' positioning is uncontested.",
35
40
  read: true,
36
41
  toolName: null,
37
42
  toolInput: null,
38
43
  response: null,
39
44
  respondedAt: null,
40
- createdAt: new Date(now - 12 * DAY),
45
+ createdAt: new Date(now - 18 * DAY),
41
46
  },
42
47
  {
43
48
  id: crypto.randomUUID(),
44
- taskId: taskIds[15], // Book flightscompleted
49
+ taskId: taskIds[7], // Article writtenP2
45
50
  type: "task_completed",
46
- title: "Flight booking confirmed",
47
- body: "Booked United round-trip SFO↔JFK for Mar 15-18. Total: $660, Economy Plus.",
51
+ title: "SEO article published",
52
+ body: "Published 'AI Agent Orchestration Guide' 1,920 words, FK score 42, keyword density 1.4%. LinkedIn hook and newsletter intro drafted.",
48
53
  read: true,
49
54
  toolName: null,
50
55
  toolInput: null,
51
56
  response: null,
52
57
  respondedAt: null,
53
- createdAt: new Date(now - 6 * DAY),
58
+ createdAt: new Date(now - 10 * DAY),
54
59
  },
55
60
  {
56
61
  id: crypto.randomUUID(),
57
- taskId: taskIds[5], // Audit competitorscompleted
62
+ taskId: taskIds[20], // DD memoP4
58
63
  type: "task_completed",
59
- title: "Competitor audit ready for review",
60
- body: "Analyzed Notion, Linear, Vercel, and Stripe landing pages. Key opportunity: dynamic hero personalization.",
64
+ title: "Due diligence memo delivered",
65
+ body: "HealthSync DD memo complete (12 pages). Recommendation: GO at $45M valuation ($5.5x ARR). Condition: 3 new enterprise logos in 6 months.",
61
66
  read: false,
62
67
  toolName: null,
63
68
  toolInput: null,
64
69
  response: null,
65
70
  respondedAt: null,
66
- createdAt: new Date(now - 9 * DAY),
71
+ createdAt: new Date(now - 5 * DAY),
67
72
  },
68
73
  {
69
74
  id: crypto.randomUUID(),
70
- taskId: taskIds[11], // Enrich prospect data failed
75
+ taskId: taskIds[36], // Pipeline snapshotP7
76
+ type: "task_completed",
77
+ title: "Weekly pipeline snapshot ready",
78
+ body: "34 active deals, $2.8M weighted pipeline. +6 new deals this week ($420K). 2 lost to CrewAI on pricing.",
79
+ read: false,
80
+ toolName: null,
81
+ toolInput: null,
82
+ response: null,
83
+ respondedAt: null,
84
+ createdAt: new Date(now - 5 * DAY),
85
+ },
86
+ {
87
+ id: crypto.randomUUID(),
88
+ taskId: taskIds[44], // Compliance report — P8
89
+ type: "task_completed",
90
+ title: "March compliance report delivered",
91
+ body: "Overall posture: GREEN. 14/16 controls satisfied (87.5%). Improving trend from February. 2 gaps with remediation plans.",
92
+ read: true,
93
+ toolName: null,
94
+ toolInput: null,
95
+ response: null,
96
+ respondedAt: null,
97
+ createdAt: new Date(now - 3 * DAY),
98
+ },
99
+
100
+ // ── task_failed (3) ─────────────────────────────────────────────
101
+ {
102
+ id: crypto.randomUUID(),
103
+ taskId: taskIds[5], // Social calendar — P1
71
104
  type: "task_failed",
72
- title: "Prospect enrichment failed",
73
- body: "Rate limit exceeded when querying enrichment API. 0 of 15 prospects enriched. Retry recommended after cooldown period.",
105
+ title: "Social media calendar generation failed",
106
+ body: "Rate limit exceeded when querying social media APIs for engagement benchmarks. 0 of 5 channels analyzed. Retry recommended after 30-minute cooldown.",
74
107
  read: false,
75
108
  toolName: null,
76
109
  toolInput: null,
77
110
  response: null,
78
111
  respondedAt: null,
79
- createdAt: new Date(now - 6 * DAY),
112
+ createdAt: new Date(now - 7 * DAY),
80
113
  },
81
114
  {
82
115
  id: crypto.randomUUID(),
83
- taskId: taskIds[12], // Draft outreachqueued
84
- type: "permission_required",
85
- title: "Permission to send outreach emails",
86
- body: "Agent wants to send personalized emails to 12 prospects using drafted templates.",
116
+ taskId: taskIds[23], // NovaPay financialsP4
117
+ type: "task_failed",
118
+ title: "NovaPay financial extraction failed",
119
+ body: "Could not parse NovaPay's Q4 reporting package PDF format changed from prior quarters. Manual extraction required.",
87
120
  read: false,
121
+ toolName: null,
122
+ toolInput: null,
123
+ response: null,
124
+ respondedAt: null,
125
+ createdAt: new Date(now - 5 * DAY),
126
+ },
127
+ {
128
+ id: crypto.randomUUID(),
129
+ taskId: taskIds[28], // Pricing analysis — P5
130
+ type: "task_failed",
131
+ title: "Competitor pricing scrape blocked",
132
+ body: "Anti-bot protection on 3 of 5 competitor sites prevented price data extraction. Consider using browser automation tools or a manual fallback.",
133
+ read: true,
134
+ toolName: null,
135
+ toolInput: null,
136
+ response: null,
137
+ respondedAt: null,
138
+ createdAt: new Date(now - 2 * DAY),
139
+ },
140
+
141
+ // ── permission_required (6) ─────────────────────────────────────
142
+ // All pre-responded with proper JSON format matching what the API writes
143
+ {
144
+ id: crypto.randomUUID(),
145
+ taskId: taskIds[1], // Write copy — P1
146
+ type: "permission_required",
147
+ title: "Permission to write launch campaign plan",
148
+ body: "Agent wants to save the launch campaign plan as a DOCX file with headline variants, email sequence, and social calendar.",
149
+ read: true,
150
+ toolName: "Write",
151
+ toolInput: JSON.stringify({
152
+ file_path: "launch-campaign-plan.docx",
153
+ description: "Launch campaign plan with 3 headline variants and email sequence",
154
+ }),
155
+ response: JSON.stringify({ behavior: "allow" }),
156
+ respondedAt: new Date(now - 15 * DAY),
157
+ createdAt: new Date(now - 15 * DAY - 30 * MIN),
158
+ },
159
+ {
160
+ id: crypto.randomUUID(),
161
+ taskId: taskIds[8], // LinkedIn series — P2
162
+ type: "permission_required",
163
+ title: "Permission to schedule LinkedIn posts",
164
+ body: "Agent wants to schedule 5 LinkedIn posts via the content distribution API. Posts are queued for Mon/Wed/Fri at 8:30am ET.",
165
+ read: true,
88
166
  toolName: "SendEmail",
89
167
  toolInput: JSON.stringify({
90
- recipients: 12,
91
- template: "pain-point-hook",
92
- subject: "{Company}'s engineering velocity — quick question",
168
+ channel: "linkedin",
169
+ posts: 5,
170
+ schedule: "MWF 8:30am ET",
93
171
  }),
94
- response: null,
95
- respondedAt: null,
96
- createdAt: new Date(now - 4 * DAY),
172
+ response: JSON.stringify({ behavior: "allow", alwaysAllow: true }),
173
+ respondedAt: new Date(now - 7 * DAY),
174
+ createdAt: new Date(now - 8 * DAY),
97
175
  },
98
176
  {
99
177
  id: crypto.randomUUID(),
100
- taskId: taskIds[21], // Categorize deductionsrunning
178
+ taskId: taskIds[13], // Churn analysisP3
101
179
  type: "permission_required",
102
- title: "Permission to write expense categorization",
103
- body: "Agent categorized 25 expenses into IRS-recognized deduction categories. Ready to save results.",
180
+ title: "Permission to export churn risk report",
181
+ body: "Agent generated a churn risk report for 5 at-risk accounts and wants to save it as an XLSX file.",
104
182
  read: true,
105
183
  toolName: "Write",
106
184
  toolInput: JSON.stringify({
107
- file_path: "categorized-expenses.csv",
108
- description: "Categorized deductible expenses with IRS categories",
185
+ file_path: "churn-risk-report.xlsx",
186
+ description: "Account health scores with intervention recommendations",
109
187
  }),
110
- response: "approved",
111
- respondedAt: new Date(now - 2 * HOUR),
112
- createdAt: new Date(now - 3 * HOUR),
188
+ response: JSON.stringify({ behavior: "allow" }),
189
+ respondedAt: new Date(now - 9 * DAY),
190
+ createdAt: new Date(now - 9 * DAY - 15 * MIN),
113
191
  },
114
192
  {
115
193
  id: crypto.randomUUID(),
116
- taskId: taskIds[7], // Design hero component running
194
+ taskId: taskIds[26], // Review sentimentP5
195
+ type: "permission_required",
196
+ title: "Permission to run browser automation",
197
+ body: "Agent wants to use Chrome automation to scrape product review pages on 3 e-commerce platforms for sentiment monitoring.",
198
+ read: true,
199
+ toolName: "Bash",
200
+ toolInput: JSON.stringify({
201
+ command: "playwright scrape --sites amazon,walmart,target --sku SKU-1042",
202
+ description: "Scrape product reviews for Bamboo Kitchen Set",
203
+ }),
204
+ response: JSON.stringify({ behavior: "deny", message: "Use the dedicated review API instead of browser scraping" }),
205
+ respondedAt: new Date(now - 1 * HOUR),
206
+ createdAt: new Date(now - 2 * HOUR),
207
+ },
208
+ {
209
+ id: crypto.randomUUID(),
210
+ taskId: taskIds[37], // Risk scoring — P7
211
+ type: "permission_required",
212
+ title: "Permission to query CRM data",
213
+ body: "Agent needs to read deal activity logs from the CRM export to calculate stall risk scores for 7 flagged deals.",
214
+ read: true,
215
+ toolName: "Read",
216
+ toolInput: JSON.stringify({
217
+ file_path: "crm-export/deal-activity-log.csv",
218
+ description: "CRM deal activity data for risk scoring",
219
+ }),
220
+ response: JSON.stringify({ behavior: "allow" }),
221
+ respondedAt: new Date(now - 3 * DAY),
222
+ createdAt: new Date(now - 3 * DAY - 10 * MIN),
223
+ },
224
+ {
225
+ id: crypto.randomUUID(),
226
+ taskId: taskIds[42], // Gather logs — P8
227
+ type: "permission_required",
228
+ title: "Permission to search execution logs",
229
+ body: "Agent wants to search all March execution logs and permission records for the SOC 2 compliance audit.",
230
+ read: true,
231
+ toolName: "WebSearch",
232
+ toolInput: JSON.stringify({
233
+ query: "execution logs March 2026 permission decisions",
234
+ scope: "internal audit trail",
235
+ }),
236
+ response: JSON.stringify({ behavior: "allow", alwaysAllow: true }),
237
+ respondedAt: new Date(now - 4 * DAY),
238
+ createdAt: new Date(now - 4 * DAY - 5 * MIN),
239
+ },
240
+
241
+ // ── agent_message (4) ───────────────────────────────────────────
242
+ {
243
+ id: crypto.randomUUID(),
244
+ taskId: taskIds[2], // Build landing page — P1 (running)
117
245
  type: "agent_message",
118
- title: "Need clarification on brand color palette",
119
- body: "The design brief specifies OKLCH hue 250, but the existing codebase uses hue 220 in some components. Should I use 250 consistently, or match the existing 220?",
246
+ title: "Landing page: dark mode support?",
247
+ body: "The design brief mentions OKLCH hue 250 for light mode, but doesn't specify dark mode colors. Should I implement a dark mode toggle with auto-detected preference, or ship light-only for launch?",
120
248
  read: false,
121
249
  toolName: null,
122
250
  toolInput: null,
@@ -126,24 +254,51 @@ export function createNotifications(taskIds: string[]): NotificationSeed[] {
126
254
  },
127
255
  {
128
256
  id: crypto.randomUUID(),
129
- taskId: taskIds[22], // Calculate home office queued
257
+ taskId: taskIds[14], // Draft playbookP3 (running)
258
+ type: "agent_message",
259
+ title: "Intervention escalation path unclear",
260
+ body: "For red accounts (NPS <30), should the intervention go directly to the CSM manager, or should the assigned CSM get first crack at a rescue plan? The current playbook is ambiguous on escalation timing.",
261
+ read: false,
262
+ toolName: null,
263
+ toolInput: null,
264
+ response: null,
265
+ respondedAt: null,
266
+ createdAt: new Date(now - 3 * HOUR),
267
+ },
268
+ {
269
+ id: crypto.randomUUID(),
270
+ taskId: taskIds[21], // Board deck — P4 (running)
130
271
  type: "agent_message",
131
- title: "Found 3 potential deduction methods",
132
- body: "Simplified method ($5/sq ft, max $1,500), actual expense method (pro-rata utilities + depreciation), or Section 280A election. Simplified gives $750, actual estimate is $2,100. Which method should I apply?",
272
+ title: "NovaPay data missing for board deck",
273
+ body: "NovaPay's Q4 financial extraction failed earlier. I can include Q3 data with a 'Q4 pending' note, or hold the deck until NovaPay data is manually extracted. Which do you prefer?",
133
274
  read: false,
134
275
  toolName: null,
135
276
  toolInput: null,
136
277
  response: null,
137
278
  respondedAt: null,
138
- createdAt: new Date(now - 30 * 60_000),
279
+ createdAt: new Date(now - 45 * MIN),
139
280
  },
140
- // Budget alert — unread, needs attention
141
281
  {
142
282
  id: crypto.randomUUID(),
143
- taskId: taskIds[2], // Compare dividend yield — running
283
+ taskId: taskIds[39], // Executive noteP7 (running)
284
+ type: "agent_message",
285
+ title: "Include lost deal analysis in exec note?",
286
+ body: "Two deals lost to CrewAI on pricing this week. Should I include a competitive pricing analysis section in the executive operating note, or keep it focused on active pipeline only?",
287
+ read: false,
288
+ toolName: null,
289
+ toolInput: null,
290
+ response: null,
291
+ respondedAt: null,
292
+ createdAt: new Date(now - 30 * MIN),
293
+ },
294
+
295
+ // ── budget_alert (3) ────────────────────────────────────────────
296
+ {
297
+ id: crypto.randomUUID(),
298
+ taskId: taskIds[9], // Newsletter — P2 (running)
144
299
  type: "budget_alert",
145
300
  title: "Daily budget 80% consumed",
146
- body: "Agent tasks have used $4.02 of your $5.00 daily budget. 2 running tasks may exceed the limit. Consider pausing non-critical tasks or increasing the daily cap in Settings → Budget Guardrails.",
301
+ body: "Agent tasks have used $4.02 of your $5.00 daily budget. 3 running tasks may exceed the limit. Consider pausing non-critical tasks or increasing the daily cap in Settings → Budget Guardrails.",
147
302
  read: false,
148
303
  toolName: null,
149
304
  toolInput: null,
@@ -151,44 +306,163 @@ export function createNotifications(taskIds: string[]): NotificationSeed[] {
151
306
  respondedAt: null,
152
307
  createdAt: new Date(now - 2 * HOUR),
153
308
  },
154
- // Context proposal — unread, needs attention (agent learned something)
155
309
  {
156
310
  id: crypto.randomUUID(),
157
- taskId: taskIds[0], // Analyze portfoliocompleted
158
- type: "context_proposal",
159
- title: "Learned: Portfolio rebalancing threshold",
160
- body: "From the portfolio analysis task, I learned that your preferred sector concentration limit is 35%. I'd like to remember this for future investment analysis tasks so I can flag overweight positions automatically.",
311
+ taskId: taskIds[15], // NPS monitoringP3 (running)
312
+ type: "budget_alert",
313
+ title: "Monthly budget 60% consumed (day 12 of 30)",
314
+ body: "You've used $89.40 of your $150.00 monthly budget with 18 days remaining. Current burn rate projects $223 for the month. Heartbeat schedules account for 45% of spend.",
161
315
  read: false,
162
316
  toolName: null,
317
+ toolInput: null,
318
+ response: null,
319
+ respondedAt: null,
320
+ createdAt: new Date(now - 6 * HOUR),
321
+ },
322
+ {
323
+ id: crypto.randomUUID(),
324
+ taskId: taskIds[21], // Board deck — P4 (running)
325
+ type: "budget_alert",
326
+ title: "Project over-budget: TechVenture Partners",
327
+ body: "The TechVenture Partners project has used $32.50 against a $25.00 per-project weekly cap. The board deck generation task is the primary driver. Consider adjusting the project budget or pausing lower-priority tasks.",
328
+ read: true,
329
+ toolName: null,
330
+ toolInput: null,
331
+ response: null,
332
+ respondedAt: null,
333
+ createdAt: new Date(now - 4 * HOUR),
334
+ },
335
+
336
+ // ── context_proposal (4) — all pre-responded ─────────────────────
337
+ {
338
+ id: crypto.randomUUID(),
339
+ taskId: taskIds[1], // Copy variants — P1
340
+ type: "context_proposal",
341
+ title: "Learned: benefit-led headlines preferred",
342
+ body: "From the launch copy task, I observed that you consistently chose benefit-led headlines over feature-led ones. I'd like to remember this for future marketing tasks so I prioritize pain/outcome framing over feature announcements.",
343
+ read: true,
344
+ toolName: null,
345
+ toolInput: JSON.stringify({
346
+ pattern: "headline_style_preference",
347
+ value: "benefit-led over feature-led",
348
+ confidence: 0.91,
349
+ }),
350
+ response: JSON.stringify({ behavior: "allow" }),
351
+ respondedAt: new Date(now - 13 * DAY),
352
+ createdAt: new Date(now - 14 * DAY),
353
+ },
354
+ {
355
+ id: crypto.randomUUID(),
356
+ taskId: taskIds[7], // Article — P2
357
+ type: "context_proposal",
358
+ title: "Learned: target 1,500-2,000 words for SEO",
359
+ body: "Based on the orchestration guide's performance (position 14 after 5 days), articles in the 1,500-2,000 word range perform best for our target keywords. Shorter pieces don't rank; longer ones have lower completion rates.",
360
+ read: true,
361
+ toolName: null,
163
362
  toolInput: JSON.stringify({
164
- pattern: "sector_concentration_limit",
165
- value: "35%",
363
+ pattern: "optimal_article_length",
364
+ value: "1500-2000 words",
365
+ confidence: 0.85,
366
+ }),
367
+ response: JSON.stringify({ behavior: "allow" }),
368
+ respondedAt: new Date(now - 9 * DAY),
369
+ createdAt: new Date(now - 10 * DAY),
370
+ },
371
+ {
372
+ id: crypto.randomUUID(),
373
+ taskId: taskIds[37], // Risk scoring — P7
374
+ type: "context_proposal",
375
+ title: "Learned: deal stall threshold is 5 business days",
376
+ body: "Your deal review process consistently flags deals at 5+ business days without activity. I'd like to use this as the default stall threshold for future pipeline analysis and coaching notes.",
377
+ read: true,
378
+ toolName: null,
379
+ toolInput: JSON.stringify({
380
+ pattern: "deal_stall_threshold",
381
+ value: "5 business days",
382
+ confidence: 0.94,
383
+ }),
384
+ response: JSON.stringify({ behavior: "allow" }),
385
+ respondedAt: new Date(now - 2 * DAY),
386
+ createdAt: new Date(now - 3 * DAY),
387
+ },
388
+ {
389
+ id: crypto.randomUUID(),
390
+ taskId: taskIds[13], // Churn analysis — P3
391
+ type: "context_proposal",
392
+ title: "Learned: NPS <30 triggers immediate outreach",
393
+ body: "From the churn analysis, I identified that accounts with NPS below 30 consistently require immediate CSM outreach. I'd like to apply this threshold as a standard trigger for future health monitoring.",
394
+ read: true,
395
+ toolName: null,
396
+ toolInput: JSON.stringify({
397
+ pattern: "nps_intervention_threshold",
398
+ value: "NPS < 30",
399
+ confidence: 0.89,
400
+ }),
401
+ response: JSON.stringify({ behavior: "allow" }),
402
+ respondedAt: new Date(now - 8 * DAY),
403
+ createdAt: new Date(now - 9 * DAY),
404
+ },
405
+
406
+ // ── context_proposal_batch (3) — all pre-responded ──────────────
407
+ {
408
+ id: crypto.randomUUID(),
409
+ taskId: taskIds[20], // DD memo — P4
410
+ type: "context_proposal_batch",
411
+ title: "4 patterns learned from due diligence",
412
+ body: "After completing the HealthSync DD memo, I identified 4 reusable patterns:\n\n1. **Financial snapshot format** — always include ARR, gross margin, net retention, and runway\n2. **Risk framework** — top 3 risks with specific mitigants\n3. **Market sizing** — always include both top-down and bottom-up approaches\n4. **Recommendation format** — GO/NO-GO with conditions\n\nShall I remember these for future DD work?",
413
+ read: true,
414
+ toolName: null,
415
+ toolInput: JSON.stringify({
416
+ patterns: [
417
+ { key: "dd_financial_snapshot", value: "ARR, GM, NRR, runway" },
418
+ { key: "dd_risk_framework", value: "top 3 with mitigants" },
419
+ { key: "dd_market_sizing", value: "top-down + bottom-up" },
420
+ { key: "dd_recommendation", value: "GO/NO-GO with conditions" },
421
+ ],
166
422
  confidence: 0.92,
167
423
  }),
168
- response: null,
169
- respondedAt: null,
170
- createdAt: new Date(now - 5 * HOUR),
424
+ response: JSON.stringify({ behavior: "allow" }),
425
+ respondedAt: new Date(now - 4 * DAY),
426
+ createdAt: new Date(now - 5 * DAY),
171
427
  },
172
- // Context proposal batch — read, already responded
173
428
  {
174
429
  id: crypto.randomUUID(),
175
- taskId: taskIds[5], // Audit competitorscompleted
430
+ taskId: taskIds[36], // Pipeline snapshotP7
176
431
  type: "context_proposal_batch",
177
- title: "3 patterns learned from competitor audit",
178
- body: "After completing the competitor landing page audit, I identified 3 reusable patterns:\n\n1. **Social proof placement** — above the fold, not below\n2. **CTA limit** — max 3 CTAs per page for focus\n3. **Hero personalization** — dynamic content based on referral source\n\nShall I remember these for future marketing tasks?",
432
+ title: "3 patterns learned from deal review",
433
+ body: "From the weekly deal review process, I identified 3 operating patterns:\n\n1. **Forecast buckets** — committed, best-case, and upside (not just total)\n2. **Coaching format** — 1-2 notes per rep, specific to their deals\n3. **Action limit** — top 3 actions only, ranked by leverage\n\nShall I apply these to future operating notes?",
179
434
  read: true,
180
435
  toolName: null,
181
436
  toolInput: JSON.stringify({
182
437
  patterns: [
183
- { key: "social_proof_placement", value: "above_fold" },
184
- { key: "cta_limit", value: 3 },
185
- { key: "hero_personalization", value: "referral_based" },
438
+ { key: "forecast_buckets", value: "committed/best-case/upside" },
439
+ { key: "coaching_format", value: "per-rep, deal-specific" },
440
+ { key: "action_limit", value: "top 3 by leverage" },
186
441
  ],
187
442
  confidence: 0.88,
188
443
  }),
189
- response: "approved",
190
- respondedAt: new Date(now - 8 * HOUR),
191
- createdAt: new Date(now - 10 * HOUR),
444
+ response: JSON.stringify({ behavior: "allow" }),
445
+ respondedAt: new Date(now - 3 * DAY),
446
+ createdAt: new Date(now - 4 * DAY),
447
+ },
448
+ {
449
+ id: crypto.randomUUID(),
450
+ taskId: taskIds[43], // SOC 2 analysis — P8
451
+ type: "context_proposal_batch",
452
+ title: "2 compliance patterns codified",
453
+ body: "From the March compliance audit, I identified 2 reusable compliance patterns:\n\n1. **Auto-approve scope** — Read and Grep always, Write never, WebSearch context-dependent\n2. **Severity rating** — Critical (data breach risk), High (policy violation), Medium (process gap), Low (best practice miss)\n\nShall I apply these to future audits?",
454
+ read: true,
455
+ toolName: null,
456
+ toolInput: JSON.stringify({
457
+ patterns: [
458
+ { key: "auto_approve_scope", value: "Read/Grep always, Write never" },
459
+ { key: "severity_rating", value: "Critical/High/Medium/Low" },
460
+ ],
461
+ confidence: 0.95,
462
+ }),
463
+ response: JSON.stringify({ behavior: "allow" }),
464
+ respondedAt: new Date(now - 3 * DAY),
465
+ createdAt: new Date(now - 3 * DAY - 30 * MIN),
192
466
  },
193
467
  ];
194
468
  }