spine-framework-cortex 0.1.9 → 1.0.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 (52) hide show
  1. package/LICENSE.md +215 -5
  2. package/README.md +185 -13
  3. package/custom/apps/cortex/LICENSE.md +13 -0
  4. package/custom/apps/cortex/README.md +27 -0
  5. package/custom/apps/cortex/api/cortex-handler.ts +35 -0
  6. package/custom/apps/cortex/docs/configuration.md +222 -0
  7. package/custom/apps/cortex/kb-ingestion.tsx +217 -0
  8. package/{manifest.json → custom/apps/cortex/manifest.json} +12 -1
  9. package/custom/apps/cortex/package.json +31 -0
  10. package/package.json +81 -20
  11. /package/{components → custom/apps/cortex/components}/CortexSidebar.tsx +0 -0
  12. /package/{functions → custom/apps/cortex/functions}/custom_anonymous-sessions.ts +0 -0
  13. /package/{functions → custom/apps/cortex/functions}/custom_case_analysis.ts +0 -0
  14. /package/{functions → custom/apps/cortex/functions}/custom_community-escalation.ts +0 -0
  15. /package/{functions → custom/apps/cortex/functions}/custom_cortex-chunks.ts +0 -0
  16. /package/{functions → custom/apps/cortex/functions}/custom_cortex-handler.ts +0 -0
  17. /package/{functions → custom/apps/cortex/functions}/custom_funnel-scoring.ts +0 -0
  18. /package/{functions → custom/apps/cortex/functions}/custom_funnel-signal.ts +0 -0
  19. /package/{functions → custom/apps/cortex/functions}/custom_funnel-timers.ts +0 -0
  20. /package/{functions → custom/apps/cortex/functions}/custom_kb-chunker-test.ts +0 -0
  21. /package/{functions → custom/apps/cortex/functions}/custom_kb-chunker.ts +0 -0
  22. /package/{functions → custom/apps/cortex/functions}/custom_kb-embeddings.ts +0 -0
  23. /package/{functions → custom/apps/cortex/functions}/custom_kb-ingestion.ts +0 -0
  24. /package/{functions → custom/apps/cortex/functions}/custom_support-triage.ts +0 -0
  25. /package/{functions → custom/apps/cortex/functions}/custom_tag_management.ts +0 -0
  26. /package/{functions → custom/apps/cortex/functions}/webhook-handlers.ts +0 -0
  27. /package/{index.tsx → custom/apps/cortex/index.tsx} +0 -0
  28. /package/{lib → custom/apps/cortex/lib}/resolveTypeId.ts +0 -0
  29. /package/{pages → custom/apps/cortex/pages}/CortexDashboard.tsx +0 -0
  30. /package/{pages → custom/apps/cortex/pages}/community/CommunityPage.tsx +0 -0
  31. /package/{pages → custom/apps/cortex/pages}/courses/CoursesPage.tsx +0 -0
  32. /package/{pages → custom/apps/cortex/pages}/crm/AccountDetailPage.tsx +0 -0
  33. /package/{pages → custom/apps/cortex/pages}/crm/AccountsPage.tsx +0 -0
  34. /package/{pages → custom/apps/cortex/pages}/crm/ActivityPage.tsx +0 -0
  35. /package/{pages → custom/apps/cortex/pages}/crm/ContactDetailPage.tsx +0 -0
  36. /package/{pages → custom/apps/cortex/pages}/crm/ContactsPage.tsx +0 -0
  37. /package/{pages → custom/apps/cortex/pages}/crm/DealDetailPage.tsx +0 -0
  38. /package/{pages → custom/apps/cortex/pages}/crm/DealsPage.tsx +0 -0
  39. /package/{pages → custom/apps/cortex/pages}/crm/HealthPage.tsx +0 -0
  40. /package/{pages → custom/apps/cortex/pages}/intelligence/IntelligencePage.tsx +0 -0
  41. /package/{pages → custom/apps/cortex/pages}/kb/KBEditorPage.tsx +0 -0
  42. /package/{pages → custom/apps/cortex/pages}/kb/KBIngestionPage.tsx +0 -0
  43. /package/{pages → custom/apps/cortex/pages}/kb/KBPage.tsx +0 -0
  44. /package/{pages → custom/apps/cortex/pages}/support/RedactionReview.tsx +0 -0
  45. /package/{pages → custom/apps/cortex/pages}/support/SupportPage.tsx +0 -0
  46. /package/{pages → custom/apps/cortex/pages}/support/TicketDetailPage.tsx +0 -0
  47. /package/{seed → custom/apps/cortex/seed}/accounts.json +0 -0
  48. /package/{seed → custom/apps/cortex/seed}/link-types.json +0 -0
  49. /package/{seed → custom/apps/cortex/seed}/pipelines.json +0 -0
  50. /package/{seed → custom/apps/cortex/seed}/roles.json +0 -0
  51. /package/{seed → custom/apps/cortex/seed}/triggers.json +0 -0
  52. /package/{seed → custom/apps/cortex/seed}/types.json +0 -0
package/LICENSE.md CHANGED
@@ -2,12 +2,222 @@
2
2
 
3
3
  **Source-available. Free for internal use. Commercial rights reserved.**
4
4
 
5
- Copyright © 2026 Dahl Ventures Inc. All rights reserved.
5
+ This license is based on the structure and intent of the PolyForm Internal Use License 1.0.0, but it has been modified for Spine Framework. This is not the unmodified PolyForm Internal Use License.
6
6
 
7
- This software is licensed under the Spine Framework Internal Use License 1.0.0.
7
+ ## Required Notice
8
8
 
9
- For full license terms, see: https://github.com/spine-framework/spine-framework/blob/main/LICENSE.md
9
+ Required Notice: Copyright © 2026 Dahl Ventures Inc. All rights reserved.
10
10
 
11
- **Summary:** You may use this software for internal business use only. Commercial use, resale, SaaS offering, white-labeling, and distribution require a separate Commercial License.
11
+ ## 1. Acceptance
12
12
 
