@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.
- package/Booker/README.md +41 -0
- package/Booker/package.json +11 -0
- package/Booker/src/agent.js +15 -0
- package/Booker/src/calendar-adapter.js +75 -0
- package/Booker/src/index.js +4 -0
- package/Booker/src/intake-parser.js +96 -0
- package/Booker/src/validation.js +34 -0
- package/Booker/test/booker.test.js +35 -0
- package/CashHound/README.md +181 -0
- package/CashHound/package.json +21 -0
- package/CashHound/src/agent.js +621 -0
- package/CashHound/src/bank-reconciler.js +66 -0
- package/CashHound/src/dunning.js +380 -0
- package/CashHound/src/index.js +32 -0
- package/CashHound/src/invoice.js +371 -0
- package/CashHound/src/mobile.js +35 -0
- package/CashHound/src/npv-optimizer.js +259 -0
- package/CashHound/test/advanced.test.js +44 -0
- package/CashHound/test/cashhound.test.js +530 -0
- package/CashHound/test/mobile.test.js +25 -0
- package/CashHound/test/security.test.js +35 -0
- package/Clerk/README.md +30 -0
- package/Clerk/package.json +11 -0
- package/Clerk/src/agent.js +18 -0
- package/Clerk/src/index.js +2 -0
- package/Clerk/src/reconciliation.js +52 -0
- package/Clerk/test/clerk.test.js +39 -0
- package/LocalRoar/README.md +37 -0
- package/LocalRoar/package.json +13 -0
- package/LocalRoar/src/agent.js +70 -0
- package/LocalRoar/src/booking-router.js +74 -0
- package/LocalRoar/src/feedback-interceptor.js +47 -0
- package/LocalRoar/src/index.js +7 -0
- package/LocalRoar/src/lead-engine.js +52 -0
- package/LocalRoar/src/mobile.js +23 -0
- package/LocalRoar/src/review-booster.js +24 -0
- package/LocalRoar/src/route-density.js +46 -0
- package/LocalRoar/test/advanced.test.js +41 -0
- package/LocalRoar/test/localroar.test.js +59 -0
- package/LocalRoar/test/mobile.test.js +12 -0
- package/OmniLife/README.md +39 -0
- package/OmniLife/package.json +13 -0
- package/OmniLife/src/agent.js +47 -0
- package/OmniLife/src/bill-negotiator.js +43 -0
- package/OmniLife/src/browser-cancel.js +28 -0
- package/OmniLife/src/conflict-engine.js +49 -0
- package/OmniLife/src/index.js +6 -0
- package/OmniLife/src/mobile.js +18 -0
- package/OmniLife/src/subscription-manager.js +66 -0
- package/OmniLife/test/advanced.test.js +29 -0
- package/OmniLife/test/mobile.test.js +12 -0
- package/OmniLife/test/omnilife.test.js +71 -0
- package/PulseMD/README.md +42 -0
- package/PulseMD/package.json +13 -0
- package/PulseMD/src/agent.js +67 -0
- package/PulseMD/src/ambient-scribe.js +46 -0
- package/PulseMD/src/auth.js +63 -0
- package/PulseMD/src/charting.js +54 -0
- package/PulseMD/src/index.js +7 -0
- package/PulseMD/src/mobile.js +18 -0
- package/PulseMD/src/prior-auth.js +39 -0
- package/PulseMD/src/safety-guard.js +88 -0
- package/PulseMD/test/advanced.test.js +50 -0
- package/PulseMD/test/mobile.test.js +12 -0
- package/PulseMD/test/pulsemd.test.js +71 -0
- package/README.md +203 -2
- package/ResolveX/README.md +274 -0
- package/ResolveX/package.json +20 -0
- package/ResolveX/src/agent.js +679 -0
- package/ResolveX/src/carrier-listener.js +405 -0
- package/ResolveX/src/diagnosis.js +315 -0
- package/ResolveX/src/index.js +36 -0
- package/ResolveX/src/mobile.js +31 -0
- package/ResolveX/src/policy.js +325 -0
- package/ResolveX/src/vision.js +384 -0
- package/ResolveX/test/advanced.test.js +445 -0
- package/ResolveX/test/mobile.test.js +15 -0
- package/ResolveX/test/resolvex.test.js +428 -0
- package/SentinelMesh/README.md +51 -0
- package/SentinelMesh/package.json +13 -0
- package/SentinelMesh/src/governor.js +61 -0
- package/SentinelMesh/src/index.js +4 -0
- package/SentinelMesh/src/mobile.js +19 -0
- package/SentinelMesh/src/policy.js +63 -0
- package/SentinelMesh/src/sandbox.js +152 -0
- package/SentinelMesh/test/mobile.test.js +12 -0
- package/SentinelMesh/test/sentinel.test.js +135 -0
- package/Sidekick/README.md +43 -0
- package/Sidekick/package.json +11 -0
- package/Sidekick/src/agent.js +15 -0
- package/Sidekick/src/evidence.js +45 -0
- package/Sidekick/src/index.js +3 -0
- package/Sidekick/src/validation.js +15 -0
- package/Sidekick/test/sidekick.test.js +33 -0
- package/agent-os-mobile/README.md +26 -0
- package/agent-os-mobile/src/api.js +97 -0
- package/agent-os-mobile/src/biometric.js +41 -0
- package/agent-os-mobile/src/components/ApprovalStack.js +207 -0
- package/agent-os-mobile/src/components/OutcomeCard.js +98 -0
- package/agent-os-mobile/src/memory-graph.js +114 -0
- package/agent-os-mobile/src/screens/CashHoundMobileScreen.js +111 -0
- package/agent-os-mobile/src/screens/LocalRoarMobileScreen.js +183 -0
- package/agent-os-mobile/src/screens/OmniLifeMobileScreen.js +111 -0
- package/agent-os-mobile/src/screens/PulseMDMobileScreen.js +55 -0
- package/agent-os-mobile/src/screens/ResolveXMobileScreen.js +96 -0
- package/agent-os-mobile/src/screens/SentinelMeshMobileScreen.js +199 -0
- package/agent-os-mobile/src/self-healer.js +104 -0
- package/agent-os-mobile/src/speculative-verifier.js +69 -0
- package/agent-os-mobile/src/spekra-bridge.js +216 -0
- package/agent-os-mobile/src/swarm.js +72 -0
- package/agent-os-mobile/src/voice.js +51 -0
- package/bin/agentos.js +260 -0
- package/package.json +51 -4
- package/src/index.js +91 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet, View, Text, TouchableOpacity } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export function ApprovalStack({ approvals = [], onApprove, onReject }) {
|
|
5
|
+
if (approvals.length === 0) {
|
|
6
|
+
return (
|
|
7
|
+
<View style={styles.emptyContainer}>
|
|
8
|
+
<Text style={styles.emptyIcon}>🛡️</Text>
|
|
9
|
+
<Text style={styles.emptyTitle}>Approval Queue Clear</Text>
|
|
10
|
+
<Text style={styles.emptySubtitle}>All autonomous agent actions operating within policy bounds.</Text>
|
|
11
|
+
</View>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<View style={styles.stackContainer}>
|
|
17
|
+
<View style={styles.titleRow}>
|
|
18
|
+
<Text style={styles.sectionHeading}>Pending Approval Stack</Text>
|
|
19
|
+
<View style={styles.countBadge}>
|
|
20
|
+
<Text style={styles.countText}>{approvals.length} pending</Text>
|
|
21
|
+
</View>
|
|
22
|
+
</View>
|
|
23
|
+
|
|
24
|
+
{approvals.map((item) => (
|
|
25
|
+
<View key={item.id} style={styles.itemCard}>
|
|
26
|
+
<View style={styles.itemHeader}>
|
|
27
|
+
<View style={styles.agentTag}>
|
|
28
|
+
<Text style={styles.agentTagText}>{item.agentName}</Text>
|
|
29
|
+
</View>
|
|
30
|
+
<Text style={styles.itemTime}>{item.timestamp || 'Just now'}</Text>
|
|
31
|
+
</View>
|
|
32
|
+
|
|
33
|
+
<Text style={styles.itemTitle}>{item.title}</Text>
|
|
34
|
+
<Text style={styles.itemDescription}>{item.description}</Text>
|
|
35
|
+
|
|
36
|
+
{item.amountFormatted && (
|
|
37
|
+
<View style={styles.amountBox}>
|
|
38
|
+
<Text style={styles.amountLabel}>Total Value at Risk:</Text>
|
|
39
|
+
<Text style={styles.amountValue}>{item.amountFormatted}</Text>
|
|
40
|
+
</View>
|
|
41
|
+
)}
|
|
42
|
+
|
|
43
|
+
<View style={styles.actionRow}>
|
|
44
|
+
<TouchableOpacity
|
|
45
|
+
style={[styles.btn, styles.rejectBtn]}
|
|
46
|
+
onPress={() => onReject && onReject(item.id)}
|
|
47
|
+
activeOpacity={0.7}
|
|
48
|
+
>
|
|
49
|
+
<Text style={styles.rejectBtnText}>Decline</Text>
|
|
50
|
+
</TouchableOpacity>
|
|
51
|
+
|
|
52
|
+
<TouchableOpacity
|
|
53
|
+
style={[styles.btn, styles.approveBtn]}
|
|
54
|
+
onPress={() => onApprove && onApprove(item.id)}
|
|
55
|
+
activeOpacity={0.7}
|
|
56
|
+
>
|
|
57
|
+
<Text style={styles.approveBtnText}>Approve & Execute</Text>
|
|
58
|
+
</TouchableOpacity>
|
|
59
|
+
</View>
|
|
60
|
+
</View>
|
|
61
|
+
))}
|
|
62
|
+
</View>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const styles = StyleSheet.create({
|
|
67
|
+
stackContainer: {
|
|
68
|
+
marginBottom: 24
|
|
69
|
+
},
|
|
70
|
+
titleRow: {
|
|
71
|
+
flexDirection: 'row',
|
|
72
|
+
justifyContent: 'space-between',
|
|
73
|
+
alignItems: 'center',
|
|
74
|
+
marginBottom: 16
|
|
75
|
+
},
|
|
76
|
+
sectionHeading: {
|
|
77
|
+
color: '#F8FAFC',
|
|
78
|
+
fontSize: 16,
|
|
79
|
+
fontWeight: '700'
|
|
80
|
+
},
|
|
81
|
+
countBadge: {
|
|
82
|
+
backgroundColor: '#EF4444',
|
|
83
|
+
paddingHorizontal: 10,
|
|
84
|
+
paddingVertical: 3,
|
|
85
|
+
borderRadius: 12
|
|
86
|
+
},
|
|
87
|
+
countText: {
|
|
88
|
+
color: '#FFFFFF',
|
|
89
|
+
fontSize: 12,
|
|
90
|
+
fontWeight: '700'
|
|
91
|
+
},
|
|
92
|
+
itemCard: {
|
|
93
|
+
backgroundColor: '#1E293B',
|
|
94
|
+
borderRadius: 14,
|
|
95
|
+
padding: 18,
|
|
96
|
+
marginBottom: 16,
|
|
97
|
+
borderWidth: 1,
|
|
98
|
+
borderColor: '#334155'
|
|
99
|
+
},
|
|
100
|
+
itemHeader: {
|
|
101
|
+
flexDirection: 'row',
|
|
102
|
+
justifyContent: 'space-between',
|
|
103
|
+
alignItems: 'center',
|
|
104
|
+
marginBottom: 12
|
|
105
|
+
},
|
|
106
|
+
agentTag: {
|
|
107
|
+
backgroundColor: '#3B82F6',
|
|
108
|
+
paddingHorizontal: 8,
|
|
109
|
+
paddingVertical: 3,
|
|
110
|
+
borderRadius: 6
|
|
111
|
+
},
|
|
112
|
+
agentTagText: {
|
|
113
|
+
color: '#FFFFFF',
|
|
114
|
+
fontSize: 11,
|
|
115
|
+
fontWeight: '700',
|
|
116
|
+
textTransform: 'uppercase'
|
|
117
|
+
},
|
|
118
|
+
itemTime: {
|
|
119
|
+
color: '#94A3B8',
|
|
120
|
+
fontSize: 12
|
|
121
|
+
},
|
|
122
|
+
itemTitle: {
|
|
123
|
+
color: '#F1F5F9',
|
|
124
|
+
fontSize: 16,
|
|
125
|
+
fontWeight: '700',
|
|
126
|
+
marginBottom: 6
|
|
127
|
+
},
|
|
128
|
+
itemDescription: {
|
|
129
|
+
color: '#CBD5E1',
|
|
130
|
+
fontSize: 13,
|
|
131
|
+
lineHeight: 18,
|
|
132
|
+
marginBottom: 14
|
|
133
|
+
},
|
|
134
|
+
amountBox: {
|
|
135
|
+
flexDirection: 'row',
|
|
136
|
+
justifyContent: 'space-between',
|
|
137
|
+
backgroundColor: 'rgba(239, 68, 68, 0.1)',
|
|
138
|
+
padding: 10,
|
|
139
|
+
borderRadius: 8,
|
|
140
|
+
marginBottom: 16
|
|
141
|
+
},
|
|
142
|
+
amountLabel: {
|
|
143
|
+
color: '#F87171',
|
|
144
|
+
fontSize: 12,
|
|
145
|
+
fontWeight: '600'
|
|
146
|
+
},
|
|
147
|
+
amountValue: {
|
|
148
|
+
color: '#EF4444',
|
|
149
|
+
fontSize: 14,
|
|
150
|
+
fontWeight: '700'
|
|
151
|
+
},
|
|
152
|
+
actionRow: {
|
|
153
|
+
flexDirection: 'row',
|
|
154
|
+
justifyContent: 'space-between',
|
|
155
|
+
gap: 12
|
|
156
|
+
},
|
|
157
|
+
btn: {
|
|
158
|
+
flex: 1,
|
|
159
|
+
paddingVertical: 12,
|
|
160
|
+
borderRadius: 8,
|
|
161
|
+
alignItems: 'center',
|
|
162
|
+
justifyContent: 'center'
|
|
163
|
+
},
|
|
164
|
+
rejectBtn: {
|
|
165
|
+
backgroundColor: '#334155',
|
|
166
|
+
borderWidth: 1,
|
|
167
|
+
borderColor: '#475569'
|
|
168
|
+
},
|
|
169
|
+
rejectBtnText: {
|
|
170
|
+
color: '#E2E8F0',
|
|
171
|
+
fontSize: 13,
|
|
172
|
+
fontWeight: '600'
|
|
173
|
+
},
|
|
174
|
+
approveBtn: {
|
|
175
|
+
backgroundColor: '#10B981'
|
|
176
|
+
},
|
|
177
|
+
approveBtnText: {
|
|
178
|
+
color: '#FFFFFF',
|
|
179
|
+
fontSize: 13,
|
|
180
|
+
fontWeight: '700'
|
|
181
|
+
},
|
|
182
|
+
emptyContainer: {
|
|
183
|
+
alignItems: 'center',
|
|
184
|
+
justifyContent: 'center',
|
|
185
|
+
padding: 32,
|
|
186
|
+
backgroundColor: '#131B2E',
|
|
187
|
+
borderRadius: 16,
|
|
188
|
+
marginBottom: 24,
|
|
189
|
+
borderWidth: 1,
|
|
190
|
+
borderColor: '#1E293B'
|
|
191
|
+
},
|
|
192
|
+
emptyIcon: {
|
|
193
|
+
fontSize: 32,
|
|
194
|
+
marginBottom: 12
|
|
195
|
+
},
|
|
196
|
+
emptyTitle: {
|
|
197
|
+
color: '#F8FAFC',
|
|
198
|
+
fontSize: 16,
|
|
199
|
+
fontWeight: '700',
|
|
200
|
+
marginBottom: 6
|
|
201
|
+
},
|
|
202
|
+
emptySubtitle: {
|
|
203
|
+
color: '#64748B',
|
|
204
|
+
fontSize: 13,
|
|
205
|
+
textAlign: 'center'
|
|
206
|
+
}
|
|
207
|
+
});
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet, View, Text } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export function OutcomeCard({ title, subtitle, metric, highlightColor = '#10B981', details = [] }) {
|
|
5
|
+
return (
|
|
6
|
+
<View style={styles.card}>
|
|
7
|
+
<View style={styles.headerRow}>
|
|
8
|
+
<View style={styles.textContainer}>
|
|
9
|
+
<Text style={styles.title}>{title}</Text>
|
|
10
|
+
{subtitle ? <Text style={styles.subtitle}>{subtitle}</Text> : null}
|
|
11
|
+
</View>
|
|
12
|
+
{metric ? (
|
|
13
|
+
<View style={[styles.metricBadge, { borderColor: highlightColor }]}>
|
|
14
|
+
<Text style={[styles.metricText, { color: highlightColor }]}>{metric}</Text>
|
|
15
|
+
</View>
|
|
16
|
+
) : null}
|
|
17
|
+
</View>
|
|
18
|
+
|
|
19
|
+
{details.length > 0 && (
|
|
20
|
+
<View style={styles.detailsContainer}>
|
|
21
|
+
{details.map((item, idx) => (
|
|
22
|
+
<View key={idx} style={styles.detailRow}>
|
|
23
|
+
<Text style={styles.detailLabel}>{item.label}</Text>
|
|
24
|
+
<Text style={styles.detailValue}>{item.value}</Text>
|
|
25
|
+
</View>
|
|
26
|
+
))}
|
|
27
|
+
</View>
|
|
28
|
+
)}
|
|
29
|
+
</View>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const styles = StyleSheet.create({
|
|
34
|
+
card: {
|
|
35
|
+
backgroundColor: '#131B2E',
|
|
36
|
+
borderRadius: 16,
|
|
37
|
+
padding: 20,
|
|
38
|
+
marginBottom: 24,
|
|
39
|
+
borderWidth: 1,
|
|
40
|
+
borderColor: '#1E293B',
|
|
41
|
+
shadowColor: '#000',
|
|
42
|
+
shadowOffset: { width: 0, height: 4 },
|
|
43
|
+
shadowOpacity: 0.2,
|
|
44
|
+
shadowRadius: 8,
|
|
45
|
+
elevation: 3
|
|
46
|
+
},
|
|
47
|
+
headerRow: {
|
|
48
|
+
flexDirection: 'row',
|
|
49
|
+
justifyContent: 'space-between',
|
|
50
|
+
alignItems: 'flex-start',
|
|
51
|
+
marginBottom: 16
|
|
52
|
+
},
|
|
53
|
+
textContainer: {
|
|
54
|
+
flex: 1,
|
|
55
|
+
marginRight: 12
|
|
56
|
+
},
|
|
57
|
+
title: {
|
|
58
|
+
color: '#F8FAFC',
|
|
59
|
+
fontSize: 18,
|
|
60
|
+
fontWeight: '700',
|
|
61
|
+
letterSpacing: -0.3
|
|
62
|
+
},
|
|
63
|
+
subtitle: {
|
|
64
|
+
color: '#94A3B8',
|
|
65
|
+
fontSize: 13,
|
|
66
|
+
marginTop: 4
|
|
67
|
+
},
|
|
68
|
+
metricBadge: {
|
|
69
|
+
borderWidth: 1,
|
|
70
|
+
borderRadius: 20,
|
|
71
|
+
paddingHorizontal: 12,
|
|
72
|
+
paddingVertical: 4,
|
|
73
|
+
backgroundColor: 'rgba(16, 185, 129, 0.1)'
|
|
74
|
+
},
|
|
75
|
+
metricText: {
|
|
76
|
+
fontSize: 14,
|
|
77
|
+
fontWeight: '700'
|
|
78
|
+
},
|
|
79
|
+
detailsContainer: {
|
|
80
|
+
borderTopWidth: 1,
|
|
81
|
+
borderTopColor: '#1E293B',
|
|
82
|
+
paddingTop: 16
|
|
83
|
+
},
|
|
84
|
+
detailRow: {
|
|
85
|
+
flexDirection: 'row',
|
|
86
|
+
justifyContent: 'space-between',
|
|
87
|
+
marginBottom: 10
|
|
88
|
+
},
|
|
89
|
+
detailLabel: {
|
|
90
|
+
color: '#64748B',
|
|
91
|
+
fontSize: 13
|
|
92
|
+
},
|
|
93
|
+
detailValue: {
|
|
94
|
+
color: '#E2E8F0',
|
|
95
|
+
fontSize: 13,
|
|
96
|
+
fontWeight: '600'
|
|
97
|
+
}
|
|
98
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Privacy partitions for cross-agent memory.
|
|
5
|
+
* Guarantees that sensitive domains (e.g. healthcare PHI) cannot leak to commercial bots.
|
|
6
|
+
*/
|
|
7
|
+
export const MemoryPrivacyTier = Object.freeze({
|
|
8
|
+
PUBLIC: 'PUBLIC',
|
|
9
|
+
ORGANIZATION: 'ORGANIZATION',
|
|
10
|
+
CONFIDENTIAL: 'CONFIDENTIAL',
|
|
11
|
+
RESTRICTED_PHI: 'RESTRICTED_PHI' // Medical / clinical only
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export class AgentMemoryGraph {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.nodes = new Map(); // entityId -> Array<MemoryRecord>
|
|
17
|
+
this.agentPermissions = new Map(); // agentId -> Set<MemoryPrivacyTier>
|
|
18
|
+
|
|
19
|
+
// Default permission mappings
|
|
20
|
+
this.setAgentPermissions('localroar', [MemoryPrivacyTier.PUBLIC, MemoryPrivacyTier.ORGANIZATION]);
|
|
21
|
+
this.setAgentPermissions('cashhound', [MemoryPrivacyTier.PUBLIC, MemoryPrivacyTier.ORGANIZATION, MemoryPrivacyTier.CONFIDENTIAL]);
|
|
22
|
+
this.setAgentPermissions('resolvex', [MemoryPrivacyTier.PUBLIC, MemoryPrivacyTier.ORGANIZATION, MemoryPrivacyTier.CONFIDENTIAL]);
|
|
23
|
+
this.setAgentPermissions('pulsemd', [MemoryPrivacyTier.PUBLIC, MemoryPrivacyTier.ORGANIZATION, MemoryPrivacyTier.RESTRICTED_PHI]);
|
|
24
|
+
this.setAgentPermissions('omnilife', [MemoryPrivacyTier.PUBLIC, MemoryPrivacyTier.ORGANIZATION, MemoryPrivacyTier.CONFIDENTIAL]);
|
|
25
|
+
this.setAgentPermissions('sentinelmesh', [MemoryPrivacyTier.PUBLIC, MemoryPrivacyTier.ORGANIZATION, MemoryPrivacyTier.CONFIDENTIAL, MemoryPrivacyTier.RESTRICTED_PHI]);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
setAgentPermissions(agentId, allowedTiers = []) {
|
|
29
|
+
this.agentPermissions.set(agentId.toLowerCase(), new Set(allowedTiers));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
recordFact({
|
|
33
|
+
entityId,
|
|
34
|
+
factType,
|
|
35
|
+
factKey,
|
|
36
|
+
factValue,
|
|
37
|
+
sourceAgent,
|
|
38
|
+
privacyTier = MemoryPrivacyTier.ORGANIZATION,
|
|
39
|
+
confidence = 1.0,
|
|
40
|
+
ttlDays = 365
|
|
41
|
+
}) {
|
|
42
|
+
if (!entityId || !factKey) throw new Error('entityId and factKey are required');
|
|
43
|
+
|
|
44
|
+
const timestamp = new Date().toISOString();
|
|
45
|
+
const memoryId = `MEM-${crypto.randomBytes(8).toString('hex')}`;
|
|
46
|
+
|
|
47
|
+
const record = {
|
|
48
|
+
memoryId,
|
|
49
|
+
entityId,
|
|
50
|
+
factType: factType || 'ATTRIBUTE',
|
|
51
|
+
factKey,
|
|
52
|
+
factValue,
|
|
53
|
+
sourceAgent,
|
|
54
|
+
privacyTier,
|
|
55
|
+
confidence: Math.max(0, Math.min(1.0, confidence)),
|
|
56
|
+
recordedAt: timestamp,
|
|
57
|
+
lastObservedAt: timestamp,
|
|
58
|
+
ttlDays,
|
|
59
|
+
isInvalidated: false
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
if (!this.nodes.has(entityId)) {
|
|
63
|
+
this.nodes.set(entityId, []);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const entityMemories = this.nodes.get(entityId);
|
|
67
|
+
// Invalidate prior versions of this specific fact key if new one has higher/equal confidence
|
|
68
|
+
for (const mem of entityMemories) {
|
|
69
|
+
if (mem.factKey === factKey && !mem.isInvalidated) {
|
|
70
|
+
mem.isInvalidated = true;
|
|
71
|
+
mem.invalidatedReason = `Superseded by memory ${memoryId}`;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
entityMemories.push(record);
|
|
76
|
+
return record;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
queryMemories(entityId, callerAgentId, options = {}) {
|
|
80
|
+
const memories = this.nodes.get(entityId) || [];
|
|
81
|
+
const agentTiers = this.agentPermissions.get(callerAgentId.toLowerCase()) || new Set([MemoryPrivacyTier.PUBLIC]);
|
|
82
|
+
const { includeInvalidated = false, minConfidence = 0.5 } = options;
|
|
83
|
+
|
|
84
|
+
return memories.filter(mem => {
|
|
85
|
+
// 1. Privacy partition check
|
|
86
|
+
if (!agentTiers.has(mem.privacyTier)) return false;
|
|
87
|
+
|
|
88
|
+
// 2. Active status check
|
|
89
|
+
if (!includeInvalidated && mem.isInvalidated) return false;
|
|
90
|
+
|
|
91
|
+
// 3. Confidence check
|
|
92
|
+
if (mem.confidence < minConfidence) return false;
|
|
93
|
+
|
|
94
|
+
// 4. Stale TTL check
|
|
95
|
+
const ageDays = (Date.now() - new Date(mem.lastObservedAt).getTime()) / (24 * 60 * 60 * 1000);
|
|
96
|
+
if (ageDays > mem.ttlDays) return false;
|
|
97
|
+
|
|
98
|
+
return true;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
invalidateFact(entityId, factKey, reason = 'Reported outdated by agent') {
|
|
103
|
+
const memories = this.nodes.get(entityId) || [];
|
|
104
|
+
let count = 0;
|
|
105
|
+
for (const mem of memories) {
|
|
106
|
+
if (mem.factKey === factKey && !mem.isInvalidated) {
|
|
107
|
+
mem.isInvalidated = true;
|
|
108
|
+
mem.invalidatedReason = reason;
|
|
109
|
+
count++;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return { entityId, factKey, invalidatedCount: count };
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { StyleSheet, View, Text, TouchableOpacity, Alert, TextInput } from 'react-native';
|
|
3
|
+
import { OutcomeCard } from '../components/OutcomeCard.js';
|
|
4
|
+
import { ApprovalStack } from '../components/ApprovalStack.js';
|
|
5
|
+
|
|
6
|
+
export function CashHoundMobileScreen() {
|
|
7
|
+
const [approvals, setApprovals] = useState([
|
|
8
|
+
{
|
|
9
|
+
id: 'inv-high-99',
|
|
10
|
+
agentName: 'CashHound',
|
|
11
|
+
title: 'High-Value Dunning Notice: Acme Corp',
|
|
12
|
+
description: 'Invoice #1094 is 38 days overdue. CashHound drafted a Tier-2 firm reminder. Balance exceeds $5,000 threshold.',
|
|
13
|
+
amountFormatted: '$8,400.00',
|
|
14
|
+
timestamp: '10m ago'
|
|
15
|
+
}
|
|
16
|
+
]);
|
|
17
|
+
|
|
18
|
+
const [activeBucket, setActiveBucket] = useState('30+');
|
|
19
|
+
const [testCustomer, setTestCustomer] = useState('');
|
|
20
|
+
|
|
21
|
+
const handleApprove = (id) => {
|
|
22
|
+
setApprovals(approvals.filter(a => a.id !== id));
|
|
23
|
+
Alert.alert('Action Dispatched', 'Firm reminder sent to client with secure Stripe payment link.');
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const handleReject = (id) => {
|
|
27
|
+
setApprovals(approvals.filter(a => a.id !== id));
|
|
28
|
+
Alert.alert('Action Cancelled', 'Dunning message cancelled. Account tagged for executive outreach.');
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<View style={styles.container}>
|
|
33
|
+
<OutcomeCard
|
|
34
|
+
title="Revenue Recovery Velocity"
|
|
35
|
+
subtitle="CashHound Autonomous Collections"
|
|
36
|
+
metric="$24,650 Recovered"
|
|
37
|
+
highlightColor="#10B981"
|
|
38
|
+
details={[
|
|
39
|
+
{ label: 'Days Sales Outstanding (DSO)', value: '31 Days (-14d improvement)' },
|
|
40
|
+
{ label: 'Active Dunning Campaigns', value: '18 in progress' },
|
|
41
|
+
{ label: 'Settlement Plan Inquiries', value: '4 pending' }
|
|
42
|
+
]}
|
|
43
|
+
/>
|
|
44
|
+
|
|
45
|
+
{/* Aging Filter */}
|
|
46
|
+
<View style={styles.agingSection}>
|
|
47
|
+
<Text style={styles.sectionTitle}>Aging Portfolio Breakdown</Text>
|
|
48
|
+
<View style={styles.bucketRow}>
|
|
49
|
+
{['Current', '30+', '60+', '90+'].map((bucket) => (
|
|
50
|
+
<TouchableOpacity
|
|
51
|
+
key={bucket}
|
|
52
|
+
style={[styles.bucketTab, activeBucket === bucket && styles.bucketTabActive]}
|
|
53
|
+
onPress={() => setActiveBucket(bucket)}
|
|
54
|
+
>
|
|
55
|
+
<Text style={[styles.bucketText, activeBucket === bucket && styles.bucketTextActive]}>
|
|
56
|
+
{bucket}
|
|
57
|
+
</Text>
|
|
58
|
+
</TouchableOpacity>
|
|
59
|
+
))}
|
|
60
|
+
</View>
|
|
61
|
+
</View>
|
|
62
|
+
|
|
63
|
+
<ApprovalStack
|
|
64
|
+
approvals={approvals}
|
|
65
|
+
onApprove={handleApprove}
|
|
66
|
+
onReject={handleReject}
|
|
67
|
+
/>
|
|
68
|
+
</View>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const styles = StyleSheet.create({
|
|
73
|
+
container: {
|
|
74
|
+
paddingBottom: 24
|
|
75
|
+
},
|
|
76
|
+
agingSection: {
|
|
77
|
+
marginBottom: 24
|
|
78
|
+
},
|
|
79
|
+
sectionTitle: {
|
|
80
|
+
color: '#F8FAFC',
|
|
81
|
+
fontSize: 16,
|
|
82
|
+
fontWeight: '700',
|
|
83
|
+
marginBottom: 12
|
|
84
|
+
},
|
|
85
|
+
bucketRow: {
|
|
86
|
+
flexDirection: 'row',
|
|
87
|
+
gap: 8
|
|
88
|
+
},
|
|
89
|
+
bucketTab: {
|
|
90
|
+
flex: 1,
|
|
91
|
+
paddingVertical: 10,
|
|
92
|
+
backgroundColor: '#1E293B',
|
|
93
|
+
borderRadius: 8,
|
|
94
|
+
alignItems: 'center',
|
|
95
|
+
borderWidth: 1,
|
|
96
|
+
borderColor: '#334155'
|
|
97
|
+
},
|
|
98
|
+
bucketTabActive: {
|
|
99
|
+
backgroundColor: '#3B82F6',
|
|
100
|
+
borderColor: '#60A5FA'
|
|
101
|
+
},
|
|
102
|
+
bucketText: {
|
|
103
|
+
color: '#94A3B8',
|
|
104
|
+
fontSize: 13,
|
|
105
|
+
fontWeight: '600'
|
|
106
|
+
},
|
|
107
|
+
bucketTextActive: {
|
|
108
|
+
color: '#FFFFFF',
|
|
109
|
+
fontWeight: '700'
|
|
110
|
+
}
|
|
111
|
+
});
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { StyleSheet, View, Text, TouchableOpacity, Alert, TextInput } from 'react-native';
|
|
3
|
+
import { OutcomeCard } from '../components/OutcomeCard.js';
|
|
4
|
+
|
|
5
|
+
export function LocalRoarMobileScreen() {
|
|
6
|
+
const [inquiryText, setInquiryText] = useState('Pipe burst under master bathroom sink! Water everywhere, need help now. 555-401-2019');
|
|
7
|
+
const [parsedLead, setParsedLead] = useState(null);
|
|
8
|
+
|
|
9
|
+
const handleSimulateInquiry = () => {
|
|
10
|
+
setParsedLead({
|
|
11
|
+
service: 'Emergency Plumbing Repair',
|
|
12
|
+
urgency: 'HIGH',
|
|
13
|
+
estQuote: '$112.50',
|
|
14
|
+
slot: 'Today, 2:00 PM',
|
|
15
|
+
phone: '555-401-2019'
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const handleConfirmAndSendQuote = () => {
|
|
20
|
+
Alert.alert(
|
|
21
|
+
'Lead Converted & Booked!',
|
|
22
|
+
`Quote of ${parsedLead.estQuote} dispatched via SMS to ${parsedLead.phone}. Slot locked. 5-star review request scheduled 2h post completion.`
|
|
23
|
+
);
|
|
24
|
+
setParsedLead(null);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<View style={styles.container}>
|
|
29
|
+
<OutcomeCard
|
|
30
|
+
title="Local Business Growth Engine"
|
|
31
|
+
subtitle="LocalRoar 24/7 Inbound Machine"
|
|
32
|
+
metric="68% Conversion Rate"
|
|
33
|
+
highlightColor="#F59E0B"
|
|
34
|
+
details={[
|
|
35
|
+
{ label: 'Weekly Projected Revenue', value: '$4,850.00' },
|
|
36
|
+
{ label: 'Jobs Booked (Last 7d)', value: '38 completed' },
|
|
37
|
+
{ label: 'Google Review Invites Sent', value: '34 sent (4.9 avg rating)' }
|
|
38
|
+
]}
|
|
39
|
+
/>
|
|
40
|
+
|
|
41
|
+
<View style={styles.leadSimulatorCard}>
|
|
42
|
+
<Text style={styles.cardHeader}>Inbound Lead Receiver (SMS / Web / WhatsApp)</Text>
|
|
43
|
+
<TextInput
|
|
44
|
+
style={styles.textInput}
|
|
45
|
+
multiline
|
|
46
|
+
numberOfLines={3}
|
|
47
|
+
value={inquiryText}
|
|
48
|
+
onChangeText={setInquiryText}
|
|
49
|
+
/>
|
|
50
|
+
<TouchableOpacity
|
|
51
|
+
style={styles.parseBtn}
|
|
52
|
+
onPress={handleSimulateInquiry}
|
|
53
|
+
>
|
|
54
|
+
<Text style={styles.parseBtnText}>Process Lead with LocalRoar</Text>
|
|
55
|
+
</TouchableOpacity>
|
|
56
|
+
</View>
|
|
57
|
+
|
|
58
|
+
{parsedLead && (
|
|
59
|
+
<View style={styles.quoteProposalCard}>
|
|
60
|
+
<View style={styles.quoteHeader}>
|
|
61
|
+
<Text style={styles.quoteTitle}>{parsedLead.service}</Text>
|
|
62
|
+
<View style={styles.urgentBadge}>
|
|
63
|
+
<Text style={styles.urgentText}>{parsedLead.urgency}</Text>
|
|
64
|
+
</View>
|
|
65
|
+
</View>
|
|
66
|
+
|
|
67
|
+
<View style={styles.quoteRow}>
|
|
68
|
+
<Text style={styles.quoteLabel}>Dynamic Estimate:</Text>
|
|
69
|
+
<Text style={styles.quoteVal}>{parsedLead.estQuote}</Text>
|
|
70
|
+
</View>
|
|
71
|
+
<View style={styles.quoteRow}>
|
|
72
|
+
<Text style={styles.quoteLabel}>Reserved Slot:</Text>
|
|
73
|
+
<Text style={styles.quoteVal}>{parsedLead.slot}</Text>
|
|
74
|
+
</View>
|
|
75
|
+
|
|
76
|
+
<TouchableOpacity
|
|
77
|
+
style={styles.bookBtn}
|
|
78
|
+
onPress={handleConfirmAndSendQuote}
|
|
79
|
+
>
|
|
80
|
+
<Text style={styles.bookBtnText}>Confirm Booking & Send SMS Quote</Text>
|
|
81
|
+
</TouchableOpacity>
|
|
82
|
+
</View>
|
|
83
|
+
)}
|
|
84
|
+
</View>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const styles = StyleSheet.create({
|
|
89
|
+
container: {
|
|
90
|
+
paddingBottom: 24
|
|
91
|
+
},
|
|
92
|
+
leadSimulatorCard: {
|
|
93
|
+
backgroundColor: '#1E293B',
|
|
94
|
+
borderRadius: 14,
|
|
95
|
+
padding: 18,
|
|
96
|
+
marginBottom: 24,
|
|
97
|
+
borderWidth: 1,
|
|
98
|
+
borderColor: '#334155'
|
|
99
|
+
},
|
|
100
|
+
cardHeader: {
|
|
101
|
+
color: '#F8FAFC',
|
|
102
|
+
fontSize: 14,
|
|
103
|
+
fontWeight: '700',
|
|
104
|
+
marginBottom: 12
|
|
105
|
+
},
|
|
106
|
+
textInput: {
|
|
107
|
+
backgroundColor: '#0F172A',
|
|
108
|
+
borderRadius: 8,
|
|
109
|
+
padding: 12,
|
|
110
|
+
color: '#F8FAFC',
|
|
111
|
+
fontSize: 13,
|
|
112
|
+
borderWidth: 1,
|
|
113
|
+
borderColor: '#334155',
|
|
114
|
+
marginBottom: 16
|
|
115
|
+
},
|
|
116
|
+
parseBtn: {
|
|
117
|
+
backgroundColor: '#3B82F6',
|
|
118
|
+
borderRadius: 8,
|
|
119
|
+
paddingVertical: 12,
|
|
120
|
+
alignItems: 'center'
|
|
121
|
+
},
|
|
122
|
+
parseBtnText: {
|
|
123
|
+
color: '#FFFFFF',
|
|
124
|
+
fontSize: 13,
|
|
125
|
+
fontWeight: '700'
|
|
126
|
+
},
|
|
127
|
+
quoteProposalCard: {
|
|
128
|
+
backgroundColor: '#131B2E',
|
|
129
|
+
borderRadius: 14,
|
|
130
|
+
padding: 18,
|
|
131
|
+
borderWidth: 1,
|
|
132
|
+
borderColor: '#10B981',
|
|
133
|
+
marginBottom: 24
|
|
134
|
+
},
|
|
135
|
+
quoteHeader: {
|
|
136
|
+
flexDirection: 'row',
|
|
137
|
+
justifyContent: 'space-between',
|
|
138
|
+
alignItems: 'center',
|
|
139
|
+
marginBottom: 14
|
|
140
|
+
},
|
|
141
|
+
quoteTitle: {
|
|
142
|
+
color: '#F8FAFC',
|
|
143
|
+
fontSize: 16,
|
|
144
|
+
fontWeight: '700'
|
|
145
|
+
},
|
|
146
|
+
urgentBadge: {
|
|
147
|
+
backgroundColor: '#EF4444',
|
|
148
|
+
paddingHorizontal: 8,
|
|
149
|
+
paddingVertical: 2,
|
|
150
|
+
borderRadius: 4
|
|
151
|
+
},
|
|
152
|
+
urgentText: {
|
|
153
|
+
color: '#FFFFFF',
|
|
154
|
+
fontSize: 10,
|
|
155
|
+
fontWeight: '800'
|
|
156
|
+
},
|
|
157
|
+
quoteRow: {
|
|
158
|
+
flexDirection: 'row',
|
|
159
|
+
justifyContent: 'space-between',
|
|
160
|
+
marginBottom: 10
|
|
161
|
+
},
|
|
162
|
+
quoteLabel: {
|
|
163
|
+
color: '#94A3B8',
|
|
164
|
+
fontSize: 13
|
|
165
|
+
},
|
|
166
|
+
quoteVal: {
|
|
167
|
+
color: '#F1F5F9',
|
|
168
|
+
fontSize: 14,
|
|
169
|
+
fontWeight: '700'
|
|
170
|
+
},
|
|
171
|
+
bookBtn: {
|
|
172
|
+
backgroundColor: '#10B981',
|
|
173
|
+
borderRadius: 8,
|
|
174
|
+
paddingVertical: 12,
|
|
175
|
+
alignItems: 'center',
|
|
176
|
+
marginTop: 12
|
|
177
|
+
},
|
|
178
|
+
bookBtnText: {
|
|
179
|
+
color: '#FFFFFF',
|
|
180
|
+
fontSize: 13,
|
|
181
|
+
fontWeight: '700'
|
|
182
|
+
}
|
|
183
|
+
});
|