@spekra.in/agent-os 0.0.0-stage → 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 (114) hide show
  1. package/Booker/README.md +41 -0
  2. package/Booker/package.json +11 -0
  3. package/Booker/src/agent.js +15 -0
  4. package/Booker/src/calendar-adapter.js +75 -0
  5. package/Booker/src/index.js +4 -0
  6. package/Booker/src/intake-parser.js +96 -0
  7. package/Booker/src/validation.js +34 -0
  8. package/Booker/test/booker.test.js +35 -0
  9. package/CashHound/README.md +181 -0
  10. package/CashHound/package.json +21 -0
  11. package/CashHound/src/agent.js +621 -0
  12. package/CashHound/src/bank-reconciler.js +66 -0
  13. package/CashHound/src/dunning.js +380 -0
  14. package/CashHound/src/index.js +32 -0
  15. package/CashHound/src/invoice.js +371 -0
  16. package/CashHound/src/mobile.js +35 -0
  17. package/CashHound/src/npv-optimizer.js +259 -0
  18. package/CashHound/test/advanced.test.js +44 -0
  19. package/CashHound/test/cashhound.test.js +530 -0
  20. package/CashHound/test/mobile.test.js +25 -0
  21. package/CashHound/test/security.test.js +35 -0
  22. package/Clerk/README.md +30 -0
  23. package/Clerk/package.json +11 -0
  24. package/Clerk/src/agent.js +18 -0
  25. package/Clerk/src/index.js +2 -0
  26. package/Clerk/src/reconciliation.js +52 -0
  27. package/Clerk/test/clerk.test.js +39 -0
  28. package/LocalRoar/README.md +37 -0
  29. package/LocalRoar/package.json +13 -0
  30. package/LocalRoar/src/agent.js +70 -0
  31. package/LocalRoar/src/booking-router.js +74 -0
  32. package/LocalRoar/src/feedback-interceptor.js +47 -0
  33. package/LocalRoar/src/index.js +7 -0
  34. package/LocalRoar/src/lead-engine.js +52 -0
  35. package/LocalRoar/src/mobile.js +23 -0
  36. package/LocalRoar/src/review-booster.js +24 -0
  37. package/LocalRoar/src/route-density.js +46 -0
  38. package/LocalRoar/test/advanced.test.js +41 -0
  39. package/LocalRoar/test/localroar.test.js +59 -0
  40. package/LocalRoar/test/mobile.test.js +12 -0
  41. package/OmniLife/README.md +39 -0
  42. package/OmniLife/package.json +13 -0
  43. package/OmniLife/src/agent.js +47 -0
  44. package/OmniLife/src/bill-negotiator.js +43 -0
  45. package/OmniLife/src/browser-cancel.js +28 -0
  46. package/OmniLife/src/conflict-engine.js +49 -0
  47. package/OmniLife/src/index.js +6 -0
  48. package/OmniLife/src/mobile.js +18 -0
  49. package/OmniLife/src/subscription-manager.js +66 -0
  50. package/OmniLife/test/advanced.test.js +29 -0
  51. package/OmniLife/test/mobile.test.js +12 -0
  52. package/OmniLife/test/omnilife.test.js +71 -0
  53. package/PulseMD/README.md +42 -0
  54. package/PulseMD/package.json +13 -0
  55. package/PulseMD/src/agent.js +67 -0
  56. package/PulseMD/src/ambient-scribe.js +46 -0
  57. package/PulseMD/src/auth.js +63 -0
  58. package/PulseMD/src/charting.js +54 -0
  59. package/PulseMD/src/index.js +7 -0
  60. package/PulseMD/src/mobile.js +18 -0
  61. package/PulseMD/src/prior-auth.js +39 -0
  62. package/PulseMD/src/safety-guard.js +88 -0
  63. package/PulseMD/test/advanced.test.js +50 -0
  64. package/PulseMD/test/mobile.test.js +12 -0
  65. package/PulseMD/test/pulsemd.test.js +71 -0
  66. package/README.md +203 -2
  67. package/ResolveX/README.md +274 -0
  68. package/ResolveX/package.json +20 -0
  69. package/ResolveX/src/agent.js +679 -0
  70. package/ResolveX/src/carrier-listener.js +405 -0
  71. package/ResolveX/src/diagnosis.js +315 -0
  72. package/ResolveX/src/index.js +36 -0
  73. package/ResolveX/src/mobile.js +31 -0
  74. package/ResolveX/src/policy.js +325 -0
  75. package/ResolveX/src/vision.js +384 -0
  76. package/ResolveX/test/advanced.test.js +445 -0
  77. package/ResolveX/test/mobile.test.js +15 -0
  78. package/ResolveX/test/resolvex.test.js +428 -0
  79. package/SentinelMesh/README.md +51 -0
  80. package/SentinelMesh/package.json +13 -0
  81. package/SentinelMesh/src/governor.js +61 -0
  82. package/SentinelMesh/src/index.js +4 -0
  83. package/SentinelMesh/src/mobile.js +19 -0
  84. package/SentinelMesh/src/policy.js +63 -0
  85. package/SentinelMesh/src/sandbox.js +152 -0
  86. package/SentinelMesh/test/mobile.test.js +12 -0
  87. package/SentinelMesh/test/sentinel.test.js +135 -0
  88. package/Sidekick/README.md +43 -0
  89. package/Sidekick/package.json +11 -0
  90. package/Sidekick/src/agent.js +15 -0
  91. package/Sidekick/src/evidence.js +45 -0
  92. package/Sidekick/src/index.js +3 -0
  93. package/Sidekick/src/validation.js +15 -0
  94. package/Sidekick/test/sidekick.test.js +33 -0
  95. package/agent-os-mobile/README.md +26 -0
  96. package/agent-os-mobile/src/api.js +97 -0
  97. package/agent-os-mobile/src/biometric.js +41 -0
  98. package/agent-os-mobile/src/components/ApprovalStack.js +207 -0
  99. package/agent-os-mobile/src/components/OutcomeCard.js +98 -0
  100. package/agent-os-mobile/src/memory-graph.js +114 -0
  101. package/agent-os-mobile/src/screens/CashHoundMobileScreen.js +111 -0
  102. package/agent-os-mobile/src/screens/LocalRoarMobileScreen.js +183 -0
  103. package/agent-os-mobile/src/screens/OmniLifeMobileScreen.js +111 -0
  104. package/agent-os-mobile/src/screens/PulseMDMobileScreen.js +55 -0
  105. package/agent-os-mobile/src/screens/ResolveXMobileScreen.js +96 -0
  106. package/agent-os-mobile/src/screens/SentinelMeshMobileScreen.js +199 -0
  107. package/agent-os-mobile/src/self-healer.js +104 -0
  108. package/agent-os-mobile/src/speculative-verifier.js +69 -0
  109. package/agent-os-mobile/src/spekra-bridge.js +216 -0
  110. package/agent-os-mobile/src/swarm.js +72 -0
  111. package/agent-os-mobile/src/voice.js +51 -0
  112. package/bin/agentos.js +260 -0
  113. package/package.json +51 -4
  114. package/src/index.js +91 -0