13
- Contact: webmaster@spine-framework.com
13
+ In order to receive any license under these terms, you must agree to these terms as both strict obligations and conditions to all licenses granted to you.
14
+
15
+ If you do not agree to these terms, you do not have permission to use, copy, modify, run, install, access, or create works based on Spine Framework.
16
+
17
+ ## 2. Definitions
18
+
19
+ **Software** means Spine Framework, including its source code, object code, packages, modules, templates, schemas, migrations, configuration files, documentation, examples, command-line tools, SDKs, application packs, and related materials provided by the licensor.
20
+
21
+ **Licensor** means the legal owner of Spine Framework.
22
+
23
+ **You** means the individual or legal entity receiving the Software.
24
+
25
+ **Your Company** means the legal entity on whose behalf you use the Software, including that entity's employees and authorized contractors.
26
+
27
+ **Internal Business Use** means use of the Software solely inside Your Company for Your Company's own internal business operations, internal workflows, internal applications, internal data, internal users, and internal customers or accounts.
28
+
29
+ **Third Party** means any person or legal entity other than You or Your Company.
30
+
31
+ **Commercial License** means a separate written agreement signed by the Licensor that grants rights beyond this license.
32
+
33
+ ## 3. Copyright License
34
+
35
+ The Licensor grants You a copyright license to do everything with the Software that would otherwise infringe the Licensor's copyright, but only for Internal Business Use and only as permitted by these terms.
36
+
37
+ You may install, run, access, evaluate, test, configure, and use the Software for Internal Business Use.
38
+
39
+ You may copy the Software only as reasonably necessary for Internal Business Use, including backup, deployment, development, testing, staging, disaster recovery, and internal security review.
40
+
41
+ You may not distribute the Software except as expressly allowed in these terms.
42
+
43
+ ## 4. Changes and New Works
44
+
45
+ The Licensor grants You a copyright license to modify the Software and create new works based on the Software, but only for Internal Business Use.
46
+
47
+ You may create internal applications, extensions, workflows, integrations, automations, schemas, roles, agents, triggers, pipelines, dashboards, reports, and other internal business systems using the Software.
48
+
49
+ You may not distribute, sell, sublicense, transfer, lease, rent, host for others, white-label, resell, or commercially exploit any modified version, derivative work, extension, application pack, template, or implementation of the Software except under a Commercial License.
50
+
51
+ ## 5. Internal Contractors
52
+
53
+ Your Company may allow employees and contractors to access and use the Software solely on behalf of Your Company and solely for Your Company's Internal Business Use.
54
+
55
+ Contractors do not receive any independent right to use the Software for themselves, their other clients, their own products, or any Third Party.
56
+
57
+ Your Company is responsible for all use of the Software by its employees, contractors, agents, and representatives.
58
+
59
+ ## 6. Your Data and Application-Specific Work
60
+
61
+ As between You and the Licensor, You own Your Company's data, records, content, prompts, business logic, customer records, internal workflows, and application-specific code that You independently create using the Software.
62
+
63
+ These terms do not give the Licensor ownership of Your Company's data or independently created application-specific business content.
64
+
65
+ However, ownership of Your Company's data or application-specific work does not give You the right to distribute, resell, white-label, host, or commercially exploit the Software or any portion of the Software except as allowed by these terms or a Commercial License.
66
+
67
+ ## 7. Prohibited Uses
68
+
69
+ You may not do any of the following without a Commercial License:
70
+
71
+ 1. Sell, resell, sublicense, rent, lease, lend, transfer, assign, publish, or distribute the Software.
72
+ 2. Offer the Software, or any modified version of the Software, to Third Parties as software, infrastructure, a framework, a platform, a service, or a hosted product.
73
+ 3. Offer the Software as SaaS, PaaS, IaaS, framework-as-a-service, backend-as-a-service, workflow-as-a-service, automation-as-a-service, AI-agent platform, managed service, or similar commercial service.
74
+ 4. White-label, private-label, rebrand, or remove Spine Framework identity from the Software in order to provide it to Third Parties.
75
+ 5. Embed, bundle, package, or include the Software in any product, service, appliance, marketplace offering, application pack, starter kit, template library, SDK, CLI, distribution, or managed implementation made available to Third Parties.
76
+ 6. Use the Software to operate, power, support, or provide a product or service for Third Parties where those Third Parties receive access to the Software or to functionality substantially provided by the Software.
77
+ 7. Use the Software to build, operate, or improve a competing framework, platform, marketplace, application generator, agentic software infrastructure product, or commercial development infrastructure product.
78
+ 8. Provide implementation, consulting, hosting, support, customization, training, migration, or managed services for the Software to Third Parties as a paid or commercial offering, except as expressly authorized by the Licensor.
79
+ 9. Remove, alter, obscure, or bypass copyright notices, license notices, attribution, trademarks, branding, license keys, license checks, usage limits, or technical protection measures included in the Software.
80
+ 10. Use the Software in violation of law, regulation, third-party rights, or these terms.
81
+
82
+ ## 8. Examples of Permitted Use
83
+
84
+ The following are permitted under this license, provided they are solely for Internal Business Use:
85
+
86
+ 1. A company installs Spine Framework to build its own internal CRM.
87
+ 2. A company uses Spine Framework to operate an internal customer support portal for its own support team and its own customers.
88
+ 3. A company modifies Spine Framework for its internal workflows, roles, permissions, automations, pipelines, and integrations.
89
+ 4. A company lets its employees and authorized contractors configure, maintain, and support its internal Spine Framework installation.
90
+ 5. A company creates internal dashboards, agents, knowledge bases, audit trails, and operational tools on top of Spine Framework.
91
+
92
+ ## 9. Examples Requiring a Commercial License
93
+
94
+ The following are not permitted under this license and require a Commercial License:
95
+
96
+ 1. Selling Spine Framework or a modified version of Spine Framework.
97
+ 2. Offering Spine Framework as a hosted SaaS product.
98
+ 3. Offering a white-labeled application built on Spine Framework to customers.
99
+ 4. Packaging Spine Framework into a commercial starter kit, template, marketplace app, agency offering, or developer platform.
100
+ 5. Running Spine Framework for multiple clients as a managed service provider, agency, consultant, systems integrator, or outsourcing firm.
101
+ 6. Embedding Spine Framework into a product sold to customers.
102
+ 7. Forking Spine Framework to launch a competing framework, backend, app platform, AI-agent platform, or development infrastructure product.
103
+ 8. Publishing modified Spine Framework source code to a public repository.
104
+ 9. Giving a customer, client, partner, reseller, or affiliate a copy of Spine Framework.
105
+
106
+ ## 10. Distribution
107
+
108
+ You may not distribute the Software, modified versions of the Software, or works based on the Software to any Third Party except as expressly permitted by these terms or a Commercial License.
109
+
110
+ You may share copies of the Software with employees and contractors of Your Company only as necessary for Internal Business Use and only if they are bound by obligations consistent with these terms.
111
+
112
+ Any copy of the Software must include this license and all Required Notices.
113
+
114
+ ## 11. Trademarks
115
+
116
+ This license does not grant You any right to use the Licensor's names, trademarks, service marks, logos, product names, domain names, or branding except as necessary to identify the Software for Internal Business Use.
117
+
118
+ You may not use Spine Framework branding in a way that suggests sponsorship, endorsement, partnership, certification, resale authorization, or commercial authorization without written permission from the Licensor.
119
+
120
+ ## 12. Patent License
121
+
122
+ The Licensor grants You a patent license for the Software that covers patent claims the Licensor can license, or later becomes able to license, that You would infringe by using the Software as permitted by these terms.
123
+
124
+ ## 13. Patent Defense
125
+
126
+ If You make any written claim that the Software infringes or contributes to infringement of any patent, Your patent license for the Software ends immediately.
127
+
128
+ If Your Company makes such a claim, Your Company's patent license ends immediately.
129
+
130
+ ## 14. Fair Use and Other Legal Rights
131
+
132
+ You may have fair use, fair dealing, or other rights under applicable law. These terms do not limit rights that the law does not allow these terms to limit.
133
+
134
+ ## 15. No Other Rights
135
+
136
+ These terms do not allow You to sublicense, transfer, assign, or delegate any license granted under these terms except as expressly allowed here.
137
+
138
+ These terms do not prevent the Licensor from granting licenses to anyone else.
139
+
140
+ These terms do not imply any license other than the licenses expressly granted here.
141
+
142
+ All rights not expressly granted are reserved by the Licensor.
143
+
144
+ ## 16. Violations and Cure
145
+
146
+ The first time You are notified in writing that You have violated these terms, or done anything with the Software not covered by these terms, Your licenses can continue if You:
147
+
148
+ 1. come into full compliance with these terms;
149
+ 2. take practical steps to correct past violations; and
150
+ 3. complete both within 32 days of receiving written notice.
151
+
152
+ If You do not satisfy those requirements, all licenses granted to You under these terms end immediately.
153
+
154
+ For any later violation, all licenses granted to You under these terms end immediately without any cure period.
155
+
156
+ ## 17. Termination
157
+
158
+ When Your licenses end, You must stop all use of the Software and destroy all copies of the Software in Your possession or control, except copies You are legally required to retain for archival, compliance, or legal purposes.
159
+
160
+ Sections concerning ownership, prohibited uses, trademarks, patent defense, no other rights, violations, termination, no warranty, limitation of liability, and general terms survive termination.
161
+
162
+ ## 18. No Warranty
163
+
164
+ As far as the law allows, the Software is provided as is and as available, without any warranty or condition, express or implied.
165
+
166
+ The Licensor disclaims all warranties and conditions, including warranties of merchantability, fitness for a particular purpose, title, non-infringement, availability, accuracy, security, and quiet enjoyment.
167
+
168
+ ## 19. Limitation of Liability
169
+
170
+ As far as the law allows, the Licensor will not be liable to You for any indirect, incidental, special, consequential, exemplary, punitive, or other damages arising out of these terms or the Software.
171
+
172
+ As far as the law allows, the Licensor will not be liable for lost profits, lost revenue, lost savings, lost data, business interruption, security incidents, procurement of substitute services, or loss of goodwill.
173
+
174
+ The Licensor's total liability arising out of these terms or the Software will not exceed the amount You paid the Licensor for the Software during the 12 months before the event giving rise to liability, or USD $100 if You paid nothing.
175
+
176
+ ## 20. Commercial Licensing
177
+
178
+ Rights not granted under this license may be available under a separate Commercial License from the Licensor.
179
+
180
+ A Commercial License is required for resale, redistribution, SaaS, managed services, white-label use, OEM use, marketplace distribution, partner use, commercial hosting, commercial support offerings, or any use outside Internal Business Use.
181
+
182
+ To request commercial rights, contact:
183
+
184
+ - spine-framework.com
185
+ - webmaster@spine-framework.com
186
+
187
+ ## 21. License Updates
188
+
189
+ The Licensor may publish updated versions of this license from time to time.
190
+
191
+ Each release, package, download, or copy of the Software is governed by the license terms included with that release, package, download, or copy, unless You and the Licensor have signed a separate written agreement.
192
+
193
+ Updated license terms apply only to future releases, downloads, packages, updates, upgrades, patches, hosted access, or other versions of the Software made available after the updated terms are published.
194
+
195
+ The Licensor may require acceptance of updated license terms as a condition of receiving or using future releases, updates, hosted services, commercial features, support, documentation, marketplace access, license keys, portals, application packs, or other Spine Framework services.
196
+
197
+ Nothing in this section gives You rights to continue using future versions of the Software under earlier license terms.
198
+
199
+ ## 22. General Terms
200
+
201
+ If any part of these terms is held unenforceable, the rest remains in effect as far as the law allows.
202
+
203
+ Failure by the Licensor to enforce any term is not a waiver.
204
+
205
+ Any waiver must be in writing and signed by the Licensor.
206
+
207
+ These terms are the entire license terms for the Software unless You and the Licensor have signed a separate written agreement.
208
+
209
+ ## 23. Plain-English Summary
210
+
211
+ This summary is not part of the legal license.
212
+
213
+ You may use Spine Framework inside your own company for your own internal business operations.
214
+
215
+ You may modify Spine Framework for your own internal use.
216
+
217
+ You may let your employees and contractors work on your internal Spine Framework installation.
218
+
219
+ You may not sell it, redistribute it, white-label it, host it for others, offer it as SaaS, package it into another product, use it as a managed service offering, or use it to build a competing framework without a separate commercial license.
220
+
221
+ Future versions, updates, services, support, portals, packs, license keys, and commercial features may require acceptance of updated terms.
222
+
223
+ Spine Framework is source-available. It is not open source.
package/README.md CHANGED
@@ -1,27 +1,199 @@
1
- # spine-framework-cortex
1
+ # Spine Framework Cortex
2
2
 
3
- AI-powered support, CRM, and knowledge base app for Spine Framework.
3
+ A unified workspace for CRM, Support, Community, and Knowledge Base built on the Spine Framework.
4
+
5
+ ## Overview
6
+
7
+ Cortex is a comprehensive business management application that provides:
8
+
9
+ - **CRM** - Customer relationship management with accounts, contacts, and deals
10
+ - **Support** - Ticket management and customer service workflows
11
+ - **Community** - Discussion forums and user engagement
12
+ - **Knowledge Base** - Documentation and article management
13
+ - **Courses** - Learning management and course delivery
14
+ - **Intelligence** - AI-powered insights and analytics
4
15
 
5
16
  ## Installation
6
17
 
7
- ```bash
8
- npm install spine-framework-cortex
18
+ ### Prerequisites
19
+
20
+ - Spine Framework installed
21
+ - Node.js 18+
22
+ - PostgreSQL database
23
+ - Supabase project (for database and auth)
24
+
25
+ ### Setup
26
+
27
+ 1. **Install the package**:
28
+ ```bash
29
+ npm install spine-framework-cortex
30
+ ```
31
+
32
+ 2. **Configure the database**:
33
+ See [docs/configuration.md](custom/apps/cortex/docs/configuration.md) for complete database setup instructions.
34
+
35
+ 3. **Install the app**:
36
+ ```bash
37
+ npx spine install-app cortex
38
+ ```
39
+
40
+ ## Configuration
41
+
42
+ ### Database Setup
43
+
44
+ Cortex requires specific database tables and configurations:
45
+
46
+ ```sql
47
+ -- Insert Cortex app
48
+ INSERT INTO public.apps (
49
+ slug, name, description, route_prefix, renderer,
50
+ required_roles, nav_items, is_active
51
+ ) VALUES (
52
+ 'cortex', 'Cortex',
53
+ 'Unified workspace for CRM, Support, Community, and Knowledge Base',
54
+ '/cortex', 'custom', '["support"]',
55
+ -- nav_items JSON from manifest.json
56
+ true
57
+ );
58
+
59
+ -- Install for your account
60
+ INSERT INTO public.app_installations (account_id, app_slug, is_enabled)
61
+ VALUES ('your-account-id', 'cortex', true);
9
62
  ```
10
63
 
11
- ## Usage
64
+ ### Route Configuration
12
65
 
13
- ```bash
14
- npx spine-framework install-app cortex
66
+ By default, Cortex serves from `/cortex`. To serve from root:
67
+
68
+ ```sql
69
+ UPDATE public.apps SET route_prefix = '/' WHERE slug = 'cortex';
15
70
  ```