@@ -0,0 +1,2 @@
1
+ export { settlementAgent } from './agent.js';
2
+ export { SettlementReconciler } from './reconciliation.js';
@@ -0,0 +1,52 @@
1
+ import { randomUUID } from 'node:crypto';
2
+
3
+ /**
4
+ * Clerk Settlement & Payment Reconciliation Helpers
5
+ */
6
+ export class SettlementReconciler {
7
+ constructor() {
8
+ this.invoices = new Map();
9
+ this.payments = new Map();
10
+ this.claims = new Map();
11
+ }
12
+
13
+ issueInvoice(tenant, jobId, amount, currency = 'INR') {
14
+ if (!Number.isSafeInteger(amount) || amount <= 0) throw new Error('Invalid invoice amount');
15
+ const invoice = {
16
+ id: randomUUID(),
17
+ tenant,
18
+ jobId,
19
+ amount,
20
+ currency,
21
+ issuedAt: new Date().toISOString()
22
+ };
23
+ this.invoices.set(`${tenant}:${jobId}`, invoice);
24
+ return invoice;
25
+ }
26
+
27
+ recordPayment(tenant, jobId, invoiceId, amount, currency, reference) {
28
+ const payment = {
29
+ id: randomUUID(),
30
+ tenant,
31
+ jobId,
32
+ invoiceId,
33
+ amount,
34
+ currency,
35
+ reference,
36
+ paidAt: new Date().toISOString()
37
+ };
38
+ this.payments.set(`${tenant}:${jobId}`, payment);
39
+ return payment;
40
+ }
41
+
42
+ verifyPayment(tenant, jobId) {
43
+ const invoice = this.invoices.get(`${tenant}:${jobId}`);
44
+ const payment = this.payments.get(`${tenant}:${jobId}`);
45
+ if (!invoice || !payment) return { verified: false, reason: 'Missing invoice or payment record' };
46
+ if (payment.invoiceId !== invoice.id) return { verified: false, reason: 'Payment does not match invoice ID' };
47
+ if (payment.amount !== invoice.amount || payment.currency !== invoice.currency) {
48
+ return { verified: false, reason: 'Payment amount or currency mismatch' };
49
+ }
50
+ return { verified: true, payment };
51
+ }
52
+ }
@@ -0,0 +1,39 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { settlementAgent, SettlementReconciler } from '../src/index.js';
4
+
5
+ test('Clerk: blocks settlement if charges differ from accepted estimate', () => {
6
+ const jobMismatched = {
7
+ input: { amount: 150000 },
8
+ report: { amount: 200000 }
9
+ };
10
+ const decision = settlementAgent.next(jobMismatched);
11
+ assert.equal(decision.wait, 'blocked');
12
+ assert.match(decision.reason, /charges differ/);
13
+ });
14
+
15
+ test('Clerk: proposes invoice and payment verification when charges agree', () => {
16
+ const jobStandard = {
17
+ input: { amount: 150000 },
18
+ report: { amount: 150000, warranty: false }
19
+ };
20
+ const decision1 = settlementAgent.next(jobStandard);
21
+ assert.equal(decision1.tool, 'invoice');
22
+ assert.equal(decision1.permission, 'invoice');
23
+
24
+ const decision2 = settlementAgent.next({ ...jobStandard, invoice: { id: 'inv-1', amount: 150000 } });
25
+ assert.equal(decision2.tool, 'verifyPayment');
26
+ });
27
+
28
+ test('Clerk: payment reconciliation confirms exact amount and invoice binding', () => {
29
+ const reconciler = new SettlementReconciler();
30
+ const invoice = reconciler.issueInvoice('t1', 'job-1', 150000, 'INR');
31
+
32
+ // Mismatched amount
33
+ reconciler.recordPayment('t1', 'job-1', invoice.id, 100000, 'INR', 'ref-01');
34
+ assert.equal(reconciler.verifyPayment('t1', 'job-1').verified, false);
35
+
36
+ // Exact match
37
+ reconciler.recordPayment('t1', 'job-1', invoice.id, 150000, 'INR', 'ref-02');
38
+ assert.equal(reconciler.verifyPayment('t1', 'job-1').verified, true);
39
+ });
@@ -0,0 +1,37 @@
1
+ # LocalRoar — 24/7 Autonomous Growth Operator for Local Businesses
2
+
3
+ **LocalRoar** is the always-on operator that converts inbound customer inquiries into paying jobs, prevents booking collisions, requests five-star customer reviews, and compiles weekly revenue digests.
4
+
5
+ ## Capabilities
6
+
7
+ 1. **Omnichannel Lead Parsing:** Instantly extracts intent, emergency status, contact info, and matches against the business service catalog.
8
+ 2. **Instant Dynamic Quotes:** Provides transparent, policy-compliant price estimates tailored for standard or emergency dispatches.
9
+ 3. **Collision-Free Slot Booking:** Enforces calendar duration boundaries to prevent double-booking.
10
+ 4. **Automated Review Velocity:** Triggers personalized SMS/email feedback outreach post-service to build local reputation.
11
+ 5. **Executive Digest:** Provides owners with automated weekly conversion rates and pipeline volume.
12
+
13
+ ## Usage
14
+
15
+ ```javascript
16
+ import { LocalRoarAgent } from 'localroar-agent';
17
+
18
+ const agent = new LocalRoarAgent('Apex Plumbing & Heating');
19
+
20
+ // 1. Ingest inbound lead from web or SMS
21
+ const quote = agent.handleInquiry('Hi, pipe leaking under kitchen sink! Phone: 555-019-2834', 'sms');
22
+
23
+ // 2. Lock in slot
24
+ const reservation = agent.confirmBooking('David Miller', '2026-12-05T14:00:00Z', 'plumbing', 11250);
25
+
26
+ // 3. Review scheduled outreach
27
+ console.log(reservation.scheduledReviewOutreach.message);
28
+
29
+ // 4. View weekly digest
30
+ console.log(agent.generateWeeklyDigest());
31
+ ```
32
+
33
+ ## Testing
34
+
35
+ ```sh
36
+ npm test
37
+ ```
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "localroar-agent",
3
+ "version": "0.1.0",
4
+ "description": "LocalRoar - 24/7 Autonomous Growth & Revenue Operator for Local Businesses",
5
+ "private": true,
6
+ "type": "module",
7
+ "engines": {
8
+ "node": ">=20"
9
+ },
10
+ "scripts": {
11
+ "test": "node --test"
12
+ }
13
+ }
@@ -0,0 +1,70 @@
1
+ import { LeadEngine } from './lead-engine.js';
2
+ import { BookingRouter } from './booking-router.js';
3
+ import { ReviewBooster } from './review-booster.js';
4
+
5
+ /**
6
+ * LocalRoar Agent: 24/7 Autonomous operator for local business growth.
7
+ */
8
+ export class LocalRoarAgent {
9
+ constructor(businessName = 'LocalPro') {
10
+ this.businessName = businessName;
11
+ this.leadEngine = new LeadEngine();
12
+ this.bookingRouter = new BookingRouter();
13
+ this.reviewBooster = new ReviewBooster();
14
+ this.history = [];
15
+ }
16
+
17
+ handleInquiry(inquiryText, channel = 'web') {
18
+ const lead = this.leadEngine.parseInquiry(inquiryText, channel);
19
+ this.history.push({ type: 'LEAD_RECEIVED', lead, timestamp: new Date().toISOString() });
20
+
21
+ if (!lead.serviceKey) {
22
+ return {
23
+ action: 'CLARIFY',
24
+ reply: `Hello! We'd love to help you. Could you let us know what service you require (e.g., plumbing, electrical, hvac)?`
25
+ };
26
+ }
27
+
28
+ return {
29
+ action: 'QUOTE_AND_BOOK',
30
+ lead,
31
+ suggestedReply: `Thanks for contacting ${this.businessName}! Our estimated rate for ${lead.serviceName} is $${(lead.estimatedAmount / 100).toFixed(2)}. Would you like to schedule an appointment?`
32
+ };
33
+ }
34
+
35
+ confirmBooking(customerName, slot, serviceKey, estimatedAmount) {
36
+ const booking = this.bookingRouter.bookSlot({
37
+ customerName,
38
+ slot,
39
+ serviceKey,
40
+ estimatedAmount
41
+ });
42
+
43
+ this.history.push({ type: 'BOOKING_CONFIRMED', booking, timestamp: new Date().toISOString() });
44
+
45
+ const reviewJob = this.reviewBooster.generateReviewRequest(booking, this.businessName);
46
+
47
+ return {
48
+ status: 'CONFIRMED',
49
+ booking,
50
+ scheduledReviewOutreach: reviewJob
51
+ };
52
+ }
53
+
54
+ generateWeeklyDigest() {
55
+ const totalLeads = this.history.filter(h => h.type === 'LEAD_RECEIVED').length;
56
+ const confirmedBookings = this.bookingRouter.bookings.length;
57
+ const totalProjectedRevenue = this.bookingRouter.bookings.reduce((sum, b) => sum + (b.estimatedAmount || 0), 0);
58
+
59
+ return {
60
+ period: 'Last 7 Days',
61
+ metrics: {
62
+ totalLeadsCaptured: totalLeads,
63
+ bookingsConverted: confirmedBookings,
64
+ conversionRate: totalLeads > 0 ? `${Math.round((confirmedBookings / totalLeads) * 100)}%` : '0%',
65
+ projectedRevenueCents: totalProjectedRevenue,
66
+ projectedRevenueFormatted: `$${(totalProjectedRevenue / 100).toFixed(2)}`
67
+ }
68
+ };
69
+ }
70
+ }
@@ -0,0 +1,74 @@
1
+ /**
2
+ * LocalRoar Booking Router: Manages local appointment slots and confirms bookings.
3
+ * Hardened against Calendar Denial-of-Inventory (Resource Exhaustion).
4
+ */
5
+
6
+ export class BookingRouter {
7
+ constructor(options = {}) {
8
+ this.bookings = [];
9
+ this.maxActivePerCustomer = options.maxActivePerCustomer || 3;
10
+ }
11
+
12
+ isSlotAvailable(requestedIsoTime, durationMinutes = 60) {
13
+ const reqStart = new Date(requestedIsoTime).getTime();
14
+ if (Number.isNaN(reqStart)) {
15
+ throw new Error(`Invalid ISO timestamp: ${requestedIsoTime}`);
16
+ }
17
+
18
+ const reqEnd = reqStart + durationMinutes * 60 * 1000;
19
+
20
+ for (const b of this.bookings) {
21
+ if (b.status === 'CANCELLED') continue;
22
+
23
+ const bStart = new Date(b.slot).getTime();
24
+ const bEnd = bStart + b.durationMinutes * 60 * 1000;
25
+
26
+ // Overlap check
27
+ if (reqStart < bEnd && reqEnd > bStart) {
28
+ return false;
29
+ }
30
+ }
31
+ return true;
32
+ }
33
+
34
+ bookSlot(bookingDetails) {
35
+ const { slot, durationMinutes = 60, customerName, serviceKey, estimatedAmount } = bookingDetails;
36
+
37
+ if (!customerName || typeof customerName !== 'string' || customerName.trim().length === 0) {
38
+ throw new Error('Valid customer name required for booking');
39
+ }
40
+
41
+ const slotTime = new Date(slot).getTime();
42
+ if (Number.isNaN(slotTime)) {
43
+ throw new Error(`Invalid slot timestamp: ${slot}`);
44
+ }
45
+
46
+ // SEC-05: Rate-limiting & Inventory Denial-of-Service Defense
47
+ // Prevent a single user or bot from monopolizing all calendar slots
48
+ const activeCustomerBookings = this.bookings.filter(
49
+ b => b.customerName.toLowerCase() === customerName.toLowerCase() && b.status === 'CONFIRMED'
50
+ ).length;
51
+
52
+ if (activeCustomerBookings >= this.maxActivePerCustomer) {
53
+ throw new Error(`Booking limit exceeded: customer '${customerName}' already has ${activeCustomerBookings} active reservations`);
54
+ }
55
+
56
+ if (!this.isSlotAvailable(slot, durationMinutes)) {
57
+ throw new Error(`Slot ${slot} is already booked.`);
58
+ }
59
+
60
+ const bookingRecord = {
61
+ id: `book_${Date.now()}_${Math.floor(Math.random() * 1000)}`,
62
+ customerName: customerName.trim(),
63
+ serviceKey,
64
+ slot,
65
+ durationMinutes,
66
+ estimatedAmount,
67
+ status: 'CONFIRMED',
68
+ createdAt: new Date().toISOString()
69
+ };
70
+
71
+ this.bookings.push(bookingRecord);
72
+ return bookingRecord;
73
+ }
74
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * LocalRoar Negative Feedback Interceptor: Catches dissatisfied customers privately,
3
+ * triggering immediate owner outreach to defuse complaints before public Google Reviews.
4
+ */
5
+
6
+ export class FeedbackInterceptor {
7
+ constructor(ownerPhone = '555-901-PROS') {
8
+ this.ownerPhone = ownerPhone;
9
+ this.interceptedTickets = [];
10
+ }
11
+
12
+ processCustomerReview(bookingId, customerName, rating, feedbackText = '') {
13
+ const isSatisfied = rating >= 4;
14
+
15
+ if (isSatisfied) {
16
+ return {
17
+ action: 'ROUTE_TO_PUBLIC_GOOGLE_REVIEW',
18
+ bookingId,
19
+ customerName,
20
+ rating,
21
+ publicReviewUrl: `https://g.page/r/apex-pros/review?b=${encodeURIComponent(bookingId)}`,
22
+ thankYouMessage: `Thank you so much, ${customerName}! We're thrilled you had a 5-star experience. Would you mind sharing your review on Google? It means the world to our team.`
23
+ };
24
+ }
25
+
26
+ // Intercept 1-3 star review privately
27
+ const ticketId = `INT-${Date.now()}`;
28
+ const ticket = {
29
+ ticketId,
30
+ bookingId,
31
+ customerName,
32
+ rating,
33
+ feedbackText,
34
+ status: 'INTERCEPTED_PRIVATE',
35
+ ownerAlertMessage: `🚨 URGENT CUSTOMER ALERT: ${customerName} gave a ${rating}-star rating on Job #${bookingId}. Feedback: "${feedbackText}". Call customer immediately at priority dispatch.`,
36
+ customerApologyMessage: `We're deeply sorry to hear your service was not 100% satisfactory, ${customerName}. Our owner has been alerted and will personally call you within 30 minutes to make this right.`,
37
+ interceptedAt: new Date().toISOString()
38
+ };
39
+
40
+ this.interceptedTickets.push(ticket);
41
+
42
+ return {
43
+ action: 'INTERCEPT_PRIVATELY',
44
+ ticket
45
+ };
46
+ }
47
+ }
@@ -0,0 +1,7 @@
1
+ export { SERVICE_CATALOG, LeadEngine } from './lead-engine.js';
2
+ export { BookingRouter } from './booking-router.js';
3
+ export { ReviewBooster } from './review-booster.js';
4
+ export { LocalRoarAgent } from './agent.js';
5
+ export { LocalRoarMobileAdapter } from './mobile.js';
6
+ export { RouteDensityOptimizer } from './route-density.js';
7
+ export { FeedbackInterceptor } from './feedback-interceptor.js';
@@ -0,0 +1,52 @@
1
+ /**
2
+ * LocalRoar Lead Engine: Ingests unstructured inquiries and estimates pricing.
3
+ * Hardened against ReDoS and oversized payload denial-of-service.
4
+ */
5
+
6
+ export const SERVICE_CATALOG = {
7
+ plumbing: { name: 'Plumbing Repair', baseRate: 7500, estMinutes: 60 },
8
+ electrical: { name: 'Electrical Diagnostics', baseRate: 8500, estMinutes: 60 },
9
+ hvac: { name: 'HVAC Tune-up & Inspection', baseRate: 12000, estMinutes: 90 },
10
+ detailing: { name: 'Auto Detailing', baseRate: 9500, estMinutes: 120 }
11
+ };
12
+
13
+ export class LeadEngine {
14
+ parseInquiry(rawText, channel = 'web') {
15
+ // SEC-10: Cap input length to 2000 characters to prevent ReDoS and CPU exhaustion
16
+ const safeText = typeof rawText === 'string' ? rawText.slice(0, 2000) : '';
17
+ const cleaned = safeText.toLowerCase();
18
+
19
+ let detectedService = null;
20
+ for (const [key, details] of Object.entries(SERVICE_CATALOG)) {
21
+ if (cleaned.includes(key) || cleaned.includes(details.name.toLowerCase())) {
22
+ detectedService = key;
23
+ break;
24
+ }
25
+ }
26
+
27
+ // Default to plumbing if general pipe/leak mentioned
28
+ if (!detectedService && (cleaned.includes('pipe') || cleaned.includes('leak') || cleaned.includes('clog'))) {
29
+ detectedService = 'plumbing';
30
+ }
31
+
32
+ // Urgent flag
33
+ const isUrgent = cleaned.includes('emergency') || cleaned.includes('urgent') || cleaned.includes('asap') || cleaned.includes('flooding');
34
+
35
+ // Extract basic phone/email safely with bounded regex
36
+ const phoneMatch = safeText.match(/\b\d{3}[-.\s]?\d{3}[-.\s]?\d{4}\b/);
37
+ const emailMatch = safeText.match(/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,10}/);
38
+
39
+ const quoteAmount = detectedService ? Math.round(SERVICE_CATALOG[detectedService].baseRate * (isUrgent ? 1.5 : 1.0)) : null;
40
+
41
+ return {
42
+ channel,
43
+ serviceKey: detectedService,
44
+ serviceName: detectedService ? SERVICE_CATALOG[detectedService].name : 'Custom Service',
45
+ estimatedAmount: quoteAmount,
46
+ isUrgent,
47
+ customerPhone: phoneMatch ? phoneMatch[0] : null,
48
+ customerEmail: emailMatch ? emailMatch[0] : null,
49
+ rawText: safeText
50
+ };
51
+ }
52
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * LocalRoar Mobile Adapter: Formats mobile growth cards and 1-tap quote dispatchers.
3
+ */
4
+
5
+ export class LocalRoarMobileAdapter {
6
+ constructor(agent) {
7
+ this.agent = agent;
8
+ }
9
+
10
+ getMobileOutcomeCard() {
11
+ const digest = this.agent.generateWeeklyDigest();
12
+ return {
13
+ title: 'LocalRoar Growth Engine',
14
+ outcomeMetric: `${digest.metrics.conversionRate} Conversion`,
15
+ revenueProjected: digest.metrics.projectedRevenueFormatted,
16
+ statusBadge: 'ONLINE_24_7'
17
+ };
18
+ }
19
+
20
+ getMobileLeadCard(inquiryText, channel = 'sms') {
21
+ return this.agent.handleInquiry(inquiryText, channel);
22
+ }
23
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * LocalRoar Review Booster: Automatically triggers personalized post-job review outreach.
3
+ */
4
+
5
+ export class ReviewBooster {
6
+ generateReviewRequest(booking, businessName = 'Prime Services') {
7
+ return {
8
+ recipient: booking.customerName,
9
+ channel: 'sms',
10
+ message: `Hi ${booking.customerName}, thanks for choosing ${businessName} for your ${booking.serviceKey || 'recent service'}! How did we do? Please leave us a quick review: https://review.localroar.app/${booking.id}`,
11
+ scheduledDelayMinutes: 120 // 2 hours after completion
12
+ };
13
+ }
14
+
15
+ processFeedback(rating, comments = '') {
16
+ const isPositive = rating >= 4;
17
+ return {
18
+ rating,
19
+ sentiment: isPositive ? 'POSITIVE' : 'NEEDS_ATTENTION',
20
+ escalateToOwner: !isPositive,
21
+ suggestedAction: isPositive ? 'POST_TO_GOOGLE_BUSINESS' : 'NOTIFY_OWNER_IMMEDIATELY'
22
+ };
23
+ }
24
+ }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * LocalRoar Route Density Optimizer: Matches lead locations with active technician routes
3
+ * and injects dynamic proximity discounts to pack daily travel clusters.
4
+ */
5
+
6
+ export class RouteDensityOptimizer {
7
+ constructor(activeJobs = []) {
8
+ this.activeJobs = activeJobs; // e.g. [{ id: 'job-1', technicianId: 'tech-101', postalCode: '560038', street: '12th Main Road' }]
9
+ }
10
+
11
+ addActiveJob(job) {
12
+ this.activeJobs.push(job);
13
+ }
14
+
15
+ evaluateProximity(leadAddress) {
16
+ if (!leadAddress || typeof leadAddress !== 'string') {
17
+ return { hasProximityAdvantage: false, discountPercentage: 0 };
18
+ }
19
+
20
+ const cleanedLead = leadAddress.toLowerCase();
21
+
22
+ for (const job of this.activeJobs) {
23
+ if (job.postalCode && cleanedLead.includes(job.postalCode)) {
24
+ return {
25
+ hasProximityAdvantage: true,
26
+ matchedTechnicianId: job.technicianId,
27
+ matchedPostalCode: job.postalCode,
28
+ discountPercentage: 10,
29
+ reason: `Technician ${job.technicianId} is already scheduled in your postal code (${job.postalCode}). Proximity discount applied.`
30
+ };
31
+ }
32
+
33
+ if (job.street && cleanedLead.includes(job.street.toLowerCase())) {
34
+ return {
35
+ hasProximityAdvantage: true,
36
+ matchedTechnicianId: job.technicianId,
37
+ matchedStreet: job.street,
38
+ discountPercentage: 15,
39
+ reason: `Technician ${job.technicianId} is servicing a customer on your exact street (${job.street})!`
40
+ };
41
+ }
42
+ }
43
+
44
+ return { hasProximityAdvantage: false, discountPercentage: 0, reason: 'Standard travel dispatch zone' };
45
+ }
46
+ }
@@ -0,0 +1,41 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { RouteDensityOptimizer, FeedbackInterceptor } from '../src/index.js';
4
+
5
+ test('LocalRoar Route Density: detects proximity matches and applies neighborhood discounts', () => {
6
+ const optimizer = new RouteDensityOptimizer([
7
+ { id: 'job-101', technicianId: 'tech-alpha', postalCode: '94107', street: 'Mission Street' }
8
+ ]);
9
+
10
+ // Match by postal code
11
+ const postalMatch = optimizer.evaluateProximity('420 3rd St, San Francisco, CA 94107');
12
+ assert.equal(postalMatch.hasProximityAdvantage, true);
13
+ assert.equal(postalMatch.discountPercentage, 10);
14
+ assert.equal(postalMatch.matchedTechnicianId, 'tech-alpha');
15
+
16
+ // Match by street
17
+ const streetMatch = optimizer.evaluateProximity('888 Mission Street, Apt 4B');
18
+ assert.equal(streetMatch.hasProximityAdvantage, true);
19
+ assert.equal(streetMatch.discountPercentage, 15);
20
+
21
+ // No match
22
+ const noMatch = optimizer.evaluateProximity('99 Sunset Blvd, Los Angeles, CA 90028');
23
+ assert.equal(noMatch.hasProximityAdvantage, false);
24
+ assert.equal(noMatch.discountPercentage, 0);
25
+ });
26
+
27
+ test('LocalRoar Feedback Interceptor: routes 5-star to Google Reviews and intercepts 2-star privately', () => {
28
+ const interceptor = new FeedbackInterceptor('555-OWNER-HOTLINE');
29
+
30
+ // Positive review routes to Google
31
+ const posResult = interceptor.processCustomerReview('book-001', 'Happy Customer', 5, 'Great job fixing the leak!');
32
+ assert.equal(posResult.action, 'ROUTE_TO_PUBLIC_GOOGLE_REVIEW');
33
+ assert.ok(posResult.publicReviewUrl.includes('apex-pros'));
34
+
35
+ // Negative review is intercepted privately
36
+ const negResult = interceptor.processCustomerReview('book-002', 'Unhappy Customer', 2, 'Technician was 30 mins late.');
37
+ assert.equal(negResult.action, 'INTERCEPT_PRIVATELY');
38
+ assert.equal(negResult.ticket.status, 'INTERCEPTED_PRIVATE');
39
+ assert.ok(negResult.ticket.ownerAlertMessage.includes('URGENT CUSTOMER ALERT'));
40
+ assert.equal(interceptor.interceptedTickets.length, 1);
41
+ });
@@ -0,0 +1,59 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { LocalRoarAgent } from '../src/index.js';
4
+
5
+ test('LocalRoar: parses inbound lead and generates instant quote', () => {
6
+ const agent = new LocalRoarAgent('Apex Plumbing & Heating');
7
+ const inquiry = 'Hi, our pipe burst under the sink! It is urgent, can you come asap? Phone: 555-019-2834';
8
+
9
+ const res = agent.handleInquiry(inquiry, 'sms');
10
+ assert.equal(res.action, 'QUOTE_AND_BOOK');
11
+ assert.equal(res.lead.serviceKey, 'plumbing');
12
+ assert.equal(res.lead.isUrgent, true);
13
+ assert.equal(res.lead.customerPhone, '555-019-2834');
14
+ // Plumbing base is 7500, with urgent 1.5x = 11250 cents ($112.50)
15
+ assert.equal(res.lead.estimatedAmount, 11250);
16
+ });
17
+
18
+ test('LocalRoar: books appointment slot and schedules post-service review outreach', () => {
19
+ const agent = new LocalRoarAgent('Apex Plumbing');
20
+ const slot = '2026-12-05T14:00:00Z';
21
+
22
+ const booking = agent.confirmBooking('David Miller', slot, 'plumbing', 11250);
23
+ assert.equal(booking.status, 'CONFIRMED');
24
+ assert.equal(booking.booking.customerName, 'David Miller');
25
+ assert.ok(booking.scheduledReviewOutreach.message.includes('Apex Plumbing'));
26
+
27
+ // Attempting to book overlapping slot should throw
28
+ assert.throws(() => {
29
+ agent.confirmBooking('Other Customer', slot, 'plumbing', 7500);
30
+ }, /already booked/);
31
+ });
32
+
33
+ test('LocalRoar: produces executive weekly performance metrics digest', () => {
34
+ const agent = new LocalRoarAgent('Apex Plumbing');
35
+ agent.handleInquiry('Need hvac tune-up', 'web');
36
+ agent.handleInquiry('Help with electrical socket', 'web');
37
+
38
+ agent.confirmBooking('John Doe', '2026-12-05T10:00:00Z', 'hvac', 12000);
39
+
40
+ const digest = agent.generateWeeklyDigest();
41
+ assert.equal(digest.metrics.totalLeadsCaptured, 2);
42
+ assert.equal(digest.metrics.bookingsConverted, 1);
43
+ assert.equal(digest.metrics.conversionRate, '50%');
44
+ assert.equal(digest.metrics.projectedRevenueFormatted, '$120.00');
45
+ });
46
+
47
+ test('LocalRoar Security: blocks calendar denial-of-inventory flood attempts', () => {
48
+ const agent = new LocalRoarAgent('Apex Plumbing');
49
+
50
+ // Book 3 slots (allowed limit)
51
+ agent.confirmBooking('Spam Bot', '2026-12-10T10:00:00Z', 'plumbing', 7500);
52
+ agent.confirmBooking('Spam Bot', '2026-12-10T12:00:00Z', 'plumbing', 7500);
53
+ agent.confirmBooking('Spam Bot', '2026-12-10T14:00:00Z', 'plumbing', 7500);
54
+
55
+ // 4th slot should throw booking limit exceeded
56
+ assert.throws(() => {
57
+ agent.confirmBooking('Spam Bot', '2026-12-10T16:00:00Z', 'plumbing', 7500);
58
+ }, /Booking limit exceeded/);
59
+ });
@@ -0,0 +1,12 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { LocalRoarAgent, LocalRoarMobileAdapter } from '../src/index.js';
4
+
5
+ test('LocalRoar Mobile Adapter: formats mobile growth outcome cards', () => {
6
+ const agent = new LocalRoarAgent('Prime HVAC');
7
+ const mobile = new LocalRoarMobileAdapter(agent);
8
+
9
+ const card = mobile.getMobileOutcomeCard();
10
+ assert.equal(card.title, 'LocalRoar Growth Engine');
11
+ assert.equal(card.statusBadge, 'ONLINE_24_7');
12
+ });
@@ -0,0 +1,39 @@
1
+ # OmniLife — Autonomous Life Operating System Agent
2
+
3
+ **OmniLife** is the personal life operator that manages administrative overhead across subscriptions, travel validity, calendar conflicts, and financial commitments—with clear human-in-the-loop safeguards.
4
+
5
+ ## Capabilities
6
+
7
+ 1. **Dormant Subscription Pruning:** Discovers recurring subscriptions unused for 90+ days and evaluates annual cost savings.
8
+ 2. **Termination Penalty Guard:** Identifies cancellation penalties and pauses for explicit user approval before terminating contracts.
9
+ 3. **Passport & Travel Compliance:** Verifies that passport expiration complies with international 6-month validity rules before flights.
10
+ 4. **Collision Resolver:** Detects overlapping meetings and itineraries.
11
+
12
+ ## Usage
13
+
14
+ ```javascript
15
+ import { OmniLifeAgent } from 'omnilife-agent';
16
+
17
+ const agent = new OmniLifeAgent('Alex');
18
+
19
+ // 1. Register subscription
20
+ agent.subscriptions.addSubscription({
21
+ name: 'Gym Club',
22
+ monthlyCostCents: 6000,
23
+ lastUsedDaysAgo: 120,
24
+ hasEarlyTerminationPenalty: true,
25
+ penaltyAmountCents: 5000
26
+ });
27
+
28
+ // 2. Audit life operations
29
+ const status = agent.evaluateLifeOSStatus([], '2027-02-01T00:00:00Z', '2027-01-01T00:00:00Z');
30
+
31
+ // 3. User approves cancellation
32
+ agent.approveCancellation(status.pendingApprovals[0].subscription.id, true);
33
+ ```
34
+
35
+ ## Testing
36
+
37
+ ```sh
38
+ npm test
39
+ ```
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "omnilife-agent",
3
+ "version": "0.1.0",
4
+ "description": "OmniLife - Autonomous Life Operating System Agent",
5
+ "private": true,
6
+ "type": "module",
7
+ "engines": {
8
+ "node": ">=20"
9
+ },
10
+ "scripts": {
11
+ "test": "node --test"
12
+ }
13
+ }