16
71
 
72
+ See [docs/configuration.md](custom/apps/cortex/docs/configuration.md) for detailed configuration options.
73
+
17
74
  ## Features
18
75
 
19
- - Knowledge Base (KB) management with AI-powered article generation
20
- - Support ticket routing with AI triage
21
- - Anonymous visitor tracking and funnel signal processing
22
- - Opportunity queue for high-engagement prospects
23
- - Case analysis and resolution tracking
76
+ ### CRM
77
+ - Account and contact management
78
+ - Deal tracking and pipeline management
79
+ - Activity logging and health metrics
80
+
81
+ ### Support
82
+ - Ticket creation and management
83
+ - AI-powered triage and routing
84
+ - Knowledge base integration
85
+
86
+ ### Community
87
+ - Discussion forums
88
+ - User engagement tracking
89
+ - Content moderation
90
+
91
+ ### Knowledge Base
92
+ - Article creation and management
93
+ - Search and categorization
94
+ - Version control
95
+
96
+ ### Courses
97
+ - Lesson creation and delivery
98
+ - Progress tracking
99
+ - Completion certificates
100
+
101
+ ### Intelligence
102
+ - AI-powered insights
103
+ - Data analytics and reporting
104
+ - Predictive analytics
105
+
106
+ ## Development
107
+
108
+ ### Project Structure
109
+
110
+ ```
111
+ custom/apps/cortex/
112
+ ├── index.tsx # Main app component
113
+ ├── manifest.json # App configuration
114
+ ├── components/ # Reusable components
115
+ ├── pages/ # Page components
116
+ │ ├── crm/ # CRM pages
117
+ │ ├── support/ # Support pages
118
+ │ ├── community/ # Community pages
119
+ │ ├── kb/ # Knowledge base pages
120
+ │ └── courses/ # Course pages
121
+ ├── hooks/ # Custom React hooks
122
+ ├── config/ # Configuration files
123
+ ├── seed/ # Seed data
124
+ ├── functions/ # Serverless functions
125
+ ├── migrations/ # Database migrations
126
+ └── docs/ # Documentation
127
+ ```
128
+
129
+ ### Prefix-Aware Routing
130
+
131
+ Cortex uses prefix-aware routing that automatically adapts to the configured `route_prefix`:
132
+
133
+ ```typescript
134
+ // Automatically works for both /cortex and / serving
135
+ const base = app.route_prefix === '/' ? '' : (app.route_prefix || '')
136
+ const NavLink to={`${base}${path}`}
137
+ ```
138
+
139
+ ### Customization
140
+
141
+ 1. **Branding**: Update components in `components/`
142
+ 2. **Features**: Modify `manifest.json` routes and nav_items
143
+ 3. **Workflows**: Add custom functions in `functions/`
144
+ 4. **Data**: Extend with custom migrations in `migrations/`
145
+
146
+ ## Deployment
147
+
148
+ ### Subdirectory Deployment (Default)
149
+
150
+ - Access: `https://yourdomain.com/cortex`
151
+ - Safe for multi-app deployments
152
+ - Default configuration
153
+
154
+ ### Root Deployment
155
+
156
+ - Access: `https://yourdomain.com/`
157
+ - Set `route_prefix: "/"` in database
158
+ - For dedicated Cortex deployments
159
+
160
+ ## Authentication & Authorization
161
+
162
+ Cortex requires users to have the `support` role:
163
+
164
+ ```sql
165
+ -- Create support role
166
+ INSERT INTO public.roles (slug, name, description)
167
+ VALUES ('support', 'Support Agent', 'Can access Cortex features');
168
+
169
+ -- Assign to users
170
+ INSERT INTO public.people (account_id, user_id, role_id)
171
+ VALUES ('account-id', 'user-id', (SELECT id FROM roles WHERE slug = 'support'));
172
+ ```
173
+
174
+ ## API Integration
175
+
176
+ Cortex integrates with Spine Framework APIs:
177
+
178
+ - `/api/apps?action=list` - App discovery
179
+ - `/.netlify/functions/admin-data` - Data management
180
+ - `/.netlify/functions/ai-agents` - AI features
181
+ - Custom functions in `functions/` directory
182
+
183
+ ## Support
184
+
185
+ - **Documentation**: [docs/configuration.md](custom/apps/cortex/docs/configuration.md)
186
+ - **Issues**: Report via your Spine Framework support channel
187
+ - **Community**: Join the Spine Framework community
24
188
 
25
189
  ## License
26
190
 
27
- MIT
191
+ This package is licensed under the [Spine Framework Internal Use License](LICENSE.md).
192
+
193
+ - ✅ Free for internal business use
194
+ - ❌ Commercial redistribution requires separate license
195
+ - 📞 Contact: spine-framework.com for commercial licensing
196
+
197
+ ## Version History
198
+
199
+ See [manifest.json](custom/apps/cortex/manifest.json) for version information and changelog.
@@ -0,0 +1,13 @@
1
+ # Spine Framework Internal Use License 1.0.0
2
+
3
+ **Source-available. Free for internal use. Commercial rights reserved.**
4
+
5
+ Copyright © 2026 Dahl Ventures Inc. All rights reserved.
6
+
7
+ This software is licensed under the Spine Framework Internal Use License 1.0.0.
8
+
9
+ For full license terms, see: https://github.com/spine-framework/spine-framework/blob/main/LICENSE.md
10
+
11
+ **Summary:** You may use this software for internal business use only. Commercial use, resale, SaaS offering, white-labeling, and distribution require a separate Commercial License.
12
+
13
+ Contact: webmaster@spine-framework.com
@@ -0,0 +1,27 @@
1
+ # spine-framework-cortex
2
+
3
+ AI-powered support, CRM, and knowledge base app for Spine Framework.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install spine-framework-cortex
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```bash
14
+ npx spine-framework install-app cortex
15
+ ```
16
+
17
+ ## Features
18
+
19
+ - Knowledge Base (KB) management with AI-powered article generation
20
+ - Support ticket routing with AI triage
21
+ - Anonymous visitor tracking and funnel signal processing
22
+ - Opportunity queue for high-engagement prospects
23
+ - Case analysis and resolution tracking
24
+
25
+ ## License
26
+
27
+ MIT
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Cortex Webhook Handler
3
+ *
4
+ * Returns "Serenity" for valid requests
5
+ * Receives sanitized data and full context from integration-routes
6
+ */
7
+
8
+ export default async function handler(
9
+ data: any,
10
+ ctx: {
11
+ integrationId: string
12
+ accountId: string
13
+ slug: string
14
+ principal: any
15
+ requestId: string
16
+ headers: Record<string, string>
17
+ },
18
+ event: {
19
+ httpMethod: string
20
+ headers: Record<string, string>
21
+ body: any
22
+ path: string
23
+ queryStringParameters: Record<string, string>
24
+ }
25
+ ): Promise<string> {
26
+ // Log the received data for debugging
27
+ console.log(`[${ctx.requestId}] Cortex handler received:`, {
28
+ testText: data['test-text'],
29
+ integrationId: ctx.integrationId,
30
+ accountId: ctx.accountId
31
+ })
32
+
33
+ // Return Serenity as plain text
34
+ return 'Serenity'
35
+ }
@@ -0,0 +1,222 @@
1
+ # Cortex App Configuration
2
+
3
+ This guide explains how to configure and deploy the Cortex app for customer support, CRM, and community management.
4
+
5
+ ## Database Configuration
6
+
7
+ ### 1. Apps Table Entry
8
+
9
+ Insert the Cortex app into the `public.apps` table:
10
+
11
+ ```sql
12
+ INSERT INTO public.apps (
13
+ id,
14
+ slug,
15
+ name,
16
+ description,
17
+ version,
18
+ app_type,
19
+ source,
20
+ owner_account_id,
21
+ is_active,
22
+ is_system,
23
+ min_role,
24
+ config,
25
+ nav_items,
26
+ route_prefix,
27
+ renderer,
28
+ created_at
29
+ ) VALUES (
30
+ gen_random_uuid(),
31
+ 'cortex',
32
+ 'Cortex',
33
+ 'Unified workspace for CRM, Support, Community, and Knowledge Base',
34
+ '1.0.0',
35
+ 'custom',
36
+ 'spine-framework',
37
+ 'd3ab4cf8-33de-4ca5-97a2-dbc288c94338', -- spine-system account
38
+ true,
39
+ false,
40
+ 'support',
41
+ '{}',
42
+ '[
43
+ {
44
+ "title": "Dashboard",
45
+ "path": "/dashboard",
46
+ "icon": "LayoutDashboard",
47
+ "order": 1
48
+ },
49
+ {
50
+ "title": "CRM",
51
+ "path": "/crm",
52
+ "icon": "Users",
53
+ "order": 2,
54
+ "children": [
55
+ {"title": "Accounts", "path": "/crm/accounts"},
56
+ {"title": "Contacts", "path": "/crm/contacts"},
57
+ {"title": "Deals", "path": "/crm/deals"},
58
+ {"title": "Health", "path": "/crm/health"},
59
+ {"title": "Activity", "path": "/crm/activity"}
60
+ ]
61
+ },
62
+ {
63
+ "title": "Support",
64
+ "path": "/support",
65
+ "icon": "Headphones",
66
+ "order": 3
67
+ },
68
+ {
69
+ "title": "Community",
70
+ "path": "/community",
71
+ "icon": "Users",
72
+ "order": 4
73
+ },
74
+ {
75
+ "title": "Knowledge Base",
76
+ "path": "/kb",
77
+ "icon": "BookOpen",
78
+ "order": 5
79
+ },
80
+ {
81
+ "title": "Courses",
82
+ "path": "/courses",
83
+ "icon": "GraduationCap",
84
+ "order": 6
85
+ },
86
+ {
87
+ "title": "Intelligence",
88
+ "path": "/intelligence",
89
+ "icon": "Brain",
90
+ "order": 7
91
+ }
92
+ ]',
93
+ '/cortex', -- Change to '/' for root serving
94
+ 'custom',
95
+ now()
96
+ );
97
+ ```
98
+
99
+ ### 2. App Installation
100
+
101
+ Install Cortex for your account:
102
+
103
+ ```sql
104
+ INSERT INTO public.app_installations (
105
+ account_id,
106
+ app_slug,
107
+ is_enabled
108
+ ) VALUES (
109
+ 'your-account-id', -- Replace with your account ID
110
+ 'cortex',
111
+ true
112
+ );
113
+ ```
114
+
115
+ ### 3. Required Roles
116
+
117
+ Cortex requires users to have the `support` role. Create this role if it doesn't exist:
118
+
119
+ ```sql
120
+ INSERT INTO public.roles (
121
+ slug,
122
+ name,
123
+ description,
124
+ is_system,
125
+ is_active
126
+ ) VALUES (
127
+ 'support',
128
+ 'Support Agent',
129
+ 'Can access Cortex support features',
130
+ false,
131
+ true
132
+ ) ON CONFLICT (slug) DO NOTHING;
133
+ ```
134
+
135
+ Assign the support role to users who need Cortex access:
136
+
137
+ ```sql
138
+ INSERT INTO public.people (
139
+ account_id,
140
+ user_id,
141
+ role_id,
142
+ is_active
143
+ ) VALUES (
144
+ 'your-account-id',
145
+ 'user-id',
146
+ (SELECT id FROM public.roles WHERE slug = 'support'),
147
+ true
148
+ );
149
+ ```
150
+
151
+ ## Manifest Configuration
152
+
153
+ The `manifest.json` file controls app behavior and routing:
154
+
155
+ ### Key Settings
156
+
157
+ - **`required_roles`**: `["support"]` - Users must have support role
158
+ - **`routes`**: Define all available routes in the app
159
+ - **`nav_items`**: Navigation structure and icons
160
+ - **`route_prefix`**: Where the app is served from
161
+
162
+ ### Route Prefix Configuration
163
+
164
+ #### Subdirectory Serving (Default)
165
+ ```json
166
+ {
167
+ "route_prefix": "/cortex"
168
+ }
169
+ ```
170
+ - App accessible at: `http://domain.com/cortex`
171
+ - Safe for multi-app deployments
172
+ - Default configuration
173
+
174
+ #### Root Serving
175
+ ```json
176
+ {
177
+ "route_prefix": "/"
178
+ }
179
+ ```
180
+ - App accessible at: `http://domain.com/`
181
+ - Use for single-app deployments
182
+ - Requires updating database `route_prefix` field
183
+
184
+ ### Prefix-Aware Routing
185
+
186
+ Cortex uses prefix-aware routing that automatically adapts to the `route_prefix`:
187
+
188
+ - Navigation links automatically include the base path
189
+ - Route definitions work regardless of serving location
190
+ - Breadcrumbs and redirects are prefix-aware
191
+
192
+ No code changes needed when switching between subdirectory and root serving.
193
+
194
+ ## Deployment Options
195
+
196
+ ### Option 1: Subdirectory Deployment (Recommended)
197
+
198
+ 1. Set `route_prefix: "/cortex"` in database
199
+ 2. App available at `/cortex/*` URLs
200
+ 3. Multiple apps can coexist safely
201
+
202
+ ### Option 2: Root Deployment
203
+
204
+ 1. Set `route_prefix: "/"` in database
205
+ 2. App available at root URLs (`/`, `/dashboard`, etc.)
206
+ 3. Use for dedicated Cortex deployments
207
+
208
+ ## Verification
209
+
210
+ Test the configuration:
211
+
212
+ 1. Check `/api/apps?action=list` returns Cortex
213
+ 2. Navigate to the configured route prefix
214
+ 3. Verify navigation works correctly
215
+ 4. Confirm all pages load without errors
216
+
217
+ ## Troubleshooting
218
+
219
+ - **404 errors**: Check `route_prefix` matches database entry
220
+ - **Access denied**: Verify user has `support` role
221
+ - **Navigation broken**: Ensure prefix-aware routing is enabled
222
+ - **Missing pages**: Check all route components exist and export defaults
@@ -0,0 +1,217 @@
1
+ import React, { useState } from 'react'
2
+ import { useApi } from '../../../v2-core/src/hooks/useApi'
3
+ import { Button } from '../../../v2-core/src/components/ui/button'
4
+ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../../../v2-core/src/components/ui/card'
5
+ import { Progress } from '../../../v2-core/src/components/ui/progress'
6
+ import { Alert, AlertDescription } from '../../../v2-core/src/components/ui/alert'
7
+ import { Badge } from '../../../v2-core/src/components/ui/badge'
8
+
9
+ interface IngestionResponse {
10
+ success: boolean
11
+ items_created: number
12
+ items_updated: number
13
+ embeddings_generated: number
14
+ errors: string[]
15
+ skipped: string[]
16
+ }
17
+
18
+ interface IngestionStats {
19
+ total: number
20
+ processed: number
21
+ created: number
22
+ updated: number
23
+ errors: number
24
+ }
25
+
26
+ export default function KBIngestion() {
27
+ const [isIngesting, setIsIngesting] = useState(false)
28
+ const [stats, setStats] = useState<IngestionStats | null>(null)
29
+ const [error, setError] = useState<string | null>(null)
30
+ const [logs, setLogs] = useState<string[]>([])
31
+ const apiFetch = useApi()
32
+
33
+ const addLog = (message: string) => {
34
+ const timestamp = new Date().toLocaleTimeString()
35
+ setLogs(prev => [...prev, `[${timestamp}] ${message}`])
36
+ }
37
+
38
+ const loadChunks = async (): Promise<any[]> => {
39
+ try {
40
+ const response = await fetch('/chunks.json')
41
+ if (!response.ok) {
42
+ throw new Error('Failed to load chunks file')
43
+ }
44
+ const data = await response.json()
45
+ return data.chunks || []
46
+ } catch (err) {
47
+ throw new Error(`Could not load chunks: ${err instanceof Error ? err.message : 'Unknown error'}`)
48
+ }
49
+ }
50
+
51
+ const ingestBatch = async (chunks: any[], batchSize = 10): Promise<IngestionResponse> => {
52
+ const response = await apiFetch('/.netlify/functions/custom_kb-ingestion', {
53
+ method: 'POST',
54
+ headers: {
55
+ 'Content-Type': 'application/json',
56
+ },
57
+ body: JSON.stringify({
58
+ chunks,
59
+ force_update: false
60
+ })
61
+ })
62
+
63
+ if (!response.ok) {
64
+ const errorData = await response.json().catch(() => ({ error: 'Unknown error' }))
65
+ throw new Error(`Batch failed: ${errorData.error || response.statusText}`)
66
+ }
67
+
68
+ return await response.json()
69
+ }
70
+
71
+ const startIngestion = async () => {
72
+ setIsIngesting(true)
73
+ setError(null)
74
+ setStats(null)
75
+ setLogs([])
76
+
77
+ try {
78
+ addLog('Loading chunks from file...')
79
+ const chunks = await loadChunks()
80
+ addLog(`Loaded ${chunks.length} chunks`)
81
+
82
+ if (chunks.length === 0) {
83
+ throw new Error('No chunks found to ingest')
84
+ }
85
+
86
+ const results: IngestionStats = {
87
+ total: chunks.length,
88
+ processed: 0,
89
+ created: 0,
90
+ updated: 0,
91
+ errors: 0
92
+ }
93
+
94
+ const batchSize = 10
95
+ const totalBatches = Math.ceil(chunks.length / batchSize)
96
+
97
+ for (let i = 0; i < chunks.length; i += batchSize) {
98
+ const batch = chunks.slice(i, i + batchSize)
99
+ const batchNum = Math.floor(i / batchSize) + 1
100
+
101
+ addLog(`Processing batch ${batchNum}/${totalBatches} (${batch.length} chunks)...`)
102
+
103
+ try {
104
+ const response = await ingestBatch(batch)
105
+
106
+ results.processed += batch.length
107
+ results.created += response.items_created || 0
108
+ results.updated += response.items_updated || 0
109
+
110
+ if (response.errors && response.errors.length > 0) {
111
+ results.errors += response.errors.length
112
+ addLog(`Batch ${batchNum} had ${response.errors.length} errors`)
113
+ }
114
+
115
+ if (response.skipped && response.skipped.length > 0) {
116
+ addLog(`Batch ${batchNum} skipped ${response.skipped.length} chunks`)
117
+ }
118
+
119
+ addLog(`Batch ${batchNum} complete: ${response.items_created || 0} created, ${response.items_updated || 0} updated`)
120
+
121
+ // Update progress
122
+ setStats({ ...results })
123
+
124
+ // Small delay to prevent overwhelming the server
125
+ await new Promise(resolve => setTimeout(resolve, 500))
126
+
127
+ } catch (batchError) {
128
+ results.errors += batch.length
129
+ addLog(`Batch ${batchNum} failed: ${batchError instanceof Error ? batchError.message : 'Unknown error'}`)
130
+ }
131
+ }
132
+
133
+ addLog(`Ingestion complete! Created: ${results.created}, Updated: ${results.updated}, Errors: ${results.errors}`)
134
+ setStats(results)
135
+
136
+ } catch (err) {
137
+ const errorMessage = err instanceof Error ? err.message : 'Unknown error occurred'
138
+ setError(errorMessage)
139
+ addLog(`ERROR: ${errorMessage}`)
140
+ } finally {
141
+ setIsIngesting(false)
142
+ }
143
+ }
144
+
145
+ const progress = stats ? (stats.processed / stats.total) * 100 : 0
146
+
147
+ return (
148
+ <div className="max-w-4xl mx-auto p-6 space-y-6">
149
+ <Card>
150
+ <CardHeader>
151
+ <CardTitle>KB Code Chunk Ingestion</CardTitle>
152
+ <CardDescription>
153
+ Ingest parsed code chunks from v2-core functions into the Knowledge Base system.
154
+ This creates KB articles and embeddings for each code chunk.
155
+ </CardDescription>
156
+ </CardHeader>
157
+ <CardContent className="space-y-4">
158
+ <div className="flex items-center gap-4">
159
+ <Button
160
+ onClick={startIngestion}
161
+ disabled={isIngesting}
162
+ size="lg"
163
+ >
164
+ {isIngesting ? 'Ingesting...' : 'Start Ingestion'}
165
+ </Button>
166
+
167
+ {stats && (
168
+ <div className="flex gap-2">
169
+ <Badge variant="outline">
170
+ Total: {stats.total}
171
+ </Badge>
172
+ <Badge variant="outline">
173
+ Created: {stats.created}
174
+ </Badge>
175
+ <Badge variant="outline">
176
+ Updated: {stats.updated}
177
+ </Badge>
178
+ {stats.errors > 0 && (
179
+ <Badge variant="destructive">
180
+ Errors: {stats.errors}
181
+ </Badge>
182
+ )}
183
+ </div>
184
+ )}
185
+ </div>
186
+
187
+ {isIngesting && (
188
+ <div className="space-y-2">
189
+ <div className="flex justify-between text-sm">
190
+ <span>Progress</span>
191
+ <span>{stats ? `${stats.processed}/${stats.total}` : 'Starting...'}</span>
192
+ </div>
193
+ <Progress value={progress} className="w-full" />
194
+ </div>
195
+ )}
196
+
197
+ {error && (
198
+ <Alert variant="destructive">
199
+ <AlertDescription>{error}</AlertDescription>
200
+ </Alert>
201
+ )}
202
+
203
+ {logs.length > 0 && (
204
+ <div className="space-y-2">
205
+ <h4 className="font-medium">Activity Log</h4>
206
+ <div className="bg-gray-50 dark:bg-gray-900 p-4 rounded-lg max-h-64 overflow-y-auto">
207
+ <pre className="text-xs font-mono whitespace-pre-wrap">
208
+ {logs.join('\n')}
209
+ </pre>
210
+ </div>
211
+ </div>
212
+ )}
213
+ </CardContent>
214
+ </Card>
215
+ </div>
216
+ )
217
+ }
@@ -5,7 +5,6 @@
5
5
  "version": "1.0.0",
6
6
  "required_roles": ["support"],
7
7
  "routes": [
8
- "/cortex",
9
8
  "/cortex/dashboard",
10
9
  "/cortex/crm",
11
10
  "/cortex/crm/accounts",
@@ -75,6 +74,18 @@
75
74
  "order": 7
76
75
  }
77
76
  ],
77
+ "changelog": [
78
+ {
79
+ "version": "1.0.0",
80
+ "notes": [
81
+ "Root-relative nav paths for subdomain deployment model",
82
+ "Prefix-aware sidebar navigation via useCurrentApp()",
83
+ "Prefix-aware breadcrumbs with Navigate index redirect",
84
+ "FilterTab replaces FunnelTab (lucide Filter icon)",
85
+ "Initial release"
86
+ ]
87
+ }
88
+ ],
78
89
  "features": ["crm", "support", "community", "kb", "courses", "intelligence"],
79
90
  "dependencies": ["items", "accounts", "pipelines", "integrations"],
80
91
  "entry_point": "./index.tsx",
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "spine-framework-cortex",
3
+ "version": "0.1.9",
4
+ "description": "Cortex — AI-powered support, CRM, and knowledge base app for Spine Framework",
5
+ "type": "module",
6
+ "license": "SEE LICENSE IN LICENSE.md",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/spine-framework/cortex",
10
+ "directory": "custom/apps/cortex"
11
+ },
12
+ "peerDependencies": {
13
+ "spine-framework": ">=0.1.0"
14
+ },
15
+ "files": [
16
+ "index.tsx",
17
+ "manifest.json",
18
+ "seed/",
19
+ "pages/",
20
+ "components/",
21
+ "functions/",
22
+ "lib/",
23
+ "README.md",
24
+ "LICENSE.md"
25
+ ],
26
+ "spine": {
27
+ "type": "app",
28
+ "slug": "cortex",
29
+ "manifestPath": "manifest.json"
30
+ }
31
+ }
package/package.json CHANGED
@@ -1,31 +1,92 @@
1
1
  {
2
2
  "name": "spine-framework-cortex",
3
- "version": "0.1.9",
4
- "description": "Cortex AI-powered support, CRM, and knowledge base app for Spine Framework",
5
- "type": "module",
6
- "license": "SEE LICENSE IN LICENSE.md",
3
+ "version": "1.0.0",
4
+ "description": "Unified workspace for CRM, Support, Community, and Knowledge Base built on Spine Framework",
5
+ "main": "custom/apps/cortex/index.tsx",
6
+ "homepage": "https://spine-framework.com",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "https://github.com/spine-framework/cortex",
10
- "directory": "custom/apps/cortex"
11
- },
12
- "peerDependencies": {
13
- "spine-framework": ">=0.1.0"
9
+ "url": "https://github.com/spine-framework/spine-framework-cortex.git"
14
10
  },
11
+ "keywords": [
12
+ "spine-framework",
13
+ "crm",
14
+ "support",
15
+ "community",
16
+ "knowledge-base",
17
+ "courses",
18
+ "customer-service",
19
+ "business-management"
20
+ ],
21
+ "author": "Dahl Ventures Inc.",
22
+ "license": "SEE LICENSE IN LICENSE.md",
15
23
  "files": [
16
- "index.tsx",
17
- "manifest.json",
18
- "seed/",
19
- "pages/",
20
- "components/",
21
- "functions/",
22
- "lib/",
24
+ "custom/apps/cortex/**/*",
25
+ "LICENSE.md",
23
26
  "README.md",
24
- "LICENSE.md"
27
+ "package.json"
25
28
  ],
29
+ "engines": {
30
+ "node": ">=18.0.0"
31
+ },
32
+ "peerDependencies": {
33
+ "spine-framework": "^1.0.0",
34
+ "react": "^18.0.0",
35
+ "react-dom": "^18.0.0"
36
+ },
37
+ "dependencies": {
38
+ "@spine-framework/core": "^1.0.0"
39
+ },
40
+ "devDependencies": {
41
+ "@types/react": "^18.0.0",
42
+ "@types/react-dom": "^18.0.0",
43
+ "typescript": "^5.0.0",
44
+ "vite": "^5.0.0"
45
+ },
46
+ "scripts": {
47
+ "build": "vite build",
48
+ "dev": "vite dev",
49
+ "type-check": "tsc --noEmit",
50
+ "lint": "eslint custom/apps/cortex --ext .ts,.tsx",
51
+ "test": "vitest"
52
+ },
53
+ "exports": {
54
+ ".": {
55
+ "types": "./custom/apps/cortex/index.tsx",
56
+ "default": "./custom/apps/cortex/index.tsx"
57
+ },
58
+ "./components": {
59
+ "types": "./custom/apps/cortex/components/index.ts",
60
+ "default": "./custom/apps/cortex/components/index.ts"
61
+ },
62
+ "./hooks": {
63
+ "types": "./custom/apps/cortex/hooks/index.ts",
64
+ "default": "./custom/apps/cortex/hooks/index.ts"
65
+ },
66
+ "./types": {
67
+ "types": "./custom/apps/cortex/types/index.ts",
68
+ "default": "./custom/apps/cortex/types/index.ts"
69
+ },
70
+ "./package.json": "./package.json"
71
+ },
72
+ "publishConfig": {
73
+ "access": "public",
74
+ "registry": "https://registry.npmjs.org/"
75
+ },
26
76
  "spine": {
27
- "type": "app",
28
- "slug": "cortex",
29
- "manifestPath": "manifest.json"
77
+ "app": {
78
+ "slug": "cortex",
79
+ "name": "Cortex",
80
+ "version": "1.0.0",
81
+ "entry": "custom/apps/cortex/index.tsx",
82
+ "manifest": "custom/apps/cortex/manifest.json",
83
+ "requiredRoles": ["support"],
84
+ "routePrefix": "/cortex",
85
+ "renderer": "custom"
86
+ },
87
+ "compatibility": {
88
+ "framework": "^1.0.0",
89
+ "node": ">=18.0.0"
90
+ }
30
91
  }
31
92
  }
File without changes
File without changes
File without changes
File without changes
File without changes